Add entities in app component in order to handle notification groups properly.

This commit is contained in:
Konstantinos Triantafyllou 2022-08-05 15:00:21 +03:00
parent 8ca270d48a
commit c65047f61d
4 changed files with 9 additions and 5 deletions

View File

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

View File

@ -38,6 +38,7 @@ export class AppComponent implements OnInit, OnDestroy {
specialSideBarMenuItem: MenuItem = null; specialSideBarMenuItem: MenuItem = null;
menuItems: RootMenuItem[] = []; menuItems: RootMenuItem[] = [];
notificationGroups: Option[] = []; notificationGroups: Option[] = [];
entities: string[];
notificationGroupsInitialized: boolean = false; notificationGroupsInitialized: boolean = false;
stakeholderUtils: StakeholderUtils = new StakeholderUtils(); stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public stakeholderEntities = StakeholderEntities; public stakeholderEntities = StakeholderEntities;
@ -180,6 +181,7 @@ export class AppComponent implements OnInit, OnDestroy {
} }
public setNotificationGroups() { public setNotificationGroups() {
this.entities = this.stakeholderUtils.types.map(option => option.value);
this.notificationGroups = []; this.notificationGroups = [];
if (Session.isPortalAdministrator(this.user)) { if (Session.isPortalAdministrator(this.user)) {
this.notificationGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'}); this.notificationGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'});
@ -187,6 +189,8 @@ export class AppComponent implements OnInit, OnDestroy {
for (let type of this.stakeholderUtils.types) { for (let type of this.stakeholderUtils.types) {
if (Session.isCurator(type.value, this.user) || Session.isPortalAdministrator(this.user)) { if (Session.isCurator(type.value, this.user) || Session.isPortalAdministrator(this.user)) {
this.notificationGroups.push({value: Role.curator(type.value), label: type.label + ' Curators'}); this.notificationGroups.push({value: Role.curator(type.value), label: type.label + ' Curators'});
this.notificationGroups.push({value: Role.typeManager(type.value), label: type.label + ' Managers'});
this.notificationGroups.push({value: Role.typeMember(type.value), label: type.label + ' Members'});
} }
} }
this.subscriptions.push(this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL).subscribe(stakeholders => { this.subscriptions.push(this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL).subscribe(stakeholders => {
@ -250,7 +254,7 @@ export class AppComponent implements OnInit, OnDestroy {
this.adminMenuItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/admin/" + this.stakeholder.alias + "/admin-tools")); this.adminMenuItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/admin/" + this.stakeholder.alias + "/admin-tools"));
} }
} }
this.specialSideBarMenuItem = new MenuItem("back", "Manage profiles", "", "/admin", false, [], null, {}, {name: 'west'}); this.specialSideBarMenuItem = new MenuItem("back", "Manage profiles", "", "/admin", false, [], null, {}, {name: 'search', class: 'uk-text-secondary'});
this.sideBarItems = items; this.sideBarItems = items;
this.hasSidebar = this.hasSidebar && this.sideBarItems.length > 0; this.hasSidebar = this.hasSidebar && this.sideBarItems.length > 0;
} }

@ -1 +1 @@
Subproject commit 3756f8df83aaa0c063d45b7f1c51798acac67961 Subproject commit 460cbdfc9a3427181a7404012f179c604d74a7ca

View File

@ -4,9 +4,9 @@
<a [routerLink]="'/admin/' + stakeholder.alias" class="uk-button uk-button-link uk-margin-left"> <a [routerLink]="'/admin/' + stakeholder.alias" class="uk-button uk-button-link uk-margin-left">
<h6 class="uk-flex uk-flex-middle uk-flex-center uk-margin-remove-bottom"> <h6 class="uk-flex uk-flex-middle uk-flex-center uk-margin-remove-bottom">
<div class="uk-width-auto"> <div class="uk-width-auto">
<icon class="menu-icon" name="west" [flex]="true"></icon> <icon class="menu-icon" name="west" [flex]="true" ratio="1.5"></icon>
</div> </div>
<span class="uk-width-expand uk-text-truncate uk-margin-left" <span class="uk-width-expand uk-text-truncate uk-margin-small-left"
[class.uk-hidden]="!open">Indicators</span> [class.uk-hidden]="!open">Indicators</span>
</h6> </h6>
</a> </a>