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-04-12 13:05:28 +02:00
import { SubscribeService } from './openaireLibrary/utils/subscribe/subscribe.service' ;
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" ;
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 ' " >
2019-12-23 16:45:47 +01:00
< navbar * ngIf = "properties && showMenu && !community" [ portal ] = " properties.dashboard " [ onlyTop ] = false
2019-09-13 09:47:29 +02:00
[ userMenuItems ] = userMenuItems [ menuItems ] = menuItems [ user ] = "user"
2020-04-23 15:35:54 +02:00
[ showMenu ] = showMenu [ properties ] = "properties" [ showHomeMenuItem ] = "false" communityId = "connect" > < / navbar >
2019-12-23 16:45:47 +01:00
< navbar * ngIf = "properties && showMenu && community" [ portal ] = " properties.dashboard " [ onlyTop ] = false
2019-11-08 12:04:10 +01:00
[ communityId ] = "community.id"
2019-09-13 09:47:29 +02:00
[ userMenuItems ] = userMenuItems [ menuItems ] = menuItems [ user ] = "user"
2020-05-07 12:29:52 +02:00
[ community ] = community [ 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 >
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-04-28 13:07:36 +02:00
< subscribe [ communityId ] = " communityId " [ properties ] = " properties " > < / subscribe >
< invite * ngIf = "managerOfCommunities" [ longView ] = false [ buttonSizeSmall ] = false [ properties ] = " properties " > < / invite >
< / 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
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 >
< / 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 >
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 ;
managerOfCommunities = false ;
2019-09-13 09:47:29 +02:00
user : User ;
2020-04-24 18:38:35 +02:00
communityId : string = "" ;
2018-02-12 12:41:40 +01:00
2019-08-28 14:54:35 +02:00
// community: {id:string, name:string, logoUrl:string};
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
private _communitiesService : CommunitiesService , private _subscribeService : SubscribeService ,
2019-09-13 09:47:29 +02:00
private router : Router , private userManagementService : UserManagementService ) {
2019-08-28 14:54:35 +02:00
router . events . forEach ( ( event ) = > {
if ( event instanceof NavigationStart ) {
HelperFunctions . scroll ( ) ;
}
} ) ;
}
2019-04-16 16:26:09 +02:00
2019-08-28 14:54:35 +02:00
ngOnInit() {
this . propertiesService . loadEnvironment ( )
. then ( es = > {
this . properties = this . propertiesService . envSpecific ;
this . _communitiesService . updateCommunities ( this . properties , this . properties . communitiesAPI ) ;
2019-11-08 12:04:10 +01:00
if ( typeof document !== 'undefined' ) {
try {
this . isClient = true ;
} catch ( e ) {
2019-08-28 14:54:35 +02:00
}
2019-11-08 12:04:10 +01:00
}
2019-12-23 16:45:47 +01:00
this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
2019-11-08 13:08:15 +01:00
this . user = user ;
2019-11-08 12:04:10 +01:00
this . init ( ) ;
2019-11-08 13:08:15 +01:00
} ) ;
2019-11-08 12:04:10 +01:00
} , error = > {
console . log ( "App couldn't fetch properties" ) ;
console . log ( error ) ;
} ) ;
}
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 ;
this . route . queryParams . subscribe ( params = > {
2020-04-03 18:02:40 +02:00
communityId = ( params [ 'communityId' ] ) ? params [ 'communityId' ] : ConnectHelper . getCommunityFromDomain ( this . properties . domain ) ;
2019-11-08 12:04:10 +01:00
this . buildMenu ( communityId ) ;
} )
} else {
this . showMenu = false ;
communityId = ConnectHelper . getCommunityFromDomain ( this . properties . domain ) ;
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 ) {
let community = null ;
this . community = null ;
this . _communitiesService . getCommunitiesState ( ) . subscribe (
communities = > {
if ( ! communities || communities . length == 0 && communityId !== null && communityId !== '' ) {
return ;
}
for ( var com of communities ) {
if ( ( communityId && communityId != "" && com . communityId == communityId
&& community != null ) ||
(
! ( communityId && communityId != "" && com . communityId == communityId )
&&
this . managerOfCommunities && this . subscriberOfCommunities ) ) {
break ;
}
2019-09-13 09:47:29 +02:00
if ( this . user && com [ 'status' ] != "hidden" ) {
if ( Session . isCommunityCurator ( this . user ) || Session . isPortalAdministrator ( this . user ) ) {
2019-08-28 14:54:35 +02:00
this . managerOfCommunities = true ;
2019-09-13 09:47:29 +02:00
} else if ( com . managers . indexOf ( this . user . email ) != - 1 ) {
2019-08-28 14:54:35 +02:00
this . managerOfCommunities = true ;
}
}
2019-04-17 16:48:06 +02:00
2019-08-28 14:54:35 +02:00
if ( communityId && communityId != "" && com . communityId == communityId ) {
community = com ;
let isCommunityManager : boolean = false ;
2019-09-13 09:47:29 +02:00
if ( Session . isCommunityCurator ( this . user ) || Session . isPortalAdministrator ( this . user ) ) {
2019-08-28 14:54:35 +02:00
isCommunityManager = true ;
2019-09-16 11:33:23 +02:00
} else if ( this . user && com . managers . indexOf ( this . user . email ) != - 1 ) {
2019-08-28 14:54:35 +02:00
isCommunityManager = true ;
}
this . community = {
id : community.communityId ,
name : ( community . shortTitle ) ? community.shortTitle : community.title ,
logoUrl : community.logoUrl
} ;
this . menuItems = [ ] ;
2019-06-25 16:27:27 +02:00
2019-08-28 14:54:35 +02:00
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-04-10 12:04:09 +02:00
new MenuItem ( "" , "Sources and methology" , "" , "/content" , false , [ ] , [ "/content" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } ) ,
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
]
} ) ;
2019-08-28 14:54:35 +02:00
if ( isCommunityManager ) {
this . menuItems . push (
{
rootItem : new MenuItem ( "manage" , "Manage" , 'https://beta.admin.connect.openaire.eu/dashboard?communityId=' + community . communityId , "" , false , [ ] , [ ] , { } ) ,
items : [ ]
} ) ;
}
2019-06-20 15:34:07 +02:00
2019-08-28 14:54:35 +02:00
}
2019-04-17 16:48:06 +02:00
2019-08-28 14:54:35 +02:00
}
if ( community == null ) {
this . menuItems = [ ] ;
this . menuItems . push ( {
rootItem : new MenuItem ( "about" , "About" , "" , "/about/learn-how" , false , [ ] , null , { } ) ,
2020-04-10 12:04:09 +02:00
items : [
new MenuItem ( "" , "Learn the process" , "" , "/about/learn-how" , false , [ ] , [ ] , { } ) ,
2020-04-10 14:08:46 +02:00
new MenuItem ( "" , "Publications" , "" , "/publications" , false , [ ] , [ "/publications" ] , { } ) ,
2020-04-10 12:04:09 +02:00
new MenuItem ( "" , "Roadmap" , "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard" , "" , false , [ ] , [ ] , { } ) ,
2020-04-23 15:35:54 +02:00
new MenuItem ( "" , "FAQs" , "" , "/about/faq" , false , [ ] , [ "/about/faq" ] , { } )
2020-04-10 12:04:09 +02:00
]
2019-08-28 14:54:35 +02:00
} ) ;
this . menuItems . push ( {
rootItem : new MenuItem ( "communities" , "Communities" , "" , "/search/find/communities" , false , [ ] , null , { } ) ,
items : [ ]
} ) ;
this . menuItems . push ( {
2020-04-23 15:35:54 +02:00
rootItem : new MenuItem ( "contact-us" , "Contact us" , "" , "/contact-us" , false , [ ] , null , { } ) ,
2019-08-28 14:54:35 +02:00
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 , [ ] , [ ] , { } )
] ;
2019-11-08 12:04:10 +01:00
this . userMenuItems = [ ] ;
2019-09-13 09:47:29 +02:00
if ( Session . isPortalAdministrator ( this . user ) ) {
2019-08-28 14:54:35 +02:00
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 , [ ] , [ ] , { } ) )
}
2019-09-13 09:47:29 +02:00
if ( this . user ) {
2019-08-28 14:54:35 +02:00
this . userMenuItems . push ( new MenuItem ( "my-communities" , "My Communities" , "" ,
"/myCommunities" , false , [ ] , [ ] , { } ) ) ;
}
} else {
this . bottomMenuItems = [
2020-04-23 15:35:54 +02:00
new MenuItem ( "" , "Supporting organizations" , "" , "/organizations" , false , [ ] , [ "/organizations" ] , this . properties . environment != "development" ? { } : { communityId : community.communityId } )
2019-08-28 14:54:35 +02:00
] ;
if ( this . properties . showContent ) {
2020-04-23 15:35:54 +02:00
this . bottomMenuItems . push ( new MenuItem ( "" , "Sources and methology" , "" , "/content" , false , [ ] , [ ] , { } ) ) ;
2019-08-28 14:54:35 +02:00
}
2019-12-03 11:03:58 +01:00
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 . managerOfCommunities ) {
this . userMenuItems . push ( new MenuItem ( "" , "Support" , "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611" , "" , false , [ ] , [ ] , { } ) )
}
2019-08-28 14:54:35 +02:00
}
}
this . showMenu = true ;
} ) ;
}
2018-01-26 16:00:07 +01:00
}