353 lines
12 KiB
TypeScript
353 lines
12 KiB
TypeScript
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
|
import {Observable} from 'rxjs';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {Location} from '@angular/common';
|
|
import "rxjs/add/observable/zip";
|
|
import {Title, Meta} from '@angular/platform-browser';
|
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
|
import { FetchDataproviders} from '../openaireLibrary/utils/fetchEntitiesClasses/fetchDataproviders.class';
|
|
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 { SearchFields} from '../openaireLibrary/utils/properties/searchFields';
|
|
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class';
|
|
|
|
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";
|
|
|
|
@Component({
|
|
selector: 'home',
|
|
templateUrl: 'home.component.html',
|
|
})
|
|
export class HomeComponent {
|
|
public piwiksub: any;
|
|
public subfunders: any;
|
|
|
|
// MAX 12 logos in every slide
|
|
public logos = {
|
|
"publication": [
|
|
[
|
|
"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"
|
|
],
|
|
[
|
|
"logo-crossref.png",
|
|
"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"
|
|
]
|
|
],
|
|
"software": [
|
|
[
|
|
"logo-software-heritage.png",
|
|
"logo-github.png",
|
|
"logo-doecode.png",
|
|
"logo-bitbucket.png",
|
|
"logo-elixir-bio-tools.png",
|
|
"logo-google-code.png",
|
|
"logo-sourceforge.png",
|
|
"logo-zenodo.png"
|
|
]
|
|
],
|
|
"dataset": [
|
|
[
|
|
"logo-scholexplorer.png",
|
|
"logo-zenodo.png",
|
|
"logo-datacite.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"
|
|
]
|
|
],
|
|
//"other": [],
|
|
"persistent": [
|
|
[
|
|
"logo-re3data.png",
|
|
"logo-orcid.png",
|
|
"logo-opendoar.png",
|
|
"logo-grid.png"
|
|
]
|
|
],
|
|
"funder": [
|
|
[
|
|
"logo-european-commision.png",
|
|
"logo-nsf.png",
|
|
"logo-miur.png",
|
|
"logo-nhmrc.png",
|
|
"logo-sfi.png",
|
|
"logo-nwo.png",
|
|
"logo-welcome-trust.png",
|
|
"logo-fct.png",
|
|
"logo-gsrt.png",
|
|
"logo-fnsnf.png"
|
|
]
|
|
]
|
|
};
|
|
|
|
public pageTitle = "OpenAIRE";
|
|
public keyword:string = "";
|
|
|
|
public searchFields:SearchFields = new SearchFields();
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
public publicationsSize:any = null;
|
|
public datasetsSize:any = null;
|
|
public softwareSize: any = null;
|
|
public otherSize: any = null;
|
|
public fundersSize:any = null;
|
|
public projectsSize:any = null;
|
|
public datasourcesSize:any = null;
|
|
|
|
private numResults: number = 2;
|
|
public fetchDataproviders : FetchDataproviders;
|
|
|
|
showPublications:boolean= false;
|
|
showDatasets:boolean= false;
|
|
showSoftware: boolean = false;
|
|
showOrp: boolean = false;
|
|
showProjects:boolean= false;
|
|
showDataProviders:boolean= false;
|
|
properties: EnvProperties;
|
|
public readMore: boolean = false;
|
|
public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|
public subSoft;
|
|
public subOrp;
|
|
trelloImg: string = 'trello.svg';
|
|
trelloImg2: string = 'trello.svg';
|
|
|
|
public pageContents = null;
|
|
|
|
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 config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
|
private helper: HelperService
|
|
) {
|
|
|
|
var description = "openAIRE explore, open access, publications, research results, European commission, search";
|
|
|
|
var title = "OpenAIRE | Explore";
|
|
|
|
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'");
|
|
|
|
|
|
//this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
|
}
|
|
|
|
private getPageContents() {
|
|
this.helper.getPageHelpContents(this._router.url, this.properties, 'openaire').subscribe(contents => {
|
|
this.pageContents = contents;
|
|
})
|
|
}
|
|
|
|
public getKeys(obj: {}) {
|
|
return Object.keys(obj);
|
|
}
|
|
|
|
createRange(number){
|
|
var items: number[] = [];
|
|
for(var i = 1; i <= number; i++){
|
|
items.push(i);
|
|
}
|
|
return items;
|
|
}
|
|
|
|
public ceil(num: number) {
|
|
return Math.ceil(num);
|
|
}
|
|
|
|
public ngOnInit() {
|
|
this.route.data
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
this.properties = data.envSpecific;
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
|
this.getPageContents();
|
|
|
|
if(this.properties!=null){
|
|
var url = this.properties.baseLink+this._router.url;
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
|
|
}
|
|
|
|
this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(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.getNumbers();
|
|
// if(this.showDataProviders) {
|
|
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
|
// }
|
|
},
|
|
error => {
|
|
this.handleError("Error getting community information", error);
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
}
|
|
public ngOnDestroy() {
|
|
if(this.piwiksub){
|
|
this.piwiksub.unsubscribe();
|
|
}
|
|
if(this.subfunders){
|
|
this.subfunders.unsubscribe();
|
|
}
|
|
if(this.subPub){
|
|
this.subPub.unsubscribe();
|
|
}
|
|
if(this.subData){
|
|
this.subData.unsubscribe();
|
|
}
|
|
// if(this.subProjects){
|
|
// this.subProjects.unsubscribe();
|
|
// }
|
|
// if(this.subOrg){
|
|
// this.subOrg.unsubscribe();
|
|
// }
|
|
if(this.subDataPr){
|
|
this.subDataPr.unsubscribe();
|
|
}
|
|
|
|
}
|
|
|
|
private getNumbers() {
|
|
if(this.showPublications){
|
|
this.subPub = this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
|
|
data => {
|
|
if(data && data != null && data > 0 ){
|
|
this.publicationsSize = NumberUtils.roundNumber(data);
|
|
|
|
}
|
|
},
|
|
err => {
|
|
//console.log(err);
|
|
this.handleError("Error getting number of publications", err);
|
|
}
|
|
);
|
|
}
|
|
if(this.showDatasets){
|
|
this.subData = this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
|
data => {
|
|
if(data && data != null && data > 0 ){
|
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
|
}
|
|
},
|
|
err => {
|
|
//console.log(err);
|
|
this.handleError("Error getting number of research data", err);
|
|
}
|
|
);
|
|
}
|
|
if (this.showSoftware) {
|
|
this.subSoft = this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
|
data => {
|
|
if (data && data > 0) {
|
|
this.softwareSize = NumberUtils.roundNumber(data);
|
|
}else{
|
|
this.showSoftware = false;
|
|
}
|
|
},
|
|
err => {
|
|
this.handleError("Error getting number of software data", err);
|
|
}
|
|
);
|
|
}
|
|
if (this.showOrp) {
|
|
this.subOrp = this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
|
data => {
|
|
if (data && data > 0) {
|
|
this.otherSize = NumberUtils.roundNumber(data);
|
|
}else{
|
|
this.showOrp = false;
|
|
}
|
|
},
|
|
err => {
|
|
this.handleError("Error getting number of software data", err);
|
|
}
|
|
);
|
|
}
|
|
if(this.showProjects){
|
|
this.subfunders = this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe(
|
|
data => {
|
|
|
|
|
|
if(data[0] && data[0] > 0 ){
|
|
this.projectsSize = NumberUtils.roundNumber(data[0]);
|
|
}
|
|
if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){
|
|
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
|
|
}
|
|
|
|
},
|
|
err => {
|
|
//console.log(err);
|
|
this.handleError("Error getting 'funder' field results of projects", err);
|
|
});
|
|
}
|
|
if(this.showDataProviders){
|
|
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
|
|
data => {
|
|
if(data && data != null && data > 0 ){
|
|
this.datasourcesSize = NumberUtils.roundNumber(data);
|
|
}
|
|
|
|
},
|
|
err => {
|
|
//console.log(err);
|
|
this.handleError("Error getting number of content providers", err);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
private handleError(message: string, error) {
|
|
console.error("Home Page: "+message, error);
|
|
}
|
|
}
|