2019-09-13 09:46:57 +02:00
import { Component } from '@angular/core' ;
2019-06-03 15:21:49 +02:00
import { ActivatedRoute , NavigationStart , Router } from '@angular/router' ;
2018-02-05 14:16:11 +01:00
2019-06-03 15:21:49 +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' ;
2018-02-05 14:16:11 +01:00
2019-09-13 09:46:57 +02:00
import { Session , User } from './openaireLibrary/login/utils/helper.class' ;
2019-06-03 15:21:49 +02:00
import { HelperFunctions } from "./openaireLibrary/utils/HelperFunctions.class" ;
2019-09-13 09:46:57 +02:00
import { UserManagementService } from "./openaireLibrary/services/user-management.service" ;
2020-07-13 00:22:43 +02:00
import { ConfigurationService } from "./openaireLibrary/utils/configuration/configuration.service" ;
2020-10-14 13:19:00 +02:00
import { Header } from "./openaireLibrary/sharedComponents/navigationBar.component" ;
2020-11-11 15:44:21 +01:00
import { Subscriber } from "rxjs" ;
2020-12-07 10:17:53 +01:00
import { Meta } from "@angular/platform-browser" ;
import { properties } from "../environments/environment" ;
2018-02-05 14:16:11 +01:00
2018-01-23 11:07:39 +01:00
@Component ( {
//changeDetection: ChangeDetectionStrategy.Default,
//encapsulation: ViewEncapsulation.Emulated,
selector : 'app-root' ,
template : `
2020-10-14 13:19:00 +02:00
< navbar * ngIf = "properties && header" [ header ] = " header " [ portal ] = " properties.dashboard " [ properties ] = properties [ onlyTop ] = false [ user ] = " user "
2019-06-05 16:31:43 +02:00
[ communityId ] = "properties.adminToolsCommunity" [ userMenuItems ] = userMenuItems [ menuItems ] = menuItems > < / navbar >
2020-09-18 16:02:48 +02:00
< schema2jsonld * ngIf = "properties" [ URL ] = " properties.domain + properties.baseLink "
[ logoURL ] = "properties.domain+properties.baseLink+'/assets/common-assets/logo-small-explore.png'" type = "home"
2020-08-19 12:59:28 +02:00
name = "OpenAIRE | Find and Share research" description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide." > < / schema2jsonld >
2019-06-03 15:21:49 +02:00
< div class = "custom-main-content" >
< main >
< router - outlet > < / r o u t e r - o u t l e t >
< / main >
< / div >
< cookie - law * ngIf = "isClient" position = "bottom" >
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
href = "//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target = "_blank" > Read more < span class = "uk-icon" >
< 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 >
2018-01-23 11:07:39 +01:00
< / span > < / a >
2019-06-03 15:21:49 +02:00
< / c o o k i e - l a w >
2019-07-24 14:47:47 +02:00
< bottom * ngIf = "isClient && properties" [ properties ] = " properties " > < / bottom >
2018-01-23 11:07:39 +01:00
2019-06-03 15:21:49 +02:00
`
2018-01-23 11:07:39 +01:00
} )
export class AppComponent {
2019-06-03 15:21:49 +02:00
isClient : boolean = false ;
clientLoad = 0 ;
userMenuItems : MenuItem [ ] = [ new MenuItem ( "" , "My profile" , "" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "My links" , "" , "/myclaims" , false , [ ] , [ "/myclaims" ] , { } ) ]
2019-07-24 14:47:47 +02:00
menuItems : RootMenuItem [ ] = [ ] ;
2018-10-15 12:48:31 +02:00
2019-07-24 14:47:47 +02:00
feedbackmail : string ;
2019-06-03 15:21:49 +02:00
properties : EnvProperties ;
2019-09-13 09:46:57 +02:00
user : User ;
2020-10-14 13:19:00 +02:00
header : Header ;
logoPath : string = 'assets/common-assets/' ;
2020-11-11 15:44:21 +01:00
subscriptions = [ ] ;
2018-10-15 12:48:31 +02:00
2019-06-03 15:21:49 +02:00
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
2020-07-13 00:22:43 +02:00
private router : Router , private userManagementService : UserManagementService ,
2020-12-07 10:17:53 +01:00
private configurationService : ConfigurationService , private _meta : Meta ) {
2020-11-11 15:44:21 +01:00
this . subscriptions . push ( router . events . forEach ( ( event ) = > {
2019-06-03 15:21:49 +02:00
if ( event instanceof NavigationStart ) {
2020-05-26 12:20:32 +02:00
// console.log(event.url);
2019-06-03 15:21:49 +02:00
HelperFunctions . scroll ( ) ;
}
2020-11-11 15:44:21 +01:00
} ) ) ;
2019-06-03 15:21:49 +02:00
}
2018-01-23 11:07:39 +01:00
2019-06-03 15:21:49 +02:00
ngOnInit() {
2020-12-07 10:17:53 +01:00
2019-06-03 15:21:49 +02:00
if ( typeof document !== 'undefined' ) {
try {
this . isClient = true ;
2018-12-19 15:35:59 +01:00
2019-06-03 15:21:49 +02:00
} catch ( e ) {
}
2018-02-05 14:16:11 +01:00
2019-06-03 15:21:49 +02:00
}
2020-11-11 15:44:21 +01:00
this . subscriptions . push ( this . propertiesService . loadEnvironment ( )
2019-06-03 15:21:49 +02:00
. then ( es = > {
this . propertiesService . setEnvProperties ( es ) ;
this . properties = this . propertiesService . envSpecific ;
2020-07-13 00:22:43 +02:00
this . configurationService . initCommunityInformation ( this . properties , this . properties . adminToolsCommunity ) ;
2019-06-03 15:21:49 +02:00
this . feedbackmail = this . properties . feedbackmail ;
2020-12-23 17:21:03 +01:00
if ( this . properties . environment == "production" || this . properties . environment == "development" ) {
2020-12-07 10:17:53 +01:00
this . subscriptions . push ( this . route . queryParams . subscribe ( data = > {
this . _meta . updateTag ( { content : 'all' , name : 'robots' } ) ;
} ) ) ;
}
2020-11-11 15:44:21 +01:00
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
2019-09-13 09:46:57 +02:00
this . user = user ;
this . buildMenu ( ) ;
2020-10-14 13:19:00 +02:00
this . header = {
route : "/" ,
url : null ,
title : 'explore' ,
logoUrl : this.logoPath + 'logo-large-explore.png' ,
logoSmallUrl :this.logoPath + 'logo-small-explore.png' ,
position : 'left' ,
badge :true
} ;
2020-11-11 15:44:21 +01:00
} ) ) ;
2019-06-03 15:21:49 +02:00
//console.log(this.properties.loginUrl);
} , error = > {
console . log ( "App couldn't fetch properties" ) ;
console . log ( error ) ;
2020-11-11 15:44:21 +01:00
} ) ) ;
}
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
this . configurationService . clearSubscriptions ( ) ;
this . userManagementService . clearSubscriptions ( ) ;
2019-06-03 15:21:49 +02:00
}
2019-07-24 14:47:47 +02:00
buildMenu() {
2020-02-11 16:09:08 +01:00
//TODO add check for research results route
2019-07-24 14:47:47 +02:00
this . menuItems = [
{
2020-12-23 17:21:03 +01:00
rootItem : new MenuItem ( "search" , "Search" , "" , "/search/find" , false , [ ] , [ "/search/find" ] , { qf :true } ) ,
2020-02-11 16:09:08 +01:00
items : [
2020-06-01 11:20:11 +02:00
new MenuItem ( "" , "Research Outcomes" , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { qf :true } ) ,
2019-07-24 14:47:47 +02:00
new MenuItem ( "" , "Projects" , "" , "/search/find/projects/" , false , [ "project" ] , [ "/search/find/projects" ] , { } ) ,
new MenuItem ( "" , "Content Providers" , "" , "/search/find/dataproviders" , false , [ "datasource" ] , [ "/search/find/dataproviders" ] , { } ) ,
new MenuItem ( "" , "Organizations" , "" , "/search/find/organizations/" , false , [ "organization" ] , [ "/search/find/organizations" ] , { } )
]
} ,
{
2019-10-31 12:18:19 +01:00
rootItem : new MenuItem ( "deposit" , "Deposit" , "" , "/participate/deposit/learn-how" , false , [ ] , [ "/participate/deposit/learn-how" ] , { } ) ,
2019-10-17 15:49:05 +02:00
//rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}),
items : [ ]
//rootItem: new MenuItem("share", "Share", "", "", false, [], ["/participate/deposit-publications", "/participate/deposit-datasets"], {}),
//items: [new MenuItem("", "Publications", "", "/participate/deposit-publications", false, ["publication"], ["/participate/deposit-publications"], {}),
// new MenuItem("", "Research Data", "", "/participate/deposit-datasets", false, ["dataset"], ["/participate/deposit-datasets"], {})]
2019-07-24 14:47:47 +02:00
} ,
{
rootItem : new MenuItem ( "link" , "Link" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , { } ) ,
items : [ new MenuItem ( "" , "Start linking" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , { } ) ,
new MenuItem ( "" , "Learn more" , this . properties . claimsInformationLink , "" , false , [ ] , [ ] , { } ) ]
} ,
{
rootItem : new MenuItem ( "datasources" , "Content Providers" , "" , "" , false , [ "datasource" ] , [ ] , { } ) ,
items : [ new MenuItem ( "" , "Data Policies" , "https://beta.openaire.eu/oa-policies-mandates" , "" , false , [ "datasource" ] , [ "" ] , { } ) ,
new MenuItem ( "" , "Repositories" , "" , "/search/content-providers" , false , [ "datasource" ] , [ "/search/content-providers" ] , { } ) ,
new MenuItem ( "" , "Journals" , "" , "/search/journals" , false , [ "datasource" ] , [ "/search/journals" ] , { } ) ,
new MenuItem ( "" , "Registries" , "" , "/search/entity-registries" , false , [ "datasource" ] , [ "/search/entity-registries" ] , { } ) ,
new MenuItem ( "" , "Browse all" , "" , "/search/find/dataproviders" , false , [ "datasource" ] , [ "/search/find/dataproviders" ] , { } ) ]
}
] ;
2019-09-13 09:46:57 +02:00
if ( Session . isPortalAdministrator ( this . user ) ) {
2019-07-24 14:47:47 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "Manage all links" , "" , "/claims" , false , [ ] , [ "/claims" ] , { } ) ) ;
this . userMenuItems . push ( new MenuItem ( "" , "Manage helptexts" ,
( ( this . properties . environment == "beta" ) ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu" ) + "/dashboard?communityId=openaire" , "" , true , [ ] , [ ] , { } ) )
2019-09-13 09:46:57 +02:00
} else if ( Session . isClaimsCurator ( this . user ) ) {
2019-07-24 14:47:47 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "Manage all links" , "" , "/claims" , false , [ ] , [ "/claims" ] , { } ) ) ;
}
2019-12-03 10:57:22 +01:00
if ( this . user ) {
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "" , "/user-info" , false , [ ] , [ ] , { } ) ) ;
}
2019-07-24 14:47:47 +02:00
}
2018-01-23 11:07:39 +01:00
}
2019-07-24 14:47:47 +02:00