From 29537d917d7e8052ce2125ae2c53432afd7963ae Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Tue, 3 Nov 2020 10:59:48 +0000 Subject: [PATCH] [Monitor Dashboard|Trunk] -app component: add monitor menu items for non admin pages update user menu items - add user info and manage profiles in any page -update role check check for stakeholder types git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59751 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app.component.ts | 43 +++++++++++-------- .../edit-stakeholder.component.ts | 16 +++---- src/app/utils/indicator-utils.ts | 4 +- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index db7a185..34ad4c5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -43,7 +43,7 @@ export class AppComponent implements OnInit, OnDestroy { stickyAnimation: false }; - userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})]; + userMenuItems: MenuItem[] = []; adminMenuItems: MenuItem[] = []; stakeholder: Stakeholder = null; activeTopic: Topic = null; @@ -212,12 +212,12 @@ export class AppComponent implements OnInit, OnDestroy { this.menuItems = []; this.adminMenuItems = []; this.userMenuItems = []; - if (this.isAdmin()) { - this.userMenuItems.push(new MenuItem("", "Manage profiles", - "", "/admin", true, [], [], {})) - } if (this.user) { this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); + if (this.isCurator()) { + this.userMenuItems.push(new MenuItem("", "Manage profiles", + "", "/admin", false, [], [], {})); + } } if (this.stakeholder) { if (this.isFrontPage) { @@ -231,7 +231,7 @@ export class AppComponent implements OnInit, OnDestroy { badge: false, stickyAnimation: false }; - if (this.isAdmin()) { + if (this.isCurator()) { this.menuItems.push({ rootItem: new MenuItem("manage", "Manage", "", "/admin", false, [], null, {}), items: [] @@ -263,13 +263,6 @@ export class AppComponent implements OnInit, OnDestroy { this.specialSideBarMenuItem.icon = '' + arrow_left.data + ''; // ''; this.specialSideBarMenuItem.customClass = 'uk-text-uppercase uk-text-bold uk-text-secondary'; } - this.userMenuItems = []; - /* if (Session.isPortalAdministrator(this.user)) { - this.userMenuItems.push(new MenuItem("", "Manage helptexts", - "", "/helptexts", true, [], [], {communityId:'openaire'})) - - }*/ - } else { if (this.isFrontPage || !this.hasAdminMenu) { this.menuHeader = { @@ -282,8 +275,18 @@ export class AppComponent implements OnInit, OnDestroy { badge: true, stickyAnimation: false }; - //TODO monitor menu items? - + this.menuItems.push({ + rootItem: new MenuItem("about", "About", + "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/about/learn-how', "", false, [], null, {}), items: [] + }); + this.menuItems.push({ + rootItem: new MenuItem("browse", "Browse", + "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/browse', "", false, [], null, {}), items: [] + }); + this.menuItems.push({ + rootItem: new MenuItem("contact", "Contact us", + "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/contact-us', "", false, [], null, {}), items: [] + }); } else { this.menuHeader = { route: "/", @@ -315,9 +318,11 @@ export class AppComponent implements OnInit, OnDestroy { } } - - public isAdmin() { - return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || (this.stakeholder && Session.isManager(this.stakeholder.type, this.stakeholder.alias, this.user))); + public isCurator() { + return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isKindOfMonitorManager(this.user)); + } + public isManager(stakeholder:Stakeholder) { + return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user)); } private resolvePageInner() { @@ -341,7 +346,7 @@ export class AppComponent implements OnInit, OnDestroy { } else { if (this.isViewPublic) { // preview for not members return false; - } else if (this.isAdmin()) { + } else if (this.isManager(this.stakeholder)) { // if user is member, return true return true; } diff --git a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts index 6226468..697af0b 100644 --- a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts +++ b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts @@ -16,7 +16,7 @@ declare var UIkit; @Component({ selector: 'edit-stakeholder', template: ` -
@@ -81,7 +81,7 @@ declare var UIkit;
+ label="Type" [options]="stakeholderUtils.getTypesByUserRoles(user, stakeholder.alias)" type="select">
{ - this.stakeholderFb.get('type').disable(); - }, 0); - } else { - setTimeout(() => { - this.stakeholderFb.get('type').enable(); - }, 0); - } + setTimeout(() => { + this.stakeholderFb.get('type').disable(); + }, 0); } } diff --git a/src/app/utils/indicator-utils.ts b/src/app/utils/indicator-utils.ts index 0cb2320..a47ef0c 100644 --- a/src/app/utils/indicator-utils.ts +++ b/src/app/utils/indicator-utils.ts @@ -24,10 +24,10 @@ export class StakeholderUtils { {value: 'project', label: 'Project'}, {value: 'organization', label: 'Organization'} ]; - getTypesByUserRoles(user):Option[]{ + getTypesByUserRoles(user, id:string = null):Option[]{ let types = []; for(let type of this.types){ - if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)){ + if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)|| Session.isManager(type.value, id, user)){ types.push(type); } }