[Monitor dashboard | Trunk]: Notifications for development

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@60573 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2021-03-04 11:35:10 +00:00
parent 47e723facb
commit 2ac2e0aed1
11 changed files with 245 additions and 109 deletions

View File

@ -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'
},
{

View File

@ -25,5 +25,7 @@
[centered]="true" [properties]="properties" [showMenuItems]="true"></bottom>
<role-verification *ngIf="stakeholder"
[id]="stakeholder.alias" [name]="stakeholder.name" [type]="stakeholder.type"></role-verification>
<notification-sidebar *ngIf="properties.environment === 'development' && user && notificationGroupsInitialized"
[user]="user" [availableGroups]="notificationGroups" service="monitor"></notification-sidebar>
</div>
</div>

View File

@ -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) {

View File

@ -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],

View File

@ -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: `
<div *ngIf="stakeholderFb && user" [ngStyle]="{'max-height': maxHeight}"
<div [ngStyle]="{'max-height': maxHeight}"
[class.uk-padding-small]="!paddingLarge" [class.uk-padding-large]="paddingLarge"
class="uk-overflow-auto uk-padding-remove-bottom"
[formGroup]="stakeholderFb">
<div class="uk-grid" [class.uk-margin-small-bottom]="!paddingLarge" [class.uk-margin-large-bottom]="paddingLarge" uk-grid uk-height-match=".uk-form-hint">
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('name')" label="Name"
placeholder="Write a name..."
hint="Set a name for your profile."></div>
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('alias')"
hint="Set an URL alias for your profile."
label="URL Alias" placeholder="Write an alias..."></div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_id')"
label="Index ID" placeholder="Write index ID.">
</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_name')"
label="Index Name" placeholder="Write index name.">
</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_shortName')"
label="Index Short Name" placeholder="Write index short name.">
</div>
<div dashboard-input class="uk-width-1-1" [type]="'textarea'" placeholder="Write a description..."
hint="Write a description for your profile"
[rows]="4" [formInput]="stakeholderFb.get('description')" label="Description"></div>
<input #file id="photo" type="file" class="uk-hidden" (change)="fileChangeEvent($event)"/>
<div dashboard-input class="uk-width-1-1" [hideControl]="stakeholderFb.get('isUpload').value"
hint="Upload or link the logo of your profile" [placeholder]="'Write link to the logo'"
[formInput]="stakeholderFb.get('logoUrl')" label="Logo">
<div *ngIf="!stakeholderFb.get('isUpload').value" class="uk-width-2-5@l uk-width-1-1">
<div class="uk-grid uk-flex uk-flex-middle" uk-grid>
<div class="uk-width-3-4@l uk-width-1-1 uk-flex uk-flex-center">
<button class="uk-button uk-button-secondary uk-flex uk-flex-middle uk-flex-wrap"
(click)="file.click()">
<icon name="cloud_upload" [flex]="true"></icon>
<span class="uk-margin-small-left">Upload a file</span>
class="uk-overflow-auto uk-padding-remove-bottom">
<form *ngIf="stakeholderFb" [formGroup]="stakeholderFb">
<div class="uk-grid" [class.uk-margin-small-bottom]="!paddingLarge"
[class.uk-margin-large-bottom]="paddingLarge" uk-grid uk-height-match=".uk-form-hint">
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('name')" label="Name"
placeholder="Write a name..."
hint="Set a name for your profile."></div>
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('alias')"
hint="Set an URL alias for your profile."
label="URL Alias" placeholder="Write an alias..."></div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_id')"
label="Index ID" placeholder="Write index ID.">
</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_name')"
label="Index Name" placeholder="Write index name.">
</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('index_shortName')"
label="Index Short Name" placeholder="Write index short name.">
</div>
<div dashboard-input class="uk-width-1-1" [type]="'textarea'" placeholder="Write a description..."
hint="Write a description for your profile"
[rows]="4" [formInput]="stakeholderFb.get('description')" label="Description"></div>
<input #file id="photo" type="file" class="uk-hidden" (change)="fileChangeEvent($event)"/>
<div dashboard-input class="uk-width-1-1" type="logoURL" flex="top" [hideControl]="stakeholderFb.get('isUpload').value"
hint="Upload or link the logo of your profile" [placeholder]="'Write link to the logo'"
[formInput]="stakeholderFb.get('logoUrl')" label="Logo">
<div *ngIf="!stakeholderFb.get('isUpload').value" style="margin-top: 7px;" class="uk-width-2-5@l uk-width-1-1">
<div class="uk-grid uk-flex uk-flex-middle" uk-grid>
<div class="uk-width-3-4@l uk-width-1-1 uk-flex uk-flex-center">
<button class="uk-button uk-button-secondary uk-flex uk-flex-middle uk-flex-wrap"
(click)="file.click()">
<icon name="cloud_upload" [flex]="true"></icon>
<span class="uk-margin-small-left">Upload a file</span>
</button>
</div>
<div class="uk-text-center uk-text-bold uk-width-expand">
OR
</div>
</div>
</div>
<div *ngIf="stakeholderFb.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">
<img class="uk-position-center" [src]="photo">
</div>
<div class="uk-margin-left">
<button (click)="remove()" class="uk-button-secondary outlined uk-icon-button">
<icon name="remove"></icon>
</button>
</div>
<div class="uk-text-center uk-text-bold uk-width-expand">
OR
<div class="uk-margin-small-left">
<button class="uk-button-secondary uk-icon-button" (click)="file.click()">
<icon name="edit"></icon>
</button>
</div>
</div>
</div>
<div *ngIf="stakeholderFb.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">
<img class="uk-position-center" [src]="photo">
<div *ngIf="uploadError" class="uk-text-danger uk-width-1-1">{{uploadError}}</div>
<div class="uk-width-1-1 uk-grid uk-child-width-1-1" [class.uk-child-width-1-2@m]="!canChooseType"
[class.uk-child-width-1-3@m]="canChooseType" uk-grid>
<div dashboard-input [formInput]="stakeholderFb.get('visibility')"
[placeholder]="'Select a status'"
label="Status" hint="Select the visibility status of your profile"
[options]="stakeholderUtils.statuses" type="select">
</div>
<div class="uk-margin-left">
<button (click)="remove()" class="uk-button-secondary outlined uk-icon-button">
<icon name="remove"></icon>
</button>
</div>
<div class="uk-margin-small-left">
<button class="uk-button-secondary uk-icon-button" (click)="file.click()">
<icon name="edit"></icon>
</button>
<div dashboard-input [formInput]="stakeholderFb.get('type')"
[placeholder]="'Select a type'" hint="Select the type of your profile"
label="Type" [options]="types" type="select">
</div>
<ng-container *ngIf="canChooseType">
<div [placeholder]="'Select a template'"
hint="Select a template for your profile"
dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('defaultId')"
label="Template" [options]="defaultStakeholdersOptions" type="select"></div>
</ng-container>
</div>
</div>
<div *ngIf="!stakeholderFb.get('isUpload').value && !secure" class="uk-margin-remove-top uk-width-1-1">
<div class="uk-flex uk-flex-right" uk-grid>
<div class="uk-width-3-5@l uk-width-1-1 uk-text-small uk-text-warning">
<span class="uk-text-bold">Note:</span> Prefer urls like "<span class="uk-text-bold">https://</span>example.com/my-secure-image.png"
instead of "<span class="uk-text-bold">http://</span>example.com/my-image.png".
<span class="uk-text-bold">Browsers may not load non secure content.</span>
</div>
</div>
</div>
<div *ngIf="uploadError" class="uk-text-danger uk-width-1-1">{{uploadError}}</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('visibility')"
[placeholder]="'Select a status'"
label="Status" hint="Select the visibility status of your profile"
[options]="stakeholderUtils.statuses" type="select">
</div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('type')"
[placeholder]="'Select a type'" hint="Select the type of your profile"
label="Type" [options]="types" type="select">
</div>
<ng-container
*ngIf="!stakeholderFb.get('isDefault').value && isNew && stakeholderFb.get('type').valid && defaultStakeholdersOptions">
<div [placeholder]="'Select a template'"
hint="Select a template for your profile"
dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('defaultId')"
label="Template" [options]="defaultStakeholdersOptions" type="select"></div>
</ng-container>
</div>
</form>
<div #notify notify-form [class.uk-hidden]="properties.environment !== 'development'" class="uk-width-1-1 uk-margin-medium-top uk-margin-medium-bottom"></div>
</div>`,
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 <b>successfully created</b>', {
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 <b>successfully saved</b>', {
status: 'success',
timeout: 6000,

