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" ;
2020-10-12 14:54:57 +02:00
import { MenuItem , RootMenuItem } from "./openaireLibrary/sharedComponents/menu" ;
2020-10-23 15:58:16 +02:00
import { Stakeholder , 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-23 15:58:16 +02:00
import { arrow_left } from "./openaireLibrary/utils/icons/icons" ;
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" ;
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 ;
2020-07-06 11:19:01 +02:00
isFrontPage : boolean = false ;
2020-12-11 19:34:50 +01:00
isDashboard : boolean = false ;
2020-07-06 11:19:01 +02:00
isViewPublic : boolean = false ;
sideBarItems : MenuItem [ ] = [ ] ;
2020-10-30 12:33:51 +01:00
specialSideBarMenuItem : MenuItem = null ;
2020-10-12 14:54:57 +02:00
menuItems : RootMenuItem [ ] = [ ] ;
2021-03-04 12:35:10 +01:00
notificationGroups : Option [ ] = [ ] ;
notificationGroupsInitialized : boolean = false ;
stakeholderUtils : StakeholderUtils = new StakeholderUtils ( ) ;
2020-10-30 12:33:51 +01:00
menuHeader : Header = {
route : "/" ,
url : null ,
title : "Default menu header" ,
logoUrl : null ,
logoSmallUrl : null ,
position : 'center' ,
2020-10-30 14:59:37 +01:00
badge : false ,
2020-11-01 16:41:56 +01:00
stickyAnimation : false
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 ;
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 ,
2020-12-18 16:31:21 +01:00
private cdr : ChangeDetectorRef , private configurationService : ConfigurationService ) {
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 ) {
2020-12-11 19:34:50 +01:00
if ( this . layoutService . isSmallScreen && event . target . innerWidth > 1219 ) {
2020-11-26 17:23:21 +01:00
this . layoutService . setSmallScreen ( false ) ;
2020-12-11 19:34:50 +01:00
} else if ( ! this . layoutService . isSmallScreen && event . target . innerWidth < 1219 ) {
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 ( ) ;
} ) ) ;
2020-06-04 13:30:26 +02:00
this . subscriptions . push ( this . layoutService . isFrontPage . subscribe ( isFrontPage = > {
this . isFrontPage = isFrontPage ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2020-12-11 19:34:50 +01:00
this . subscriptions . push ( this . layoutService . isDashboard . subscribe ( isDashboard = > {
this . isDashboard = isDashboard ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2020-07-06 11:19:01 +02:00
this . route . queryParams . subscribe ( params = > {
this . isViewPublic = ( params [ 'view' ] == 'public' ) ;
} ) ;
2020-11-27 10:54:57 +01:00
this . layoutService . setSmallScreen ( ( this . innerWidth && this . innerWidth < 1219 ) ) ;
this . layoutService . setOpen ( ! ( this . innerWidth && this . innerWidth < 1219 ) ) ;
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 ;
2020-12-11 11:14:27 +01:00
let isSearch = this . router . url . includes ( '/search/' ) ;
2020-10-30 12:33:51 +01:00
if ( params && params [ 'stakeholder' ] ) {
2020-11-20 18:15:30 +01:00
// this.stakeholder = this.stakeholderService.stakeholder;
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-10-30 12:33:51 +01:00
if ( isSearch ) {
this . activeTopic = null ;
} else if ( params && params [ 'topic' ] && ! this . activeTopic ) {
this . activeTopic = this . stakeholder . topics . find ( topic = > topic . alias === decodeURIComponent ( params [ 'topic' ] ) && this . isPublicOrIsMember ( topic . visibility ) ) ;
2020-07-06 11:19:01 +02:00
} else {
2020-10-30 12:33:51 +01:00
this . activeTopic = this . stakeholder . topics . find ( topic = > this . isPublicOrIsMember ( topic . visibility ) ) ;
2020-07-06 11:19:01 +02:00
}
2020-11-05 17:50:06 +01:00
this . setSideBar ( ) ;
2020-11-20 18:15:30 +01:00
this . buildMenu ( ) ;
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 ( ) ;
2020-10-30 12:33:51 +01:00
if ( isSearch ) {
this . activeTopic = null ;
} else if ( params && params [ 'topic' ] ) {
this . activeTopic = this . stakeholder . topics . find ( topic = > topic . alias === decodeURIComponent ( params [ 'topic' ] ) && this . isPublicOrIsMember ( topic . visibility ) ) ;
} else {
this . activeTopic = this . stakeholder . topics . find ( topic = > this . isPublicOrIsMember ( topic . visibility ) ) ;
}
this . loading = false ;
2020-10-23 15:58:16 +02:00
}
2020-10-30 12:33:51 +01:00
} else {
LinksResolver . resetProperties ( ) ;
this . stakeholderService . setStakeholder ( null ) ;
this . layoutService . setOpen ( ! ( this . innerWidth && this . innerWidth < 1219 ) ) ;
this . stakeholder = null ;
this . buildMenu ( ) ;
this . loading = false ;
}
}
} ) ) ;
2021-07-14 18:02:04 +02:00
this . subscriptions . push ( this . data . subscribe ( data = > {
if ( data && data . portal ) {
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 = > {
this . user = user ;
if ( user ) {
this . buildMenu ( ) ;
2021-08-02 17:12:10 +02:00
if ( ! this . notificationGroupsInitialized ) {
2021-03-04 12:35:10 +01:00
this . setNotificationGroups ( ) ;
}
2020-10-30 12:33:51 +01:00
}
} ) ) ;
2019-12-20 12:48:35 +01:00
}
2020-07-06 11:19:01 +02:00
2021-03-04 12:35:10 +01:00
public setNotificationGroups() {
this . notificationGroups = [ ] ;
if ( Session . isPortalAdministrator ( this . user ) ) {
this . notificationGroups . push ( { value : Role.PORTAL_ADMIN , label : 'Portal Administrators' } ) ;
}
for ( let type of this . stakeholderUtils . types ) {
if ( Session . isCurator ( type . value , this . user ) || Session . isPortalAdministrator ( this . user ) ) {
this . notificationGroups . push ( { value : Role.curator ( type . value ) , label : type.label + ' Curators' } ) ;
}
}
this . subscriptions . push ( this . stakeholderService . getMyStakeholders ( this . properties . monitorServiceAPIURL ) . subscribe ( stakeholders = > {
stakeholders . forEach ( stakeholder = > {
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' } ) ;
} ) ;
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() {
2020-09-18 11:19:47 +02:00
this . router . navigate ( [ '/error' ] , { queryParams : { 'page' : this . properties . baseLink + this . router . url } } ) ;
2020-06-10 16:03:28 +02:00
}
2020-07-06 11:19:01 +02:00
2019-12-20 12:48:35 +01:00
public get open() {
return this . layoutService . open ;
}
2020-07-06 11:19:01 +02:00
private setSideBar() {
let items : MenuItem [ ] = [ ] ;
2020-12-11 19:34:50 +01:00
if ( this . isPublicOrIsMember ( this . stakeholder . visibility ) ) {
2020-11-04 12:16:47 +01:00
this . stakeholder . topics . forEach ( ( topic ) = > {
if ( this . isPublicOrIsMember ( topic . visibility ) ) {
let topicItem : MenuItem = new MenuItem ( topic . alias , topic . name , "" , (
'/' + this . stakeholder . alias + '/' + topic . alias ) ,
null , [ ] , [ ] , { } ) ;
topicItem . icon = topic . icon ;
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
}
2020-12-11 19:34:50 +01:00
} else {
let topicItem : MenuItem = new MenuItem ( "private" , "Private Data" , "" , "" , null , [ ] , [ ] , { } ) ;
2020-11-04 12:16:47 +01:00
items . push ( topicItem ) ;
2020-07-06 11:19:01 +02:00
}
this . sideBarItems = items ;
}
2019-12-20 12:48:35 +01:00
buildMenu() {
2020-10-12 14:54:57 +02:00
this . menuItems = [ ] ;
this . adminMenuItems = [ ] ;
2019-12-20 12:48:35 +01:00
this . userMenuItems = [ ] ;
2020-11-03 10:42:47 +01:00
if ( this . user ) {
2020-11-03 11:59:48 +01:00
if ( this . isCurator ( ) ) {
this . userMenuItems . push ( new MenuItem ( "" , "Manage profiles" ,
"" , "/admin" , false , [ ] , [ ] , { } ) ) ;
}
2021-01-11 10:28:34 +01:00
if ( Session . isPortalAdministrator ( this . user ) ) {
2021-01-26 18:01:22 +01:00
this . userMenuItems . push ( new MenuItem ( "adminOptions" , "Super Admin options" , "" , "/admin/admin-tools/portals" , false , [ ] , [ ] , { } ) ) ;
this . userMenuItems . push ( new MenuItem ( "monitorOptions" , "Monitor portal options" , "" , "/admin/monitor/admin-tools/pages" , false , [ ] , [ ] , { } ) ) ;
2021-01-11 10:28:34 +01:00
}
2020-11-05 09:26:05 +01:00
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "" , "/user-info" , false , [ ] , [ ] , { } ) ) ;
2020-11-03 10:42:47 +01:00
}
2020-10-30 12:33:51 +01:00
if ( this . stakeholder ) {
2020-12-11 19:34:50 +01:00
if ( ! this . isDashboard ) {
this . menuHeader = {
route : null ,
url : "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu' ,
title : "Monitor" ,
logoUrl : 'assets/common-assets/logo-large-monitor.png' ,
logoSmallUrl : "assets/common-assets/logo-small-monitor.png" ,
position : 'left' ,
badge : true ,
stickyAnimation : false
} ;
this . menuItems . push ( {
rootItem : new MenuItem ( "dashboard" , "Dashboard" ,
"" , "/" + this . stakeholder . alias , false , [ ] , null , { } ) , items : [ ]
} ) ;
2021-03-31 11:35:26 +02:00
this . menuItems . push ( {
2021-04-05 15:40:40 +02:00
rootItem : new MenuItem ( "methodology" , "Methodology" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } ) , items : [
2021-04-05 15:40:40 +02:00
new MenuItem ( "methodology" , "Terminology and construction" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } ) ,
2021-04-05 16:02:18 +02:00
new MenuItem ( "methodology" , "See how it works" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } , null , "how" ) ,
2021-04-05 15:40:40 +02:00
]
2021-03-31 11:35:26 +02:00
} ) ;
2020-12-14 16:21:17 +01:00
if ( this . stakeholder . type === "funder" ) {
this . menuItems . push ( {
rootItem : new MenuItem ( "develop" , "Develop" ,
"" , "/" + this . stakeholder . alias + "/develop" , false , [ ] , null , { } ) , items : [ ]
} ) ;
}
if ( this . isCurator ( ) ) {
this . menuItems . push ( {
rootItem : new MenuItem ( "manage" , "Manage" ,
"" , "/admin" , false , [ ] , null , { } ) , items : [ ]
} ) ;
}
2020-12-11 19:34:50 +01:00
}
else if ( this . isFrontPage ) {
2020-10-12 14:54:57 +02:00
this . menuHeader = {
route : "/" + this . stakeholder . alias ,
url : null ,
title : this.stakeholder.name ,
logoUrl : null ,
logoSmallUrl : null ,
position : 'center' ,
2020-10-30 14:59:37 +01:00
badge : false ,
stickyAnimation : false
2020-10-12 14:54:57 +02:00
} ;
2021-03-31 11:35:26 +02:00
this . menuItems . push ( {
2021-04-05 15:40:40 +02:00
rootItem : new MenuItem ( "methodology" , "Methodology" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } ) , items : [
2021-04-05 15:40:40 +02:00
new MenuItem ( "methodology" , "Terminology and construction" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } ) ,
2021-04-05 16:02:18 +02:00
new MenuItem ( "methodology" , "See how it works" ,
2021-04-05 17:36:07 +02:00
"" , "/" + this . stakeholder . alias + "/methodology" , false , [ ] , null , { } , null , "how" ) ,
2021-04-05 15:40:40 +02:00
]
2021-03-31 11:35:26 +02:00
} ) ;
2020-12-11 19:34:50 +01:00
if ( this . stakeholder . type === "funder" ) {
this . menuItems . push ( {
rootItem : new MenuItem ( "develop" , "Develop" ,
"" , "/" + this . stakeholder . alias + "/develop" , false , [ ] , null , { } ) , items : [ ]
} ) ;
}
2020-11-03 11:59:48 +01:00
if ( this . isCurator ( ) ) {
2020-10-12 14:54:57 +02:00
this . menuItems . push ( {
rootItem : new MenuItem ( "manage" , "Manage" ,
2020-10-30 12:33:51 +01:00
"" , "/admin" , false , [ ] , null , { } ) , items : [ ]
2020-10-12 14:54:57 +02:00
} ) ;
2020-10-29 10:17:39 +01:00
}
2020-12-11 19:34:50 +01:00
if ( this . isPublicOrIsMember ( this . stakeholder . visibility ) ) {
2021-05-26 11:26:54 +02:00
this . specialSideBarMenuItem = new MenuItem ( "search" , "Search research outcomes" , "" , this . properties . searchLinkToResults , false , [ ] , null , { resultbestaccessright : '"' + encodeURIComponent ( "Open Access" ) + '"' } ) ;
2020-11-04 12:16:47 +01:00
this . specialSideBarMenuItem . icon = '<span uk-icon="search"></span>' ;
2020-12-11 19:34:50 +01:00
} else {
this . specialSideBarMenuItem = null ;
2020-11-04 12:16:47 +01:00
}
2020-10-12 14:54:57 +02:00
} else {
this . menuHeader = {
route : "/admin/" + this . stakeholder . alias ,
url : null ,
title : 'Admin - ' + this . stakeholder . name ,
logoUrl : null ,
logoSmallUrl : null ,
position : 'center' ,
2020-10-30 14:59:37 +01:00
badge : false ,
stickyAnimation : false
2020-10-12 14:54:57 +02:00
} ;
this . menuItems . push ( {
rootItem : new MenuItem ( "" , "Dashboard" ,
2020-10-30 12:33:51 +01:00
"" , '/' + this . stakeholder . alias + '/' , false , [ ] , null , { } ) , items : [ ]
2020-10-12 14:54:57 +02:00
} ) ;
2020-10-30 12:33:51 +01:00
this . adminMenuItems . push ( new MenuItem ( "general" , "General" , "" , "/admin/" + this . stakeholder . alias , false , [ ] , [ ] , { } , "<i uk-icon=\"image\"></i>" ) ) ;
this . adminMenuItems . push ( new MenuItem ( "indicators" , "Indicators" , "" , "/admin/" + this . stakeholder . alias + '/indicators' , false , [ ] , [ ] , { } , "<i uk-icon=\"image\"></i>" ) ) ;
2021-01-15 17:02:30 +01:00
if ( this . stakeholder . defaultId ) {
this . adminMenuItems . push ( new MenuItem ( "users" , "Users" , "" , "/admin/" + this . stakeholder . alias + "/users" , false , [ ] , [ ] , { } , "<i uk-icon=\"users\"></i>" ) ) ;
if ( Session . isPortalAdministrator ( this . user ) ) {
2021-01-26 18:01:22 +01:00
this . adminMenuItems . push ( new MenuItem ( "admin-tools" , "Pages & Entities" , "" , "/admin/" + this . stakeholder . alias + "/admin-tools/pages" , false , [ ] , [ ] , { } , null , null , null , "/admin/" + this . stakeholder . alias + "/admin-tools" ) ) ;
2021-01-15 17:02:30 +01:00
}
2020-12-18 16:31:21 +01:00
}
2020-10-30 12:33:51 +01:00
this . specialSideBarMenuItem = new MenuItem ( "back" , "Manage profiles" , "" , "/admin" , false , [ ] , null , { } ) ;
2020-10-31 17:02:30 +01:00
this . specialSideBarMenuItem . icon = '<span class="uk-icon-button small uk-icon uk-button-secondary">' + arrow_left . data + '</span>' ; // '<span class="uk-icon-button uk-icon portal-button " uk-icon="chevron-left"></span>';
this . specialSideBarMenuItem . customClass = 'uk-text-uppercase uk-text-bold uk-text-secondary' ;
2020-10-12 14:54:57 +02:00
}
2020-10-30 12:33:51 +01:00
} else {
if ( this . isFrontPage || ! this . hasAdminMenu ) {
this . menuHeader = {
route : null ,
url : "https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu' ,
title : "Monitor" ,
logoUrl : 'assets/common-assets/logo-large-monitor.png' ,
logoSmallUrl : "assets/common-assets/logo-small-monitor.png" ,
position : 'left' ,
2020-10-30 14:59:37 +01:00
badge : true ,
stickyAnimation : false
2020-10-30 12:33:51 +01:00
} ;
2020-11-03 11:59:48 +01:00
this . menuItems . push ( {
rootItem : new MenuItem ( "about" , "About" ,
2020-12-11 19:34:50 +01:00
"https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/about/learn-how' , "" , false , [ ] , null , { } ) ,
items : [ ]
2020-11-03 11:59:48 +01:00
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "browse" , "Browse" ,
2020-12-11 19:34:50 +01:00
"https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/browse' , "" , false , [ ] , null , { } ) ,
items : [ ]
2020-11-03 11:59:48 +01:00
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "contact" , "Contact us" ,
2020-12-11 19:34:50 +01:00
"https://" + ( this . properties . environment == 'beta' ? 'beta.' : '' ) + 'monitor.openaire.eu/contact-us' , "" , false , [ ] , null , { } ) ,
items : [ ]
2020-11-03 11:59:48 +01:00
} ) ;
2020-10-30 12:33:51 +01:00
} else {
this . menuHeader = {
route : "/" ,
url : null ,
title : "Monitor Dashboard" ,
logoUrl : null ,
logoSmallUrl : null ,
position : 'center' ,
2020-10-30 14:59:37 +01:00
badge : false ,
stickyAnimation : false
2020-10-30 12:33:51 +01:00
} ;
2020-10-12 14:54:57 +02:00
this . adminMenuItems = [ ] ;
this . specialSideBarMenuItem = null ;
this . adminMenuItems . push ( new MenuItem ( "stakeholders" , "Manage profiles" , "" , "/admin" , false , [ ] , [ ] , { } , "<i uk-icon=\"cog\"></i>" ) ) ;
}
2019-12-20 12:48:35 +01:00
}
2020-10-30 12:33:51 +01: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() {
return this . user && ( Session . isPortalAdministrator ( this . user ) || Session . isMonitorCurator ( this . user ) || Session . isKindOfMonitorManager ( 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
2021-07-14 18:02:04 +02:00
public isPublicOrIsMember ( visibility : Visibility ) : boolean {
return ! ( visibility == "PRIVATE" || ( this . isViewPublic && visibility != "PUBLIC" ) ) ;
2020-11-01 16:41:56 +01:00
}
2021-07-14 18:02:04 +02:00
setProperties ( id , type = null ) {
this . properties . adminToolsCommunity = id ;
if ( type ) {
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
}