2019-09-30 14:48:48 +02:00
import { Component } from '@angular/core' ;
2020-06-29 15:16:21 +02:00
import { ActivatedRoute , NavigationEnd , NavigationStart , Params , Router } from '@angular/router' ;
2019-01-09 12:05:23 +01:00
2019-09-30 14:48:48 +02:00
import { EnvProperties } from './openaireLibrary/utils/properties/env-properties' ;
import { MenuItem , RootMenuItem } from './openaireLibrary/sharedComponents/menu' ;
import { EnvironmentSpecificService } from './openaireLibrary/utils/properties/environment-specific.service' ;
import { Session , User } from './openaireLibrary/login/utils/helper.class' ;
import { HelperFunctions } from "./openaireLibrary/utils/HelperFunctions.class" ;
import { UserManagementService } from "./openaireLibrary/services/user-management.service" ;
2020-06-11 17:34:42 +02:00
import { properties } from "../environments/environment" ;
2020-06-29 15:16:21 +02:00
import { BehaviorSubject , Subscriber } from "rxjs" ;
import { StakeholderService } from "./openaireLibrary/monitor/services/stakeholder.service" ;
2020-10-14 13:23:40 +02:00
import { Header } from "./openaireLibrary/sharedComponents/navigationBar.component" ;
2021-04-21 14:52:40 +02:00
import { SmoothScroll } from "./openaireLibrary/utils/smooth-scroll" ;
2019-01-09 12:05:23 +01:00
@Component ( {
selector : 'app-root' ,
template : `
2020-06-03 23:55:32 +02:00
< div class = "monitorApp" >
2020-10-14 13:40:12 +02:00
< navbar * ngIf = "properties && showMenu && header" portal = "monitor" [ header ] = " header " [ onlyTop ] = " false "
2019-09-30 14:48:48 +02:00
[ userMenuItems ] = userMenuItems [ menuItems ] = menuItems [ user ] = "user"
2020-06-03 23:55:32 +02:00
[ showMenu ] = showMenu [ properties ] = "properties" > < / navbar >
2020-11-16 17:28:16 +01:00
< schema2jsonld * ngIf = "properties " [ URL ] = " properties.domain + properties.baseLink "
[ logoURL ] = "properties.domain + properties.baseLink+'/assets/common-assets/logo-small-monitor.png'"
type = "home"
description = "OpenAIRE - Monitor, A new era of monitoring research. Open data. Open methodologies. Work together with us to view, understand and visualize research statistics and indicators. "
name = "OpenAIRE Monitor" [ searchAction ] = "true" [ searchActionRoute ] = "properties.domain + properties.baseLink + '/browse'" >
< / schema2jsonld >
2019-09-30 14:48:48 +02:00
< div class = "custom-main-content" >
< main >
< router - outlet > < / r o u t e r - o u t l e t >
< / main >
< / div >
2020-10-13 22:32:48 +02:00
< cookie - law position = "bottom" >
2019-09-30 14:48:48 +02:00
OpenAIRE uses cookies in order to function properly . < br >
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible .
By using the OpenAIRE portal you accept our use of cookies . < a
2020-06-05 14:59:28 +02:00
href = "//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target = "_blank" > Read more < span class = "uk-icon" >
2019-09-30 14:48:48 +02:00
< svg width = "20" height = "20" viewBox = "0 0 20 20" xmlns = "http://www.w3.org/2000/svg" icon = "chevron-right"
ratio = "1" > < polyline fill = "none" stroke = "#000" stroke - width = "1.03"
points = "7 4 13 10 7 16" > < / polyline > < / svg >
< / span > < / a >
< / c o o k i e - l a w >
2020-10-13 22:32:48 +02:00
< bottom * ngIf = "properties && showMenu" [ grantAdvance ] = " false "
2019-09-30 14:48:48 +02:00
[ properties ] = "properties" > < / bottom >
< / div >
`
2020-06-05 14:59:28 +02:00
2019-09-30 14:48:48 +02:00
} )
export class AppComponent {
userMenuItems : MenuItem [ ] = [ ] ;
menuItems : RootMenuItem [ ] = [ ] ;
bottomMenuItems : MenuItem [ ] = [ ] ;
2020-06-29 15:16:21 +02:00
properties : EnvProperties = properties ;
2019-09-30 14:48:48 +02:00
showMenu : boolean = false ;
user : User ;
2020-06-29 15:16:21 +02:00
params : BehaviorSubject < Params > = new BehaviorSubject < Params > ( null ) ;
url : string ;
2020-10-14 13:23:40 +02:00
header : Header ;
logoPath : string = 'assets/common-assets/' ;
2020-06-29 15:16:21 +02:00
private subscriptions : any [ ] = [ ] ;
2020-06-05 14:59:28 +02:00
2019-09-30 14:48:48 +02:00
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
2021-04-21 14:52:40 +02:00
private router : Router , private stakeholderService : StakeholderService , private smoothScroll : SmoothScroll ,
2020-06-29 15:16:21 +02:00
private userManagementService : UserManagementService ) {
2020-11-13 16:08:17 +01:00
this . subscriptions . push ( router . events . forEach ( ( event ) = > {
2021-07-14 17:47:49 +02:00
if ( event instanceof NavigationEnd ) {
2020-06-29 15:16:21 +02:00
this . url = event . url ;
let r = this . route ;
while ( r . firstChild ) {
r = r . firstChild ;
}
let params = r . snapshot . params ;
this . params . next ( params ) ;
2019-09-30 14:48:48 +02:00
}
2020-11-13 16:08:17 +01:00
} ) ) ;
2019-09-30 14:48:48 +02:00
}
2020-06-05 14:59:28 +02:00
2019-09-30 14:48:48 +02:00
ngOnInit() {
2020-07-13 15:05:41 +02:00
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
this . user = user ;
this . setUserMenu ( ) ;
2020-10-14 13:23:40 +02:00
this . header = {
route : "/" ,
url : null ,
title : 'monitor' ,
logoUrl : this.logoPath + 'logo-large-monitor.png' ,
logoSmallUrl :this.logoPath + 'logo-small-monitor.png' ,
position : 'left' ,
badge :true
} ;
2020-07-13 15:05:41 +02:00
this . buildMenu ( ) ;
2020-06-29 15:16:21 +02:00
} ) ) ;
}
public ngOnDestroy() {
this . subscriptions . forEach ( value = > {
if ( value instanceof Subscriber ) {
value . unsubscribe ( ) ;
}
} ) ;
2020-11-13 16:08:17 +01:00
this . userManagementService . clearSubscriptions ( ) ;
this . stakeholderService . clearSubscriptions ( ) ;
2021-04-21 14:52:40 +02:00
this . smoothScroll . clearSubscriptions ( ) ;
2020-06-29 15:16:21 +02:00
}
2020-06-05 14:59:28 +02:00
public buildMenu() {
this . menuItems = [ ] ;
this . menuItems . push ( {
rootItem : new MenuItem ( "about" , "About" , "" , "/about/learn-how" , false , [ ] , null , { } ) ,
items : [ ]
} ) ;
this . menuItems . push ( {
2020-06-29 15:16:21 +02:00
rootItem : new MenuItem ( "stakeholders" , "Browse" , "" , "browse" , false , [ ] , null , { } ) ,
2020-06-05 14:59:28 +02:00
items : [ ]
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "contact-us" , "Contact us" , "" , "/contact-us" , false , [ ] , null , { } ) ,
items : [ ]
} ) ;
this . bottomMenuItems = [
new MenuItem ( "" , "About" , "https://beta.openaire.eu/project-factsheets" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "News - Events" , "https://beta.openaire.eu/news-events" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "Blog" , "https://blogs.openaire.eu/" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "Contact us" , "https://beta.openaire.eu/contact-us" , "" , false , [ ] , [ ] , { } )
] ;
2020-06-29 15:16:21 +02:00
this . showMenu = true ;
}
public setUserMenu() {
2020-06-05 14:59:28 +02:00
this . userMenuItems = [ ] ;
2020-11-04 18:19:27 +01:00
if ( this . user ) {
if ( Session . isPortalAdministrator ( this . user ) || Session . isMonitorCurator ( this . user ) || Session . isKindOfMonitorManager ( this . user ) ) {
this . userMenuItems . push ( new MenuItem ( "" , "Manage profiles" ,
this . properties . domain + properties . baseLink + "/dashboard/admin" , "" , false , [ ] , [ ] , { } ) )
}
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "" , "/user-info" , false , [ ] , [ ] , { } ) ) ;
2020-06-05 14:59:28 +02:00
}
}
2019-01-09 12:05:23 +01:00
}