import {Component, Input} from '@angular/core'; import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; import { ErrorCodes} from '../../utils/properties/errorCodes'; import {RouterHelper} from '../../utils/routerHelper.class'; import { Observable } from 'rxjs/Observable'; import{EnvProperties} from '../../utils/properties/env-properties'; @Component({ selector: 'relatedDatasourcesTab', template: `
{{results.size}} related content providers, page {{page}} of {{totalPages(results.size)}}
Content Provider Name Number of Publications Number of Research Data
{{results.get(id).name}} {{results.get(id).countPublications}} - {{results.get(id).countDatasets}} -
` }) export class RelatedDatasourcesTabComponent { @Input() dataproviderId: string; @Input() fetchPublications : FetchPublications; @Input() fetchDatasets : FetchDatasets; // true: preprocessing is not over @Input() loading: boolean = true; // Εvery content provider's id is a single key of a map @Input() results: Map; @Input() properties:EnvProperties ; public linkToSearchPublications: string = ""; public linkToSearchResearchData: string = ""; public routerHelper:RouterHelper = new RouterHelper(); public errorCodes:ErrorCodes = new ErrorCodes(); public page: number = 1; public pageSize: number = 10; constructor () {} ngOnInit() { this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications; this.linkToSearchResearchData = this.properties.searchLinkToAdvancedDatasets; } 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; } }