View File

@ -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]
})

View File

@ -229,8 +229,8 @@
[large]="true"
(alertOutput)="saveIndicator()"
[okDisabled]="numberIndicatorFb && (numberIndicatorFb.invalid || numberIndicatorFb.pristine)">
<div *ngIf="numberIndicatorFb" class="uk-padding-small" [formGroup]="numberIndicatorFb">
<div class="uk-grid" uk-grid>
<div class="uk-padding-small">
<div *ngIf="numberIndicatorFb" class="uk-grid" [formGroup]="numberIndicatorFb" uk-grid>
<div dashboard-input class="uk-width-1-1" [formInput]="numberIndicatorFb.get('name')" placeholder="Write a title" label="Title"></div>
<div dashboard-input class="uk-width-1-1" *ngIf="stakeholder.defaultId !=-1 && ( (indicator.description &&
indicator.description.length > 0) || !stakeholder.defaultId)"
@ -345,14 +345,16 @@
</div>
</div>
</div>
<div #editNumberNotify notify-form class="uk-width-1-1 uk-margin-medium-top"
[class.uk-hidden]="properties.environment !== 'development'"></div>
</div>
</modal-alert>
<modal-alert #editChartModal
[large]="true"
(alertOutput)="saveIndicator()"
[okDisabled]="chartIndicatorFb && (chartIndicatorFb.invalid || chartIndicatorFb.pristine)">
<div *ngIf="chartIndicatorFb" class="uk-padding-small" [formGroup]="chartIndicatorFb">
<div class="uk-grid" uk-grid>
<div class="uk-padding-small">
<div *ngIf="chartIndicatorFb" [formGroup]="chartIndicatorFb" class="uk-grid" uk-grid>
<div dashboard-input class="uk-width-1-1" [formInput]="chartIndicatorFb.get('name')" placeholder="Write a title" label="Title"></div>
<div dashboard-input class="uk-width-1-1" *ngIf="stakeholder.defaultId !=-1 && ( (indicator.description &&
indicator.description.length > 0) || !stakeholder.defaultId)"
@ -472,6 +474,8 @@
</div>
</div>
</div>
<div #editChartNotify notify-form class="uk-width-1-1 uk-margin-medium-top"
[class.uk-hidden]="properties.environment !== 'development'"></div>
</div>
</modal-alert>
<modal-alert #deleteModal (alertOutput)="deleteIndicator()">
@ -484,6 +488,8 @@
<!-- Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
<div #deleteNotify notify-form class="uk-width-1-1 uk-margin-medium-top"
[class.uk-hidden]="properties.environment !== 'development'"></div>
</modal-alert>
<!--<modal-alert #deleteAllModal (alertOutput)="deleteIndicator('delete')">
You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">
@ -550,8 +556,6 @@
</div>
</div>
</ng-template>
<ng-template #description let-indicator="indicator">
<span class="descriptionIcon"
*ngIf="(indicator.description && indicator.description.length > 0)

