Add notification configuration in order to works in mobile

This commit is contained in:
Konstantinos Triantafyllou 2023-03-24 17:15:41 +02:00
parent b9381c41cf
commit 409f263479
4 changed files with 26 additions and 18 deletions

View File

@ -6,7 +6,8 @@
[class.sidebar_mini]="!open && (hasSidebar || hasAdminMenu || hasInternalSidebar)" [class.sidebar_hover]="hover"> [class.sidebar_mini]="!open && (hasSidebar || hasAdminMenu || hasInternalSidebar)" [class.sidebar_hover]="hover">
<div id="modal-container"></div> <div id="modal-container"></div>
<ng-container *ngIf="!isHidden"> <ng-container *ngIf="!isHidden">
<navbar *ngIf="hasHeader" portal="monitor_dashboard" [header]="menuHeader" [userMenuItems]=userMenuItems [menuItems]="menuItems" [user]="user"></navbar> <navbar *ngIf="hasHeader" portal="monitor_dashboard" [header]="menuHeader" [userMenuItems]=userMenuItems [menuItems]="menuItems" [user]="user"
[notificationConfiguration]="isMobile && user && notificationGroupsInitialized?notificationConfiguration:null"></navbar>
<div> <div>
<dashboard-sidebar *ngIf="stakeholder && isFrontPage && hasSidebar && !hasInternalSidebar" queryParamsHandling="merge" [items]="sideBarItems" <dashboard-sidebar *ngIf="stakeholder && isFrontPage && hasSidebar && !hasInternalSidebar" queryParamsHandling="merge" [items]="sideBarItems"
[activeItem]="activeTopic?activeTopic.alias:null" [activeSubItem]="activeCategory?activeCategory.alias:null"></dashboard-sidebar> [activeItem]="activeTopic?activeTopic.alias:null" [activeSubItem]="activeCategory?activeCategory.alias:null"></dashboard-sidebar>
@ -15,8 +16,7 @@
<router-outlet></router-outlet> <router-outlet></router-outlet>
</main> </main>
<bottom id="bottom" *ngIf="isFrontPage" [centered]="true" [properties]="properties" [showMenuItems]="true"></bottom> <bottom id="bottom" *ngIf="isFrontPage" [centered]="true" [properties]="properties" [showMenuItems]="true"></bottom>
<notification-sidebar *ngIf="user && notificationGroupsInitialized" [entities]="entities" <notification-sidebar *ngIf="!isMobile && user && notificationGroupsInitialized" [configuration]="notificationConfiguration" [user]="user"></notification-sidebar>
[user]="user" [availableGroups]="notificationGroups" service="monitor"></notification-sidebar>
</div> </div>
<div *ngIf="view" class="preview uk-text-small uk-flex uk-flex-middle"> <div *ngIf="view" class="preview uk-text-small uk-flex uk-flex-middle">
<span>You are currently in a <span class="uk-text-bold">"Preview"</span> mode. <span class="uk-visible@m"><a (click)="removeView()">The current view</a> of this dashboard may differ.</span></span> <span>You are currently in a <span class="uk-text-bold">"Preview"</span> mode. <span class="uk-visible@m"><a (click)="removeView()">The current view</a> of this dashboard may differ.</span></span>

View File

