2019-06-05 15:39:02 +02:00
import { Component } from '@angular/core' ;
2019-08-28 14:54:35 +02:00
import { ActivatedRoute , NavigationStart , Router } from '@angular/router' ;
2018-02-12 12:41:40 +01:00
2019-06-05 15:39:02 +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-03-16 09:55:38 +01:00
import { CommunitiesService } from "./openaireLibrary/connect/communities/communities.service" ;
2019-09-13 09:47:29 +02:00
import { Session , User } from './openaireLibrary/login/utils/helper.class' ;
2018-03-29 10:28:04 +02:00
import { ConnectHelper } from './openaireLibrary/connect/connectHelper' ;
2019-06-20 10:13:31 +02:00
import { HelperFunctions } from "./openaireLibrary/utils/HelperFunctions.class" ;
2019-09-13 09:47:29 +02:00
import { UserManagementService } from "./openaireLibrary/services/user-management.service" ;
2020-07-15 17:53:19 +02:00
import { ConfigurationService } from "./openaireLibrary/utils/configuration/configuration.service" ;
2020-09-24 13:43:34 +02:00
import { properties } from '../environments/environment' ;
2020-10-14 12:14:09 +02:00
import { Header } from "./openaireLibrary/sharedComponents/navigationBar.component" ;
2020-11-12 16:59:26 +01:00
import { Subscriber } from "rxjs" ;
2020-11-30 18:04:05 +01:00
import { CommunityService } from "./openaireLibrary/connect/community/community.service" ;
2021-02-19 18:52:12 +01:00
import { CommunityInfo } from "./openaireLibrary/connect/community/communityInfo" ;
2019-04-12 13:05:28 +02:00
2018-01-26 16:00:07 +01:00
@Component ( {
//changeDetection: ChangeDetectionStrategy.Default,
//encapsulation: ViewEncapsulation.Emulated,
selector : 'app-root' ,
styles : [ `
` ],
template : `
2020-04-23 15:35:54 +02:00
< div [ class ] = " ( community ) ? ( community.id + ' App communityApp ' ) : ' connectApp ' " >
2020-10-14 12:14:09 +02:00
< navbar * ngIf = "properties && showMenu && !community && header" [ portal ] = " properties.dashboard " [ onlyTop ] = false
[ userMenuItems ] = userMenuItems [ menuItems ] = menuItems [ user ] = "user" [ header ] = "header"
2020-04-23 15:35:54 +02:00
[ showMenu ] = showMenu [ properties ] = "properties" [ showHomeMenuItem ] = "false" communityId = "connect" > < / navbar >
2020-12-01 12:17:53 +01:00
< navbar * ngIf = "properties && showMenu && community && header" [ portal ] = " community.id " [ onlyTop ] = false
2020-10-14 12:14:09 +02:00
[ communityId ] = "community.id" [ header ] = "header"
2019-09-13 09:47:29 +02:00
[ userMenuItems ] = userMenuItems [ menuItems ] = menuItems [ user ] = "user"
2020-10-14 12:14:09 +02:00
[ showMenu ] = showMenu [ properties ] = "properties" [ enableSearch ] = "false"
2020-04-23 15:35:54 +02:00
searchRoute = "/search/find/research-outcomes"
[ showHomeMenuItem ] = "false" > < / navbar >
2020-05-07 15:31:13 +02:00
< customization * ngIf = "properties && communityId && communityId.length > 0" [ properties ] = " properties "
[ communityId ] = "communityId" > < / customization >
2021-02-19 18:52:12 +01:00
< schema2jsonld * ngIf = "properties && showMenu && !community" [ URL ] = " properties.domain + properties.baseLink "
[ logoURL ] = "properties.domain + properties.baseLink+'/assets/common-assets/logo-small-connect.png'"
type = "home"
2020-08-10 17:32:33 +02:00
[ searchActionRoute ] = "properties.searchLinkToCommunities" [ searchAction ] = "true"
name = "OpenAIRE Connect"
description = "Build a Gateway for your Community: Turn Open Science into Practice. It takes your open and linked research outcomes." >
< / schema2jsonld >
2021-02-19 18:52:12 +01:00
< schema2jsonld * ngIf = "properties && showMenu && communityId && communityId.length > 0 && community"
[ URL ] = "properties.domain + properties.baseLink"
2020-08-10 17:32:33 +02:00
[ logoURL ] = "community.logoUrl" type = "home" [ searchActionRoute ] = "properties.searchLinkToResults"
2021-02-19 18:52:12 +01:00
[ name ] = "community.name" [ description ] = "community.description" >
2020-08-10 17:32:33 +02:00
< / schema2jsonld >
2019-08-28 14:54:35 +02:00
< div class = "custom-main-content" >
< main >
< router - outlet > < / r o u t e r - o u t l e t >
< / main >
2019-07-15 14:21:18 +02:00
< / div >
2020-05-07 15:31:13 +02:00
< div id = "subscribeAndInviteBtn" * ngIf = "isClient && properties && community" >
2020-09-24 13:43:34 +02:00
< subscribe [ communityId ] = " community.id " [ properties ] = " properties " > < / subscribe >
2021-02-19 18:52:12 +01:00
< invite * ngIf = "isManager" [ longView ] = false [ buttonSizeSmall ] = false [ properties ] = " properties " > < / invite >
2020-04-28 13:07:36 +02:00
< / div >
2019-08-28 14:54:35 +02:00
<!-- feedback * ngIf = "isClient && properties" portalName = "Connect" [ feedbackQuestionaire ] = properties . feedbackQuestionaire > < / f e e d b a c k - - >
< 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
2021-02-19 18:52:12 +01:00
href = "//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target = "_blank" > Read more < span class = "uk-icon" >
2019-08-28 14:54:35 +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 >
< bottom * ngIf = "properties && isClient && showMenu && !community" [ grantAdvance ] = " false "
[ properties ] = "properties" > < / bottom >
2020-05-07 15:31:13 +02:00
< bottom * ngIf = "properties && isClient && showMenu && community" class = " communityPanelBackground "
2019-08-28 14:54:35 +02:00
[ showSocialButtons ] = "true" [ showMenuItems ] = "true" [ grantAdvance ] = "false" [ showOpenaire ] = "true"
2020-04-23 15:35:54 +02:00
[ communityId ] = "community.id" [ menuItems ] = bottomMenuItems [ properties ] = "properties"
2020-05-07 15:31:13 +02:00
[ darkBackground ] = "true" [ centered ] = "true" > < / bottom >
2021-02-19 18:52:12 +01:00
< role - verification * ngIf = "community" service = "connect"
[ id ] = "community.id" [ name ] = "community.name" [ type ] = "'community'" > < / r o l e - v e r i f i c a t i o n >
2019-08-28 14:54:35 +02:00
< / div >
`
2018-01-26 16:00:07 +01:00
} )
export class AppComponent {
2019-08-28 14:54:35 +02:00
isClient : boolean = false ;
2018-01-26 16:00:07 +01:00
2019-08-28 14:54:35 +02:00
userMenuItems : MenuItem [ ] = [ ] ;
2018-02-12 12:41:40 +01:00
2019-08-28 14:54:35 +02:00
menuItems : RootMenuItem [ ] = [ ] ;
bottomMenuItems : MenuItem [ ] = [ ] ;
2018-03-01 12:45:37 +01:00
public community = null ;
2019-08-28 14:54:35 +02:00
properties : EnvProperties ;
showMenu : boolean = false ;
2018-03-22 17:01:06 +01:00
communities = null ;
2019-04-16 16:26:09 +02:00
subscriberOfCommunities = false ;
2019-09-13 09:47:29 +02:00
user : User ;
2020-04-24 18:38:35 +02:00
communityId : string = "" ;
2020-10-14 12:14:09 +02:00
header : Header ;
logoPath : string = 'assets/common-assets/' ;
2020-11-12 16:59:26 +01:00
subscriptions = [ ] ;
2019-08-28 14:54:35 +02:00
// community: {id:string, name:string, logoUrl:string};
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
2021-02-19 18:52:12 +01:00
private _communitiesService : CommunitiesService ,
2020-07-15 17:53:19 +02:00
private router : Router , private userManagementService : UserManagementService ,
2020-11-30 18:04:05 +01:00
private configurationService : ConfigurationService , private _communityService : CommunityService ) {
2020-11-12 16:59:26 +01:00
this . subscriptions . push ( router . events . forEach ( ( event ) = > {
2019-08-28 14:54:35 +02:00
if ( event instanceof NavigationStart ) {
HelperFunctions . scroll ( ) ;
}
2020-11-12 16:59:26 +01:00
} ) ) ;
}
2021-02-19 18:52:12 +01:00
2020-11-12 16:59:26 +01:00
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
2019-08-28 14:54:35 +02:00
} ) ;
2020-11-12 16:59:26 +01:00
this . _communitiesService . clearSubscriptions ( ) ;
this . userManagementService . clearSubscriptions ( ) ;
this . configurationService . clearSubscriptions ( ) ;
2020-11-30 18:04:05 +01:00
this . _communityService . clearSubscriptions ( ) ;
2019-08-28 14:54:35 +02:00
}
2019-04-16 16:26:09 +02:00
2019-08-28 14:54:35 +02:00
ngOnInit() {
2020-09-24 13:43:34 +02:00
this . properties = properties ;
2020-11-12 16:59:26 +01:00
this . _communitiesService . updateCommunities ( this . properties , this . properties . communitiesAPI ) ;
if ( typeof document !== 'undefined' ) {
try {
this . isClient = true ;
} catch ( e ) {
}
}
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
this . user = user ;
this . init ( ) ;
} , error = > this . init ( ) ) ) ;
2019-11-08 12:04:10 +01:00
}
2021-02-19 18:52:12 +01:00
get isManager() {
return Session . isCommunityCurator ( this . user ) || Session . isPortalAdministrator ( this . user ) || ( this . communityId && Session . isManager ( 'community' , this . communityId , this . user ) )
}
2018-02-12 12:41:40 +01:00
2019-11-08 12:04:10 +01:00
private init() {
let communityId : string = "" ;
if ( this . properties . environment == "development" ) {
this . showMenu = false ;
2020-11-12 16:59:26 +01:00
this . subscriptions . push ( this . route . queryParams . subscribe ( params = > {
2020-04-03 18:02:40 +02:00
communityId = ( params [ 'communityId' ] ) ? params [ 'communityId' ] : ConnectHelper . getCommunityFromDomain ( this . properties . domain ) ;
2020-09-24 13:43:34 +02:00
if ( communityId ) {
this . properties . adminToolsPortalType = "community" ;
}
2020-12-02 13:19:48 +01:00
this . configurationService . initCommunityInformation ( this . properties , ( communityId ) ? communityId :this.properties.adminToolsPortalType ) ;
2019-11-08 12:04:10 +01:00
this . buildMenu ( communityId ) ;
2020-11-12 16:59:26 +01:00
} ) ) ;
2019-11-08 12:04:10 +01:00
} else {
this . showMenu = false ;
communityId = ConnectHelper . getCommunityFromDomain ( this . properties . domain ) ;
2020-09-24 13:43:34 +02:00
if ( communityId ) {
this . properties . adminToolsPortalType = "community" ;
}
2020-12-02 13:19:48 +01:00
this . configurationService . initCommunityInformation ( this . properties , ( communityId ) ? communityId :this.properties.adminToolsPortalType ) ;
2019-11-08 12:04:10 +01:00
this . buildMenu ( communityId ) ;
}
2020-04-24 18:38:35 +02:00
this . communityId = communityId ;
2019-08-28 14:54:35 +02:00
}
2019-04-17 16:48:06 +02:00
2019-08-28 14:54:35 +02:00
public buildMenu ( communityId : string ) {
2021-02-19 18:52:12 +01:00
if ( communityId ) {
if ( ! this . community || this . community . communityId !== communityId ) {
2021-02-19 19:09:52 +01:00
this . subscriptions . push ( this . _communityService . getCommunity ( communityId ) . subscribe ( community = > {
2021-02-19 18:52:12 +01:00
if ( community && community . status !== 'hidden' ) {
2019-08-28 14:54:35 +02:00
this . community = {
id : community.communityId ,
name : ( community . shortTitle ) ? community.shortTitle : community.title ,
2020-08-10 17:32:33 +02:00
logoUrl : community.logoUrl ,
description :community.description
2019-08-28 14:54:35 +02:00
} ;
2020-10-14 12:14:09 +02:00
this . header = {
2020-12-01 12:17:53 +01:00
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
route : "/" ,
2020-10-14 12:14:09 +02:00
title : this.community.name ,
logoUrl : this.community.logoUrl ,
logoSmallUrl : this.community.logoUrl ,
position : 'left' ,
badge : true
} ;
2019-08-28 14:54:35 +02:00
this . menuItems = [ ] ;
this . menuItems . push ( {
rootItem : new MenuItem ( "deposit" , "Deposit" , "" , "/participate/deposit/learn-how" , false , [ ] , [ "/participate/deposit/learn-how" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2019-11-08 12:04:10 +01:00
items : [ ]
2019-08-28 14:54:35 +02:00
} ) ;
this . menuItems . push (
{
rootItem : new MenuItem ( "link" , "Link" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
items : [
2020-05-07 12:29:52 +02:00
new MenuItem ( "" , "Start linking" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
new MenuItem ( "" , "Learn more" , this . properties . claimsInformationLink , "" , false , [ ] , [ ] , { } )
]
} ) ;
this . menuItems . push (
{
rootItem : new MenuItem ( "search" , "Search" , "" , "/search/find" , false , [ ] , [ "/search/find" , "/search/find/publications" , "/search/find/datasets" , "/search/find/software" , "/search/find/other" , "/search/find/projects" , "/search/find/dataproviders" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
items : [
new MenuItem ( "" , "Research outcomes" , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
new MenuItem ( "" , "Projects" , "" , "/search/find/projects/" , false , [ "project" ] , [ "/search/find/projects" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
new MenuItem ( "" , "Content Providers" , "" , "/search/find/dataproviders" , false , [ "datasource" ] , [ "/search/find/dataproviders" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2019-08-28 14:54:35 +02:00
]
} ) ;
2020-04-10 12:04:09 +02:00
this . menuItems . push (
{
rootItem : new MenuItem ( "about" , "About" , "" , "" , false , [ ] , [ ] , { } ) ,
items : [
new MenuItem ( "" , "Supporting organizations" , "" , "/organizations" , false , [ ] , [ "/organizations" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-05-05 17:37:25 +02:00
new MenuItem ( "" , "Curators" , "" , "/curators" , false , [ ] , [ "/curators" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-09-22 12:41:12 +02:00
new MenuItem ( "" , "Sources and methodology" , "" , "/content" , false , [ ] , [ "/content" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-04-10 12:04:09 +02:00
new MenuItem ( "" , "National Bulletins" , "" , "/national-bulletins" , false , [ ] , [ "/national-bulletins" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-04-28 13:07:36 +02:00
new MenuItem ( "" , "Subjects" , "" , "/subjects" , false , [ ] , [ "/subjects" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-05-05 17:37:25 +02:00
new MenuItem ( "" , "Projects and funding Opportunities" , "" , "/projects" , false , [ ] , [ "/projects" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
2020-04-10 12:04:09 +02:00
]
} ) ;
2021-02-19 18:52:12 +01:00
if ( this . isManager ) {
2019-08-28 14:54:35 +02:00
this . menuItems . push (
{
2020-12-07 11:23:13 +01:00
rootItem : new MenuItem ( "manage" , "Manage" , this . properties . adminPortalURL + '/dashboard?communityId=' + community . communityId , "" , false , [ ] , [ ] , { } ) ,
2019-08-28 14:54:35 +02:00
items : [ ]
} ) ;
}
2021-02-19 18:52:12 +01:00
this . bottomMenuItems = [
new MenuItem ( "" , "Supporting organizations" , "" , "/organizations" , false , [ ] , [ "/organizations" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } )
2019-12-03 11:03:58 +01:00
] ;
2021-02-19 18:52:12 +01:00
if ( this . properties . showContent ) {
this . bottomMenuItems . push ( new MenuItem ( "" , "Sources and methodology" , "" , "/content" , false , [ ] , [ ] , { } ) ) ;
}
if ( this . user ) {
this . userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
new MenuItem ( "" , "My links" , "" , "/myclaims" , false , [ ] , [ "/myclaims" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
new MenuItem ( "" , "Invite users" , "" , "/invite" , false , [ ] , [ ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
] ;
if ( this . isManager ) {
this . userMenuItems . push ( new MenuItem ( "" , "Support" , "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611" , "" , false , [ ] , [ ] , { } ) )
}
2019-12-03 11:03:58 +01:00
}
2021-02-19 18:52:12 +01:00
this . showMenu = true ;
} else {
this . navigateToError ( ) ;
2019-08-28 14:54:35 +02:00
}
2021-02-19 18:52:12 +01:00
} ) ) ;
} else {
2019-08-28 14:54:35 +02:00
this . showMenu = true ;
2021-02-19 18:52:12 +01:00
}
} else {
this . header = {
route : "/" ,
url : null ,
title : 'connect' ,
logoUrl : this.logoPath + 'logo-large-connect.png' ,
logoSmallUrl :this.logoPath + 'logo-small-connect.png' ,
position : 'left' ,
badge :true
} ;
this . menuItems = [ ] ;
this . menuItems . push ( {
rootItem : new MenuItem ( "about" , "About" , "" , "/about/learn-how" , false , [ ] , [ "/about/learn-how" ] , { } ) ,
items : [
new MenuItem ( "" , "Learn the process" , "" , "/about/learn-how" , false , [ ] , [ "/about/learn-in-depth" ] , { } ) ,
new MenuItem ( "" , "Publications" , "" , "/publications" , false , [ ] , [ "/publications" ] , { } ) ,
new MenuItem ( "" , "Roadmap" , "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "FAQs" , "" , "/about/faq" , false , [ ] , [ "/about/faq" ] , { } )
]
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "communities" , "Communities" , "" , "/search/find/communities" , false , [ ] , [ '/search/find/communities' ] , { } ) ,
items : [ ]
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "contact-us" , "Contact us" , "" , "/contact-us" , false , [ ] , [ '/contact-us' ] , { } ) ,
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 , [ ] , [ ] , { } )
] ;
this . userMenuItems = [ ] ;
if ( Session . isPortalAdministrator ( this . user ) ) {
this . userMenuItems . push ( new MenuItem ( "" , "Manage Helptexts" ,
( ( this . properties . environment == "production" ) ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu" ) + "/dashboard?communityId=connect" ,
"" , false , [ ] , [ ] , { } ) )
}
if ( this . user ) {
this . userMenuItems . push ( new MenuItem ( "my-communities" , "My Communities" , "" ,
"/myCommunities" , false , [ ] , [ ] , { } ) ) ;
}
this . showMenu = true ;
}
}
private navigateToError() {
this . router . navigate ( [ '/error' ] , { queryParams : { 'page' : this . properties . baseLink + this . router . url } } ) ;
2019-08-28 14:54:35 +02:00
}
2018-01-26 16:00:07 +01:00
}