View File

@ -28,9 +28,12 @@ import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties"
import {Subscriber} from "rxjs";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {Router} from "@angular/router";
import {Session} 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 {Notification} from "../openaireLibrary/notifications/notifications";
import {NotificationUtils} from "../openaireLibrary/notifications/notification-utils";
import {NotifyFormComponent} from "../openaireLibrary/notifications/notify-form/notify-form.component";
declare var UIkit;
@ -50,7 +53,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
@Input()
public subcategoryIndex: number = 0;
public stakeholder: Stakeholder = null;
public user = null;
public user: User = null;
public preview: string;
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
@ -95,6 +98,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
urlParameterizedMessage = null;
showCheckForSchemaEnhancements:boolean = false;
private notification: Notification;
@ViewChild('editNumberNotify') editNumberNotify: NotifyFormComponent;
@ViewChild('editChartNotify') editChartNotify: NotifyFormComponent;
@ViewChild('deleteNotify') deleteNotify: NotifyFormComponent;
constructor(private layoutService: LayoutService,
private stakeholderService: StakeholderService,
private statisticsService: StatisticsService,
@ -734,9 +741,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if (this.index === -1) {
this.editNumberModal.alertTitle = 'Create a new number indicator';
this.editNumberModal.okButtonText = 'Save';
this.notification = NotificationUtils.createIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
this.editNumberNotify.reset(this.notification.message);
} else {
this.editNumberModal.alertTitle = 'Edit number indicator\'s information';
this.editNumberModal.okButtonText = 'Save Changes';
this.notification = NotificationUtils.editIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
this.editNumberNotify.reset(this.notification.message);
}
this.editNumberModal.open();
}
@ -795,9 +806,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if (this.index === -1) {
this.editChartModal.alertTitle = 'Create a new chart indicator';
this.editChartModal.okButtonText = 'Save';
this.notification = NotificationUtils.createIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
this.editChartNotify.reset(this.notification.message);
} else {
this.editChartModal.alertTitle = 'Edit chart indicator\'s information';
this.editChartModal.okButtonText = 'Save Changes';
this.notification = NotificationUtils.editIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);;
this.editChartNotify.reset(this.notification.message);
}
this.editChartModal.open();
}
@ -826,12 +841,36 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} else {
this.section.indicators.push(indicator);
}
if (this.indicator.type === "chart") {
this.filterCharts();
this.chartIndicatorFb = null;
this.notification.entity = indicator._id;
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));
if (this.indicator.type === "chart") {
this.filterCharts();
this.chartIndicatorFb = null;
this.editChartNotify.sendNotification(this.notification);
} else {
this.filterNumbers();
this.numberIndicatorFb = null;
this.editNumberNotify.sendNotification(this.notification);
}
} else {
this.filterNumbers();
this.numberIndicatorFb = null;
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 (this.indicator.type === "chart") {
this.filterCharts();
this.chartIndicatorFb = null;
this.editChartNotify.sendNotification(this.notification);
} else {
this.filterNumbers();
this.numberIndicatorFb = null;
this.editNumberNotify.sendNotification(this.notification);
}
});
}
UIkit.notification('Indicator has been <b>successfully saved</b>', {
status: 'success',
@ -916,6 +955,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.deleteModal.alertTitle = 'Delete indicator';
this.deleteModal.cancelButtonText = 'No';
this.deleteModal.okButtonText = 'Yes';
this.notification = NotificationUtils.deleteIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
this.deleteNotify.reset(this.notification.message);
this.deleteModal.open();
}
@ -942,6 +983,21 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
timeout: 6000,
pos: 'bottom-right'
});
this.notification.entity = this.indicator._id;
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.deleteNotify.sendNotification(this.notification);
} 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.deleteNotify.sendNotification(this.notification);
});
}
this.editing = false;
}, error => {
UIkit.notification(error.error.message, {

View File

@ -27,11 +27,12 @@ import {
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
import {PageContentModule} from "../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
import {LoadingModule} from "../openaireLibrary/utils/loading/loading.module";
import {NotifyFormModule} from "../openaireLibrary/notifications/notify-form/notify-form.module";
@NgModule({
imports: [
CommonModule, TopicRoutingModule, ClickModule, RouterModule, FormsModule, AlertModalModule,
ReactiveFormsModule, InputModule, IconsModule, PageContentModule, LoadingModule
ReactiveFormsModule, InputModule, IconsModule, PageContentModule, LoadingModule, NotifyFormModule
],
declarations: [
TopicComponent, IndicatorsComponent

View File

@ -9,7 +9,8 @@
<li [class.uk-active]="tab === 'member'"><a routerLink="./" fragment="member"><span class="title">Members</span></a></li>
</ul>
</ng-template>
<role-users *ngIf="!loading && alias" [id]="alias" [type]="type" [name]="name" [link]="link" [role]="tab" [message]="messages.get(tab)" [emailComposer]="emailComposer">
<role-users *ngIf="!loading && alias" [id]="alias" [type]="type" [name]="name" [link]="link" [role]="tab" [message]="messages.get(tab)"
[emailComposer]="emailComposer" [notificationFn]="(properties.environment === 'development')?notificationFn:null">
<ng-container [ngTemplateOutlet]="tabs"></ng-container>
</role-users>

View File

@ -6,6 +6,11 @@ import {Title} from "@angular/platform-browser";
import {Composer} from "../openaireLibrary/utils/email/composer";
import {Email} from "../openaireLibrary/utils/email/email";
import {ActivatedRoute} from "@angular/router";
import {NotificationUtils} from "../openaireLibrary/notifications/notification-utils";
import {Notification} from "../openaireLibrary/notifications/notifications";
import {User} from "../openaireLibrary/login/utils/helper.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
type Tab = 'member' | 'manager';
@ -22,12 +27,28 @@ export class UsersComponent implements OnInit {
public loading: boolean;
public messages: Map<Tab, string> = new Map<Tab, string>();
public tab: Tab = 'manager';
public user: User;
public properties: EnvProperties = properties;
private subscriptions = [];
public emailComposer: Function = (name, recipient, role): Email => {
return Composer.composeEmailForMonitorDashboard(name, recipient, role);
}
public notificationFn: Function = (name, recipient, role, invitation): Notification => {
if(invitation) {
invitation.link = this.link + invitation.link;
}
let notification: Notification = NotificationUtils.invite(this.name, role, this.user.firstname + ' ' + this.user.lastname, invitation);
notification.entity = recipient;
notification.stakeholderType = this.type;
notification.stakeholder = this.alias;
notification.name = this.user.firstname;
notification.surname = this.user.lastname;
notification.groups = [recipient];
return notification;
}
constructor(private stakeholderService: StakeholderService,
private userManagementService: UserManagementService,
private route: ActivatedRoute,
private title: Title) {
}
@ -55,6 +76,9 @@ export class UsersComponent implements OnInit {
this.loading = false;
}
}));
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
}));
}
ngOnDestroy() {