2017-12-19 13:53:46 +01:00
|
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
|
|
|
|
|
|
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
|
|
|
|
import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
2018-07-05 17:50:43 +02:00
|
|
|
|
import { FetchSoftware } from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
|
2018-07-26 18:38:59 +02:00
|
|
|
|
import { FetchOrps } from '../../utils/fetchEntitiesClasses/fetchOrps.class';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
2018-02-15 11:36:12 +01:00
|
|
|
|
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
|
import { Observable } from 'rxjs/Observable';
|
2018-02-05 14:14:59 +01:00
|
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'relatedDatasourcesTab',
|
|
|
|
|
template: `
|
2018-07-26 18:38:59 +02:00
|
|
|
|
<errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status, fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]"
|
2018-07-05 17:50:43 +02:00
|
|
|
|
[type]="'related content providers'" tab_error_class=true>
|
|
|
|
|
</errorMessages>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
2018-07-26 18:38:59 +02:00
|
|
|
|
<div *ngIf="(fetchPublications.searchUtils.status == errorCodes.DONE || fetchDatasets.searchUtils.status == errorCodes.DONE
|
|
|
|
|
|| fetchSoftware.searchUtils.status == errorCodes.DONE || fetchOrps.searchUtils.status == errorCodes.DONE)
|
|
|
|
|
&& !loading">
|
2017-12-19 13:53:46 +01:00
|
|
|
|
<div *ngIf="results && results.size > pageSize" class="uk-margin">
|
2018-05-18 14:47:26 +02:00
|
|
|
|
<span class="uk-text-bold">{{results.size | number}} related content providers, page {{page | number}} of {{totalPages(results.size) | number}}</span>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="results.size" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<table class="uk-table uk-table-striped">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th class="uk-text-center">Content Provider Name</th>
|
|
|
|
|
<th *ngIf="fetchPublications.results.length > 0 || fetchPublications.searchUtils.status == errorCodes.ERROR"
|
|
|
|
|
class="uk-text-center">
|
|
|
|
|
Number of Publications
|
|
|
|
|
</th>
|
|
|
|
|
<th *ngIf="fetchDatasets.results.length > 0 || fetchDatasets.searchUtils.status == errorCodes.ERROR"
|
|
|
|
|
class="uk-text-center">
|
|
|
|
|
Number of Research Data
|
|
|
|
|
</th>
|
2018-07-05 17:50:43 +02:00
|
|
|
|
<th *ngIf="fetchSoftware.results.length > 0 || fetchSoftware.searchUtils.status == errorCodes.ERROR"
|
|
|
|
|
class="uk-text-center">
|
|
|
|
|
Number of Software
|
|
|
|
|
</th>
|
2018-07-26 18:38:59 +02:00
|
|
|
|
<th *ngIf="fetchOrps.results.length > 0 || fetchOrps.searchUtils.status == errorCodes.ERROR"
|
|
|
|
|
class="uk-text-center">
|
|
|
|
|
Number of Other Research Products
|
|
|
|
|
</th>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<ng-container *ngIf="results">
|
2018-07-26 18:38:59 +02:00
|
|
|
|
<ng-container *ngFor="let id of getKeys(results); let i=index">
|
2017-12-19 13:53:46 +01:00
|
|
|
|
<tr *ngIf="i>=(page-1)*pageSize && i<page*pageSize">
|
|
|
|
|
<td class="uk-text-center">
|
|
|
|
|
<a [queryParams]="{datasourceId: id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
|
|
|
|
{{results.get(id).name}}
|
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
<td *ngIf="fetchPublications.results.length > 0" class="uk-text-center">
|
2018-07-05 12:52:42 +02:00
|
|
|
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
2017-12-19 13:53:46 +01:00
|
|
|
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchPublications">
|
2018-05-18 14:47:26 +02:00
|
|
|
|
{{results.get(id).countPublications | number}}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
<td *ngIf="fetchPublications.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
|
|
|
|
|
|
|
|
|
<td *ngIf="fetchDatasets.results.length > 0" class="uk-text-center">
|
2018-07-05 12:52:42 +02:00
|
|
|
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
2017-12-19 13:53:46 +01:00
|
|
|
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchResearchData">
|
2018-05-18 14:47:26 +02:00
|
|
|
|
{{results.get(id).countDatasets | number}}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
<td *ngIf="fetchDatasets.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
2018-07-05 17:50:43 +02:00
|
|
|
|
|
|
|
|
|
<td *ngIf="fetchSoftware.results.length > 0" class="uk-text-center">
|
|
|
|
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
|
|
|
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchSoftware">
|
|
|
|
|
{{results.get(id).countSoftware | number}}
|
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
<td *ngIf="fetchSoftware.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
2018-07-26 18:38:59 +02:00
|
|
|
|
|
|
|
|
|
<td *ngIf="fetchOrps.results.length > 0" class="uk-text-center">
|
|
|
|
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
|
|
|
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchOrps">
|
|
|
|
|
{{results.get(id).countOrps | number}}
|
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
<td *ngIf="fetchOrps.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
</tr>
|
|
|
|
|
</ng-container>
|
|
|
|
|
</ng-container>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export class RelatedDatasourcesTabComponent {
|
|
|
|
|
@Input() dataproviderId: string;
|
|
|
|
|
@Input() fetchPublications : FetchPublications;
|
|
|
|
|
@Input() fetchDatasets : FetchDatasets;
|
2018-07-05 17:50:43 +02:00
|
|
|
|
@Input() fetchSoftware : FetchSoftware;
|
2018-07-26 18:38:59 +02:00
|
|
|
|
@Input() fetchOrps: FetchOrps;
|
2018-07-05 17:50:43 +02:00
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
// true: preprocessing is not over
|
|
|
|
|
@Input() loading: boolean = true;
|
|
|
|
|
// Εvery content provider's id is a single key of a map
|
2018-07-26 18:38:59 +02:00
|
|
|
|
@Input() results: Map<string, {"name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string}>;
|
2018-02-05 14:14:59 +01:00
|
|
|
|
@Input() properties:EnvProperties ;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
public linkToSearchPublications: string = "";
|
|
|
|
|
public linkToSearchResearchData: string = "";
|
2018-07-05 17:50:43 +02:00
|
|
|
|
public linkToSearchSoftware: string = "";
|
2018-07-26 18:38:59 +02:00
|
|
|
|
public linkToSearchOrps: string = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
|
|
public page: number = 1;
|
|
|
|
|
public pageSize: number = 10;
|
|
|
|
|
|
|
|
|
|
constructor () {}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
|
this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;
|
|
|
|
|
this.linkToSearchResearchData = this.properties.searchLinkToAdvancedDatasets;
|
2018-07-05 17:50:43 +02:00
|
|
|
|
this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
|
2018-07-26 18:38:59 +02:00
|
|
|
|
this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2018-07-26 18:38:59 +02:00
|
|
|
|
|
|
|
|
|
public getKeys( map) {
|
|
|
|
|
return Array.from(map.keys());
|
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
}
|