2022-11-01 10:29:40 +01:00
import { ChangeDetectorRef , Component , ElementRef , ViewChild } from '@angular/core' ;
2022-05-13 14:46:23 +02:00
import { ActivatedRoute , Router } from '@angular/router' ;
2019-06-03 15:21:49 +02:00
import { EnvProperties } from './openaireLibrary/utils/properties/env-properties' ;
2022-09-20 17:00:20 +02:00
import { MenuItem } from './openaireLibrary/sharedComponents/menu' ;
2019-06-03 15:21:49 +02:00
import { EnvironmentSpecificService } from './openaireLibrary/utils/properties/environment-specific.service' ;
2019-09-13 09:46:57 +02:00
import { Session , User } from './openaireLibrary/login/utils/helper.class' ;
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" ;
2021-04-21 14:28:02 +02:00
import { SmoothScroll } from "./openaireLibrary/utils/smooth-scroll" ;
2021-05-19 09:42:56 +02:00
import { SEOService } from "./openaireLibrary/sharedComponents/SEO/SEO.service" ;
2022-04-20 09:33:52 +02:00
import { OpenaireEntities } from "./openaireLibrary/utils/properties/searchFields" ;
2022-10-12 14:31:34 +02:00
import { FormBuilder , FormGroup , Validators } from '@angular/forms' ;
import { QuickContactComponent } from './openaireLibrary/sharedComponents/quick-contact/quick-contact.component' ;
import { EmailService } from './openaireLibrary/utils/email/email.service' ;
import { Composer } from "./openaireLibrary/utils/email/composer" ;
import { AlertModal } from './openaireLibrary/utils/modal/alert' ;
import { NotificationHandler } from "./openaireLibrary/utils/notification-handler" ;
import { QuickContactService } from './openaireLibrary/sharedComponents/quick-contact/quick-contact.service' ;
import { LayoutService } from './openaireLibrary/dashboard/sharedComponents/sidebar/layout.service' ;
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 : `
2022-06-20 12:02:23 +02:00
< div id = "modal-container" > < / div >
2021-04-01 16:32:23 +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 >
2021-04-01 16:32:23 +02:00
< schema2jsonld * ngIf = "properties" [ URL ] = " properties.domain + properties.baseLink "
2022-05-13 14:46:23 +02:00
[ logoURL ] = "properties.domain+properties.baseLink+'/assets/common-assets/logo-services/explore/main.svg'"
2021-04-01 16:32:23 +02:00
type = "home"
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" >
2021-05-28 15:36:46 +02:00
< span class = "uk-visible@m" > OpenAIRE uses cookies in order to function properly . < br >
2019-06-03 15:21:49 +02:00
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
2021-05-28 15:36:46 +02:00
experience possible . < / span >
2019-06-03 15:21:49 +02:00
By using the OpenAIRE portal you accept our use of cookies . < a
2021-12-10 11:32:37 +01:00
href = "https://www.openaire.eu/privacy-policy#cookies" target = "_blank" > Read more < span class = "uk-icon" >
2019-06-03 15:21:49 +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 >
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 >
2022-11-01 10:29:40 +01:00
< bottom id = "bottom" # bottom * ngIf = "isClient && properties" [ properties ] = " properties " > < / bottom >
2022-10-12 14:31:34 +02:00
< quick - contact # quickContact * ngIf = "showQuickContact && contactForm" ( sendEmitter ) = " send ( $ event ) "
[ contactForm ] = "contactForm" [ sending ] = "sending" [ contact ] = "'Help'" > < / q u i c k - c o n t a c t >
< modal - alert # modal [ overflowBody ] = " false " > < / m o d a l - a l e r t >
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 ;
2021-02-24 20:49:55 +01:00
userMenuItems : MenuItem [ ] = [ ] ;
2022-09-20 17:00:20 +02:00
menuItems : MenuItem [ ] = [ ] ;
2019-07-24 14:47:47 +02:00
feedbackmail : string ;
2021-04-01 16:32:23 +02:00
properties : EnvProperties = properties ;
2019-09-13 09:46:57 +02:00
user : User ;
2020-10-14 13:19:00 +02:00
header : Header ;
2022-10-12 14:31:34 +02:00
public showQuickContact : boolean ;
public contactForm : FormGroup ;
public sending : boolean = false ;
@ViewChild ( 'quickContact' ) quickContact : QuickContactComponent ;
@ViewChild ( 'modal' ) modal : AlertModal ;
2022-11-01 10:29:40 +01:00
@ViewChild ( 'bottom' , { read : ElementRef } ) bottom : ElementRef ;
2022-10-12 14:31:34 +02:00
2020-11-11 15:44:21 +01:00
subscriptions = [ ] ;
2021-04-01 16:32:23 +02:00
2019-06-03 15:21:49 +02:00
constructor ( private route : ActivatedRoute , private propertiesService : EnvironmentSpecificService ,
2021-04-21 14:28:02 +02:00
private router : Router , private userManagementService : UserManagementService , private smoothScroll : SmoothScroll ,
2022-10-12 14:31:34 +02:00
private configurationService : ConfigurationService , private _meta : Meta , private seoService : SEOService ,
private emailService : EmailService , private fb : FormBuilder , private quickContactService : QuickContactService ,
private layoutService : LayoutService , private cdr : ChangeDetectorRef ) {
2019-06-03 15:21:49 +02:00
}
2021-04-01 16:32:23 +02:00
2019-06-03 15:21:49 +02:00
ngOnInit() {
if ( typeof document !== 'undefined' ) {
2021-04-01 16:32:23 +02:00
this . isClient = true ;
2019-06-03 15:21:49 +02:00
}
2022-10-12 14:31:34 +02:00
this . subscriptions . push ( this . layoutService . hasQuickContact . subscribe ( hasQuickContact = > {
this . showQuickContact = hasQuickContact ;
this . cdr . detectChanges ( ) ;
} ) ) ;
2021-04-01 16:32:23 +02:00
this . configurationService . initCommunityInformation ( this . properties , this . properties . adminToolsCommunity ) ;
this . feedbackmail = this . properties . feedbackmail ;
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 09:42:56 +02:00
this . seoService . removeLinkForPrevURL ( ) ;
this . seoService . removeLinkForNextURL ( ) ;
2020-11-11 15:44:21 +01:00
} ) ) ;
2021-04-01 16:32:23 +02:00
}
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
this . user = user ;
this . buildMenu ( ) ;
this . header = {
route : "/" ,
url : null ,
title : 'explore' ,
2022-05-13 14:46:23 +02:00
logoUrl : 'assets/common-assets/logo-services/explore/main.svg' ,
logoSmallUrl : 'assets/common-assets/logo-services/explore/small.svg' ,
2021-04-01 16:32:23 +02:00
position : 'left' ,
badge : true
} ;
2022-10-12 14:31:34 +02:00
this . reset ( ) ;
} ) ) ;
this . subscriptions . push ( this . quickContactService . isDisplayed . subscribe ( display = > {
this . showQuickContact = display ;
2021-04-01 16:32:23 +02:00
} ) ) ;
2020-11-11 15:44:21 +01:00
}
2021-04-01 16:32:23 +02:00
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 ( ) ;
2021-04-21 14:28:02 +02:00
this . smoothScroll . clearSubscriptions ( ) ;
2019-06-03 15:21:49 +02:00
}
2022-11-01 10:29:40 +01:00
ngAfterViewInit() {
if ( typeof window !== "undefined" ) {
this . createObservers ( ) ;
}
}
createObservers() {
2022-11-01 12:36:36 +01:00
let options = {
root : null ,
rootMargin : '0px' ,
threshold : 0.1
} ;
2022-11-01 10:29:40 +01:00
let intersectionObserver = new IntersectionObserver ( entries = > {
entries . forEach ( entry = > {
if ( entry . isIntersecting && this . showQuickContact ) {
this . showQuickContact = false ;
this . quickContactService . setDisplay ( this . showQuickContact ) ;
} else if ( ! entry . isIntersecting && ! this . showQuickContact ) {
this . showQuickContact = true ;
this . quickContactService . setDisplay ( this . showQuickContact ) ;
}
} ) ;
2022-11-01 12:36:36 +01:00
} , options ) ;
2022-11-01 10:29:40 +01:00
intersectionObserver . observe ( this . bottom . nativeElement ) ;
this . subscriptions . push ( intersectionObserver ) ;
}
2021-04-01 16:32:23 +02:00
2019-07-24 14:47:47 +02:00
buildMenu() {
2022-09-28 16:13:30 +02:00
this . userMenuItems = [ ] ;
this . userMenuItems . push ( new MenuItem ( "" , "My profile" , "" , "" , false , [ ] , [ ] , { } ) ) ;
this . userMenuItems . push ( new MenuItem ( "" , "My ORCID links" , "" , "/my-orcid-links" , false , [ ] , [ "" ] , { } ) ) ;
this . userMenuItems . push ( new MenuItem ( "" , "My links" , "" , "/myclaims" , false , [ ] , [ "/myclaims" ] , { } ) ) ;
2022-05-18 11:31:46 +02:00
let researchOutcomesMenu = new MenuItem ( "" , OpenaireEntities . RESULTS , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { resultbestaccessright : '"' + encodeURIComponent ( "Open Access" ) + '"' } ) ;
2021-08-09 14:31:19 +02:00
researchOutcomesMenu . items = [
2022-04-20 09:33:52 +02:00
new MenuItem ( "" , OpenaireEntities . PUBLICATIONS , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { type : '"' + encodeURIComponent ( "publications" ) + '"' } ) ,
new MenuItem ( "" , OpenaireEntities . DATASETS , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { type : '"' + encodeURIComponent ( "datasets" ) + '"' } ) ,
new MenuItem ( "" , OpenaireEntities . SOFTWARE , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { type : '"' + encodeURIComponent ( "software" ) + '"' } ) ,
new MenuItem ( "" , OpenaireEntities . OTHER , "" , "/search/find/research-outcomes" , false , [ ] , [ "/search/find/research-outcomes" ] , { type : '"' + encodeURIComponent ( "other" ) + '"' } ) ] ;
2021-04-01 16:32:23 +02:00
//TODO add check for research results route
2019-07-24 14:47:47 +02:00
this . menuItems = [
2022-09-20 17:00:20 +02:00
new MenuItem ( "search" , "Search" , "" , "/search/find" , false , [ ] , [ "/search/find" ] , { qf : true } ,
null , null , null , null , "_blank" , "internal" , false ,
[
2021-08-09 14:31:19 +02:00
researchOutcomesMenu ,
2022-04-20 09:33:52 +02:00
new MenuItem ( "" , OpenaireEntities . PROJECTS , "" , "/search/find/projects/" , false , [ "project" ] , [ "/search/find/projects" ] , { } ) ,
new MenuItem ( "" , OpenaireEntities . DATASOURCES , "" , "/search/find/dataproviders" , false , [ "datasource" ] , [ "/search/find/dataproviders" ] , { } ) ,
new MenuItem ( "" , OpenaireEntities . ORGANIZATIONS , "" , "/search/find/organizations/" , false , [ "organization" ] , [ "/search/find/organizations" ] , { } )
2019-07-24 14:47:47 +02:00
]
2022-09-20 17:00:20 +02:00
) ,
new MenuItem ( "deposit" , "Deposit" , "" , "/participate/deposit/learn-how" , false , [ ] , [ "/participate/deposit/learn-how" ] , { } ) ,
new MenuItem ( "link" , "Link" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , { } ,
null , null , null , null , "_blank" , "internal" , false ,
[ new MenuItem ( "" , "Start linking" , "" , "/participate/claim" , false , [ ] , [ "/participate/claim" ] , { } ) ,
2019-07-24 14:47:47 +02:00
new MenuItem ( "" , "Learn more" , this . properties . claimsInformationLink , "" , false , [ ] , [ ] , { } ) ]
2022-09-20 17:00:20 +02:00
) ,
new MenuItem ( "datasources" , OpenaireEntities . DATASOURCES , "" , "" , false , [ "datasource" ] , [ ] , { } ,
null , null , null , null , "_blank" , "internal" , false ,
[ new MenuItem ( "" , "Data Policies" , "https://beta.openaire.eu/oa-policies-mandates" , "" , false , [ "datasource" ] , [ "" ] , { } ) ,
2019-07-24 14:47:47 +02:00
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" ] , { } ) ]
2022-10-03 12:47:06 +02:00
) ,
2019-07-24 14:47:47 +02:00
] ;
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" ] , { } ) ) ;
2021-04-21 13:13:07 +02:00
this . userMenuItems . push ( new MenuItem ( "" , "Manage helptexts" , this . properties . adminPortalURL + "/openaire/admin-tools/pages" , "" , 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" ] , { } ) ) ;
2021-04-01 16:32:23 +02:00
2019-07-24 14:47:47 +02:00
}
2021-04-01 16:32:23 +02:00
if ( this . user ) {
2019-12-03 10:57:22 +01:00
this . userMenuItems . push ( new MenuItem ( "" , "User information" , "" , "/user-info" , false , [ ] , [ ] , { } ) ) ;
}
2022-10-12 14:31:34 +02:00
}
public send ( event ) {
if ( event . valid === true ) {
this . sendMail ( this . properties . admins ) ;
}
}
private sendMail ( admins : string [ ] ) {
this . sending = true ;
this . subscriptions . push ( this . emailService . contact ( this . properties ,
Composer . composeEmailForExplore ( 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 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 ( '' ) ,
message : this.fb.control ( '' , Validators . required ) ,
recaptcha : this.fb.control ( '' , Validators . required ) ,
} ) ;
}
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 . 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 ( '' ) ;
2019-07-24 14:47:47 +02:00
}
2018-01-23 11:07:39 +01:00
}
2019-07-24 14:47:47 +02:00