1
|
import {Component, Input} from '@angular/core';
|
2
|
|
3
|
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
4
|
import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
5
|
import { FetchSoftware } from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
|
6
|
import { FetchOrps } from '../../utils/fetchEntitiesClasses/fetchOrps.class';
|
7
|
|
8
|
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
9
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
10
|
import { Observable } from 'rxjs';
|
11
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
12
|
|
13
|
@Component({
|
14
|
selector: 'relatedDatasourcesTab',
|
15
|
template: `
|
16
|
<errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status, fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]"
|
17
|
[type]="'related content providers'" tab_error_class=true>
|
18
|
</errorMessages>
|
19
|
|
20
|
<div *ngIf="(fetchPublications.searchUtils.status == errorCodes.DONE || fetchDatasets.searchUtils.status == errorCodes.DONE
|
21
|
|| fetchSoftware.searchUtils.status == errorCodes.DONE || fetchOrps.searchUtils.status == errorCodes.DONE)
|
22
|
&& !loading">
|
23
|
<div *ngIf="results && results.size > pageSize" class="uk-margin">
|
24
|
<span class="uk-text-bold">{{results.size | number}} related content providers, page {{page | number}} of {{totalPages(results.size) | number}}</span>
|
25
|
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="results.size" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
|
26
|
</div>
|
27
|
|
28
|
<table class="uk-table uk-table-striped">
|
29
|
<thead>
|
30
|
<tr>
|
31
|
<th class="uk-text-center">Content Provider Name</th>
|
32
|
<th *ngIf="fetchPublications.results.length > 0 || fetchPublications.searchUtils.status == errorCodes.ERROR"
|
33
|
class="uk-text-center">
|
34
|
Number of Publications
|
35
|
</th>
|
36
|
<th *ngIf="fetchDatasets.results.length > 0 || fetchDatasets.searchUtils.status == errorCodes.ERROR"
|
37
|
class="uk-text-center">
|
38
|
Number of Research Data
|
39
|
</th>
|
40
|
<th *ngIf="fetchSoftware.results.length > 0 || fetchSoftware.searchUtils.status == errorCodes.ERROR"
|
41
|
class="uk-text-center">
|
42
|
Number of Software
|
43
|
</th>
|
44
|
<th *ngIf="fetchOrps.results.length > 0 || fetchOrps.searchUtils.status == errorCodes.ERROR"
|
45
|
class="uk-text-center">
|
46
|
Number of Other Research Products
|
47
|
</th>
|
48
|
</tr>
|
49
|
</thead>
|
50
|
<tbody>
|
51
|
<ng-container *ngIf="results">
|
52
|
<ng-container *ngFor="let id of getKeys(results); let i=index">
|
53
|
<tr *ngIf="i>=(page-1)*pageSize && i<page*pageSize">
|
54
|
<td class="uk-text-center">
|
55
|
<a [queryParams]="{datasourceId: id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
56
|
{{results.get(id).name}}
|
57
|
</a>
|
58
|
</td>
|
59
|
<td *ngIf="fetchPublications.results.length > 0" class="uk-text-center">
|
60
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
61
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchPublications">
|
62
|
{{results.get(id).countPublications | number}}
|
63
|
</a>
|
64
|
</td>
|
65
|
<td *ngIf="fetchPublications.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
66
|
|
67
|
<td *ngIf="fetchDatasets.results.length > 0" class="uk-text-center">
|
68
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
69
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchResearchData">
|
70
|
{{results.get(id).countDatasets | number}}
|
71
|
</a>
|
72
|
</td>
|
73
|
<td *ngIf="fetchDatasets.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
74
|
|
75
|
<td *ngIf="fetchSoftware.results.length > 0" class="uk-text-center">
|
76
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
77
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchSoftware">
|
78
|
{{results.get(id).countSoftware | number}}
|
79
|
</a>
|
80
|
</td>
|
81
|
<td *ngIf="fetchSoftware.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
82
|
|
83
|
<td *ngIf="fetchOrps.results.length > 0" class="uk-text-center">
|
84
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'hs', 'collectedFrom', 'cl'], [id, 'and', dataproviderId, 'and'])"
|
85
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchOrps">
|
86
|
{{results.get(id).countOrps | number}}
|
87
|
</a>
|
88
|
</td>
|
89
|
<td *ngIf="fetchOrps.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
|
90
|
</tr>
|
91
|
</ng-container>
|
92
|
</ng-container>
|
93
|
</tbody>
|
94
|
</table>
|
95
|
</div>
|
96
|
`
|
97
|
})
|
98
|
|
99
|
export class RelatedDatasourcesTabComponent {
|
100
|
@Input() dataproviderId: string;
|
101
|
@Input() fetchPublications : FetchPublications;
|
102
|
@Input() fetchDatasets : FetchDatasets;
|
103
|
@Input() fetchSoftware : FetchSoftware;
|
104
|
@Input() fetchOrps: FetchOrps;
|
105
|
|
106
|
// true: preprocessing is not over
|
107
|
@Input() loading: boolean = true;
|
108
|
// Εvery content provider's id is a single key of a map
|
109
|
@Input() results: Map<string, {"name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string}>;
|
110
|
@Input() properties:EnvProperties ;
|
111
|
|
112
|
public linkToSearchPublications: string = "";
|
113
|
public linkToSearchResearchData: string = "";
|
114
|
public linkToSearchSoftware: string = "";
|
115
|
public linkToSearchOrps: string = "";
|
116
|
|
117
|
public routerHelper:RouterHelper = new RouterHelper();
|
118
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
119
|
|
120
|
public page: number = 1;
|
121
|
public pageSize: number = 10;
|
122
|
|
123
|
constructor () {}
|
124
|
|
125
|
ngOnInit() {
|
126
|
this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;
|
127
|
this.linkToSearchResearchData = this.properties.searchLinkToAdvancedDatasets;
|
128
|
this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
|
129
|
this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps;
|
130
|
}
|
131
|
|
132
|
ngOnDestroy() {}
|
133
|
|
134
|
totalPages(totalResults: number): number {
|
135
|
let totalPages:any = totalResults/this.pageSize;
|
136
|
if(!(Number.isInteger(totalPages))) {
|
137
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
138
|
}
|
139
|
return totalPages;
|
140
|
}
|
141
|
|
142
|
updatePage($event) {
|
143
|
this.page = $event.value;
|
144
|
}
|
145
|
|
146
|
public getKeys( map) {
|
147
|
return Array.from(map.keys());
|
148
|
}
|
149
|
}
|