2020-11-26 17:23:21 +01:00
import { ChangeDetectorRef , Component , HostListener , OnDestroy , OnInit } from '@angular/core' ;
2021-07-14 18:02:04 +02:00
import { ActivatedRoute , Data , NavigationEnd , Params , Router } from '@angular/router' ;
2019-10-24 09:44:29 +02:00
import { EnvProperties } from './openaireLibrary/utils/properties/env-properties' ;
2021-03-04 12:35:10 +01:00
import { Role , Session , User } from './openaireLibrary/login/utils/helper.class' ;
2019-10-24 09:44:29 +02:00
import { UserManagementService } from "./openaireLibrary/services/user-management.service" ;
2020-06-03 15:44:03 +02:00
import { StakeholderService } from "./openaireLibrary/monitor/services/stakeholder.service" ;
2019-12-21 14:32:43 +01:00
import { BehaviorSubject , Subscriber } from "rxjs" ;
2019-12-23 14:54:37 +01:00
import { LayoutService } from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service" ;
2022-09-20 22:59:26 +02:00
import { MenuItem } from "./openaireLibrary/sharedComponents/menu" ;
2022-11-04 15:36:51 +01:00
import {
Category ,
Stakeholder ,
StakeholderEntities ,
Topic ,
Visibility
} from "./openaireLibrary/monitor/entities/stakeholder" ;
2020-07-10 10:38:52 +02:00
import { LinksResolver } from "./search/links-resolver" ;
2020-10-19 11:07:43 +02:00
import { Header } from "./openaireLibrary/sharedComponents/navigationBar.component" ;
2020-10-30 12:33:51 +01:00
import { properties } from "../environments/environment" ;
2020-12-18 16:31:21 +01:00
import { ConfigurationService } from "./openaireLibrary/utils/configuration/configuration.service" ;
2021-03-04 12:35:10 +01:00
import { Option } from "./openaireLibrary/sharedComponents/input/input.component" ;
import { StakeholderUtils } from "./utils/indicator-utils" ;
2021-04-12 23:56:46 +02:00
import { SmoothScroll } from "./openaireLibrary/utils/smooth-scroll" ;
2021-07-14 18:02:04 +02:00
import { ConnectHelper } from "./openaireLibrary/connect/connectHelper" ;
2022-07-29 13:47:32 +02:00
import { ResourcesService } from "./openaireLibrary/monitor/services/resources.service" ;
2022-08-04 14:33:49 +02:00
import { StringUtils } from "./openaireLibrary/utils/string-utils.class" ;
2019-11-24 17:30:04 +01:00
2019-10-24 09:44:29 +02:00
@Component ( {
2019-12-20 12:48:35 +01:00
selector : 'app-root' ,
templateUrl : './app.component.html'
2019-10-24 09:44:29 +02:00
} )
2019-11-24 17:30:04 +01:00
export class AppComponent implements OnInit , OnDestroy {
2020-11-01 16:41:56 +01:00
properties : EnvProperties = properties ;
2019-12-20 12:48:35 +01:00
user : User ;
2019-12-21 14:32:43 +01:00
params : BehaviorSubject < Params > = new BehaviorSubject < Params > ( null ) ;
2021-07-14 18:02:04 +02:00
data : BehaviorSubject < Data > = new BehaviorSubject < Data > ( null ) ;
2019-12-20 12:48:35 +01:00
hasSidebar : boolean = false ;
hasHeader : boolean = false ;
2019-12-23 14:54:37 +01:00
hasAdminMenu : boolean = false ;
2022-11-04 15:36:51 +01:00
hasInternalSidebar : boolean = false ;
2020-07-06 11:19:01 +02:00
isFrontPage : boolean = false ;
2022-12-20 16:40:46 +01:00
view : Visibility ;
2020-07-06 11:19:01 +02:00
sideBarItems : MenuItem [ ] = [ ] ;
2020-10-30 12:33:51 +01:00
specialSideBarMenuItem : MenuItem = null ;
2022-09-20 22:59:26 +02:00
menuItems : MenuItem [ ] = [ ] ;
2021-03-04 12:35:10 +01:00
notificationGroups : Option [ ] = [ ] ;
2022-08-05 14:00:21 +02:00
entities : string [ ] ;
2021-03-04 12:35:10 +01:00
notificationGroupsInitialized : boolean = false ;
stakeholderUtils : StakeholderUtils = new StakeholderUtils ( ) ;
2022-08-02 22:34:30 +02:00
public stakeholderEntities = StakeholderEntities ;
2020-10-30 12:33:51 +01:00
menuHeader : Header = {
route : "/" ,
url : null ,
title : "Default menu header" ,
logoUrl : null ,
logoSmallUrl : null ,
2022-12-20 16:40:46 +01:00
position : 'left' ,
2022-03-02 22:58:53 +01:00
badge : true ,
2022-02-28 17:02:38 +01:00
menuPosition : "center"
2020-10-30 12:33:51 +01:00
} ;
2020-11-01 16:41:56 +01:00
2020-11-03 11:59:48 +01:00
userMenuItems : MenuItem [ ] = [ ] ;
2019-12-23 14:54:37 +01:00
adminMenuItems : MenuItem [ ] = [ ] ;
2020-07-06 11:19:01 +02:00
stakeholder : Stakeholder = null ;
activeTopic : Topic = null ;
2022-11-04 15:36:51 +01:00
activeCategory : Category = null ;
2020-10-30 12:33:51 +01:00
loading : boolean = true ;
paramsResolved : boolean = false ;
2020-08-04 09:57:51 +02:00
innerWidth ;
2019-12-21 14:32:43 +01:00
private subscriptions : any [ ] = [ ] ;
constructor ( private route : ActivatedRoute ,
2019-12-20 12:48:35 +01:00
private router : Router ,
private userManagementService : UserManagementService ,
private layoutService : LayoutService ,
2021-04-12 23:56:46 +02:00
private smoothScroll : SmoothScroll ,
2019-12-20 12:48:35 +01:00
private stakeholderService : StakeholderService ,
2022-07-29 13:47:32 +02:00
private cdr : ChangeDetectorRef ,
private configurationService : ConfigurationService ,
private resourcesService : ResourcesService ) {
2019-12-21 14:32:43 +01:00
this . subscriptions . push ( this . router . events . subscribe ( event = > {
if ( event instanceof NavigationEnd ) {
let r = this . route ;
while ( r . firstChild ) {
r = r . firstChild ;
}
2020-10-30 12:33:51 +01:00
this . paramsResolved = true ;
2021-07-14 18:02:04 +02:00
this . params . next ( r . snapshot . params ) ;
this . data . next ( r . snapshot . data ) ;
2019-12-21 14:32:43 +01:00
}
} ) ) ;
2019-12-20 12:48:35 +01:00
}
2019-12-21 14:32:43 +01:00
2020-11-26 17:23:21 +01:00
@HostListener ( 'window:resize' , [ '$event' ] )
onResize ( event ) {
2022-04-09 15:25:09 +02:00
if ( this . layoutService . isSmallScreen && event . target . innerWidth > 640 ) {
2020-11-26 17:23:21 +01:00
this . layoutService . setSmallScreen ( false ) ;
2022-04-09 15:25:09 +02:00
} else if ( ! this . layoutService . isSmallScreen && event . target . innerWidth <= 640 ) {
2020-11-26 17:23:21 +01:00
this . layoutService . setSmallScreen ( true ) ;
this . layoutService . setOpen ( false ) ;
}
}
2019-12-20 12:48:35 +01:00
ngOnInit() {
2020-11-20 18:15:30 +01:00
if ( typeof document !== 'undefined' && window ) {
2020-08-04 09:57:51 +02:00
this . innerWidth = window . innerWidth ;
}
2019-12-20 12:48:35 +01:00
this . subscriptions . push ( this . layoutService . hasSidebar . subscribe ( hasSidebar = > {
this . hasSidebar = hasSidebar ;
this . cdr . detectChanges ( ) ;
} ) ) ;
this . subscriptions . push ( this . layoutService . hasHeader . subscribe ( hasHeader = > {
this . hasHeader = hasHeader ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2019-12-23 14:54:37 +01:00
this . subscriptions . push ( this . layoutService . hasAdminMenu . subscribe ( hasAdminMenu = > {
this . hasAdminMenu = hasAdminMenu ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2022-11-04 15:36:51 +01:00
this . subscriptions . push ( this . layoutService . hasInternalSidebar . subscribe ( hasInternalSidebar = > {
this . hasInternalSidebar = hasInternalSidebar ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2020-06-04 13:30:26 +02:00
this . subscriptions . push ( this . layoutService . isFrontPage . subscribe ( isFrontPage = > {
this . isFrontPage = isFrontPage ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2020-07-06 11:19:01 +02:00
this . route . queryParams . subscribe ( params = > {
2022-12-20 16:40:46 +01:00
this . view = params [ 'view' ] ;
2020-07-06 11:19:01 +02:00
} ) ;
2022-04-09 15:25:09 +02:00
this . layoutService . setSmallScreen ( ( this . innerWidth && this . innerWidth <= 640 ) ) ;
this . layoutService . setOpen ( ! ( this . innerWidth && this . innerWidth <= 640 ) ) ;
2020-10-30 12:33:51 +01:00
this . subscriptions . push ( this . params . subscribe ( params = > {
2020-11-01 16:41:56 +01:00
if ( this . paramsResolved ) {
2020-10-30 12:33:51 +01:00
this . loading = true ;
if ( params && params [ 'stakeholder' ] ) {
2020-11-20 18:15:30 +01:00
if ( ! this . stakeholder || this . stakeholder . alias !== params [ 'stakeholder' ] ) {
2020-11-13 17:42:12 +01:00
this . subscriptions . push ( this . stakeholderService . getStakeholder ( params [ 'stakeholder' ] ) . subscribe ( stakeholder = > {
2020-10-30 12:33:51 +01:00
if ( stakeholder ) {
this . stakeholder = stakeholder ;
LinksResolver . setProperties ( this . stakeholder . alias ) ;
2021-07-14 18:02:04 +02:00
this . setProperties ( this . stakeholder . alias , this . stakeholder . type ) ;
2020-11-20 18:15:30 +01:00
this . buildMenu ( ) ;
2022-11-08 14:10:20 +01:00
this . setActives ( params ) ;
this . setSideBar ( ) ;
2020-10-30 12:33:51 +01:00
this . loading = false ;
} else {
2020-11-25 18:33:07 +01:00
this . stakeholder = null ;
2020-07-10 10:38:52 +02:00
LinksResolver . resetProperties ( ) ;
2020-06-10 16:03:28 +02:00
this . navigateToError ( ) ;
2020-10-12 14:54:57 +02:00
this . buildMenu ( ) ;
2020-10-30 12:33:51 +01:00
this . loading = false ;
2020-07-06 11:19:01 +02:00
}
2020-11-13 17:42:12 +01:00
} ) ) ;
2019-12-21 14:32:43 +01:00
} else {
2020-10-23 15:58:16 +02:00
this . buildMenu ( ) ;
2022-11-08 14:10:20 +01:00
this . setActives ( params ) ;
2020-10-30 12:33:51 +01:00
this . loading = false ;
2020-10-23 15:58:16 +02:00
}
2020-10-30 12:33:51 +01:00
} else {
2022-07-03 10:55:49 +02:00
LinksResolver . resetProperties ( ) ;
this . stakeholderService . setStakeholder ( null ) ;
this . stakeholder = null ;
this . buildMenu ( ) ;
2020-10-30 12:33:51 +01:00
this . loading = false ;
}
}
} ) ) ;
2021-07-14 18:02:04 +02:00
this . subscriptions . push ( this . data . subscribe ( data = > {
2022-03-02 22:58:53 +01:00
if ( data && data . portal ) {
2021-07-14 18:02:04 +02:00
this . setProperties ( data . portal ) ;
this . configurationService . initCommunityInformation ( this . properties , this . properties . adminToolsCommunity ) ;
}
} ) ) ;
2020-10-30 12:33:51 +01:00
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
if ( user ) {
2022-09-08 15:51:10 +02:00
this . user = user ;
2020-10-30 12:33:51 +01:00
this . buildMenu ( ) ;
2022-03-02 22:58:53 +01:00
if ( ! this . notificationGroupsInitialized ) {
2021-03-04 12:35:10 +01:00
this . setNotificationGroups ( ) ;
}
2022-09-08 15:51:10 +02:00
} else if ( this . user ) {
this . user = user ;
this . buildMenu ( ) ;
this . notificationGroupsInitialized = false ;
this . notificationGroups = [ ] ;
2020-10-30 12:33:51 +01:00
}
} ) ) ;
2019-12-20 12:48:35 +01:00
}
2020-07-06 11:19:01 +02:00
2022-11-08 14:10:20 +01:00
setActives ( params : Params ) {
if ( params && params [ 'topic' ] ) {
2022-12-20 16:40:46 +01:00
this . activeTopic = this . stakeholder . topics . find ( topic = > topic . alias === decodeURIComponent ( params [ 'topic' ] ) && this . hasPermission ( topic . visibility ) ) ;
2022-11-08 14:10:20 +01:00
} else {
2022-12-20 16:40:46 +01:00
this . activeTopic = this . stakeholder . topics . find ( topic = > this . hasPermission ( topic . visibility ) ) ;
2022-11-08 14:10:20 +01:00
}
if ( this . activeTopic ) {
if ( params && params [ 'category' ] ) {
2022-12-20 16:40:46 +01:00
this . activeCategory = this . activeTopic . categories . find ( category = > category . alias === decodeURIComponent ( params [ 'category' ] ) && this . hasPermission ( category . visibility ) ) ;
2022-11-08 14:10:20 +01:00
} else {
2022-12-20 16:40:46 +01:00
this . activeCategory = this . activeTopic . categories . find ( category = > this . hasPermission ( category . visibility ) ) ;
2022-11-08 14:10:20 +01:00
}
}
}
2021-03-04 12:35:10 +01:00
public setNotificationGroups() {
2022-08-05 14:00:21 +02:00
this . entities = this . stakeholderUtils . types . map ( option = > option . value ) ;
2021-03-04 12:35:10 +01:00
this . notificationGroups = [ ] ;
2022-03-02 22:58:53 +01:00
if ( Session . isPortalAdministrator ( this . user ) ) {
2021-03-04 12:35:10 +01:00
this . notificationGroups . push ( { value : Role.PORTAL_ADMIN , label : 'Portal Administrators' } ) ;
}
2022-03-02 22:58:53 +01:00
for ( let type of this . stakeholderUtils . types ) {
if ( Session . isCurator ( type . value , this . user ) || Session . isPortalAdministrator ( this . user ) ) {
2021-03-04 12:35:10 +01:00
this . notificationGroups . push ( { value : Role.curator ( type . value ) , label : type.label + ' Curators' } ) ;
2022-08-05 14:00:21 +02:00
this . notificationGroups . push ( { value : Role.typeManager ( type . value ) , label : type.label + ' Managers' } ) ;
this . notificationGroups . push ( { value : Role.typeMember ( type . value ) , label : type.label + ' Members' } ) ;
2021-03-04 12:35:10 +01:00
}
}
this . subscriptions . push ( this . stakeholderService . getMyStakeholders ( this . properties . monitorServiceAPIURL ) . subscribe ( stakeholders = > {
stakeholders . forEach ( stakeholder = > {
2022-03-02 22:58:53 +01:00
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'
} ) ;
2021-03-04 12:35:10 +01:00
} ) ;
this . notificationGroupsInitialized = true ;
} ) ) ;
}
2019-12-20 12:48:35 +01:00
public ngOnDestroy() {
this . subscriptions . forEach ( value = > {
if ( value instanceof Subscriber ) {
value . unsubscribe ( ) ;
}
} ) ;
2020-11-13 17:42:12 +01:00
this . userManagementService . clearSubscriptions ( ) ;
this . layoutService . clearSubscriptions ( ) ;
this . stakeholderService . clearSubscriptions ( ) ;
2020-12-18 16:31:21 +01:00
this . configurationService . clearSubscriptions ( ) ;
2021-04-12 23:56:46 +02:00
this . smoothScroll . clearSubscriptions ( ) ;
2019-12-20 12:48:35 +01:00
}
2020-06-10 16:03:28 +02:00
private navigateToError() {
2022-05-11 11:57:00 +02:00
this . router . navigate ( [ this . properties . errorLink ] , { queryParams : { 'page' : this . properties . baseLink + this . router . url } } ) ;
2020-06-10 16:03:28 +02:00
}
2020-07-06 11:19:01 +02:00
2022-12-20 16:40:46 +01:00
public removeView() {
this . router . navigate ( [ ] , { relativeTo : this.route } ) ;
}
2019-12-20 12:48:35 +01:00
public get open() {
return this . layoutService . open ;
}
2020-07-06 11:19:01 +02:00
2022-12-20 16:40:46 +01:00
get isHidden() {
return this . stakeholder && ! this . hasPermission ( this . view?this.view :this.stakeholder.visibility ) ;
}
2020-07-06 11:19:01 +02:00
private setSideBar() {
let items : MenuItem [ ] = [ ] ;
2022-12-20 16:40:46 +01:00
if ( this . hasPermission ( this . view?this.view :this.stakeholder.visibility ) ) {
2022-11-04 15:36:51 +01:00
this . stakeholder . topics . forEach ( ( topic : Topic ) = > {
2022-12-20 16:40:46 +01:00
if ( this . hasPermission ( topic . visibility ) ) {
2022-11-04 15:36:51 +01:00
let topicItem : MenuItem = new MenuItem ( topic . alias , topic . name , "" , '/' + this . stakeholder . alias + '/' + topic . alias ,
2022-04-07 00:25:36 +02:00
null , [ ] , [ ] , { } , { svg : topic.icon } , null , null , (
2022-03-28 10:40:22 +02:00
'/' + this . stakeholder . alias + '/' + topic . alias ) ) ;
2022-11-04 15:36:51 +01:00
topicItem . items = topic . categories . map ( category = > {
return new MenuItem ( category . alias , category . name , "" , ( '/' + this . stakeholder . alias + '/' + topic . alias + '/' + category . alias ) ,
null , [ ] , [ ] , { } , { svg : topic.icon } , null , null ,
( '/' + this . stakeholder . alias + '/' + topic . alias + '/' + category . alias ) ) ;
} ) ;
2020-11-04 12:16:47 +01:00
items . push ( topicItem ) ;
}
} ) ;
if ( items . length === 0 ) {
items . push ( new MenuItem ( 'noTopics' , 'No topics available yet' , "" , "" , false , [ ] , [ ] , { } ) ) ;
2020-07-06 11:19:01 +02:00
}
}
2022-07-02 20:27:29 +02:00
this . adminMenuItems = [ ] ;
this . adminMenuItems . push ( new MenuItem ( "general" , "General" , "" , "/admin/" + this . stakeholder . alias , false , [ ] , [ ] , { } , { name : 'badge' } ) ) ;
this . adminMenuItems . push ( new MenuItem ( "indicators" , "Indicators" , "" , "/admin/" + this . stakeholder . alias + '/indicators' , false , [ ] , [ ] , { } , { name : 'bar_chart' } ) ) ;
if ( this . stakeholder . defaultId ) {
this . adminMenuItems . push ( new MenuItem ( "users" , "Users" , "" , "/admin/" + this . stakeholder . alias + "/users" , false , [ ] , [ ] , { } , { name : 'group' } , null , null , "/admin/" + this . stakeholder . alias + "/users" ) ) ;
2022-08-04 14:33:49 +02:00
if ( this . isCurator ( ) ) {
2022-07-02 20:27:29 +02:00
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" ) ) ;
}
}
2022-08-05 14:00:21 +02:00
this . specialSideBarMenuItem = new MenuItem ( "back" , "Manage profiles" , "" , "/admin" , false , [ ] , null , { } , { name : 'search' , class : 'uk-text-secondary' } ) ;
2020-07-06 11:19:01 +02:00
this . sideBarItems = items ;
2022-06-20 15:55:45 +02:00
this . hasSidebar = this . hasSidebar && this . sideBarItems . length > 0 ;
2020-07-06 11:19:01 +02:00
}
2019-12-20 12:48:35 +01:00
buildMenu() {
2020-10-12 14:54:57 +02:00
this . menuItems = [ ] ;
2019-12-20 12:48:35 +01:00
this . userMenuItems = [ ] ;
2020-11-03 10:42:47 +01:00
if ( this . user ) {
2022-08-04 14:33:49 +02:00
if ( this . isKindOfMonitorManager ( ) ) {
2020-11-03 11:59:48 +01:00
this . userMenuItems . push ( new MenuItem ( "" , "Manage profiles" ,
"" , "/admin" , false , [ ] , [ ] , { } ) ) ;
}
2022-03-02 22:58:53 +01:00
if ( Session . isPortalAdministrator ( this . user ) ) {
this . userMenuItems . push ( new MenuItem ( "adminOptions" , "Super Admin options" , "" , "/admin/admin-tools/portals" , false , [ ] , [ ] , { } ) ) ;
2022-07-27 11:36:18 +02:00
}
2022-08-04 14:33:49 +02:00
if ( this . isCurator ( ) ) {
this . userMenuItems . push ( new MenuItem ( "monitorOptions" , "Monitor options" , "" , "/admin/monitor/admin-tools/pages" , false , [ ] , [ ] , { } ) ) ;
2021-01-11 10:28:34 +01:00
}
2020-11-03 10:42:47 +01:00
}
2020-10-30 12:33:51 +01:00
if ( this . stakeholder ) {
2022-06-29 13:35:21 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "" , "/" + this . stakeholder . alias + "/user-info" , false , [ ] , [ ] , { } ) ) ;
2022-12-20 16:40:46 +01:00
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 )
) ;
2022-09-20 22:59:26 +02:00
this . menuItems . push (
new MenuItem ( "search" , "Browse Data" , "" , this . properties . searchLinkToResults ,
2022-03-28 10:40:22 +02:00
false , [ ] , null , { resultbestaccessright : '"' + encodeURIComponent ( "Open Access" ) + '"' } ,
2022-09-20 22:59:26 +02:00
null , null , null , null )
) ;
2022-09-21 11:03:18 +02:00
this . resourcesService . setResources ( this . menuItems , "/" + this . stakeholder . alias ) ;
2022-06-20 15:55:45 +02:00
if ( this . stakeholder . type === "funder" ) {
2022-09-20 22:59:26 +02:00
this . menuItems . push (
new MenuItem ( "develop" , "Develop" ,
"" , "/" + this . stakeholder . alias + "/develop" , false , [ ] , null , { } )
) ;
2022-06-20 15:55:45 +02:00
}
2022-03-28 10:40:22 +02:00
}
if ( this . isManager ( this . stakeholder ) ) {
2022-09-20 22:59:26 +02:00
this . menuItems . push (
new MenuItem ( "manage" , "Manage" ,
2022-03-28 10:40:22 +02:00
"" , "/admin/" + this . stakeholder . alias , false , [ ] , null , { }
2022-09-20 22:59:26 +02:00
, null , null , null , null )
) ;
2022-03-28 10:40:22 +02:00
}
2022-03-14 17:36:50 +01:00
if ( ! this . hasAdminMenu && this . isFrontPage ) {
2020-12-11 19:34:50 +01:00
this . menuHeader = {
2022-12-12 15:18:55 +01:00
route : './' + this . stakeholder . alias ,
url : null ,
title : this.stakeholder.name ,
logoUrl : StringUtils.getLogoUrl ( this . stakeholder ) ,
logoSmallUrl : StringUtils.getLogoUrl ( this . stakeholder ) ,
logoInfo : '<div class="uk-margin-left uk-width-medium"><div class="uk-margin-remove uk-text-background uk-text-bold uk-text-small">Monitor</div>' +
'<div class="uk-h6 uk-text-truncate uk-margin-remove">Dashboard</div></div>' ,
2022-12-20 16:40:46 +01:00
position : 'left' ,
2020-12-11 19:34:50 +01:00
badge : true ,
2022-12-12 15:18:55 +01:00
menuPosition : "center"
2020-12-11 19:34:50 +01:00
} ;
2020-10-12 14:54:57 +02:00
} else {
this . menuHeader = {
2022-12-12 15:18:55 +01:00
route : './' + this . stakeholder . alias ,
url : null ,
title : this.stakeholder.name ,
logoUrl : StringUtils.getLogoUrl ( this . stakeholder ) ,
logoSmallUrl : StringUtils.getLogoUrl ( this . stakeholder ) ,
logoInfo : '<div class="uk-margin-left uk-width-medium"><div class="uk-margin-remove uk-text-background uk-text-bold uk-text-small">Monitor Admin</div>' +
'<div class="uk-h6 uk-text-truncate uk-margin-remove">Dashboard</div></div>' ,
2022-12-20 16:40:46 +01:00
position : 'left' ,
2022-07-14 13:38:20 +02:00
badge : true ,
2022-12-12 15:18:55 +01:00
menuPosition : "center"
2020-10-12 14:54:57 +02:00
} ;
}
2020-10-30 12:33:51 +01:00
} else {
2022-08-04 14:33:49 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/user-info' , '' , false , [ ] , [ ] , { } , null , null , null , null , "_self" ) ) ;
this . menuHeader = {
route : null ,
url : "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu' ,
title : "Monitor" ,
logoUrl : 'assets/common-assets/logo-services/monitor/main.svg' ,
logoSmallUrl : "assets/common-assets/logo-services/monitor/small.svg" ,
position : 'left' ,
badge : true ,
menuPosition : "center"
} ;
2022-09-20 22:59:26 +02:00
this . menuItems . push (
new MenuItem ( "stakeholders" , "Browse " + this . stakeholderEntities . STAKEHOLDERS ,
"https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/browse' , "" , false , [ ] , null , { } , null , null , null , null , "_self" )
) ;
2022-09-21 11:03:18 +02:00
this . resourcesService . setResources ( this . menuItems , '' , "https://" + ( this . properties . environment === 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu' ) ;
2022-11-09 11:36:14 +01:00
let about = new MenuItem ( "about" , "About" , "" , "" , false , [ ] , null , { } ) ;
about . items = [
new MenuItem ( "how-it-works" , "How it works" , "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/about/how-it-works' , "" , false , [ ] , null , { } , null , null , null , null , "_self" ) ,
new MenuItem ( "faqs" , "FAQs" , "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/about/faqs' , "" , false , [ ] , null , { } , null , null , null , null , "_self" )
]
this . menuItems . push ( about ) ;
2022-08-04 14:33:49 +02:00
if ( this . hasAdminMenu ) {
2020-10-12 14:54:57 +02:00
this . adminMenuItems = [ ] ;
this . specialSideBarMenuItem = null ;
2022-06-24 17:22:55 +02:00
this . adminMenuItems . push ( new MenuItem ( "stakeholders" , "Manage profiles" , "" , "/admin" , false , [ ] , [ ] , { } , { name : 'settings' } ) ) ;
2022-04-07 19:31:55 +02:00
if ( Session . isPortalAdministrator ( this . user ) ) {
2022-08-04 14:33:49 +02:00
this . adminMenuItems . push ( new MenuItem ( "super_admin" , "Super Admin options" , "" , "/admin/admin-tools/portals" , false , [ ] , [ ] , { } , { name : 'settings' } , null , null , '/admin/admin-tools' ) ) ;
2022-07-27 11:36:18 +02:00
}
if ( Session . isPortalAdministrator ( this . user ) || Session . isMonitorCurator ( this . user ) ) {
2022-08-04 14:33:49 +02:00
this . adminMenuItems . push ( new MenuItem ( "monitor" , "Monitor options" , "" , "/admin/monitor/admin-tools/pages" , false , [ ] , [ ] , { } , { name : 'settings' } , null , null , '/admin/monitor/admin-tools' ) ) ;
2022-04-07 19:31:55 +02:00
}
2022-08-04 14:33:49 +02:00
this . hasAdminMenu = this . hasAdminMenu && this . adminMenuItems . length > 1 ;
2020-10-12 14:54:57 +02:00
}
2019-12-20 12:48:35 +01:00
}
}
2020-12-11 19:34:50 +01:00
2020-11-03 11:59:48 +01:00
public isCurator() {
2022-08-04 14:33:49 +02:00
return this . user && ( Session . isPortalAdministrator ( this . user ) || Session . isMonitorCurator ( this . user ) ) ;
}
public isKindOfMonitorManager() {
2020-11-03 11:59:48 +01:00
return this . user && ( Session . isPortalAdministrator ( this . user ) || Session . isMonitorCurator ( this . user ) || Session . isKindOfMonitorManager ( this . user ) ) ;
}
2020-12-11 19:34:50 +01:00
2022-12-20 16:40:46 +01:00
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 ) ) ;
}
2020-12-11 19:34:50 +01:00
public isManager ( stakeholder : Stakeholder ) {
2020-11-03 11:59:48 +01:00
return this . user && ( Session . isPortalAdministrator ( this . user ) || Session . isCurator ( stakeholder . type , this . user ) || Session . isManager ( stakeholder . type , stakeholder . alias , this . user ) ) ;
2020-07-06 11:19:01 +02:00
}
2020-10-30 12:33:51 +01:00
2022-12-20 16:40:46 +01:00
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 ) ;
}
2020-11-01 16:41:56 +01:00
}
2022-03-02 22:58:53 +01:00
setProperties ( id , type = null ) {
2021-07-14 18:02:04 +02:00
this . properties . adminToolsCommunity = id ;
2022-03-02 22:58:53 +01:00
if ( type ) {
2021-07-14 18:02:04 +02:00
this . properties . adminToolsPortalType = type ;
} else {
ConnectHelper . setPortalTypeFromPid ( id ) ;
2020-12-11 19:34:50 +01:00
}
2020-12-18 16:31:21 +01:00
this . configurationService . initCommunityInformation ( this . properties , this . properties . adminToolsCommunity ) ;
}
2019-10-24 09:44:29 +02:00
}