2019-05-24 15:54:22 +02:00
|
|
|
import {Component} from '@angular/core';
|
2019-05-23 15:38:44 +02:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import "rxjs/add/observable/zip";
|
2019-05-24 15:54:22 +02:00
|
|
|
import {Meta, Title} from '@angular/platform-browser';
|
2019-05-23 15:38:44 +02:00
|
|
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
2019-05-24 15:54:22 +02:00
|
|
|
import {SearchPublicationsService} from '../openaireLibrary/services/searchPublications.service';
|
|
|
|
import {FetchDataproviders} from '../openaireLibrary/utils/fetchEntitiesClasses/fetchDataproviders.class';
|
|
|
|
import {SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
|
|
|
|
import {SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
|
|
|
|
import {SearchDatasetsService} from '../openaireLibrary/services/searchDatasets.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';
|
2019-05-23 15:38:44 +02:00
|
|
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
2019-05-24 15:54:22 +02:00
|
|
|
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
|
|
|
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
|
|
|
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
|
|
|
import {SearchSoftwareService} from "../openaireLibrary/services/searchSoftware.service";
|
|
|
|
import {SearchOrpsService} from "../openaireLibrary/services/searchOrps.service";
|
2019-06-13 14:40:03 +02:00
|
|
|
import {FilterInfo, PortalAggregators} from "../utils/aggregators";
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-05-24 15:54:22 +02:00
|
|
|
selector: 'home',
|
|
|
|
templateUrl: 'home.component.html',
|
2019-05-23 15:38:44 +02:00
|
|
|
})
|
|
|
|
export class HomeComponent {
|
|
|
|
public piwiksub: any;
|
|
|
|
public subfunders: any;
|
|
|
|
|
|
|
|
public pageTitle = "OpenAIRE"
|
2019-05-24 15:54:22 +02:00
|
|
|
public keyword: string = "";
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
public searchFields: SearchFields = new SearchFields();
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
public publicationsSize: any = null;
|
|
|
|
public datasetsSize: any = null;
|
|
|
|
public softwareSize: any = null;
|
|
|
|
public otherSize: any = null;
|
|
|
|
public organizationsSize: any = null;
|
|
|
|
public fundersSize: any = null;
|
|
|
|
public projectsSize: any = null;
|
|
|
|
public datasourcesSize: any = null;
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
public fetchDataproviders: FetchDataproviders;
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
showPublications: boolean = false;
|
|
|
|
showDatasets: boolean = false;
|
|
|
|
showSoftware: boolean = false;
|
|
|
|
showOrp: boolean = false;
|
|
|
|
showOrganizations: boolean = false;
|
|
|
|
showProjects: boolean = false;
|
|
|
|
showDataProviders: boolean = false;
|
2019-05-23 15:38:44 +02:00
|
|
|
properties: EnvProperties;
|
2019-05-24 15:54:22 +02:00
|
|
|
public subPub;
|
|
|
|
public subSoft;
|
|
|
|
public subOrp;
|
|
|
|
public subData;
|
|
|
|
public subProjects;
|
|
|
|
public subOrg;
|
|
|
|
public subDataPr;
|
2019-06-13 14:40:03 +02:00
|
|
|
customFilter:SearchCustomFilter= null;
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
constructor(
|
2019-05-23 15:38:44 +02:00
|
|
|
private route: ActivatedRoute,
|
2019-05-24 15:54:22 +02:00
|
|
|
private _router: Router,
|
|
|
|
private _searchPublicationsService: SearchPublicationsService,
|
|
|
|
private _searchDataprovidersService: SearchDataprovidersService,
|
|
|
|
private _searchProjectsService: SearchProjectsService,
|
|
|
|
private _searchDatasetsService: SearchDatasetsService,
|
|
|
|
private _searchSoftwareService: SearchSoftwareService,
|
|
|
|
private _searchOrpsService: SearchOrpsService,
|
|
|
|
private _searchOrganizationsService: SearchOrganizationsService,
|
|
|
|
private _refineFieldResultsService: RefineFieldResultsService,
|
|
|
|
private location: Location, private _piwikService: PiwikService,
|
|
|
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService
|
|
|
|
) {
|
2019-06-13 14:40:03 +02:00
|
|
|
let id = this.route.snapshot.paramMap.get('id');
|
|
|
|
console.log(id);
|
|
|
|
let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id);
|
|
|
|
this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg);
|
|
|
|
let description = "openAIRE, open access, publications, research results, European commission, search";
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-06-13 14:40:03 +02:00
|
|
|
let title = "OpenAIRE | "+agg.title;
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +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'");
|
2019-06-13 14:40:03 +02:00
|
|
|
|
|
|
|
// this.customFilter.setValues("Country", "country", "CA" , "Canada");
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
2019-06-13 14:40:03 +02:00
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
this.route.data
|
2019-05-24 15:54:22 +02:00
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
2019-05-23 15:38:44 +02:00
|
|
|
this.properties = data.envSpecific;
|
2019-05-24 15:54:22 +02:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
|
|
|
|
let url = this.properties.baseLink + this._router.url;
|
|
|
|
this._meta.updateTag({content: url}, "property='og:url'");
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
2019-05-23 15:38:44 +02:00
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
|
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
this.showPublications = true;
|
|
|
|
this.showOrp = true;
|
|
|
|
this.showOrganizations = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
2019-06-14 15:14:22 +02:00
|
|
|
this.showProjects = true;
|
|
|
|
this.showDataProviders = true;
|
2019-05-24 15:54:22 +02:00
|
|
|
this.getNumbers();
|
2019-05-23 15:38:44 +02:00
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
/* this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.properties.adminToolsCommunity).subscribe(data => {
|
|
|
|
let showEntity = {};
|
|
|
|
for (let 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.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);
|
|
|
|
}
|
|
|
|
);*/
|
|
|
|
|
|
|
|
});
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
public ngOnDestroy() {
|
2019-05-24 15:54:22 +02:00
|
|
|
if (this.piwiksub) {
|
2019-05-23 15:38:44 +02:00
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
if (this.subfunders) {
|
2019-05-23 15:38:44 +02:00
|
|
|
this.subfunders.unsubscribe();
|
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
if (this.subPub) {
|
|
|
|
this.subPub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subOrp) {
|
|
|
|
this.subOrp.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subSoft) {
|
|
|
|
this.subSoft.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() {
|
2019-06-13 14:40:03 +02:00
|
|
|
let refineQuery = null;
|
2019-05-24 15:54:22 +02:00
|
|
|
if(this.customFilter){
|
|
|
|
refineQuery= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )));
|
|
|
|
}
|
|
|
|
if (this.showPublications) {
|
|
|
|
this.subPub = this._searchPublicationsService.numOfSearchPublications("", this.properties,refineQuery).subscribe(
|
|
|
|
data => {
|
|
|
|
if (data && data > 0) {
|
|
|
|
this.publicationsSize = NumberUtils.roundNumber(data);
|
|
|
|
}else{
|
|
|
|
this.showPublications = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of publications", err);
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.showDatasets) {
|
|
|
|
this.subData = this._searchDatasetsService.numOfSearchDatasets("", this.properties,refineQuery).subscribe(
|
|
|
|
data => {
|
|
|
|
if (data && data > 0) {
|
|
|
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
|
|
|
}else{
|
|
|
|
this.showDatasets = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of research data", err);
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.showSoftware) {
|
|
|
|
this.subSoft = this._searchSoftwareService.numOfSearchSoftware("", this.properties,refineQuery).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);
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2019-05-24 15:54:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.showOrp) {
|
|
|
|
this.subOrp = this._searchOrpsService.numOfSearchOrps("", this.properties,refineQuery).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) {
|
2019-06-14 15:14:22 +02:00
|
|
|
this.subfunders = this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"], "project", this.properties, refineQuery).subscribe(
|
2019-05-24 15:54:22 +02:00
|
|
|
data => {
|
|
|
|
if (data[0] && data[0] > 0) {
|
|
|
|
this.projectsSize = NumberUtils.roundNumber(data[0]);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.showProjects = false;
|
|
|
|
}
|
|
|
|
if (data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values) {
|
|
|
|
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting 'funder' field results of projects", err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (this.showDataProviders) {
|
2019-06-14 15:14:22 +02:00
|
|
|
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders("", this.properties, refineQuery).subscribe(
|
2019-05-24 15:54:22 +02:00
|
|
|
data => {
|
|
|
|
if (data && data > 0) {
|
|
|
|
this.datasourcesSize = NumberUtils.roundNumber(data);
|
|
|
|
}else{
|
|
|
|
this.showDataProviders = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of content providers", err);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.showOrganizations) {
|
|
|
|
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations("", this.properties, refineQuery).subscribe(
|
|
|
|
data => {
|
|
|
|
if (data && data > 0) {
|
|
|
|
this.organizationsSize = NumberUtils.roundNumber(data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of Organizations", err);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 15:54:22 +02:00
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Home Page: " + message, error);
|
|
|
|
}
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|