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 {{collectedFromName}} are shown.
{{openaireEntities.DATASOURCE}} {{openaireEntities.RESULTS}} in Explore
{{result.name}} {{result.count | number}} {{result.count | number}}
` }) export class RelatedDatasourcesTabComponent { @Input() prevPath: string = ""; @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; this.scrollToTabTop("relatedDatasources"); } scrollToTabTop(tabId:string){ setTimeout(() => { window.scrollTo({ top: document.getElementById(tabId) ? document.getElementById(tabId).offsetTop - 250 : 250, behavior: 'smooth' }); }, 200); } public getKeys( map) { return Array.from(map.keys()); } public onLinkClick() { if(this.modal) { this.modal.cancel(); } } public addEoscPrevInParams(obj) { if(properties.adminToolsPortalType == "eosc" && this.prevPath) { let splitted: string[] = this.prevPath.split("?"); obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj); if(splitted.length > 0) { obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj); } } return obj; } }