425 lines
16 KiB
TypeScript
425 lines
16 KiB
TypeScript
import {
|
|
AfterViewInit,
|
|
ChangeDetectorRef,
|
|
Component,
|
|
ElementRef,
|
|
OnDestroy,
|
|
OnInit,
|
|
QueryList,
|
|
ViewChild,
|
|
ViewChildren
|
|
} from '@angular/core';
|
|
import {Observable, of, Subscriber, zip} from 'rxjs';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {Location} from '@angular/common';
|
|
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';
|
|
|
|
@Component({
|
|
selector: 'home',
|
|
templateUrl: 'home.component.html',
|
|
styleUrls: ['home.component.css']
|
|
})
|
|
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
|
|
// 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-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 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 openaireEntities = OpenaireEntities;
|
|
public readMore: boolean = false;
|
|
|
|
subscriptions: any[] = [];
|
|
@ViewChildren('scrolling_element') elements: QueryList<ElementRef>;
|
|
|
|
resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
|
filter: null,
|
|
selected: true,
|
|
filterId: "resultbestaccessright",
|
|
value: "Open Access"
|
|
};
|
|
selectedEntity = "all";
|
|
selectedEntitySimpleUrl;
|
|
selectedEntityAdvancedUrl;
|
|
resultTypes: Filter = {
|
|
values: [],
|
|
filterId: "type",
|
|
countSelectedValues: 0,
|
|
filterType: 'checkbox',
|
|
originalFilterId: "",
|
|
valueIsExact: true,
|
|
title: "Type",
|
|
filterOperator: "or"
|
|
};
|
|
public pageContents = null;
|
|
@ViewChild("numbersComponent", { static: true }) numbersComponent: NumbersComponent;
|
|
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"},
|
|
/* "Mathematics::Combinatorics",
|
|
"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 config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
|
private helper: HelperService,
|
|
private cdr: ChangeDetectorRef
|
|
) {
|
|
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'");
|
|
}
|
|
|
|
private getPageContents() {
|
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'openaire', this._router.url).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);
|
|
}
|
|
|
|
clear() {
|
|
this.subscriptions.forEach(value => {
|
|
if (value instanceof Subscriber) {
|
|
value.unsubscribe();
|
|
} else if (value instanceof IntersectionObserver || value instanceof MutationObserver) {
|
|
value.disconnect();
|
|
}
|
|
});
|
|
}
|
|
|
|
public ngOnInit() {
|
|
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')) {
|
|
this.subscriptions.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe());
|
|
}
|
|
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
|
this.subscriptions.push(this.config.communityInformationState.subscribe(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) {
|
|
this.resultTypes.values.push({name: "Publications", id: "publications", selected: true, number: 0});
|
|
}
|
|
if (this.showDatasets) {
|
|
this.resultTypes.values.push({name: "Research data", id: "datasets", selected: true, number: 0});
|
|
}
|
|
if (this.showSoftware) {
|
|
this.resultTypes.values.push({name: "Software", id: "software", selected: true, number: 0});
|
|
}
|
|
if (this.showOrp) {
|
|
this.resultTypes.values.push({name: "Other research products", id: "other", selected: true, number: 0});
|
|
}
|
|
this.init(this.showDatasets, this.showSoftware, this.showPublications, this.showDatasets, this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders, this.showOrganizations);
|
|
}
|
|
},
|
|
error => {
|
|
this.handleError("Error getting community information", error);
|
|
}
|
|
));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
this.clear();
|
|
}
|
|
|
|
ngAfterViewInit() {
|
|
if(typeof window !== "undefined") {
|
|
this.createObserver();
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
private handleError(message: string, error) {
|
|
console.error("Home Page: " + message, error);
|
|
}
|
|
|
|
entityChanged($event) {
|
|
this.selectedEntity = $event.entity;
|
|
this.selectedEntitySimpleUrl = $event.simpleUrl;
|
|
this.selectedEntityAdvancedUrl = $event.advancedUrl;
|
|
}
|
|
|
|
goTo(simple: boolean) {
|
|
let url = (simple) ? this.selectedEntitySimpleUrl : this.selectedEntityAdvancedUrl;
|
|
let parameterNames = [];
|
|
let parameterValues = [];
|
|
if (this.selectedEntity == "result") {
|
|
if (this.resultTypes) {
|
|
let values = [];
|
|
for (let value of this.resultTypes.values) {
|
|
if (value.selected) {
|
|
values.push(value.id);
|
|
}
|
|
}
|
|
if (values.length > 0 && values.length != 4) {
|
|
parameterNames.push("type");
|
|
parameterValues.push(values.join(","));
|
|
}
|
|
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
|
|
parameterNames.push(this.resultsQuickFilter.filterId);
|
|
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"');
|
|
}
|
|
}
|
|
} else if (this.selectedEntity == "all") {
|
|
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
|
|
parameterNames.push(this.resultsQuickFilter.filterId);
|
|
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"');
|
|
}
|
|
}
|
|
if (this.keyword.length > 0) {
|
|
parameterNames.push("fv0");
|
|
parameterValues.push(this.keyword);
|
|
parameterNames.push("f0");
|
|
parameterValues.push("q");
|
|
}
|
|
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|