Revision 53613
Added by Konstantina Galouni over 5 years ago
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/userEmailPreferences/mailPrefs.component.html | ||
---|---|---|
1 |
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle"> |
|
1 |
<!-- <div id="tm-main" class=" uk-section uk-margin-small-top tm-middle">
|
|
2 | 2 |
<div uk-grid uk-grid> |
3 |
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first"> |
|
3 |
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first"> -->
|
|
4 | 4 |
<div class="uk-container uk-margin-top"> |
5 | 5 |
<div class="uk-article-title custom-article-title"> |
6 | 6 |
User Email Preferences for Claims Notifications |
7 | 7 |
</div> |
8 | 8 |
|
9 |
<div *ngIf="userValidMessage.length > 0 " class = "uk-alert uk-alert-danger " >
|
|
10 |
User session is not valid. Please login again.
|
|
9 |
<div *ngIf="userValidMessage.length > 0" class = "uk-alert uk-alert-danger uk-animation-fade" role="alert">
|
|
10 |
{{userValidMessage}}
|
|
11 | 11 |
</div> |
12 |
<div *ngIf="savedMessage.length > 0" class="uk-alert uk-alert-success uk-animation-fade" role="alert"> |
|
13 |
{{savedMessage}} |
|
14 |
</div> |
|
12 | 15 |
<errorMessages [status]="[status]" [type]="'notification preferences'"></errorMessages> |
13 | 16 |
|
14 | 17 |
<ul class="custom-accordion" uk-accordion> |
... | ... | |
20 | 23 |
<form class="uk-form-horizontal"><!-- [formGroup]="myForm"--> |
21 | 24 |
<!--[ngClass]="{'has-error':!myForm.controls.notify.valid && myForm.controls.notify.dirty}"--> |
22 | 25 |
<div class="uk-margin"> |
23 |
<div class="uk-form-label">Do you want to receive e-mail notifications?</div>
|
|
26 |
<div class="uk-form-label inherit-color">Notify for claims:</div>
|
|
24 | 27 |
<!-- <div class="uk-form-controls uk-form-controls-text"> |
25 | 28 |
<label>Yes <input class="uk-radio" type="radio" name="radio2" [checked]="notification.notify" (click)="changeNotify(notification, true)"></label> |
26 | 29 |
<label>No <input class="uk-radio" type="radio" name="radio2" [checked]="!notification.notify" (click)="changeNotify(notification, false)"></label> |
... | ... | |
28 | 31 |
<div class="uk-form-controls uk-form-controls-text" data-uk-button-group> |
29 | 32 |
<button *ngIf="notification.notify" class="uk-button uk-button-primary uk-button-small" |
30 | 33 |
data-uk-button>ON</button> |
31 |
<button *ngIf="!notification.notify" class="uk-button-default uk-button-small" |
|
32 |
(click)="changeNotify(notification, true)" data-uk-button>ON</button> |
|
34 |
<button *ngIf="!notification.notify" class="uk-button uk-button-default uk-button-small"
|
|
35 |
(click)="changeNotify(notification, true, i)" data-uk-button>ON</button>
|
|
33 | 36 |
<button *ngIf="!notification.notify" class="uk-button uk-button-danger uk-button-small" |
34 | 37 |
data-uk-button>OFF</button> |
35 |
<button *ngIf="notification.notify" class="uk-button-default uk-button-small" |
|
36 |
(click)="changeNotify(notification, false)" data-uk-button>OFF</button> |
|
38 |
<button *ngIf="notification.notify" class="uk-button uk-button-default uk-button-small"
|
|
39 |
(click)="changeNotify(notification, false, i)" data-uk-button>OFF</button>
|
|
37 | 40 |
</div> |
38 | 41 |
</div> |
39 | 42 |
|
40 | 43 |
<!-- [ngClass]="{'has-error':!myForm.controls.frequency.valid && myForm.controls.frequency.dirty}" --> |
41 | 44 |
<div [class]="notification.notify ? 'uk-margin' : 'uk-margin cursor-not-allowed'"> |
42 |
<div class="uk-form-label" >How often?</div>
|
|
45 |
<div class="uk-form-label inherit-color">Frequency:</div>
|
|
43 | 46 |
<div class="uk-form-controls"> |
44 |
<select [class]="notification.notify ? 'uk-select' : 'uk-select uk-disabled'" id="form-horizontal-select" class="uk-select" [(ngModel)]="notification.frequency" name="select_frequency"> |
|
45 |
<option [ngValue]="24" >Daily</option> |
|
46 |
<option [ngValue]="48" >Every two days</option> |
|
47 |
<option [ngValue]="168">Weekly</option> |
|
47 |
<select [class]="notification.notify ? 'uk-select' : 'uk-select uk-disabled'" id="form-horizontal-select" |
|
48 |
[(ngModel)]="notification.frequency" name="select_frequency"> |
|
49 |
<option (click)="changeFrequency(24, i)" [ngValue]="24" >Daily</option> |
|
50 |
<option (click)="changeFrequency(48, i)" [ngValue]="48" >Every two days</option> |
|
51 |
<option (click)="changeFrequency(168, i)" [ngValue]="168">Weekly</option> |
|
48 | 52 |
</select> |
49 | 53 |
</div> |
50 | 54 |
</div> |
... | ... | |
67 | 71 |
|
68 | 72 |
<!-- {{notifications | json}} --> |
69 | 73 |
</div> |
70 |
</div> |
|
74 |
<!-- </div>
|
|
71 | 75 |
</div> |
72 |
</div> |
|
76 |
</div> --> |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/userEmailPreferences/mailPrefs.component.ts | ||
---|---|---|
9 | 9 |
import {MailPrefsService} from './mailPrefs.service'; |
10 | 10 |
import {ConnectHelper} from '../connectHelper'; |
11 | 11 |
import {ErrorCodes} from '../../utils/properties/errorCodes'; |
12 |
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; |
|
12 | 13 |
|
13 | 14 |
declare var UIkit: any; |
14 | 15 |
|
... | ... | |
27 | 28 |
|
28 | 29 |
public notifications = []; |
29 | 30 |
public initialNotifications = []; |
31 |
public prefsChanged = {}; |
|
30 | 32 |
|
31 |
public showErrorMessage:boolean = false; |
|
32 | 33 |
//public showForbiddenMessage:boolean = false; |
33 | 34 |
public userValidMessage:string = ""; |
35 |
public savedMessage: string = ""; |
|
34 | 36 |
|
35 | 37 |
public fetchId:string; |
36 | 38 |
|
... | ... | |
68 | 70 |
getEmailPreferences() { |
69 | 71 |
if(!Session.isLoggedIn()){ |
70 | 72 |
this.userValidMessage = "User session has expired. Please login again."; |
73 |
if(this.showSaveResetButtons) { |
|
74 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
75 |
} |
|
71 | 76 |
}else{ |
72 | 77 |
this.status = this.errorCodes.LOADING; |
78 |
this.savedMessage = ""; |
|
73 | 79 |
|
74 | 80 |
if(this.communityId && this.communityId != "openaire") { |
75 | 81 |
this.preferencesFor = "community"; |
... | ... | |
116 | 122 |
} |
117 | 123 |
} |
118 | 124 |
|
119 |
changeNotify(notification: any, checked: boolean) { |
|
125 |
changeNotify(notification: any, checked: boolean, index: number) { |
|
126 |
this.savedMessage = ""; |
|
127 |
this.status = this.errorCodes.DONE; |
|
120 | 128 |
notification.notify = checked; |
129 |
this.prefsChanged[index] = true; |
|
121 | 130 |
} |
122 | 131 |
|
132 |
changeFrequency(value: number, index: number) { |
|
133 |
this.savedMessage = ""; |
|
134 |
this.status = this.errorCodes.DONE; |
|
135 |
if(this.initialNotifications[index].frequency != value) { |
|
136 |
this.prefsChanged[index] = true; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
123 | 140 |
saveNotification(index: number) { |
124 |
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) { |
|
125 |
if(!Session.isLoggedIn()){ |
|
126 |
this.userValidMessage = "User session has expired. Please login again."; |
|
141 |
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { |
|
142 |
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) { |
|
143 |
if(!Session.isLoggedIn()){ |
|
144 |
this.userValidMessage = "User session has expired. Please login again."; |
|
145 |
if(this.showSaveResetButtons) { |
|
146 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
147 |
} |
|
148 |
}else{ |
|
149 |
this.status = this.errorCodes.LOADING; |
|
150 |
this.savedMessage = ""; |
|
151 |
console.info("Send notification to db: ", this.notifications[index]); |
|
127 | 152 |
|
128 |
}else{ |
|
129 |
this.status = this.errorCodes.LOADING; |
|
153 |
this._mailPrefsService.saveUserEmailPreferences(this.notifications[index], this.properties.claimsAPIURL).subscribe( |
|
154 |
data => { |
|
155 |
console.info("Notification saved successfully"); |
|
156 |
this.initialNotifications[index] = JSON.parse(JSON.stringify( this.notifications[index] )); |
|
130 | 157 |
|
131 |
console.info("Send notification to db: ", this.notifications[index]);
|
|
158 |
this.status = this.errorCodes.DONE;
|
|
132 | 159 |
|
133 |
this._mailPrefsService.saveUserEmailPreferences(this.notifications[index], this.properties.claimsAPIURL).subscribe( |
|
134 |
data => { |
|
135 |
console.info("Notification saved successfully"); |
|
136 |
this.initialNotifications[index] = JSON.parse(JSON.stringify( this.notifications[index] )); |
|
137 |
|
|
138 |
this.status = this.errorCodes.DONE; |
|
139 |
|
|
140 |
UIkit.notification({ |
|
141 |
message : '<strong>Your email preferences for '+this.notifications[index].openaireName+' have been successfully changed<strong>', |
|
142 |
status : 'success', |
|
143 |
timeout : 3000, |
|
144 |
pos : 'top-center' |
|
145 |
}); |
|
146 |
}, |
|
147 |
err => { |
|
148 |
console.log(err); |
|
149 |
this.status = this.errorCodes.NOT_SAVED; |
|
150 |
} |
|
151 |
); |
|
160 |
/*UIkit.notification({ |
|
161 |
message : '<strong>Your email preferences for '+this.notifications[index].openaireName+' have been successfully changed<strong>', |
|
162 |
status : 'success', |
|
163 |
timeout : 3000, |
|
164 |
pos : 'top-center' |
|
165 |
});*/ |
|
166 |
this.savedMessage = "Notification settings for claims saved!"; |
|
167 |
}, |
|
168 |
err => { |
|
169 |
console.log(err); |
|
170 |
this.status = this.errorCodes.NOT_SAVED; |
|
171 |
} |
|
172 |
); |
|
173 |
} |
|
174 |
} else { |
|
175 |
console.info("Notification not changed: ", this.notifications[index]); |
|
176 |
/*UIkit.notification({ |
|
177 |
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>', |
|
178 |
status : 'primary', |
|
179 |
timeout : 3000, |
|
180 |
pos : 'top-center' |
|
181 |
});*/ |
|
182 |
this.savedMessage = "Notification settings for claims saved!"; |
|
152 | 183 |
} |
153 |
} else { |
|
154 |
console.info("Notification not changed: ", this.notifications[index]); |
|
155 |
UIkit.notification({ |
|
156 |
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>', |
|
157 |
status : 'primary', |
|
158 |
timeout : 3000, |
|
159 |
pos : 'top-center' |
|
160 |
}); |
|
161 | 184 |
} |
162 | 185 |
} |
163 | 186 |
|
164 | 187 |
restoreNotification(index: number) { |
165 |
console.info("Restore Notification"); |
|
166 |
console.info(this.notifications[index]); |
|
167 |
this.notifications[index] = JSON.parse(JSON.stringify( this.initialNotifications[index] )); |
|
168 |
console.info(this.initialNotifications[index]); |
|
188 |
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { |
|
189 |
this.status = this.errorCodes.LOADING; |
|
190 |
this.savedMessage = ""; |
|
191 |
console.info("Restore Notification"); |
|
192 |
console.info(this.notifications[index]); |
|
193 |
this.notifications[index] = JSON.parse(JSON.stringify( this.initialNotifications[index] )); |
|
194 |
console.info(this.initialNotifications[index]); |
|
195 |
this.status = this.errorCodes.DONE; |
|
196 |
this.prefsChanged[index] = false; |
|
197 |
} |
|
169 | 198 |
} |
170 |
|
|
199 |
/* |
|
200 |
prefsChanged(index: number) : boolean { |
|
201 |
if(this.notifications.length > 0 && this.initialNotifications.length > 0) { |
|
202 |
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) { |
|
203 |
return true; |
|
204 |
} |
|
205 |
} |
|
206 |
return false; |
|
207 |
} |
|
208 |
*/ |
|
171 | 209 |
ngOnDestroy() { |
172 | 210 |
if(this.sub) { |
173 | 211 |
this.sub.unsubscribe(); |
... | ... | |
177 | 215 |
handleErrors(err){ |
178 | 216 |
//this.showErrorMessage = true; |
179 | 217 |
//try{ |
180 |
var error = err.json() |
|
181 |
//var code = error.code; |
|
182 |
|
|
183 |
console.info(err); |
|
184 |
var code = error.code; |
|
218 |
var code = ""; |
|
219 |
if(!err.status) { |
|
220 |
var error = err.json(); |
|
221 |
code = error.code; |
|
222 |
} else { |
|
223 |
code = err.status; |
|
224 |
} |
|
185 | 225 |
console.info(code); |
186 | 226 |
if(code == "403") { |
187 | 227 |
this.status = this.errorCodes.FORBIDDEN; |
modules/uoa-services-library/trunk/ng-openaire-library/src/assets/library.css | ||
---|---|---|
1007 | 1007 |
color: #fff !important; |
1008 | 1008 |
text-decoration: underline; |
1009 | 1009 |
} |
1010 |
|
|
1011 |
.inherit-color { |
|
1012 |
color: inherit; |
|
1013 |
} |
modules/uoa-admin-portal/trunk/src/app/pages/usernotifications/manage-user-notifications.component.html | ||
---|---|---|
1 |
<div id="manage-user-notifications" class=" uk-card uk-card-default uk-padding"> |
|
2 |
<div class="uk-text-large uk-text-center uk-width-5-6@l uk-width">Manage User Notifications</div> |
|
3 |
</div> |
|
4 |
<div *ngIf="communityId != null && userNotifications && !showLoading && !errorMessage">
|
|
1 |
<div id="manage-user-notifications" class=" uk-card uk-card-default uk-padding">
|
|
2 |
<div class="uk-text-large uk-text-center uk-width-5-6@l uk-width">Manage User Notifications</div>
|
|
3 |
</div>
|
|
4 |
<div class="uk-container uk-margin-top">
|
|
5 | 5 |
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div> |
6 | 6 |
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div> |
7 | 7 |
<div *ngIf="successfulSaveMessage" class="uk-alert uk-alert-success" role="alert">{{successfulSaveMessage}}</div> |
8 | 8 |
<div *ngIf="successfulResetMessage" class="uk-alert uk-alert-warning" role="alert">{{successfulResetMessage}}</div> |
9 | 9 |
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div> |
10 |
<table class="uk-table uk-width-1-2 uk-align-center"> |
|
10 |
<div *ngIf="communityId != null && userNotifications && !showLoading && !errorMessage" class="uk-first-column uk-align-center uk-width-2-3"> |
|
11 |
<form class="uk-form-horizontal"> |
|
12 |
<div class="uk-margin"> |
|
13 |
<div class="uk-form-label inherit-color">Notify for new managers:</div> |
|
14 |
<div class="uk-form-controls uk-form-controls-text" data-uk-button-group> |
|
15 |
<button *ngIf="userNotifications.notifyForNewManagers" class="uk-button uk-button-primary uk-button-small" |
|
16 |
data-uk-button>ON</button> |
|
17 |
<button *ngIf="!userNotifications.notifyForNewManagers" class="uk-button uk-button-default uk-button-small" |
|
18 |
(click)="changeValueForNewManagers(userNotifications.notifyForNewManagers)" data-uk-button>ON</button> |
|
19 |
<button *ngIf="!userNotifications.notifyForNewManagers" class="uk-button uk-button-danger uk-button-small" |
|
20 |
data-uk-button>OFF</button> |
|
21 |
<button *ngIf="userNotifications.notifyForNewManagers" class="uk-button uk-button-default uk-button-small" |
|
22 |
(click)="changeValueForNewManagers(userNotifications.notifyForNewManagers)" data-uk-button>OFF</button> |
|
23 |
</div> |
|
24 |
</div> |
|
25 |
<div class="uk-margin"> |
|
26 |
<div class="uk-form-label inherit-color">Notify for new subscribers:</div> |
|
27 |
<div class="uk-form-controls uk-form-controls-text" data-uk-button-group> |
|
28 |
<button *ngIf="userNotifications.notifyForNewSubscribers" class="uk-button uk-button-primary uk-button-small" |
|
29 |
data-uk-button>ON</button> |
|
30 |
<button *ngIf="!userNotifications.notifyForNewSubscribers" class="uk-button uk-button-default uk-button-small" |
|
31 |
(click)="changeValueForNewSubscribers(userNotifications.notifyForNewSubscribers)" data-uk-button>ON</button> |
|
32 |
<button *ngIf="!userNotifications.notifyForNewSubscribers" class="uk-button uk-button-danger uk-button-small" |
|
33 |
data-uk-button>OFF</button> |
|
34 |
<button *ngIf="userNotifications.notifyForNewSubscribers" class="uk-button uk-button-default uk-button-small" |
|
35 |
(click)="changeValueForNewSubscribers(userNotifications.notifyForNewSubscribers)" data-uk-button>OFF</button> |
|
36 |
</div> |
|
37 |
</div> |
|
38 |
</form> |
|
39 |
</div> |
|
40 |
</div> |
|
41 |
|
|
42 |
<!-- <table class="uk-table uk-width-1-2 uk-align-center"> |
|
11 | 43 |
<tbody> |
12 | 44 |
<div> |
13 | 45 |
<tr> |
... | ... | |
46 | 78 |
</tr> |
47 | 79 |
</div> |
48 | 80 |
</tbody> |
49 |
</table> |
|
50 |
<div class = "uk-grid-margin uk-first-column uk-align-center uk-width-1-3"> |
|
81 |
</table> -->
|
|
82 |
<!-- <div class = "uk-grid-margin uk-first-column uk-align-center uk-width-1-3">
|
|
51 | 83 |
<button *ngIf="hasChanged" class="uk-button uk-button-primary" (click)="updateUserNotifications()">Save</button> |
52 | 84 |
<button *ngIf="!hasChanged" class="uk-button uk-button-default" disabled>Save</button> |
53 | 85 |
<button class="uk-button" (click)="resetForm(communityId)">Reset</button> |
54 |
</div> |
|
55 |
</div> |
|
56 |
<mailPrefs></mailPrefs> |
|
86 |
</div> --> |
|
87 |
|
|
88 |
|
|
89 |
<mailPrefs id="mailPrefs" [showSaveResetButtons]="false"></mailPrefs> |
|
90 |
<div class = "uk-first-column uk-align-center uk-width-1-3"> |
|
91 |
<button *ngIf="hasChanged || mailPrefsChanged()" class="uk-button uk-button-primary" (click)="updateUserNotifications()">Save</button> |
|
92 |
<button *ngIf="!hasChanged && !mailPrefsChanged()" class="uk-button uk-button-default" disabled>Save</button> |
|
93 |
<button class="uk-button" (click)="resetForm(communityId)">Reset</button> |
|
94 |
</div> |
modules/uoa-admin-portal/trunk/src/app/pages/usernotifications/manage-user-notifications.component.ts | ||
---|---|---|
1 |
import {Component, OnInit, Input} from '@angular/core'; |
|
1 |
import {Component, OnInit, Input, ViewChild} from '@angular/core';
|
|
2 | 2 |
import {FormGroup, FormBuilder} from '@angular/forms'; |
3 | 3 |
import {ActivatedRoute, Router} from '@angular/router'; |
4 | 4 |
import {CommonModule} from "@angular/common"; |
... | ... | |
11 | 11 |
|
12 | 12 |
import {UserNotificationsRights} from './userNotificationsRights'; |
13 | 13 |
|
14 |
import {MailPrefsComponent} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.component'; |
|
15 |
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; |
|
16 |
|
|
14 | 17 |
@Component({ |
15 | 18 |
selector: 'manage-user-notifications', |
16 | 19 |
templateUrl: './manage-user-notifications.component.html', |
... | ... | |
24 | 27 |
public properties: EnvProperties = null; |
25 | 28 |
public communityId = null; |
26 | 29 |
public userNotifications = null; |
30 |
public initialUserNotifications = null; |
|
27 | 31 |
public userEmail = null; |
28 | 32 |
|
29 | 33 |
public showLoading: boolean = true; |
... | ... | |
35 | 39 |
|
36 | 40 |
public hasChanged: boolean = false; |
37 | 41 |
|
42 |
@ViewChild (MailPrefsComponent) mailPrefs : MailPrefsComponent; |
|
43 |
|
|
38 | 44 |
constructor (private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, |
39 | 45 |
private _manageUserNotificationsService: ManageUserNotificationsService) { |
40 | 46 |
} |
... | ... | |
49 | 55 |
this.showLoading = true; |
50 | 56 |
this.updateErrorMessage = ""; |
51 | 57 |
this.errorMessage = ""; |
58 |
this.successfulSaveMessage = ""; |
|
52 | 59 |
|
53 | 60 |
if (Session.getUser()) { |
54 | 61 |
this.userEmail = Session.getUserEmail(); |
55 | 62 |
|
56 | 63 |
this._manageUserNotificationsService.getUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", this.userEmail).subscribe( |
57 | 64 |
userNotifications => { |
58 |
this.userNotifications = userNotifications;
|
|
65 |
this.initialUserNotifications = userNotifications;
|
|
59 | 66 |
|
60 |
if (this.userNotifications['notifyForNewManagers'] == null || this.userNotifications['notifyForNewSubscribers'] == null) {
|
|
61 |
this.userNotifications = this.initiateUserNotifications();
|
|
67 |
if (this.initialUserNotifications['notifyForNewManagers'] == null || this.initialUserNotifications['notifyForNewSubscribers'] == null) {
|
|
68 |
this.initialUserNotifications = this.initiateUserNotifications();
|
|
62 | 69 |
} |
63 | 70 |
|
71 |
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications )); |
|
72 |
|
|
64 | 73 |
//TODO remove after final testing |
65 | 74 |
console.log("Before: ", userNotifications); |
66 |
console.log("After: ", this.userNotifications);
|
|
75 |
console.log("After: ", this.initialUserNotifications);
|
|
67 | 76 |
this.showLoading = false; |
68 | 77 |
}, |
69 | 78 |
error => { |
70 | 79 |
console.log(error.status); |
71 | 80 |
if (error.status == '404') { |
72 |
this.userNotifications = this.initiateUserNotifications();
|
|
73 |
console.log(this.userNotifications);
|
|
74 |
this.showLoading = false;
|
|
81 |
this.initialUserNotifications = this.initiateUserNotifications();
|
|
82 |
console.log(this.initialUserNotifications);
|
|
83 |
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications ));
|
|
75 | 84 |
} else { |
76 | 85 |
this.handleError('System error retrieving user notifications', error) |
77 | 86 |
} |
87 |
this.showLoading = false; |
|
78 | 88 |
} |
79 | 89 |
); |
80 | 90 |
} |
... | ... | |
95 | 105 |
} |
96 | 106 |
|
97 | 107 |
public updateUserNotifications() { |
98 |
if (this.communityId != null && this.communityId != '') { |
|
99 |
this.showLoading = true; |
|
100 |
var userNotifications = this.parseUpdatedUserNotifications(); |
|
101 |
console.log(userNotifications); |
|
108 |
if(!Session.isLoggedIn()){ |
|
109 |
console.info(this._router.url); |
|
110 |
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); |
|
111 |
} else { |
|
112 |
if (this.communityId != null && this.communityId != '') { |
|
113 |
this.mailPrefs.saveNotification(0); |
|
102 | 114 |
|
103 |
this._manageUserNotificationsService.updateUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", userNotifications).subscribe( |
|
104 |
userNotifications => { |
|
105 |
this.handleSuccessfulSave('Notification settings saved!') |
|
106 |
}, |
|
107 |
error => this.handleUpdateError('System error updating user notifications', error) |
|
108 |
); |
|
115 |
this.successfulSaveMessage = ""; |
|
116 |
this.showLoading = true; |
|
117 |
var userNotifications = this.parseUpdatedUserNotifications(); |
|
118 |
console.log(userNotifications); |
|
119 |
|
|
120 |
this._manageUserNotificationsService.updateUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", userNotifications).subscribe( |
|
121 |
userNotifications => { |
|
122 |
this.initialUserNotifications = JSON.parse(JSON.stringify( this.userNotifications )); |
|
123 |
this.handleSuccessfulSave('Notification settings saved!') |
|
124 |
}, |
|
125 |
error => this.handleUpdateError('System error updating user notifications', error) |
|
126 |
); |
|
127 |
} |
|
128 |
this.resetChange(); |
|
109 | 129 |
} |
110 |
this.resetChange(); |
|
111 | 130 |
} |
112 | 131 |
|
113 | 132 |
private parseUpdatedUserNotifications() : {} { |
... | ... | |
127 | 146 |
} |
128 | 147 |
|
129 | 148 |
public resetForm(communityId:string) { |
149 |
/* |
|
130 | 150 |
if (communityId != null && communityId != '') { |
131 | 151 |
this.showLoading = true; |
132 | 152 |
this.updateErrorMessage = ""; |
133 | 153 |
this.errorMessage = ""; |
134 | 154 |
|
155 |
this.mailPrefs.restoreNotification(0); |
|
156 |
|
|
135 | 157 |
this._manageUserNotificationsService.getUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", this.userEmail).subscribe( |
136 | 158 |
userNotifications => { |
137 | 159 |
this.userNotifications = userNotifications; |
... | ... | |
141 | 163 |
error => this.handleError('System error retrieving user notifications', error) |
142 | 164 |
); |
143 | 165 |
} |
166 |
|
|
167 |
*/ |
|
168 |
this.mailPrefs.restoreNotification(0); |
|
169 |
|
|
170 |
if(this.userNotifications && this.initialUserNotifications) { |
|
171 |
this.successfulSaveMessage = ""; |
|
172 |
this.showLoading = true; |
|
173 |
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications )); |
|
174 |
this.showLoading = false; |
|
175 |
} |
|
176 |
|
|
177 |
|
|
144 | 178 |
this.resetChange(); |
145 | 179 |
} |
146 | 180 |
|
... | ... | |
168 | 202 |
console.log('I have changed: I AM FALSE'); |
169 | 203 |
} |
170 | 204 |
|
205 |
public mailPrefsChanged(): boolean { |
|
206 |
return this.mailPrefs.prefsChanged["0"];//(0); |
|
207 |
} |
|
208 |
|
|
171 | 209 |
handleUpdateError(message: string, error) { |
172 | 210 |
this.updateErrorMessage = message; |
173 | 211 |
console.log('Server responded: ' +error); |
Also available in: Unified diff
1. library.css: Add class 'inherit-color' (used in user notifications: uk-form-label).
2. mailPrefs.component: make functionality of buttons like manage-user-notifications.component of admin portal (when preferences change, save button remains clickable unless 'reset' is clicked).
3. manage-user-notifications.component: Change html (stop using table for proper layout - use form instead).
4. When Session expires, redirect to '/user-info'.