From 264f5ca30b254484066b704ba95c4877c6a6a17e Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Fri, 8 Jul 2022 21:59:17 +0300 Subject: [PATCH] Fix manage user notifications buttons status --- src/app/openaireLibrary | 2 +- .../edit-community.component.ts | 32 ++--- .../manage-user-notifications.component.html | 2 +- .../manage-user-notifications.component.ts | 114 ++++++------------ src/assets/common-assets | 2 +- src/assets/dashboard-theme | 2 +- src/assets/openaire-theme | 2 +- 7 files changed, 48 insertions(+), 108 deletions(-) diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index f08c63d..02bf9ab 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit f08c63d3849e966bcfe916f0ca48788e0b401306 +Subproject commit 02bf9abee4f2b514f2f02c510fab47da6bf3431b diff --git a/src/app/pages/community-info/profile/edit-community/edit-community.component.ts b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts index 86a5e6a..5476eb8 100644 --- a/src/app/pages/community-info/profile/edit-community/edit-community.component.ts +++ b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts @@ -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; -
+
@@ -77,7 +77,7 @@ declare var UIkit;
{{uploadError}}
-
@@ -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 successfully created', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); + NotificationHandler.rise(community.shortTitle + ' has been successfully created'); 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 successfully saved', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); + NotificationHandler.rise(community.shortTitle + ' has been successfully saved'); 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'); })); } } diff --git a/src/app/pages/usernotifications/manage-user-notifications.component.html b/src/app/pages/usernotifications/manage-user-notifications.component.html index 2013ccc..4830859 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.component.html +++ b/src/app/pages/usernotifications/manage-user-notifications.component.html @@ -59,7 +59,7 @@
diff --git a/src/app/pages/usernotifications/manage-user-notifications.component.ts b/src/app/pages/usernotifications/manage-user-notifications.component.ts index 533aab1..e2fa278 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.component.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.component.ts @@ -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) { diff --git a/src/assets/common-assets b/src/assets/common-assets index 052d94e..d577c6d 160000 --- a/src/assets/common-assets +++ b/src/assets/common-assets @@ -1 +1 @@ -Subproject commit 052d94e27ce698a119755973e0b7285d2b64370b +Subproject commit d577c6d69a55901e319cf0cf5b93f900f1cdeaab diff --git a/src/assets/dashboard-theme b/src/assets/dashboard-theme index 319eff1..141c71c 160000 --- a/src/assets/dashboard-theme +++ b/src/assets/dashboard-theme @@ -1 +1 @@ -Subproject commit 319eff1cc355ffc4148cf20c4ba23e15fbc6a6f6 +Subproject commit 141c71c3104bab1382e6008697043ea87e03ea44 diff --git a/src/assets/openaire-theme b/src/assets/openaire-theme index 3c6d5ca..32040ce 160000 --- a/src/assets/openaire-theme +++ b/src/assets/openaire-theme @@ -1 +1 @@ -Subproject commit 3c6d5cab3a9e3a1e3be42e231424a5c1350749ad +Subproject commit 32040ce807ad4945e7682b39a3fbc6faecf2f619