@ -24,6 +24,9 @@ import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper"; import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
import {ResourcesService} from "./openaireLibrary/monitor/services/resources.service"; import {ResourcesService} from "./openaireLibrary/monitor/services/resources.service";
import {StringUtils} from "./openaireLibrary/utils/string-utils.class"; import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
import {
NotificationConfiguration
} from "./openaireLibrary/notifications/notifications-sidebar/notifications-sidebar.component";
@Component({ @Component({
@ -41,13 +44,13 @@ export class AppComponent implements OnInit, OnDestroy {
hasAdminMenu: boolean = false; hasAdminMenu: boolean = false;
hasInternalSidebar: boolean = false; hasInternalSidebar: boolean = false;
isFrontPage: boolean = false; isFrontPage: boolean = false;
isMobile: boolean = false;
view: Visibility; view: Visibility;
sideBarItems: MenuItem[] = []; sideBarItems: MenuItem[] = [];
backItem: MenuItem = null; backItem: MenuItem = null;
menuItems: MenuItem[] = []; menuItems: MenuItem[] = [];
notificationGroups: Option[] = [];
entities: string[];
notificationGroupsInitialized: boolean = false; notificationGroupsInitialized: boolean = false;
notificationConfiguration: NotificationConfiguration = new NotificationConfiguration();
stakeholderUtils: StakeholderUtils = new StakeholderUtils(); stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public stakeholderEntities = StakeholderEntities; public stakeholderEntities = StakeholderEntities;
menuHeader: Header = { menuHeader: Header = {
@ -118,6 +121,10 @@ export class AppComponent implements OnInit, OnDestroy {
this.isFrontPage = isFrontPage; this.isFrontPage = isFrontPage;
this.cdr.detectChanges(); this.cdr.detectChanges();
})); }));
this.subscriptions.push(this.layoutService.isMobile.subscribe(isMobile => {
this.isMobile = isMobile;
this.cdr.detectChanges();
}));
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
this.view = params['view']; this.view = params['view'];
if(this.stakeholder) { if(this.stakeholder) {
@ -136,12 +143,12 @@ export class AppComponent implements OnInit, OnDestroy {
if (user) { if (user) {
this.user = user; this.user = user;
if (!this.notificationGroupsInitialized) { if (!this.notificationGroupsInitialized) {
this.setNotificationGroups(); this.setNotificationConfiguration();
} }
} else if(this.user) { } else if(this.user) {
this.user = user; this.user = user;
this.notificationGroupsInitialized = false; this.notificationGroupsInitialized = false;
this.notificationGroups = []; this.notificationConfiguration.availableGroups = [];
} }
if(this.paramsSubscription) { if(this.paramsSubscription) {
this.paramsSubscription.unsubscribe(); this.paramsSubscription.unsubscribe();
@ -201,26 +208,27 @@ export class AppComponent implements OnInit, OnDestroy {
} }
} }
public setNotificationGroups() { public setNotificationConfiguration() {
this.entities = this.stakeholderUtils.types.map(option => option.value); this.notificationConfiguration.entities = this.stakeholderUtils.types.map(option => option.value);
this.notificationGroups = []; this.notificationConfiguration.service = 'monitor';
this.notificationConfiguration.availableGroups = [];
if (Session.isPortalAdministrator(this.user)) { if (Session.isPortalAdministrator(this.user)) {
this.notificationGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'}); this.notificationConfiguration.availableGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'});
} }
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.notificationConfiguration.availableGroups.push({value: Role.curator(type.value), label: type.label + ' Curators'});
this.notificationGroups.push({value: Role.typeManager(type.value), label: type.label + ' Managers'}); this.notificationConfiguration.availableGroups.push({value: Role.typeManager(type.value), label: type.label + ' Managers'});
this.notificationGroups.push({value: Role.typeMember(type.value), label: type.label + ' Members'}); this.notificationConfiguration.availableGroups.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 => {
stakeholders.forEach(stakeholder => { stakeholders.forEach(stakeholder => {
this.notificationGroups.push({ this.notificationConfiguration.availableGroups.push({
value: Role.manager(stakeholder.type, stakeholder.alias), value: Role.manager(stakeholder.type, stakeholder.alias),
label: stakeholder.name + ' Managers' label: stakeholder.name + ' Managers'
}); });
this.notificationGroups.push({ this.notificationConfiguration.availableGroups.push({
value: Role.member(stakeholder.type, stakeholder.alias), value: Role.member(stakeholder.type, stakeholder.alias),
label: stakeholder.name + ' Members' label: stakeholder.name + ' Members'
}); });

@ -1 +1 @@
Subproject commit 31d52de0e8f7a8ed506f597c555c5b952bcbdb02 Subproject commit a9f31d830740cfdcea33266248b2421815834899

@ -1 +1 @@
Subproject commit 22728ec7de6c106bb4ede71e12a71cb061c6e8f8 Subproject commit 7c314ad2eb1c0b855f97e8eed7295075710be2fd