Fix manage user notifications buttons status
This commit is contained in:
parent
803dc0a2d9
commit
264f5ca30b
|
@ -1 +1 @@
|
|||
Subproject commit f08c63d3849e966bcfe916f0ca48788e0b401306
|
||||
Subproject commit 02bf9abee4f2b514f2f02c510fab47da6bf3431b
|
|
@ -10,8 +10,7 @@ import {UserManagementService} from "../../../../openaireLibrary/services/user-m
|
|||
import {StringUtils} from "../../../../openaireLibrary/utils/string-utils.class";
|
||||
import {Subscription} from "rxjs";
|
||||
import {Option} from "../../../../openaireLibrary/sharedComponents/input/input.component";
|
||||
|
||||
declare var UIkit;
|
||||
import {NotificationHandler} from "../../../../openaireLibrary/utils/notification-handler";
|
||||
|
||||
@Component({
|
||||
selector: 'edit-community',
|
||||
|
@ -56,7 +55,8 @@ declare var UIkit;
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div input class="uk-width-expand" type="logoURL" [placeholder]="'Link to the logo'" [formInput]="communityFb.get('logoUrl')"></div>
|
||||
<div input class="uk-width-expand" type="logoURL" [placeholder]="'Link to the logo'"
|
||||
[formInput]="communityFb.get('logoUrl')"></div>
|
||||
</div>
|
||||
<div *ngIf="communityFb.get('isUpload').value" class="uk-width-1-1 uk-flex uk-flex-middle">
|
||||
<div class="uk-card uk-card-default uk-text-center uk-border-circle">
|
||||
|
@ -77,7 +77,7 @@ declare var UIkit;
|
|||
<div *ngIf="uploadError" class="uk-text-danger uk-margin-small-top uk-width-1-1">{{uploadError}}</div>
|
||||
</div>
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="communityFb.get('status')"
|
||||
<div input [formInput]="communityFb.get('status')"
|
||||
placeholder="Visibility status for your community's profile."
|
||||
[options]="statuses" type="select"></div>
|
||||
</div>
|
||||
|
@ -212,19 +212,11 @@ export class EditCommunityComponent {
|
|||
this.subscriptions.push(this.communityService.updateCommunity(
|
||||
this.properties.communityAPI + this.community.communityId, this.communityFb.getRawValue()).subscribe(() => {
|
||||
this.communityService.getCommunity(this.community.communityId, true).subscribe(community => {
|
||||
UIkit.notification(community.shortTitle + ' has been <b>successfully created</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise(community.shortTitle + ' has been <b>successfully created</b>');
|
||||
callback(community);
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
||||
if (errorCallback) {
|
||||
errorCallback(error)
|
||||
}
|
||||
|
@ -232,19 +224,11 @@ export class EditCommunityComponent {
|
|||
} else {
|
||||
this.subscriptions.push(this.communityService.updateCommunity(this.properties.communityAPI + this.community.communityId, this.communityFb.getRawValue()).subscribe(() => {
|
||||
this.communityService.getCommunity(this.community.communityId, true).subscribe(community => {
|
||||
UIkit.notification(community.shortTitle + ' has been <b>successfully saved</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise(community.shortTitle + ' has been <b>successfully saved</b>');
|
||||
callback(community);
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<div class="uk-flex uk-flex-between">
|
||||
<label *ngFor="let option of frequencyOptions">
|
||||
<input class="uk-radio" type="radio" [checked]="notification.frequency === option.value"
|
||||
(click)="notification.frequency = option.value">
|
||||
(click)="notification.frequency = option.value; change()">
|
||||
<span class="uk-margin-small-left">{{option.label}}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
@ -6,7 +6,6 @@ import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
|
|||
import {ManageUserNotificationsService} from './manage-user-notifications.service';
|
||||
import {UserNotificationsRights} from './userNotificationsRights';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
|
||||
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
|
||||
|
@ -15,8 +14,7 @@ import {Subscriber} from 'rxjs';
|
|||
import {MailPrefsService} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.service';
|
||||
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
|
||||
import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
|
||||
|
||||
declare var UIkit;
|
||||
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
|
||||
|
||||
@Component({
|
||||
selector: 'manage-user-notifications',
|
||||
|
@ -137,41 +135,34 @@ export class ManageUserNotificationsComponent implements OnInit {
|
|||
|
||||
|
||||
public updateUserNotifications() {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'],
|
||||
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
|
||||
} else {
|
||||
if (this.community.communityId != null && this.community.communityId !== '') {
|
||||
this.showLoading = true;
|
||||
const userNotifications = this.parseUpdatedUserNotifications();
|
||||
this.subscriptions.push(this.manageUserNotificationsService.updateUserNotifications(this.properties, this.community.communityId, userNotifications).subscribe(
|
||||
userNotifications => {
|
||||
this.initialUserNotifications = JSON.parse(JSON.stringify(this.userNotifications));
|
||||
this.handleSuccessfulSave('Notification settings saved!');
|
||||
},
|
||||
error => this.handleUpdateError('System error updating user notifications', error)
|
||||
));
|
||||
this.subscriptions.push(this.mailPrefsService.saveUserEmailPreferences(this.notifications[0], this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
this.initialNotifications[0] = JSON.parse(JSON.stringify(this.notifications[0]));
|
||||
this.handleSuccessfulSave('Claims notification settings saved!');
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error saving user email preferences: " + JSON.stringify(this.notifications[0]), err);
|
||||
}
|
||||
));
|
||||
}
|
||||
this.resetChange();
|
||||
if (this.community.communityId != null && this.community.communityId !== '') {
|
||||
this.showLoading = true;
|
||||
const userNotifications = this.parseUpdatedUserNotifications();
|
||||
this.subscriptions.push(this.manageUserNotificationsService.updateUserNotifications(this.properties, this.community.communityId, userNotifications).subscribe(
|
||||
userNotifications => {
|
||||
this.initialUserNotifications = JSON.parse(JSON.stringify(this.userNotifications));
|
||||
this.handleSuccessfulSave('Notification settings saved!');
|
||||
},
|
||||
error => this.handleUpdateError('System error updating user notifications', error)
|
||||
));
|
||||
this.subscriptions.push(this.mailPrefsService.saveUserEmailPreferences(this.notifications[0], this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
this.initialNotifications[0] = JSON.parse(JSON.stringify(this.notifications[0]));
|
||||
this.handleSuccessfulSave('Claims notification settings saved!');
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error saving user email preferences: " + JSON.stringify(this.notifications[0]), err);
|
||||
}
|
||||
));
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
|
||||
private parseUpdatedUserNotifications(): {} {
|
||||
const userNotifications = {};
|
||||
|
||||
userNotifications['notifyForNewManagers'] = this.userNotifications.notifyForNewManagers;
|
||||
userNotifications['notifyForNewSubscribers'] = this.userNotifications.notifyForNewSubscribers;
|
||||
|
||||
if (this.userNotifications.managerEmail) {
|
||||
userNotifications['managerEmail'] = this.userNotifications.managerEmail;
|
||||
}
|
||||
|
@ -179,50 +170,27 @@ export class ManageUserNotificationsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public resetForm() {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
|
||||
});
|
||||
} else {
|
||||
// this.mailPrefs.restoreNotification(0);
|
||||
this.notifications[0] = JSON.parse(JSON.stringify(this.initialNotifications[0]));
|
||||
|
||||
if (this.userNotifications && this.initialUserNotifications) {
|
||||
// this.successfulSaveMessage = '';
|
||||
this.showLoading = true;
|
||||
this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications));
|
||||
this.showLoading = false;
|
||||
}
|
||||
this.resetChange();
|
||||
this.notifications[0] = JSON.parse(JSON.stringify(this.initialNotifications[0]));
|
||||
if (this.userNotifications && this.initialUserNotifications) {
|
||||
this.showLoading = true;
|
||||
this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications));
|
||||
this.showLoading = false;
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
|
||||
public changeValueForNewManagers(notifyForManagers: any) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {' "errorCode"': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
|
||||
});
|
||||
} else {
|
||||
this.userNotifications.notifyForNewManagers = !notifyForManagers;
|
||||
this.change();
|
||||
}
|
||||
this.userNotifications.notifyForNewManagers = !notifyForManagers;
|
||||
this.change();
|
||||
}
|
||||
|
||||
public changeValueForNewSubscribers(notifyForSubscribers: any) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
|
||||
});
|
||||
} else {
|
||||
this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers;
|
||||
this.change();
|
||||
}
|
||||
this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers;
|
||||
this.change();
|
||||
}
|
||||
|
||||
private change() {
|
||||
public change() {
|
||||
this.hasChanged = true;
|
||||
// this.successfulSaveMessage = '';
|
||||
// this.successfulResetMessage = '';
|
||||
}
|
||||
|
||||
private resetChange() {
|
||||
|
@ -230,31 +198,19 @@ export class ManageUserNotificationsComponent implements OnInit {
|
|||
}
|
||||
|
||||
handleUpdateError(message: string, error) {
|
||||
// this.updateErrorMessage = message;
|
||||
console.log('Server responded: ' + error);
|
||||
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
handleError(message: string, error) {
|
||||
// this.errorMessage = message;
|
||||
console.log('Server responded: ' + error);
|
||||
UIkit.notification(message, {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
handleSuccessfulSave(message) {
|
||||
this.showLoading = false;
|
||||
// this.successfulSaveMessage = message;
|
||||
UIkit.notification(message, {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
NotificationHandler.rise(message);
|
||||
}
|
||||
|
||||
changeNotify(notification: any, checked: boolean, index: number) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 052d94e27ce698a119755973e0b7285d2b64370b
|
||||
Subproject commit d577c6d69a55901e319cf0cf5b93f900f1cdeaab
|
|
@ -1 +1 @@
|
|||
Subproject commit 319eff1cc355ffc4148cf20c4ba23e15fbc6a6f6
|
||||
Subproject commit 141c71c3104bab1382e6008697043ea87e03ea44
|
|
@ -1 +1 @@
|
|||
Subproject commit 3c6d5cab3a9e3a1e3be42e231424a5c1350749ad
|
||||
Subproject commit 32040ce807ad4945e7682b39a3fbc6faecf2f619
|
Loading…
Reference in New Issue