diff --git a/src/app/app.component.html b/src/app/app.component.html index 8bc8e17..3d54969 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -6,17 +6,25 @@ [class.sidebar_mini]="!open && (hasSidebar || hasAdminMenu || hasInternalSidebar)"> -
+
+ + + +
+
+

+ You are not authorized to see the content of this dashboard. +

+
+
+ You are currently in a "Preview" mode. The current view of this dashboard may differ.
- - -
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e341651..1e0d321 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -40,7 +40,7 @@ export class AppComponent implements OnInit, OnDestroy { hasAdminMenu: boolean = false; hasInternalSidebar: boolean = false; isFrontPage: boolean = false; - isViewPublic: boolean = false; + view: Visibility; sideBarItems: MenuItem[] = []; specialSideBarMenuItem: MenuItem = null; menuItems: MenuItem[] = []; @@ -55,7 +55,7 @@ export class AppComponent implements OnInit, OnDestroy { title: "Default menu header", logoUrl: null, logoSmallUrl: null, - position: 'center', + position: 'left', badge: true, menuPosition: "center" }; @@ -127,7 +127,7 @@ export class AppComponent implements OnInit, OnDestroy { this.cdr.detectChanges(); })); this.route.queryParams.subscribe(params => { - this.isViewPublic = (params['view'] == 'public'); + this.view = params['view']; }); this.layoutService.setSmallScreen((this.innerWidth && this.innerWidth <= 640)); this.layoutService.setOpen(!(this.innerWidth && this.innerWidth <= 640)); @@ -191,15 +191,15 @@ export class AppComponent implements OnInit, OnDestroy { setActives(params: Params) { if (params && params['topic']) { - this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); + this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.hasPermission(topic.visibility)); } else { - this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); + this.activeTopic = this.stakeholder.topics.find(topic => this.hasPermission(topic.visibility)); } if(this.activeTopic) { if (params && params['category']) { - this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility)); + this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.hasPermission(category.visibility)); } else { - this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility)); + this.activeCategory = this.activeTopic.categories.find(category => this.hasPermission(category.visibility)); } } } @@ -249,15 +249,23 @@ export class AppComponent implements OnInit, OnDestroy { this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.properties.baseLink + this.router.url}}); } + public removeView() { + this.router.navigate([], {relativeTo: this.route}); + } + public get open() { return this.layoutService.open; } + get isHidden() { + return this.stakeholder && !this.hasPermission(this.view?this.view:this.stakeholder.visibility); + } + private setSideBar() { let items: MenuItem[] = []; - if (this.isPublicOrIsMember(this.stakeholder.visibility)) { + if (this.hasPermission(this.view?this.view:this.stakeholder.visibility)) { this.stakeholder.topics.forEach((topic: Topic) => { - if (this.isPublicOrIsMember(topic.visibility)) { + if (this.hasPermission(topic.visibility)) { let topicItem: MenuItem = new MenuItem(topic.alias, topic.name, "", '/' + this.stakeholder.alias + '/' + topic.alias, null, [], [], {}, {svg: topic.icon}, null, null, ( '/' + this.stakeholder.alias + '/' + topic.alias)); @@ -304,12 +312,12 @@ export class AppComponent implements OnInit, OnDestroy { } if (this.stakeholder) { this.userMenuItems.push(new MenuItem("", "User information", "", "/" + this.stakeholder.alias + "/user-info", false, [], [], {})); - this.menuItems.push( - new MenuItem("dashboard", "Dashboard", - "", "/" + this.stakeholder.alias, false, [], null, {} - , null, null, null, null) - ); - if (this.isPublicOrIsMember(this.stakeholder.visibility)) { + if (this.hasPermission((this.view && this.isManager(this.stakeholder))?this.view:this.stakeholder.visibility)) { + this.menuItems.push( + new MenuItem("dashboard", "Dashboard", + "", "/" + this.stakeholder.alias, false, [], null, {} + , null, null, null, null) + ); this.menuItems.push( new MenuItem("search", "Browse Data", "", this.properties.searchLinkToResults, false, [], null, {resultbestaccessright: '"' + encodeURIComponent("Open Access") + '"'}, @@ -339,7 +347,7 @@ export class AppComponent implements OnInit, OnDestroy { logoSmallUrl: StringUtils.getLogoUrl(this.stakeholder), logoInfo: '
Monitor
' + '
Dashboard
', - position: 'center', + position: 'left', badge: true, menuPosition: "center" }; @@ -352,7 +360,7 @@ export class AppComponent implements OnInit, OnDestroy { logoSmallUrl: StringUtils.getLogoUrl(this.stakeholder), logoInfo: '
Monitor Admin
' + '
Dashboard
', - position: 'center', + position: 'left', badge: true, menuPosition: "center" }; @@ -403,12 +411,23 @@ export class AppComponent implements OnInit, OnDestroy { return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isKindOfMonitorManager(this.user)); } + public isMember(stakeholder: Stakeholder) { + return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) + || Session.isManager(stakeholder.type, stakeholder.alias, this.user) || Session.isMember(stakeholder.type, stakeholder.alias, 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)); } - public isPublicOrIsMember(visibility: Visibility): boolean { - return !(visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC")); + public hasPermission(visibility: Visibility): boolean { + if(visibility === 'PUBLIC') { + return true; + } else if(visibility === 'RESTRICTED') { + return (!this.view || this.view === 'RESTRICTED') && this.isMember(this.stakeholder); + } else { + return !this.view && this.isManager(this.stakeholder); + } } setProperties(id, type = null) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 050bf78..959e51b 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -24,6 +24,7 @@ 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"; +import {IconsModule} from "./openaireLibrary/utils/icons/icons.module"; @NgModule({ @@ -37,10 +38,10 @@ import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard"; NavigationBarModule, BottomModule, CookieLawModule, - BrowserModule.withServerTransition({ appId: 'serverApp' }), + BrowserModule.withServerTransition({appId: 'serverApp'}), AppRoutingModule, BrowserTransferStateModule, - SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule, NotificationsSidebarModule + SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule, NotificationsSidebarModule, IconsModule ], declarations: [AppComponent, OpenaireErrorPageComponent], exports: [AppComponent], diff --git a/src/app/monitor/monitor.component.html b/src/app/monitor/monitor.component.html index 4b67f50..1ae6fda 100644 --- a/src/app/monitor/monitor.component.html +++ b/src/app/monitor/monitor.component.html @@ -46,7 +46,7 @@