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