diff --git a/src/app/admin-tools/admin-tools-routing.module.ts b/src/app/admin-tools/admin-tools-routing.module.ts index 1d9fc44..577f642 100644 --- a/src/app/admin-tools/admin-tools-routing.module.ts +++ b/src/app/admin-tools/admin-tools-routing.module.ts @@ -9,20 +9,20 @@ import {RouterModule} from '@angular/router'; loadChildren: '../openaireLibrary/dashboard/entity/entities.module#EntitiesModule', pathMatch: 'full' }, -/* { - path: 'classContents', - loadChildren: '../openaireLibrary/dashboard/divhelpcontent/div-help-contents.module#DivHelpContentsModule' - }, - { - path: 'classContents/new', - loadChildren: '../openaireLibrary/dashboard/divhelpcontent/new-div-help-content.module#NewDivHelpContentModule', - pathMatch: 'full' - }, - { - path: 'classContents/edit', - loadChildren: '../openaireLibrary/dashboard/divhelpcontent/edit-div-help-content.module#EditDivHelpContentModule', - pathMatch: 'full' - },*/ + /* { + path: 'classContents', + loadChildren: '../openaireLibrary/dashboard/divhelpcontent/div-help-contents.module#DivHelpContentsModule' + }, + { + path: 'classContents/new', + loadChildren: '../openaireLibrary/dashboard/divhelpcontent/new-div-help-content.module#NewDivHelpContentModule', + pathMatch: 'full' + }, + { + path: 'classContents/edit', + loadChildren: '../openaireLibrary/dashboard/divhelpcontent/edit-div-help-content.module#EditDivHelpContentModule', + pathMatch: 'full' + },*/ { path: 'helptexts', loadChildren: '../openaireLibrary/dashboard/helpTexts/page-help-contents.module#PageHelpContentsModule', @@ -30,7 +30,7 @@ import {RouterModule} from '@angular/router'; }, { path: 'helptexts/edit', - loadChildren: '../openaireLibrary/dashboard/helpTexts/edit-page-help-content.module#EditPageHelpContentModule', + loadChildren: '../openaireLibrary/dashboard/helpTexts/page-help-content-form.module#PageHelpContentFormModule', pathMatch: 'full' }, { diff --git a/src/app/app.component.html b/src/app/app.component.html index 5a32966..e7a2b57 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -25,5 +25,7 @@ [centered]="true" [properties]="properties" [showMenuItems]="true"> + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4fe323c..c03b87e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -2,7 +2,7 @@ import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from '@an import {ActivatedRoute, NavigationEnd, Params, Router} from '@angular/router'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; -import {Session, User} from './openaireLibrary/login/utils/helper.class'; +import {Role, Session, User} from './openaireLibrary/login/utils/helper.class'; import {UserManagementService} from "./openaireLibrary/services/user-management.service"; import {StakeholderService} from "./openaireLibrary/monitor/services/stakeholder.service"; import {BehaviorSubject, Subscriber} from "rxjs"; @@ -14,6 +14,8 @@ import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component import {arrow_left} from "./openaireLibrary/utils/icons/icons"; import {properties} from "../environments/environment"; import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service"; +import {Option} from "./openaireLibrary/sharedComponents/input/input.component"; +import {StakeholderUtils} from "./utils/indicator-utils"; @Component({ @@ -33,6 +35,9 @@ export class AppComponent implements OnInit, OnDestroy { sideBarItems: MenuItem[] = []; specialSideBarMenuItem: MenuItem = null; menuItems: RootMenuItem[] = []; + notificationGroups: Option[] = []; + notificationGroupsInitialized: boolean = false; + stakeholderUtils: StakeholderUtils = new StakeholderUtils(); menuHeader: Header = { route: "/", url: null, @@ -169,10 +174,32 @@ export class AppComponent implements OnInit, OnDestroy { this.user = user; if (user) { this.buildMenu(); + if(!this.notificationGroupsInitialized && this.properties.environment === 'development') { + this.setNotificationGroups(); + } } })); } + public setNotificationGroups() { + this.notificationGroups = []; + if(Session.isPortalAdministrator(this.user)) { + this.notificationGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'}); + } + for(let type of this.stakeholderUtils.types) { + if(Session.isCurator(type.value, this.user) || Session.isPortalAdministrator(this.user)) { + this.notificationGroups.push({value: Role.curator(type.value), label: type.label + ' Curators'}); + } + } + this.subscriptions.push(this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL).subscribe(stakeholders => { + stakeholders.forEach(stakeholder => { + this.notificationGroups.push({value: Role.manager(stakeholder.type, stakeholder.alias), label: stakeholder.name + ' Managers'}); + this.notificationGroups.push({value: Role.member(stakeholder.type, stakeholder.alias), label: stakeholder.name + ' Members'}); + }); + this.notificationGroupsInitialized = true; + })); + } + public ngOnDestroy() { this.subscriptions.forEach(value => { if (value instanceof Subscriber) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f85c363..476b8f9 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -24,6 +24,7 @@ import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-int import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service"; import {AdminLoginGuard} from "./openaireLibrary/login/adminLoginGuard.guard"; import {AdminDashboardGuard} from "./utils/adminDashboard.guard"; +import {NotificationsSidebarModule} from "./openaireLibrary/notifications/notifications-sidebar/notifications-sidebar.module"; import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard"; @NgModule({ @@ -41,7 +42,7 @@ import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard"; BrowserModule.withServerTransition({appId: 'my-app'}), AppRoutingModule, BrowserTransferStateModule, - SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule + SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule, NotificationsSidebarModule ], declarations: [AppComponent, OpenaireErrorPageComponent], exports: [AppComponent], diff --git a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts index 2848db4..edfdf6b 100644 --- a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts +++ b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnDestroy} from "@angular/core"; +import {Component, Input, OnDestroy, ViewChild} from "@angular/core"; import {Stakeholder} from "../../openaireLibrary/monitor/entities/stakeholder"; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import {StakeholderUtils} from "../../utils/indicator-utils"; @@ -8,99 +8,98 @@ import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properti import {properties} from "../../../environments/environment"; import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service"; import {UtilitiesService} from "../../openaireLibrary/services/utilities.service"; -import {Session, User} from "../../openaireLibrary/login/utils/helper.class"; +import {Role, Session, User} from "../../openaireLibrary/login/utils/helper.class"; import {UserManagementService} from "../../openaireLibrary/services/user-management.service"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; +import {NotifyFormComponent} from "../../openaireLibrary/notifications/notify-form/notify-form.component"; +import {NotificationUtils} from "../../openaireLibrary/notifications/notification-utils"; +import {Notification} from "../../openaireLibrary/notifications/notifications"; declare var UIkit; @Component({ selector: 'edit-stakeholder', template: ` -
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- +
+
+ OR +
+
+
+
+
+ +
+
+
-
- OR +
+
-
-
- +
{{uploadError}}
+
+
-
- -
-
- +
+ +
+
-
-
-
- Note: Prefer urls like "https://example.com/my-secure-image.png" - instead of "http://example.com/my-image.png". - Browsers may not load non secure content. -
-
-
-
{{uploadError}}
-
-
-
-
- -
-
-
+ +
`, styleUrls: ['edit-stakeholder.component.css'] }) @@ -132,6 +131,8 @@ export class EditStakeholderComponent implements OnDestroy { public deleteCurrentPhoto: boolean = false; private maxsize: number = 200 * 1024; user: User; + @ViewChild('notify') notify: NotifyFormComponent; + private notification: Notification; constructor(private fb: FormBuilder, private stakeholderService: StakeholderService, @@ -204,6 +205,8 @@ export class EditStakeholderComponent implements OnDestroy { this.stakeholderFb.setControl('defaultId', this.fb.control(stakeholder.defaultId, Validators.required)); } if (!isNew) { + this.notification = NotificationUtils.editStakeholder(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name); + this.notify.reset(this.notification.message); if (this.isAdmin) { if (this.disableAlias) { setTimeout(() => { @@ -222,6 +225,8 @@ export class EditStakeholderComponent implements OnDestroy { this.stakeholderFb.get('type').disable(); }, 0); } else { + this.notification = NotificationUtils.createStakeholder(this.user.firstname + ' ' + this.user.lastname); + this.notify.reset(this.notification.message); setTimeout(() => { this.stakeholderFb.get('type').enable(); }, 0); @@ -244,6 +249,10 @@ export class EditStakeholderComponent implements OnDestroy { return this.stakeholderFb && this.stakeholderFb.dirty; } + public get canChooseType(): boolean { + return !this.stakeholderFb.get('isDefault').value && this.isNew && this.stakeholderFb.get('type').valid && !!this.defaultStakeholdersOptions; + } + reset() { this.uploadError = null; this.stakeholderFb = null; @@ -298,6 +307,11 @@ export class EditStakeholderComponent implements OnDestroy { this.removePhoto(); this.subscriptions.push(this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => { + this.notification.entity = stakeholder._id; + this.notification.stakeholder = stakeholder.alias; + this.notification.stakeholderType = stakeholder.type; + this.notification.groups = [Role.curator(stakeholder.type)]; + this.notify.sendNotification(this.notification); UIkit.notification(stakeholder.name + ' has been successfully created', { status: 'success', timeout: 6000, @@ -321,6 +335,11 @@ export class EditStakeholderComponent implements OnDestroy { this.stakeholderFb.get('index_name').enable(); this.stakeholderFb.get('index_shortName').enable(); this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => { + this.notification.entity = stakeholder._id; + this.notification.stakeholder = stakeholder.alias; + this.notification.stakeholderType = stakeholder.type; + this.notification.groups = [Role.curator(stakeholder.type), Role.manager(stakeholder.type, stakeholder.alias)]; + this.notify.sendNotification(this.notification); UIkit.notification(stakeholder.name + ' has been successfully saved', { status: 'success', timeout: 6000, diff --git a/src/app/general/edit-stakeholder/edit-stakeholder.module.ts b/src/app/general/edit-stakeholder/edit-stakeholder.module.ts index 5f16b83..441c72f 100644 --- a/src/app/general/edit-stakeholder/edit-stakeholder.module.ts +++ b/src/app/general/edit-stakeholder/edit-stakeholder.module.ts @@ -6,9 +6,10 @@ import {ReactiveFormsModule} from "@angular/forms"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; import {cloud_upload, edit, remove} from "../../openaireLibrary/utils/icons/icons"; +import {NotifyFormModule} from "../../openaireLibrary/notifications/notify-form/notify-form.module"; @NgModule({ - imports: [CommonModule, InputModule, ReactiveFormsModule, IconsModule], + imports: [CommonModule, InputModule, ReactiveFormsModule, IconsModule, NotifyFormModule], declarations: [EditStakeholderComponent], exports: [EditStakeholderComponent] }) diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index 1f319de..4307c92 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -229,8 +229,8 @@ [large]="true" (alertOutput)="saveIndicator()" [okDisabled]="numberIndicatorFb && (numberIndicatorFb.invalid || numberIndicatorFb.pristine)"> -
-
+
+
+
-
-
+
+
+
@@ -484,6 +488,8 @@ Are you sure you want to proceed? +