import {Component, Input} from '@angular/core'; import { FetchResearchResults } from '../../utils/fetchEntitiesClasses/fetchResearchResults.class'; import { ErrorCodes} from '../../utils/properties/errorCodes'; import { RouterHelper } from '../../utils/routerHelper.class'; import { EnvProperties } from '../../utils/properties/env-properties'; import {AlertModal} from "../../utils/modal/alert"; import {properties} from "../../../../environments/environment"; import {OpenaireEntities} from "../../utils/properties/searchFields"; @Component({ selector: 'relatedDatasourcesTab', template: `
*Only top 100 {{openaireEntities.DATASOURCES}} that host {{openaireEntities.RESULTS}} which are also available via the Federated Research Data Repository are shown.
{{openaireEntities.DATASOURCE}} {{openaireEntities.RESULTS}} in Explore
{{result.name}} {{result.count | number}}
` }) export class RelatedDatasourcesTabComponent { @Input() dataproviderId: string; // @Input() fetchPublications : FetchResearchResults; // @Input() fetchDatasets : FetchResearchResults; // @Input() fetchSoftware : FetchResearchResults; // @Input() fetchOrps: FetchResearchResults; @Input() fetchResults: FetchResearchResults; // true: preprocessing is not over @Input() loading: boolean = true; // Εvery datasource's id is a single key of a map //@Input() results: Map; @Input() results: {"id": string, "name": string, "count": number}[]; @Input() properties:EnvProperties ; @Input() collectedFromName: string ="[no title available]"; @Input() modal: AlertModal; public routerHelper:RouterHelper = new RouterHelper(); public errorCodes:ErrorCodes = new ErrorCodes(); public page: number = 1; public pageSize: number = 10; public dataProviderUrl; public openaireEntities = OpenaireEntities; constructor () {} ngOnInit() { this.dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0]; } ngOnDestroy() {} totalPages(totalResults: number): number { let totalPages:any = totalResults/this.pageSize; if(!(Number.isInteger(totalPages))) { totalPages = (parseInt(totalPages, this.pageSize) + 1); } return totalPages; } updatePage($event) { this.page = $event.value; } public getKeys( map) { return Array.from(map.keys()); } public onLinkClick() { if(this.modal) { this.modal.cancel(); } } }