2022-05-05 10:33:01 +02:00
import {
AfterViewInit ,
2022-05-05 14:29:29 +02:00
ChangeDetectorRef ,
2022-05-05 10:33:01 +02:00
Component ,
ElementRef ,
OnDestroy ,
OnInit ,
QueryList ,
ViewChild ,
ViewChildren
} from '@angular/core' ;
2022-06-01 16:41:28 +02:00
import { of , Subscriber , zip } from 'rxjs' ;
2018-01-23 11:07:39 +01:00
import { ActivatedRoute , Router } from '@angular/router' ;
import { Location } from '@angular/common' ;
2021-04-18 13:36:41 +02:00
import { Meta , Title } from '@angular/platform-browser' ;
2018-02-16 16:51:10 +01:00
import { ConfigurationService } from '../openaireLibrary/utils/configuration/configuration.service' ;
2021-04-01 16:40:10 +02:00
import { SearchDataprovidersService } from '../openaireLibrary/services/searchDataproviders.service' ;
import { SearchProjectsService } from '../openaireLibrary/services/searchProjects.service' ;
import { SearchOrganizationsService } from '../openaireLibrary/services/searchOrganizations.service' ;
import { RefineFieldResultsService } from '../openaireLibrary/services/refineFieldResults.service' ;
2022-05-05 14:29:29 +02:00
import { OpenaireEntities , SearchFields } from '../openaireLibrary/utils/properties/searchFields' ;
2018-01-23 11:07:39 +01:00
2021-04-01 16:40:10 +02:00
import { RouterHelper } from '../openaireLibrary/utils/routerHelper.class' ;
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties' ;
import { ErrorCodes } from '../openaireLibrary/utils/properties/errorCodes' ;
2018-02-16 16:51:10 +01:00
import { PiwikService } from '../openaireLibrary/utils/piwik/piwik.service' ;
2021-04-01 16:40:10 +02:00
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service' ;
2019-09-11 13:47:16 +02:00
import { SearchResearchResultsService } from "../openaireLibrary/services/searchResearchResults.service" ;
2019-11-02 02:37:11 +01:00
import { HelperService } from "../openaireLibrary/utils/helper/helper.service" ;
2020-02-13 15:45:55 +01:00
import { Filter } from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class" ;
2021-04-01 16:40:10 +02:00
import { properties } from "../../environments/environment" ;
2021-04-16 20:18:37 +02:00
import { Numbers , NumbersComponent } from "../openaireLibrary/sharedComponents/numbers/numbers.component" ;
2021-11-24 14:56:38 +01:00
import { StringUtils } from "../openaireLibrary/utils/string-utils.class" ;
2022-06-01 16:41:28 +02:00
import { NumberUtils } from '../openaireLibrary/utils/number-utils.class' ;
2018-01-23 11:07:39 +01:00
@Component ( {
2021-04-01 16:40:10 +02:00
selector : 'home' ,
templateUrl : 'home.component.html' ,
2022-07-18 17:59:32 +02:00
styleUrls : [ 'home.component.less' ]
2018-01-23 11:07:39 +01:00
} )
2022-06-01 16:41:28 +02:00
export class HomeComponent implements OnInit , OnDestroy , AfterViewInit {
2019-10-08 13:02:51 +02:00
// MAX 12 logos in every slide
public logos = {
"publication" : [
[
2019-10-10 18:19:47 +02:00
"logo-pubmed.png" ,
"logo-arxiv.png" ,
"logo-base.png" ,
"logo-scielo.png" ,
"logo-la-referencia.png" ,
"logo-soar.png" ,
"logo-repec.png" ,
"logo-core.png" ,
"logo-zenodo.png" ,
"logo-narcis.png"
2019-10-08 13:02:51 +02:00
] ,
[
2019-10-10 18:19:47 +02:00
"logo-unpaywall.png" ,
"logo-elsevier.png" ,
"logo-spring-nature.png" ,
"logo-frontiers.png" ,
"logo-opencitations.png" ,
"logo-doaj.png" ,
"logo-microsoft.png" ,
"logo-plos.png" ,
"logo-f1000.png" ,
"logo-copernicus.png"
2019-10-08 13:02:51 +02:00
]
] ,
"software" : [
[
2019-10-10 18:19:47 +02:00
"logo-software-heritage.png" ,
"logo-github.png" ,
"logo-doecode.png" ,
"logo-bitbucket.png" ,
2019-10-14 13:31:24 +02:00
"logo-elixir-bio-tools.png" ,
2019-10-10 18:19:47 +02:00
"logo-google-code.png" ,
"logo-sourceforge.png" ,
"logo-zenodo.png"
2019-10-08 13:02:51 +02:00
]
] ,
"dataset" : [
[
2019-10-10 18:19:47 +02:00
"logo-scholexplorer.png" ,
"logo-zenodo.png" ,
"logo-pangea.png" ,
"logo-figshare.png" ,
"logo-protocols.png" ,
"logo-opentrials.png" ,
"logo-kaggle.png" ,
"logo-reactome.png" ,
"logo-easy.png" ,
"logo-dryad.png"
2019-10-08 13:02:51 +02:00
]
] ,
//"other": [],
"persistent" : [
[
2019-10-10 18:19:47 +02:00
"logo-re3data.png" ,
"logo-orcid.png" ,
"logo-opendoar.png" ,
2022-05-30 15:53:13 +02:00
"logo-grid.png" ,
2022-06-01 16:41:28 +02:00
"logo-fairsharing.png" ,
"logo-ror.png" ,
"logo-datacite.png" ,
"logo-crossref.png"
2019-10-08 13:02:51 +02:00
]
] ,
"funder" : [
[
2019-10-10 18:19:47 +02:00
"logo-european-commision.png" ,
"logo-nsf.png" ,
"logo-nhmrc.png" ,
"logo-sfi.png" ,
"logo-nwo.png" ,
"logo-welcome-trust.png" ,
"logo-fct.png" ,
"logo-gsrt.png" ,
"logo-fnsnf.png"
2019-10-08 13:02:51 +02:00
]
]
} ;
2021-04-01 16:40:10 +02:00
2019-10-08 13:02:51 +02:00
public pageTitle = "OpenAIRE" ;
2021-04-01 16:40:10 +02:00
public keyword : string = "" ;
public searchFields : SearchFields = new SearchFields ( ) ;
public errorCodes : ErrorCodes = new ErrorCodes ( ) ;
public routerHelper : RouterHelper = new RouterHelper ( ) ;
2022-05-05 14:29:29 +02:00
public numbers : Numbers = { } ;
2021-04-01 16:40:10 +02:00
showPublications : boolean = false ;
showDatasets : boolean = false ;
2019-06-13 16:54:39 +02:00
showSoftware : boolean = false ;
showOrp : boolean = false ;
2021-04-01 16:40:10 +02:00
showProjects : boolean = false ;
showDataProviders : boolean = false ;
showOrganizations : boolean = false ;
properties : EnvProperties = properties ;
2022-06-01 16:41:28 +02:00
public openaireEntities = OpenaireEntities ;
2019-10-07 15:00:45 +02:00
public readMore : boolean = false ;
2021-04-01 16:40:10 +02:00
2022-05-05 10:33:01 +02:00
subscriptions : any [ ] = [ ] ;
@ViewChildren ( 'scrolling_element' ) elements : QueryList < ElementRef > ;
2021-04-01 16:40:10 +02:00
2020-02-13 15:45:55 +01:00
resultsQuickFilter : { filter : Filter , selected : boolean , filterId : string , value : string } = {
filter : null ,
selected : true ,
filterId : "resultbestaccessright" ,
value : "Open Access"
} ;
selectedEntity = "all" ;
selectedEntitySimpleUrl ;
selectedEntityAdvancedUrl ;
2021-04-01 16:40:10 +02:00
resultTypes : Filter = {
values : [ ] ,
filterId : "type" ,
countSelectedValues : 0 ,
filterType : 'checkbox' ,
originalFilterId : "" ,
valueIsExact : true ,
2022-03-17 14:13:07 +01:00
title : "Type" ,
2021-04-01 16:40:10 +02:00
filterOperator : "or"
} ;
2019-11-02 02:37:11 +01:00
public pageContents = null ;
2022-06-01 16:41:28 +02:00
@ViewChild ( "numbersComponent" , { static : true } ) numbersComponent : NumbersComponent ;
2021-11-24 14:56:38 +01:00
specialSubjects = [
{ value : "Physics::Atomic Physics" , label : "Atomic Physics" } ,
{ value : "Mathematics::Combinatorics" , label : "Mathematics Combinatorics" } ,
{ value : "lcsh:Medicine" , label : "Medicine" } ,
{ value : "lcsh:Science" , label : "Science" } ,
{ value : "lcsh:Biology (General)" , label : "Biology" } ,
{ value : "lcsh:Chemistry" , label : "Chemistry" } ,
{ value : "lcsh:Engineering (General). Civil engineering (General)" , label : "Civil engineering" } ,
{ value : "lcsh:Technology" , label : "Technology" } ,
2022-06-01 16:41:28 +02:00
/ * " M a t h e m a t i c s : : C o m b i n a t o r i c s " ,
"lcsh:Medicine" ,
"lcsh:Science" ,
"lcsh:Biology (General)" ,
"lcsh:Chemistry" ,
"lcsh:Engineering (General). Civil engineering (General)" ,
"lcsh:Technology" * /
2021-11-24 14:56:38 +01:00
] ;
stringUtils = new StringUtils ( ) ;
2022-04-19 01:10:50 +02:00
disableSelect : boolean = true ;
2022-05-05 10:33:01 +02:00
2021-04-01 16:40:10 +02:00
constructor (
2018-01-23 11:07:39 +01:00
private route : ActivatedRoute ,
2021-04-01 16:40:10 +02:00
private _router : Router ,
2022-05-05 14:29:29 +02:00
private searchResearchResultsService : SearchResearchResultsService ,
private searchDataprovidersService : SearchDataprovidersService ,
private searchProjectsService : SearchProjectsService ,
private searchOrganizationsService : SearchOrganizationsService ,
private refineFieldResultsService : RefineFieldResultsService ,
2021-04-01 16:40:10 +02:00
private location : Location , private _piwikService : PiwikService ,
private config : ConfigurationService , private _meta : Meta , private _title : Title , private seoService : SEOService ,
2022-05-05 14:29:29 +02:00
private helper : HelperService ,
2022-06-01 16:41:28 +02:00
private cdr : ChangeDetectorRef
2021-04-01 16:40:10 +02:00
) {
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide." ;
let title = "OpenAIRE | Find and Share research" ;
this . _title . setTitle ( title ) ;
this . _meta . updateTag ( { content : description } , "name='description'" ) ;
this . _meta . updateTag ( { content : description } , "property='og:description'" ) ;
this . _meta . updateTag ( { content : title } , "property='og:title'" ) ;
2018-01-23 11:07:39 +01:00
}
2021-04-01 16:40:10 +02:00
2019-11-02 02:37:11 +01:00
private getPageContents() {
2022-05-05 10:33:01 +02:00
this . subscriptions . push ( this . helper . getPageHelpContents ( this . properties , 'openaire' , this . _router . url ) . subscribe ( contents = > {
2019-11-02 02:37:11 +01:00
this . pageContents = contents ;
2020-07-13 00:22:43 +02:00
} ) ) ;
2019-11-02 02:37:11 +01:00
}
2021-04-01 16:40:10 +02:00
2019-10-08 13:02:51 +02:00
public getKeys ( obj : { } ) {
return Object . keys ( obj ) ;
}
2021-04-01 16:40:10 +02:00
createRange ( number ) {
2019-10-08 13:02:51 +02:00
var items : number [ ] = [ ] ;
2021-04-01 16:40:10 +02:00
for ( var i = 1 ; i <= number ; i ++ ) {
2019-10-08 13:02:51 +02:00
items . push ( i ) ;
}
return items ;
}
2021-04-01 16:40:10 +02:00
2019-10-08 13:02:51 +02:00
public ceil ( num : number ) {
return Math . ceil ( num ) ;
}
2021-04-01 16:40:10 +02:00
2022-05-05 10:33:01 +02:00
clear() {
this . subscriptions . forEach ( value = > {
if ( value instanceof Subscriber ) {
value . unsubscribe ( ) ;
} else if ( value instanceof IntersectionObserver || value instanceof MutationObserver ) {
value . disconnect ( ) ;
}
} ) ;
}
2018-01-23 11:07:39 +01:00
public ngOnInit() {
2021-04-01 16:40:10 +02:00
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . _router . url , false ) ;
this . getPageContents ( ) ;
if ( this . properties != null ) {
var url = this . properties . domain + this . properties . baseLink + this . _router . url ;
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
2022-05-05 10:33:01 +02:00
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , "OpenAIRE" ) . subscribe ( ) ) ;
2021-04-01 16:40:10 +02:00
}
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
2022-05-05 10:33:01 +02:00
this . subscriptions . push ( this . config . communityInformationState . subscribe ( data = > {
2021-04-01 16:40:10 +02:00
if ( data ) {
var showEntity = { } ;
for ( var i = 0 ; i < data [ 'entities' ] . length ; i ++ ) {
showEntity [ "" + data [ 'entities' ] [ i ] [ "pid" ] + "" ] = data [ 'entities' ] [ i ] [ "isEnabled" ] ;
}
2021-04-18 13:36:41 +02:00
this . showPublications = ! ! showEntity [ "publication" ] ;
this . showDatasets = ! ! showEntity [ "dataset" ] ;
this . showSoftware = ! ! showEntity [ "software" ] ;
this . showOrp = ! ! showEntity [ "orp" ] ;
this . showProjects = ! ! showEntity [ "project" ] ;
this . showDataProviders = ! ! showEntity [ "datasource" ] ;
this . showOrganizations = ! ! showEntity [ "organization" ] ;
2021-04-01 16:40:10 +02:00
if ( this . showPublications ) {
2022-06-01 16:41:28 +02:00
this . resultTypes . values . push ( {
name : this.openaireEntities.PUBLICATIONS ,
id : "publications" ,
selected : false ,
number : 0
} ) ;
2021-04-01 16:40:10 +02:00
}
if ( this . showDatasets ) {
2022-06-01 16:41:28 +02:00
this . resultTypes . values . push ( {
name : this.openaireEntities.DATASETS ,
id : "datasets" ,
selected : false ,
number : 0
} ) ;
2021-04-01 16:40:10 +02:00
}
if ( this . showSoftware ) {
2022-06-01 16:41:28 +02:00
this . resultTypes . values . push ( {
name : this.openaireEntities.SOFTWARE ,
id : "software" ,
selected : false ,
number : 0
} ) ;
2021-04-01 16:40:10 +02:00
}
if ( this . showOrp ) {
2022-05-23 11:53:06 +02:00
this . resultTypes . values . push ( { name : this.openaireEntities.OTHER , id : "other" , selected : false , number : 0 } ) ;
2021-04-01 16:40:10 +02:00
}
2022-05-13 13:52:10 +02:00
this . init ( this . showDatasets , this . showSoftware , this . showPublications , this . showDatasets , this . showSoftware , this . showOrp , this . showProjects , this . showDataProviders , this . showOrganizations ) ;
2020-07-13 00:22:43 +02:00
}
2021-04-01 16:40:10 +02:00
} ,
error = > {
this . handleError ( "Error getting community information" , error ) ;
}
) ) ;
}
2018-01-23 11:07:39 +01:00
}
2022-06-01 16:41:28 +02:00
2021-04-01 16:40:10 +02:00
2018-01-23 11:07:39 +01:00
public ngOnDestroy() {
2022-05-05 10:33:01 +02:00
this . clear ( ) ;
}
ngAfterViewInit() {
2022-06-01 16:41:28 +02:00
if ( typeof window !== "undefined" ) {
2022-05-06 09:53:02 +02:00
this . createObserver ( ) ;
}
2022-05-05 10:33:01 +02:00
}
createObserver() {
let mutationObserver = new MutationObserver ( entries = > {
entries . forEach ( entry = > {
if ( entry . attributeName === 'style' ) {
let opacities : number [ ] = this . elements . map ( element = > + element . nativeElement . style . opacity ) ;
let active : number = opacities . indexOf ( Math . max ( . . . opacities ) ) ;
this . elements . forEach ( ( element , index ) = > {
if ( index === active ) {
element . nativeElement . classList . remove ( 'uk-disabled' ) ;
} else {
element . nativeElement . classList . add ( 'uk-disabled' ) ;
}
} )
}
} )
} ) ;
this . elements . forEach ( element = > {
mutationObserver . observe ( element . nativeElement , { attributes : true } ) ;
} ) ;
this . subscriptions . push ( mutationObserver ) ;
2018-01-23 11:07:39 +01:00
}
2021-04-01 16:40:10 +02:00
private handleError ( message : string , error ) {
console . error ( "Home Page: " + message , error ) ;
}
entityChanged ( $event ) {
2020-02-13 15:45:55 +01:00
this . selectedEntity = $event . entity ;
this . selectedEntitySimpleUrl = $event . simpleUrl ;
this . selectedEntityAdvancedUrl = $event . advancedUrl ;
}
2021-04-01 16:40:10 +02:00
goTo ( simple : boolean ) {
let url = ( simple ) ? this . selectedEntitySimpleUrl : this.selectedEntityAdvancedUrl ;
2020-02-13 15:45:55 +01:00
let parameterNames = [ ] ;
let parameterValues = [ ] ;
if ( this . selectedEntity == "result" ) {
if ( this . resultTypes ) {
let values = [ ] ;
2021-04-01 16:40:10 +02:00
for ( let value of this . resultTypes . values ) {
2020-10-20 11:17:15 +02:00
if ( value . selected ) {
values . push ( value . id ) ;
}
2020-02-13 15:45:55 +01:00
}
2021-04-01 16:40:10 +02:00
if ( values . length > 0 && values . length != 4 ) {
2020-02-13 15:45:55 +01:00
parameterNames . push ( "type" ) ;
parameterValues . push ( values . join ( "," ) ) ;
}
2021-05-19 09:42:56 +02:00
if ( this . resultsQuickFilter && this . resultsQuickFilter . selected ) {
parameterNames . push ( this . resultsQuickFilter . filterId ) ;
2022-06-01 16:41:28 +02:00
parameterValues . push ( '"' + encodeURIComponent ( this . resultsQuickFilter . value ) + '"' ) ;
2020-02-13 15:45:55 +01:00
}
}
2021-04-01 16:40:10 +02:00
} else if ( this . selectedEntity == "all" ) {
2021-05-19 09:42:56 +02:00
if ( this . resultsQuickFilter && this . resultsQuickFilter . selected ) {
parameterNames . push ( this . resultsQuickFilter . filterId ) ;
2022-06-01 16:41:28 +02:00
parameterValues . push ( '"' + encodeURIComponent ( this . resultsQuickFilter . value ) + '"' ) ;
2020-12-15 15:38:29 +01:00
}
2020-02-13 15:45:55 +01:00
}
2021-04-01 16:40:10 +02:00
if ( this . keyword . length > 0 ) {
2020-11-02 18:13:23 +01:00
parameterNames . push ( "fv0" ) ;
2020-02-13 15:45:55 +01:00
parameterValues . push ( this . keyword ) ;
2020-11-02 18:13:23 +01:00
parameterNames . push ( "f0" ) ;
parameterValues . push ( "q" ) ;
2020-02-13 15:45:55 +01:00
}
this . _router . navigate ( [ url ] , { queryParams : this.routerHelper.createQueryParams ( parameterNames , parameterValues ) } ) ;
2021-04-01 16:40:10 +02:00
}
2022-06-01 16:41:28 +02:00
getSubjectParameter ( param ) {
return { 'f0' : 'resultsubject' , 'fv0' : '"' + ( param ) + '"' , size : 50 } ;
}
init ( getDatasetsLinked = false , getSoftwareLinked = false , getPublications = true , getDatasets = true ,
getSoftware = true , getOther = true , getProjects = true , getDataProviders = true , getOrganizations = true , refineValue : string = null ) {
this . subscriptions . push ( zip (
( getPublications ) ? this . searchResearchResultsService . numOfSearchResults ( 'publication' , '' , this . properties , null ) : of ( 0 ) ,
( getDatasets ) ? this . searchResearchResultsService . numOfSearchResults ( 'dataset' , '' , this . properties , null ) : of ( 0 ) ,
( getDatasetsLinked ) ? this . searchResearchResultsService . numOfSearchResultsLinkedToPub ( "dataset" , this . properties ) : of ( 0 ) ,
( getSoftware ) ? this . searchResearchResultsService . numOfSearchResults ( 'software' , '' , this . properties , null ) : of ( 0 ) ,
( getSoftwareLinked ) ? this . searchResearchResultsService . numOfSearchResultsLinkedToPub ( "software" , this . properties ) : of ( 0 ) ,
( getOther ) ? this . searchResearchResultsService . numOfSearchResults ( 'other' , '' , this . properties , null ) : of ( 0 ) ,
( getProjects ) ? this . refineFieldResultsService . getRefineFieldsResultsByEntityName ( [ 'funder' ] , 'project' , this . properties , null ) : of ( 0 ) ,
( getDataProviders ) ? this . searchDataprovidersService . numOfSearchDataproviders ( '' , this . properties , null ) : of ( 0 ) ,
( getOrganizations ) ? this . searchOrganizationsService . numOfSearchOrganizations2 ( '' , this . properties , null ) : of ( 0 )
) . subscribe ( ( data : any [ ] ) = > {
if ( data [ 0 ] && data [ 0 ] > 0 ) {
this . numbers . publicationsSize = NumberUtils . roundNumber ( data [ 0 ] ) ;
}
if ( data [ 1 ] && data [ 1 ] > 0 ) {
this . numbers . datasetsSize = NumberUtils . roundNumber ( data [ 1 ] ) ;
}
if ( data [ 2 ] && data [ 2 ] > 0 ) {
this . numbers . datasetsLinkedSize = NumberUtils . roundNumber ( data [ 2 ] ) ;
}
if ( data [ 3 ] && data [ 3 ] > 0 ) {
this . numbers . softwareSize = NumberUtils . roundNumber ( data [ 3 ] ) ;
}
if ( data [ 4 ] && data [ 4 ] > 0 ) {
this . numbers . softwareLinkedSize = NumberUtils . roundNumber ( data [ 4 ] ) ;
}
if ( data [ 5 ] && data [ 5 ] > 0 ) {
this . numbers . otherSize = NumberUtils . roundNumber ( data [ 5 ] ) ;
}
if ( data [ 6 ] [ 0 ] && data [ 6 ] [ 0 ] > 0 ) {
this . numbers . projectsSize = NumberUtils . roundNumber ( data [ 6 ] [ 0 ] ) ;
}
if ( data [ 6 ] [ 1 ] && data [ 6 ] [ 1 ] . length > 0 && data [ 6 ] [ 1 ] [ 0 ] . filterId == 'funder' && data [ 6 ] [ 1 ] [ 0 ] . values ) {
this . numbers . fundersSize = NumberUtils . roundNumber ( data [ 6 ] [ 1 ] [ 0 ] . values . length ) ;
}
if ( data [ 7 ] && data [ 7 ] > 0 ) {
this . numbers . datasourcesSize = NumberUtils . roundNumber ( data [ 7 ] ) ;
}
if ( data [ 8 ] && data [ 8 ] > 0 ) {
this . numbers . organizationsSize = NumberUtils . roundNumber ( data [ 8 ] ) ;
}
} , err = > {
this . handleError ( 'Error getting numbers' , err ) ;
} ) ) ;
}
disableSelectChange ( event : boolean ) {
this . disableSelect = event ;
this . cdr . detectChanges ( ) ;
}
public get showContentWithNumbers() {
if ( this . numbers && this . numbers . publicationsSize && this . numbers . datasetsSize && this . numbers . softwareSize && this . numbers . datasourcesSize && this . numbers . projectsSize && this . numbers . organizationsSize ) {
return true ;
}
2021-11-24 14:56:38 +01:00
}
2018-01-23 11:07:39 +01:00
}