@ -9,28 +9,21 @@ import {
ViewChild ,
ViewChildren
} from '@angular/core' ;
import { of , Subscriber , zip } from 'rxjs' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { Location } from '@angular/common' ;
import { Subscriber } from 'rxjs' ;
import { Router } from '@angular/router' ;
import { Meta , Title } from '@angular/platform-browser' ;
import { ConfigurationService } from '../openaireLibrary/utils/configuration/configuration.service' ;
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' ;
import { OpenaireEntities , SearchFields } from '../openaireLibrary/utils/properties/searchFields' ;
import { RouterHelper } from '../openaireLibrary/utils/routerHelper.class' ;
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties' ;
import { ErrorCodes } from '../openaireLibrary/utils/properties/errorCodes' ;
import { PiwikService } from '../openaireLibrary/utils/piwik/piwik.service' ;
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service' ;
import { SearchResearchResultsService } from "../openaireLibrary/services/searchResearchResults.service" ;
import { HelperService } from "../openaireLibrary/utils/helper/helper.service" ;
import { Filter } from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class" ;
import { properties } from "../../environments/environment" ;
import { Numbers , NumbersComponent } from "../openaireLibrary/sharedComponents/numbers/numbers.component" ;
import { StringUtils } from "../openaireLibrary/utils/string-utils.class" ;
import { NumberUtils } from '../openaireLibrary/utils/number-utils.class' ;
import { QuickContactService } from '../openaireLibrary/sharedComponents/quick-contact/quick-contact.service' ;
@Component ( {
@ -93,7 +86,6 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
"logo-dryad.png"
]
] ,
//"other": [],
"persistent" : [
[
"logo-re3data.png" ,
@ -120,29 +112,19 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
]
]
} ;
public pageTitle = "OpenAIRE" ;
public keyword : string = "" ;
public searchFields : SearchFields = new SearchFields ( ) ;
public errorCodes : ErrorCodes = new ErrorCodes ( ) ;
public routerHelper : RouterHelper = new RouterHelper ( ) ;
public numbers : Numbers = { } ;
showPublications : boolean = false ;
showDatasets : boolean = false ;
showSoftware : boolean = false ;
showOrp : boolean = false ;
showProjects : boolean = false ;
showDataProviders : boolean = false ;
showOrganizations : boolean = false ;
properties : EnvProperties = properties ;
public properties : EnvProperties = properties ;
public openaireEntities = OpenaireEntities ;
public readMore : boolean = false ;
public showQuickContact : boolean ;
@ViewChild ( 'contact' ) contact : ElementRef ;
subscriptions : any [ ] = [ ] ;
@ViewChildren ( 'scrolling_element' ) elements : QueryList < ElementRef > ;
resultsQuickFilter : { filter : Filter , selected : boolean , filterId : string , value : string } = {
filter : null ,
selected : true ,
@ -173,27 +155,13 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
{ value : "lcsh:Chemistry" , label : "Chemistry" } ,
{ value : "lcsh:Engineering (General). Civil engineering (General)" , label : "Civil engineering" } ,
{ value : "lcsh:Technology" , label : "Technology" } ,
/ * " 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" * /
] ;
stringUtils = new StringUtils ( ) ;
disableSelect : boolean = true ;
constructor (
private route : ActivatedRoute ,
private _router : Router ,
private searchResearchResultsService : SearchResearchResultsService ,
private searchDataprovidersService : SearchDataprovidersService ,
private searchProjectsService : SearchProjectsService ,
private searchOrganizationsService : SearchOrganizationsService ,
private refineFieldResultsService : RefineFieldResultsService ,
private location : Location , private _piwikService : PiwikService ,
private _piwikService : PiwikService ,
private config : ConfigurationService , private _meta : Meta , private _title : Title , private seoService : SEOService ,
private helper : HelperService ,
private cdr : ChangeDetectorRef ,
@ -248,21 +216,31 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , "OpenAIRE" ) . subscribe ( ) ) ;
}
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
if ( this . numbersComponent ) {
this . numbersComponent . showPublications = false ;
this . numbersComponent . showDatasets = false ;
this . numbersComponent . showSoftware = false ;
this . numbersComponent . showOrp = false ;
this . numbersComponent . showProjects = false ;
this . numbersComponent . showDataProviders = false ;
this . numbersComponent . showOrganizations = false ;
}
this . subscriptions . push ( this . config . communityInformationState . subscribe ( data = > {
if ( data ) {
if ( data ) {
var showEntity = { } ;
for ( var i = 0 ; i < data [ 'entities' ] . length ; i ++ ) {
showEntity [ "" + data [ 'entities' ] [ i ] [ "pid" ] + "" ] = data [ 'entities' ] [ i ] [ "isEnabled" ] ;
}
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" ] ;
if ( this . showPublications ) {
if ( this . numbersComponent ) {
this . numbersComponent . showPublications = ! ! showEntity [ "publication" ] ;
this . numbersComponent . showDatasets = ! ! showEntity [ "dataset" ] ;
this . numbersComponent . showSoftware = ! ! showEntity [ "software" ] ;
this . numbersComponent . showOrp = ! ! showEntity [ "orp" ] ;
this . numbersComponent . showProjects = ! ! showEntity [ "project" ] ;
this . numbersComponent . showDataProviders = ! ! showEntity [ "datasource" ] ;
this . numbersComponent . showOrganizations = ! ! showEntity [ "organization" ] ;
}
if ( this . numbersComponent && this . numbersComponent . showPublications ) {
this . resultTypes . values . push ( {
name : this.openaireEntities.PUBLICATIONS ,
id : "publications" ,
@ -270,7 +248,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
number : 0
} ) ;
}
if ( this . showDatasets ) {
if ( this . numbersComponent && this . numbersComponent . showDatasets ) {
this . resultTypes . values . push ( {
name : this.openaireEntities.DATASETS ,
id : "datasets" ,
@ -278,7 +256,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
number : 0
} ) ;
}
if ( this . showSoftware ) {
if ( this . numbersComponent && this . numbersComponent . showSoftware ) {
this . resultTypes . values . push ( {
name : this.openaireEntities.SOFTWARE ,
id : "software" ,
@ -286,10 +264,12 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
number : 0
} ) ;
}
if ( this . showOrp ) {
if ( this . numbersComponent && this . numbersComponent . showOrp ) {
this . resultTypes . values . push ( { name : this.openaireEntities.OTHER , id : "other" , selected : false , number : 0 } ) ;
}
this . init ( this . showDatasets , this . showSoftware , this . showPublications , this . showDatasets , this . showSoftware , this . showOrp , this . showProjects , this . showDataProviders , this . showOrganizations ) ;
if ( this . numbersComponent ) {
this . numbersComponent . init ( this . numbersComponent . showDatasets , this . numbersComponent . showSoftware , this . numbersComponent . showPublications , this . numbersComponent . showDatasets , this . numbersComponent . showSoftware , this . numbersComponent . showOrp , this . numbersComponent . showProjects , this . numbersComponent . showDataProviders , this . numbersComponent . showOrganizations ) ;
}
}
} ,
error = > {
@ -400,62 +380,8 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
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 ;
}
}
}