2018-01-23 11:07:39 +01:00
|
|
|
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
2019-06-03 15:21:49 +02:00
|
|
|
import {Observable} from 'rxjs';
|
2018-01-23 11:07:39 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import "rxjs/add/observable/zip";
|
2018-04-17 15:51:47 +02:00
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
2018-02-16 16:51:10 +01:00
|
|
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
2018-05-10 16:08:45 +02:00
|
|
|
import { FetchDataproviders} from '../openaireLibrary/utils/fetchEntitiesClasses/fetchDataproviders.class';
|
2018-02-16 16:51:10 +01: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';
|
|
|
|
import { SearchFields} from '../openaireLibrary/utils/properties/searchFields';
|
|
|
|
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class';
|
2018-01-23 11:07:39 +01:00
|
|
|
|
2018-02-16 16:51:10 +01:00
|
|
|
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';
|
2018-11-14 15:16:19 +01:00
|
|
|
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
2019-09-11 13:47:16 +02:00
|
|
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
2018-01-23 11:07:39 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'home',
|
|
|
|
templateUrl: 'home.component.html',
|
|
|
|
})
|
|
|
|
export class HomeComponent {
|
|
|
|
public piwiksub: any;
|
|
|
|
public subfunders: any;
|
|
|
|
|
2019-10-08 13:02:51 +02:00
|
|
|
// MAX 12 logos in every slide
|
|
|
|
public logos = {
|
|
|
|
"publication": [
|
|
|
|
[
|
|
|
|
"PubMed-Logo.png",
|
|
|
|
"ArXiv_web.png",
|
|
|
|
"BASE_search_engine_logo.png",
|
|
|
|
"logo-Scielo.png",
|
|
|
|
"lareferencia.png",
|
|
|
|
"ssoar_logo.png",
|
|
|
|
"repec.png",
|
|
|
|
"core.png",
|
|
|
|
"zenodo-black-1000.png",
|
|
|
|
"narcis.png"
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"crossref-logo.png",
|
|
|
|
"Unpaywall_logo.png",
|
|
|
|
"Elsevier_logo_2019.png",
|
|
|
|
"Springer_Nature.png",
|
|
|
|
"logo-home.png",
|
|
|
|
"opencitations.png",
|
|
|
|
"doaj-logo1.png",
|
|
|
|
"microsoft.png",
|
|
|
|
"plos.png",
|
|
|
|
"F1000.png",
|
|
|
|
"logo_copernicus_publications.png"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"software": [
|
|
|
|
[
|
|
|
|
"Software-heritage-logo.png",
|
|
|
|
"github_PNG23.png",
|
|
|
|
"DOEcodeBLUE_300dpi.png",
|
|
|
|
"bitbucket-logo.png",
|
|
|
|
"sourceforge.png",
|
|
|
|
"zenodo-black-1000.png"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"dataset": [
|
|
|
|
[
|
|
|
|
"zenodo-black-1000.png",
|
|
|
|
"datacite.png",
|
|
|
|
"pangaea.png",
|
|
|
|
"figshare.png",
|
|
|
|
"protocols_identity_outline.png",
|
|
|
|
"ot-logo-white.png",
|
|
|
|
"Kaggle_logo.png",
|
|
|
|
"Reactome.png",
|
|
|
|
"easy.png",
|
|
|
|
"DryadLogo.png"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
//"other": [],
|
|
|
|
"persistent": [
|
|
|
|
[
|
|
|
|
"Re3data_Logo_RGB_72dpi.png",
|
|
|
|
"ORCID_logo.png",
|
|
|
|
"opendoar_logo.png",
|
|
|
|
"GRID_rgb1.png"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"funder": [
|
|
|
|
[
|
|
|
|
"European_Commission.png",
|
|
|
|
"NSF.png",
|
|
|
|
"logo-miur.png",
|
|
|
|
"nhmrc.png",
|
|
|
|
"SFI-logo.png",
|
|
|
|
"nwo-logo.png",
|
|
|
|
"wellcome-logo.png",
|
|
|
|
"FCT-logo.png",
|
|
|
|
"gsrt_logo_eng.png",
|
|
|
|
"fnsnf.png"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
public pageTitle = "OpenAIRE";
|
2018-01-23 11:07:39 +01:00
|
|
|
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;
|
2019-06-13 16:54:39 +02:00
|
|
|
public softwareSize: any = null;
|
|
|
|
public otherSize: any = null;
|
2018-01-23 11:07:39 +01:00
|
|
|
public fundersSize:any = null;
|
|
|
|
public projectsSize:any = null;
|
|
|
|
public datasourcesSize:any = null;
|
|
|
|
|
2018-05-10 16:08:45 +02:00
|
|
|
private numResults: number = 2;
|
|
|
|
public fetchDataproviders : FetchDataproviders;
|
|
|
|
|
2018-01-23 11:07:39 +01:00
|
|
|
showPublications:boolean= false;
|
|
|
|
showDatasets:boolean= false;
|
2019-06-13 16:54:39 +02:00
|
|
|
showSoftware: boolean = false;
|
|
|
|
showOrp: boolean = false;
|
2018-01-23 11:07:39 +01:00
|
|
|
showProjects:boolean= false;
|
|
|
|
showDataProviders:boolean= false;
|
2018-02-05 14:16:11 +01:00
|
|
|
properties: EnvProperties;
|
2019-10-07 15:00:45 +02:00
|
|
|
public readMore: boolean = false;
|
2018-01-23 11:07:39 +01:00
|
|
|
public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
2019-06-13 16:54:39 +02:00
|
|
|
public subSoft;
|
|
|
|
public subOrp;
|
2019-10-07 15:00:45 +02:00
|
|
|
trelloImg: string = 'trello.svg';
|
|
|
|
trelloImg2: string = 'trello.svg';
|
2018-01-23 11:07:39 +01:00
|
|
|
constructor (
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private _router: Router,
|
2019-09-11 13:47:16 +02:00
|
|
|
private _searchResearchResultsService: SearchResearchResultsService,
|
2018-01-23 11:07:39 +01:00
|
|
|
private _searchDataprovidersService: SearchDataprovidersService,
|
|
|
|
private _searchProjectsService: SearchProjectsService,
|
|
|
|
private _searchOrganizationsService: SearchOrganizationsService,
|
|
|
|
private _refineFieldResultsService:RefineFieldResultsService,
|
2018-04-17 15:51:47 +02:00
|
|
|
private location: Location, private _piwikService:PiwikService,
|
2018-11-14 15:16:19 +01:00
|
|
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService
|
2018-01-23 11:07:39 +01:00
|
|
|
) {
|
|
|
|
|
2018-11-14 15:16:19 +01:00
|
|
|
var description = "openAIRE explore, open access, publications, research results, European commission, search";
|
2018-01-23 11:07:39 +01:00
|
|
|
|
2018-11-14 15:16:19 +01:00
|
|
|
var title = "OpenAIRE | Explore";
|
2018-01-23 11:07:39 +01:00
|
|
|
|
2018-04-17 15:51:47 +02:00
|
|
|
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-11-14 15:16:19 +01:00
|
|
|
|
2018-01-23 11:07:39 +01:00
|
|
|
|
2018-05-10 16:08:45 +02:00
|
|
|
//this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 13:02:51 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:07:39 +01:00
|
|
|
public ngOnInit() {
|
2018-02-05 14:16:11 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2019-02-11 16:10:42 +01:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
2018-02-05 14:16:11 +01:00
|
|
|
if(this.properties!=null){
|
|
|
|
var url = this.properties.baseLink+this._router.url;
|
2018-04-17 15:51:47 +02:00
|
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
2018-02-05 14:16:11 +01:00
|
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
2018-02-16 16:51:10 +01:00
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
|
2018-02-05 14:16:11 +01:00
|
|
|
}
|
|
|
|
|
2019-06-05 16:31:43 +02:00
|
|
|
this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
2018-02-05 14:16:11 +01:00
|
|
|
var showEntity = {};
|
2019-06-03 15:21:49 +02:00
|
|
|
for(var i=0; i< data['entities'].length; i++){
|
2018-02-05 14:16:11 +01:00
|
|
|
|
2019-06-03 15:21:49 +02:00
|
|
|
showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
|
2018-02-05 14:16:11 +01:00
|
|
|
}
|
|
|
|
this.showPublications = showEntity["publication"];
|
|
|
|
this.showDatasets = showEntity["dataset"];
|
2019-06-13 16:54:39 +02:00
|
|
|
this.showSoftware = showEntity["software"];
|
|
|
|
this.showOrp = showEntity["orp"];
|
2018-02-05 14:16:11 +01:00
|
|
|
this.showProjects = showEntity["project"];
|
|
|
|
this.showDataProviders = showEntity["datasource"];
|
|
|
|
this.getNumbers();
|
2018-05-10 16:08:45 +02:00
|
|
|
// if(this.showDataProviders) {
|
|
|
|
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
|
|
|
// }
|
2019-02-18 15:36:04 +01:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
this.handleError("Error getting community information", error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2018-02-05 14:16:11 +01:00
|
|
|
});
|
|
|
|
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|
|
|
|
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){
|
2019-09-11 13:47:16 +02:00
|
|
|
this.subPub = this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
|
2018-01-23 11:07:39 +01:00
|
|
|
data => {
|
|
|
|
if(data && data != null && data > 0 ){
|
|
|
|
this.publicationsSize = NumberUtils.roundNumber(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-18 15:36:04 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting number of publications", err);
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if(this.showDatasets){
|
2019-09-11 13:47:16 +02:00
|
|
|
this.subData = this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
2018-01-23 11:07:39 +01:00
|
|
|
data => {
|
|
|
|
if(data && data != null && data > 0 ){
|
|
|
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-18 15:36:04 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting number of research data", err);
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2019-06-13 16:54:39 +02:00
|
|
|
if (this.showSoftware) {
|
2019-09-11 13:47:16 +02:00
|
|
|
this.subSoft = this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
2019-06-13 16:54:39 +02:00
|
|
|
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) {
|
2019-09-11 13:47:16 +02:00
|
|
|
this.subOrp = this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
2019-06-13 16:54:39 +02:00
|
|
|
data => {
|
|
|
|
if (data && data > 0) {
|
|
|
|
this.otherSize = NumberUtils.roundNumber(data);
|
|
|
|
}else{
|
|
|
|
this.showOrp = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of software data", err);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2018-01-23 11:07:39 +01:00
|
|
|
if(this.showProjects){
|
2018-02-05 14:16:11 +01:00
|
|
|
this.subfunders = this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe(
|
2018-01-23 11:07:39 +01:00
|
|
|
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 => {
|
2019-02-18 15:36:04 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting 'funder' field results of projects", err);
|
2018-01-23 11:07:39 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if(this.showDataProviders){
|
2018-02-05 14:16:11 +01:00
|
|
|
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
|
2018-01-23 11:07:39 +01:00
|
|
|
data => {
|
|
|
|
if(data && data != null && data > 0 ){
|
|
|
|
this.datasourcesSize = NumberUtils.roundNumber(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-18 15:36:04 +01:00
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting number of content providers", err);
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-02-18 15:36:04 +01:00
|
|
|
|
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Home Page: "+message, error);
|
|
|
|
}
|
2018-01-23 11:07:39 +01:00
|
|
|
}
|