diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts index 19cbe6c2..df92f83b 100644 --- a/dashboard/users/role-users/role-users.component.ts +++ b/dashboard/users/role-users/role-users.component.ts @@ -277,7 +277,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { if (!this.pending.includes(response.email)) { this.pending.push(response.email); } - if(this.notificationFn) { + if(this.notificationFn && properties.notificationsAPIURL) { return this.notificationService.sendNotification(this.notificationFn(this.name, response.email, this.role, response.invitation)).pipe(map(notification => { return notification; }), tap(() => { diff --git a/monitor-admin/topic/indicators.component.ts b/monitor-admin/topic/indicators.component.ts index f54881a3..69b026d1 100644 --- a/monitor-admin/topic/indicators.component.ts +++ b/monitor-admin/topic/indicators.component.ts @@ -43,6 +43,7 @@ import {NotifyFormComponent} from "../../notifications/notify-form/notify-form.c import {NotificationService} from "../../notifications/notification.service"; import {NotificationHandler} from "../../utils/notification-handler"; import {IndicatorStakeholderBaseComponent} from "../utils/stakeholder-base.component"; +import {properties} from "../../../../environments/environment"; declare var UIkit; declare var copy; @@ -845,39 +846,42 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple this.setCharts(); this.setNumbers(); this.initReorder(); - this.notification = NotificationUtils.importIndicators(this.user.fullname, this.stakeholder.alias); - this.notification.entity = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index]._id; - this.notification.name = this.user.firstname; - this.notification.surname = this.user.lastname; - this.notification.stakeholder = this.stakeholder.alias; - this.notification.stakeholderType = this.stakeholder.type; - this.notification.groups = [Role.curator(this.stakeholder.type)]; - if (this.stakeholder.defaultId) { - this.notification.groups.push(Role.manager(this.stakeholder.type, this.stakeholder.alias)); - this.notificationService.sendNotification(this.notification).subscribe(notification => { - UIkit.notification('A notification has been sent successfully', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - }, error => { - UIkit.notification('An error has occurred. Please try again later', { - status: 'danger', - timeout: 6000, - pos: 'bottom-right' - }); - }); - } else { - this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => { - stakeholders.forEach(value => { - this.notification.groups.push(Role.manager(value.type, value.alias)) - }); + if(properties.notificationsAPIURL) { + this.notification = NotificationUtils.importIndicators(this.user.fullname, this.stakeholder.alias); + this.notification.entity = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index]._id; + this.notification.name = this.user.firstname; + this.notification.surname = this.user.lastname; + this.notification.stakeholder = this.stakeholder.alias; + this.notification.stakeholderType = this.stakeholder.type; + this.notification.groups = [Role.curator(this.stakeholder.type)]; + if (this.stakeholder.defaultId) { + this.notification.groups.push(Role.manager(this.stakeholder.type, this.stakeholder.alias)); this.notificationService.sendNotification(this.notification).subscribe(notification => { - NotificationHandler.rise('A notification has been sent successfully'); + UIkit.notification('A notification has been sent successfully', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => { - NotificationHandler.rise('An error has occurred. Please try again later', 'danger'); + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); }); - }); + } else { + this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => { + stakeholders.forEach(value => { + this.notification.groups.push(Role.manager(value.type, value.alias)) + }); + + this.notificationService.sendNotification(this.notification).subscribe(notification => { + NotificationHandler.rise('A notification has been sent successfully'); + }, error => { + NotificationHandler.rise('An error has occurred. Please try again later', 'danger'); + }); + }); + } } this.editing = false; this.importLoading = false; diff --git a/notifications/notify-form/notify-form.component.ts b/notifications/notify-form/notify-form.component.ts index 8ad475a9..c9196149 100644 --- a/notifications/notify-form/notify-form.component.ts +++ b/notifications/notify-form/notify-form.component.ts @@ -109,7 +109,7 @@ export class NotifyFormComponent extends BaseComponent implements OnInit { } sendNotification(notification: Notification = null) { - if (this.message) { + if (this.message && this.properties.notificationsAPIURL) { if(notification === null) { notification = new Notification('CUSTOM', [this.service], null, null); notification.groups = this.parseGroups(); diff --git a/services/user-management.service.ts b/services/user-management.service.ts index dbf512bf..7ceee541 100644 --- a/services/user-management.service.ts +++ b/services/user-management.service.ts @@ -44,7 +44,7 @@ export class UserManagementService { return this.getUserInfoSubject.asObservable(); } - public getUserInfoAt(index = 1): Observable { + public getUserInfoAt(index = 0): Observable { return this.http.get((isArray(properties.loginServiceURL)?properties.loginServiceURL[index]:properties.loginServiceURL) + UserManagementService.USERINFO, CustomOptions.registryOptions()).pipe(map(userInfo => { return new User(userInfo); @@ -54,7 +54,6 @@ export class UserManagementService { public updateUserInfo(resolve: Function = null) { this.subscription = this.getUserInfoAt().subscribe(user => { - // console.log(user) this.getUserInfoSubject.next(user); if (resolve) { resolve(); @@ -114,7 +113,6 @@ export class UserManagementService { } setURL(url: string | string[]) { - console.log(url); if(isArray(url)) { let redirectURL = ''; url.forEach((url, index) => {