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";
@Component({
selector: 'relatedDatasourcesTab',
template: `
*Only top 100 content providers that host research outcomes which are also available via the Federated Research Data Repository are shown.
pageSize"
[type]="'content providers'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="pageSize"
[totalResults]="results.length">
Content Provider Name |
0 || fetchResults.searchUtils.status == errorCodes.ERROR"
class="uk-text-center">
Number of Research Outcomes
|
=(page-1)*pageSize && i
{{result.name}}
|
0" class="uk-text-center">
{{result.count | number}}
|
pageSize"
[type]="'content providers'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="pageSize"
[totalResults]="results.length">
`
})
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 content provider'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;
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();
}
}
}