2022-06-03 11:46:01 +02:00
import { Component , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
2022-05-31 22:18:58 +02:00
import { ActivatedRoute , NavigationEnd , 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-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-03-04 14:46:40 +01:00
import { StringUtils } from "./openaireLibrary/utils/string-utils.class" ;
2021-03-29 16:05:20 +02:00
import { LoginErrorCodes } from "./openaireLibrary/login/utils/guardHelper.class" ;
2021-04-08 12:58:48 +02:00
import { CustomizationOptions } from "./openaireLibrary/connect/community/CustomizationOptions" ;
import { LayoutService } from "./openaireLibrary/services/layout.service" ;
2021-04-20 17:20:05 +02:00
import { SmoothScroll } from "./openaireLibrary/utils/smooth-scroll" ;
2021-05-12 09:31:21 +02:00
import { Meta } from "@angular/platform-browser" ;
2021-05-17 12:10:27 +02:00
import { CommunityInfo } from "./openaireLibrary/connect/community/communityInfo" ;
2021-05-19 13:17:13 +02:00
import { SEOService } from "./openaireLibrary/sharedComponents/SEO/SEO.service" ;
2022-06-02 16:30:48 +02:00
import { FormBuilder , FormGroup , Validators } from "@angular/forms" ;
2022-05-31 22:18:58 +02:00
import { QuickContactService } from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.service" ;
import { EmailService } from "./openaireLibrary/utils/email/email.service" ;
2022-06-02 16:30:48 +02:00
import { AlertModal } from "./openaireLibrary/utils/modal/alert" ;
import { QuickContactComponent } from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.component" ;
import { Composer } from "./openaireLibrary/utils/email/composer" ;
import { NotificationHandler } from "./openaireLibrary/utils/notification-handler" ;
2021-04-01 16:25:15 +02:00
2018-01-26 16:00:07 +01:00
@Component ( {
selector : 'app-root' ,
template : `
2022-06-02 16:30:48 +02:00
< div >
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"
2022-06-03 11:46:01 +02:00
[ showMenu ] = showMenu [ properties ] = "properties" [ showHomeMenuItem ] = "false" communityId = "connect" >
< ul * ngIf = "showGetStarted" extra - s class = "uk-nav uk-nav-default uk-margin-small-top" >
< li routerLinkActive = "uk-active" >
< a routerLink = "/get-started" > Get Started < / a >
< / li >
< / ul >
< a * ngIf = "showGetStarted" extra - m class = "uk-button uk-button-small uk-button-primary uk-text-uppercase uk-margin-left" routerLink = "/get-started" > Get Started < / a >
< / navbar >
2021-05-17 12:10:27 +02:00
< navbar * ngIf = "properties && showMenu && community && header" [ portal ] = " community.communityId " [ onlyTop ] = false
[ communityId ] = "community.communityId" [ 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"
2022-06-03 11:46:01 +02:00
[ showHomeMenuItem ] = "false" >
< / navbar >
2021-04-16 18:20:27 +02:00
< customization * ngIf = "properties && showMenu && communityId && communityId.length > 0 && layout" [ properties ] = " properties "
[ communityId ] = "communityId" [ layout ] = "layout" > < / customization >
2021-02-19 18:52:12 +01:00
< schema2jsonld * ngIf = "properties && showMenu && !community" [ URL ] = " properties.domain + properties.baseLink "
2022-05-31 22:18:58 +02:00
[ logoURL ] = "properties.domain + properties.baseLink + logoPath + 'main.svg'"
2021-02-19 18:52:12 +01:00
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-05-17 12:10:27 +02:00
[ name ] = "(community.shortTitle) ? community.shortTitle : community.title" [ 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 >
2021-05-17 12:10:27 +02:00
< div id = "subscribeAndInviteBtn" * ngIf = "isClient && communityId && community" >
< subscribe [ communityId ] = " community.communityId " > < / subscribe >
2021-04-23 18:27:37 +02:00
< invite * ngIf = "isManager" [ longView ] = " false " > < / 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-12-15 13:24:40 +01:00
href = "https://www.openaire.eu/privacy-policy#cookies" 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"
2021-05-17 12:10:27 +02:00
[ communityId ] = "community.communityId" [ menuItems ] = bottomMenuItems [ properties ] = "properties"
2020-05-07 15:31:13 +02:00
[ darkBackground ] = "true" [ centered ] = "true" > < / bottom >
2022-05-31 22:18:58 +02:00
< quick - contact # quickContact * ngIf = "showQuickContact && contactForm" ( sendEmitter ) = " send ( $ event ) "
2022-06-02 16:30:48 +02:00
[ contact ] = "'Help'" [ images ] = "images" [ background ] = "'uk-background-secondary'"
2022-05-31 22:18:58 +02:00
[ contactForm ] = "contactForm" [ sending ] = "sending" > < / q u i c k - c o n t a c t >
2022-06-02 16:30:48 +02:00
< modal - alert # modal [ overflowBody ] = " false " > < / m o d a l - a l e r t >
2021-02-19 18:52:12 +01:00
< role - verification * ngIf = "community" service = "connect"
2021-05-17 12:10:27 +02:00
[ id ] = "community.communityId" [ name ] = "community.title" [ 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 >
`
2021-04-01 16:25:15 +02:00
2018-01-26 16:00:07 +01:00
} )
2022-06-02 16:30:48 +02:00
export class AppComponent implements OnInit , OnDestroy {
2019-08-28 14:54:35 +02:00
isClient : boolean = false ;
userMenuItems : MenuItem [ ] = [ ] ;
menuItems : RootMenuItem [ ] = [ ] ;
bottomMenuItems : MenuItem [ ] = [ ] ;
2021-05-17 12:10:27 +02:00
public community :CommunityInfo = null ;
2021-04-23 18:27:37 +02:00
properties : EnvProperties = properties ;
2019-08-28 14:54:35 +02:00
showMenu : boolean = false ;
2018-03-22 17:01:06 +01:00
communities = null ;
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 ;
2022-05-31 22:18:58 +02:00
logoPath : string = 'assets/common-assets/logo-services/connect/' ;
/* Contact */
public showQuickContact : boolean ;
public showGetStarted : boolean = true ;
public contactForm : FormGroup ;
2022-06-02 16:30:48 +02:00
public sending = false ;
public images : string [ ] = [ ] ;
@ViewChild ( 'modal' ) modal : AlertModal ;
@ViewChild ( 'quickContact' ) quickContact : QuickContactComponent ;
private subscriptions = [ ] ;
2021-04-08 12:58:48 +02:00
layout : CustomizationOptions = null ;
2019-08-28 14:54:35 +02:00
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
2021-04-20 17:20:05 +02:00
private _communitiesService : CommunitiesService , private smoothScroll : SmoothScroll ,
2020-07-15 17:53:19 +02:00
private router : Router , private userManagementService : UserManagementService ,
2022-05-31 22:18:58 +02:00
private configurationService : ConfigurationService , private _communityService : CommunityService ,
private _layoutService : LayoutService , private _meta : Meta , private seoService : SEOService ,
private quickContactService : QuickContactService ,
private fb : FormBuilder ,
private emailService : EmailService ) {
this . subscriptions . push ( router . events . forEach ( ( event ) = > {
if ( event instanceof NavigationEnd ) {
if ( event . url === '/contact-us' ) {
this . quickContactService . setDisplay ( false ) ;
} else if ( event . url !== '/contact-us' && ! this . showQuickContact ) {
this . quickContactService . setDisplay ( true ) ;
}
this . showGetStarted = event . url !== '/get-started' ;
2020-11-12 16:59:26 +01:00
}
2022-05-31 22:18:58 +02:00
} ) ) ;
2019-08-28 14:54:35 +02:00
}
2021-04-01 16:25:15 +02:00
2019-08-28 14:54:35 +02:00
ngOnInit() {
2021-05-12 09:31:21 +02:00
if ( this . properties . environment == "production" || this . properties . environment == "development" ) {
this . subscriptions . push ( this . route . queryParams . subscribe ( data = > {
this . _meta . updateTag ( { content : 'all' , name : 'robots' } ) ;
2021-05-19 13:17:13 +02:00
this . seoService . removeLinkForPrevURL ( ) ;
this . seoService . removeLinkForNextURL ( ) ;
2021-05-12 09:31:21 +02:00
} ) ) ;
}
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 ( ) ;
2021-05-17 12:10:27 +02:00
} , error = > {
this . init ( ) } ) ) ;
2022-06-02 16:30:48 +02:00
this . subscriptions . push ( this . quickContactService . isDisplayed . subscribe ( display = > {
this . showQuickContact = display ;
} ) ) ;
2019-11-08 12:04:10 +01:00
}
2021-02-19 18:52:12 +01:00
2022-05-31 22:18:58 +02:00
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
this . _communitiesService . clearSubscriptions ( ) ;
this . userManagementService . clearSubscriptions ( ) ;
this . configurationService . clearSubscriptions ( ) ;
this . _communityService . clearSubscriptions ( ) ;
this . smoothScroll . clearSubscriptions ( ) ;
}
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 ) )
}
2021-05-17 12:10:27 +02:00
get isPrivate() {
return this . community && ! ConnectHelper . isPrivate ( this . community , this . user )
}
2021-04-01 16:25:15 +02:00
2019-11-08 12:04:10 +01:00
private init() {
2021-03-29 16:05:20 +02:00
let communityId : string = ConnectHelper . getCommunityFromDomain ( this . properties . domain ) ;
this . showMenu = false ;
2022-06-02 16:30:48 +02:00
if ( typeof document !== "undefined" ) {
if ( communityId ) {
2022-06-03 11:46:01 +02:00
document . body . classList . add ( communityId + 'App' ) ;
document . body . classList . add ( 'communityApp' ) ;
2022-06-02 16:30:48 +02:00
} else {
document . body . classList . add ( 'connectApp' ) ;
}
}
2021-03-29 16:05:20 +02:00
this . initAdminToolCommunity ( communityId ) ;
this . buildMenu ( communityId ) ;
2021-05-17 12:10:27 +02:00
// this.communityId = communityId;
2022-02-17 16:40:00 +01:00
if ( ! communityId ) {
2022-06-02 16:30:48 +02:00
this . reset ( ) ;
2021-03-17 10:58:30 +01:00
this . userManagementService . fixRedirectURL = properties . afterLoginRedirectLink ;
} else {
this . userManagementService . fixRedirectURL = null ;
}
2019-08-28 14:54:35 +02:00
}
2021-04-01 16:25:15 +02:00
initAdminToolCommunity ( communityId ) {
if ( communityId ) {
2021-03-29 16:05:20 +02:00
this . properties . adminToolsPortalType = "community" ;
2021-04-16 18:20:27 +02:00
this . initLayout ( communityId ) ;
2022-02-15 15:05:25 +01:00
} else {
this . properties . adminToolsPortalType = "connect" ;
2021-03-29 16:05:20 +02:00
}
2021-04-01 16:25:15 +02:00
this . configurationService . initCommunityInformation ( this . properties , ( communityId ) ? communityId : this.properties.adminToolsPortalType ) ;
2021-03-29 16:05:20 +02:00
}
2021-04-08 12:58:48 +02:00
initLayout ( communityId ) {
2021-12-01 16:19:01 +01:00
if ( ! this . layout && ( typeof location == 'undefined' || ( typeof location !== 'undefined' && location . pathname . indexOf ( "/preview" ) == - 1 ) ) ) {
2021-04-08 12:58:48 +02:00
this . _layoutService . getLayout ( this . properties , communityId ) . subscribe (
layout = > {
if ( layout ) {
2021-04-16 18:20:27 +02:00
this . layout = CustomizationOptions . checkForObsoleteVersion ( layout . layoutOptions , this . communityId ) ;
2021-04-08 12:58:48 +02:00
} else {
this . layout = new CustomizationOptions ( CustomizationOptions . getIdentity ( communityId ) . mainColor , CustomizationOptions . getIdentity ( communityId ) . secondaryColor ) ;
}
} ,
error = > {
this . layout = new CustomizationOptions ( CustomizationOptions . getIdentity ( communityId ) . mainColor , CustomizationOptions . getIdentity ( communityId ) . secondaryColor ) ;
}
) ;
}
}
2019-08-28 14:54:35 +02:00
public buildMenu ( communityId : string ) {
2021-04-01 16:25:15 +02:00
if ( communityId ) {
2021-05-17 12:10:27 +02:00
if ( ! this . community || this . communityId !== communityId ) {
2021-02-19 19:09:52 +01:00
this . subscriptions . push ( this . _communityService . getCommunity ( communityId ) . subscribe ( community = > {
2021-05-17 12:10:27 +02:00
if ( community ) {
this . community = community ;
} else {
this . community = null ;
this . communityId = null ;
2019-08-28 14:54:35 +02:00
}
2021-05-17 12:10:27 +02:00
this . buildCommunityMenu ( ) ;
2021-02-19 18:52:12 +01:00
} ) ) ;
} else {
2021-05-17 12:10:27 +02:00
this . buildCommunityMenu ( ) ;
2021-02-19 18:52:12 +01:00
}
} else {
2021-04-01 16:25:15 +02:00
this . buildConnectMenu ( ) ;
2021-03-29 16:05:20 +02:00
}
}
2021-05-17 12:10:27 +02:00
buildCommunityMenu ( ) {
if ( this . community && ! ConnectHelper . isPrivate ( this . community , this . user ) ) {
this . communityId = this . community . communityId ;
this . header = {
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
route : "/" ,
title : ( this . community . shortTitle ) ? this . community.shortTitle : this.community.title ,
logoUrl : ( this . community . isUpload ) ? ( properties . utilsService + '/download/' + this . community . logoUrl ) : ( StringUtils . urlPrefix ( this . community . logoUrl ) + this . community . logoUrl ) ,
logoSmallUrl : ( this . community . isUpload ) ? ( properties . utilsService + '/download/' + this . community . logoUrl ) : ( StringUtils . urlPrefix ( this . community . logoUrl ) + this . community . logoUrl ) ,
position : 'left' ,
badge : true
} ;
this . menuItems = [ ] ;
this . menuItems . push ( {
rootItem : new MenuItem ( "deposit" , "Deposit" , "" , "/participate/deposit/learn-how" , false , [ ] , [ "/participate/deposit/learn-how" ] , { } ) ,
items : [ ]
} ) ;
this . menuItems . push (
{
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 , [ ] , [ ] , { } )
]
2021-03-29 16:05:20 +02:00
} ) ;
2021-05-17 12:10:27 +02:00
this . menuItems . push (
{
2021-05-19 13:17:13 +02:00
rootItem : new MenuItem ( "search" , "Search" , "" , "/search/find" , false , [ ] , [ "/search/find" ] , { } ) ,
2021-05-17 12:10:27 +02:00
items : [
2021-05-25 00:18:32 +02:00
new MenuItem ( "" , "Research outcomes" , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { resultbestaccessright : '"' + encodeURIComponent ( "Open Access" ) + '"' } ) ,
2021-05-17 12:10:27 +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" ] , { } ) ,
]
} ) ;
this . menuItems . push (
{
rootItem : new MenuItem ( "about" , "About" , "" , "" , false , [ ] , [ ] , { } ) ,
items : [
new MenuItem ( "" , "Supporting organizations" , "" , "/organizations" , false , [ ] , [ "/organizations" ] , { } ) ,
new MenuItem ( "" , "Curators" , "" , "/curators" , false , [ ] , [ "/curators" ] , { } ) ,
new MenuItem ( "" , "Sources and methodology" , "" , "/content" , false , [ ] , [ "/content" ] , { } ) ,
new MenuItem ( "" , "National Bulletins" , "" , "/national-bulletins" , false , [ ] , [ "/national-bulletins" ] , { } ) ,
new MenuItem ( "" , "Subjects" , "" , "/subjects" , false , [ ] , [ "/subjects" ] , { } ) ,
new MenuItem ( "" , "Projects and funding Opportunities" , "" , "/projects" , false , [ ] , [ "/projects" ] , { } ) ,
]
} ) ;
if ( this . isManager ) {
this . menuItems . push (
{
rootItem : new MenuItem ( "manage" , "Manage" , this . properties . adminPortalURL + '/' + this . community . communityId , "" , false , [ ] , [ ] , { } ) ,
items : [ ]
} ) ;
2021-02-19 18:52:12 +01:00
}
2021-05-17 12:10:27 +02:00
this . bottomMenuItems = [
new MenuItem ( "" , "Supporting organizations" , "" , "/organizations" , false , [ ] , [ "/organizations" ] , { } )
] ;
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 ORCID links" , "" , "/my-orcid-links" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "My links" , "" , "/myclaims" , false , [ ] , [ "/myclaims" ] , { } ) ,
new MenuItem ( "" , "Invite users" , "" , "/invite" , false , [ ] , [ ] , { } ) ,
] ;
if ( this . isManager ) {
2021-10-11 15:28:26 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "Support" , "https://tools.openaire.eu/group/openaire_rcd" , "" , false , [ ] , [ ] , { } ) )
2021-05-17 12:10:27 +02:00
}
}
this . showMenu = true ;
2021-04-01 16:25:15 +02:00
} else {
2021-05-17 12:10:27 +02:00
this . communityId = null ;
this . properties . adminToolsPortalType = "connect" ;
this . configurationService . initCommunityInformation ( this . properties , "connect" ) ;
this . initAdminToolCommunity ( null ) ;
this . buildConnectMenu ( true ) ;
if ( this . community && this . community . status == "manager" ) {
2021-05-19 13:17:13 +02:00
if ( ! this . user ) {
if ( typeof location !== 'undefined' && location . pathname . indexOf ( "user-info" ) == - 1 ) {
2021-05-18 09:29:16 +02:00
this . router . navigate ( [ '/user-info' ] , {
queryParams : {
"errorCode" : LoginErrorCodes . NOT_LOGIN ,
"redirectUrl" : location . pathname + location . search + location . hash
}
} ) ;
}
} else {
2021-05-19 13:17:13 +02:00
if ( typeof location !== 'undefined' && location . pathname . indexOf ( "user-info" ) == - 1 ) {
this . router . navigate ( [ '/' ] , { queryParamsHandling : "merge" } ) ;
}
2021-05-17 12:10:27 +02:00
}
} else if ( this . community && this . community . status == "hidden" ) {
2022-06-02 17:43:52 +02:00
this . router . navigate ( [ this . properties . errorLink ] ) ;
2021-05-17 12:10:27 +02:00
} else {
this . router . navigate ( [ '/' ] , this . community && this . community . status ? { queryParamsHandling : "merge" } : { } ) ;
}
2021-02-19 18:52:12 +01:00
}
}
2021-04-01 16:25:15 +02:00
buildConnectMenu ( restrictedData : boolean = false ) {
let url = "https://" + ( properties . environment != "production" ? "beta." : "" ) + "connect.openaire.eu" ;
2021-03-29 16:05:20 +02:00
this . header = {
route : restrictedData ? "" : "/" ,
2021-04-01 16:25:15 +02:00
url : restrictedData ? url : "" ,
2021-03-29 16:05:20 +02:00
title : 'connect' ,
2022-05-31 22:18:58 +02:00
logoUrl : this.logoPath + 'main.svg' ,
logoSmallUrl : this.logoPath + 'small.svg' ,
2021-04-01 16:25:15 +02:00
position : 'left' ,
badge : true
2021-03-29 16:05:20 +02:00
} ;
this . menuItems = [ ] ;
this . menuItems . push ( {
2021-04-01 16:25:15 +02:00
rootItem : new MenuItem ( "about" , "About" , restrictedData ? url + "/about/learn-how" : "" , restrictedData ? "" : "/about/learn-how" , false , [ ] , [ "/about/learn-how" ] , { } ) ,
2021-03-29 16:05:20 +02:00
items : [
new MenuItem ( "" , "Learn the process" , restrictedData ? url + "/about/learn-how" : "" , restrictedData ? "" : "/about/learn-how" , false , [ ] , [ "/about/learn-in-depth" ] , { } ) ,
2021-04-01 16:25:15 +02:00
new MenuItem ( "" , "Publications" , restrictedData ? url + "/publications" : "" , restrictedData ? "" : "/publications" , false , [ ] , [ "/publications" ] , { } ) ,
2021-03-29 16:05:20 +02:00
new MenuItem ( "" , "Roadmap" , "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "FAQs" , restrictedData ? url + "/about/faq" : "" , restrictedData ? "" : "/about/faq" , false , [ ] , [ "/about/faq" ] , { } )
]
2021-04-01 16:25:15 +02:00
2021-03-29 16:05:20 +02:00
} ) ;
this . menuItems . push ( {
2021-07-14 16:51:20 +02:00
rootItem : new MenuItem ( "communities" , "Communities" , restrictedData ? url + "/search/find/communities" : "" , restrictedData ? "" : "/search/find/communities" , false , [ ] , [ '/search/find/communities' ] , { } ) ,
2021-03-29 16:05:20 +02:00
items : [ ]
} ) ;
this . bottomMenuItems = [
new MenuItem ( "" , "About" , "https://openaire.eu/project-factsheets" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "News - Events" , "https://openaire.eu/news-events" , "" , false , [ ] , [ ] , { } ) ,
new MenuItem ( "" , "Blog" , "https://blogs.openaire.eu/" , "" , false , [ ] , [ ] , { } ) ,
2021-04-01 16:25:15 +02:00
new MenuItem ( "" , "Contact us" , restrictedData ? url + "/contact-us" : "" , restrictedData ? "" : "/contact-us" , false , [ ] , [ ] , { } )
2021-03-29 16:05:20 +02:00
] ;
this . userMenuItems = [ ] ;
if ( Session . isPortalAdministrator ( this . user ) ) {
this . userMenuItems . push ( new MenuItem ( "" , "Manage Helptexts" ,
2021-04-21 13:07:32 +02:00
properties . adminPortalURL + "/connect/admin-tools/pages" , "" , false , [ ] , [ ] , { } ) )
2021-03-29 16:05:20 +02:00
}
if ( this . user ) {
this . userMenuItems . push ( new MenuItem ( "my-communities" , "My Communities" , restrictedData ? url + "/myCommunities" : "" ,
restrictedData ? "" : "/myCommunities" , false , [ ] , [ ] , { } ) ) ;
}
this . showMenu = true ;
2019-08-28 14:54:35 +02:00
}
2022-06-02 16:30:48 +02:00
/ * *
* Contact methods
* * /
public send ( event ) {
if ( event . valid === true ) {
this . sendMail ( this . properties . admins ) ;
}
}
public reset() {
if ( this . quickContact ) {
this . quickContact . close ( ) ;
}
this . contactForm = this . fb . group ( {
name : this.fb.control ( '' , Validators . required ) ,
surname : this.fb.control ( '' , Validators . required ) ,
email : this.fb.control ( '' , [ Validators . required , Validators . email ] ) ,
affiliation : this.fb.control ( '' , Validators . required ) ,
community : this.fb.control ( '' , Validators . required ) ,
message : this.fb.control ( '' , Validators . required ) ,
2022-06-03 11:46:01 +02:00
recaptcha : this.fb.control ( '' , Validators . required )
2022-06-02 16:30:48 +02:00
} ) ;
}
private sendMail ( admins : string [ ] ) {
this . sending = true ;
this . subscriptions . push ( this . emailService . contact ( this . properties ,
Composer . composeEmailForNewCommunity ( this . contactForm . value , admins ) ,
this . contactForm . value . recaptcha ) . subscribe (
res = > {
if ( res ) {
this . sending = false ;
this . reset ( ) ;
this . modalOpen ( ) ;
} else {
this . handleError ( 'Email <b>sent failed!</b> Please try again.' ) ;
}
} ,
error = > {
this . handleError ( 'Email <b>sent failed!</b> Please try again.' , error ) ;
}
) ) ;
}
public modalOpen() {
this . modal . okButton = true ;
this . modal . alertTitle = 'Your request has been successfully submitted' ;
this . modal . message = 'Our team will respond to your submission soon.' ;
this . modal . alertMessage = true ;
this . modal . cancelButton = false ;
this . modal . okButtonLeft = false ;
this . modal . okButtonText = 'OK' ;
this . modal . open ( ) ;
}
handleError ( message : string , error = null ) {
if ( error ) {
console . error ( error ) ;
}
this . sending = false ;
this . quickContact . close ( ) ;
NotificationHandler . rise ( message , 'danger' ) ;
this . contactForm . get ( 'recaptcha' ) . setValue ( '' ) ;
}
2018-01-26 16:00:07 +01:00
}