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
|
import {AlertModal} from "../../utils/modal/alert";
|
9
|
import {properties} from "../../../../environments/environment";
|
10
|
|
11
|
@Component({
|
12
|
selector: 'relatedDatasourcesTab',
|
13
|
template: `
|
14
|
<errorMessages [status]="[fetchResults.searchUtils.status]"
|
15
|
[type]="'related content providers'" tab_error_class=true>
|
16
|
</errorMessages>
|
17
|
|
18
|
<div *ngIf="fetchResults.searchUtils.status == errorCodes.DONE && !loading">
|
19
|
<div class="uk-text-muted uk-text-small uk-margin-bottom">
|
20
|
*Only top 100 content providers that host research outcomes and are aggregated by {{collectedFromName}} are shown.
|
21
|
</div>
|
22
|
<no-load-paging *ngIf="results.length >pageSize"
|
23
|
[type]="'content providers'"
|
24
|
(pageChange)="updatePage($event)"
|
25
|
[page]="page" [pageSize]="pageSize"
|
26
|
[totalResults]="results.length">
|
27
|
</no-load-paging>
|
28
|
|
29
|
<table class="uk-table uk-table-striped">
|
30
|
<thead>
|
31
|
<tr>
|
32
|
<th class="uk-text-center">Content Provider Name</th>
|
33
|
<th *ngIf="fetchResults.results.length > 0 || fetchResults.searchUtils.status == errorCodes.ERROR"
|
34
|
class="uk-text-center">
|
35
|
Number of Research Outcomes
|
36
|
</th>
|
37
|
</tr>
|
38
|
</thead>
|
39
|
<tbody>
|
40
|
<ng-container *ngIf="results">
|
41
|
<ng-container *ngFor="let result of results; let i=index">
|
42
|
<tr *ngIf="i>=(page-1)*pageSize && i<page*pageSize">
|
43
|
<td class="uk-text-center">
|
44
|
<a [queryParams]="{datasourceId: result.id}" routerLinkActive="router-link-active" [routerLink]="dataProviderUrl"
|
45
|
(click)="onLinkClick()">
|
46
|
{{result.name}}
|
47
|
</a>
|
48
|
</td>
|
49
|
<td *ngIf="fetchResults.results.length > 0" class="uk-text-center">
|
50
|
<a
|
51
|
[queryParams]="routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'f2', 'fv2', 'qf'], ['collectedfromdatasourceid', dataproviderId, 'resulthostingdatasourceid,or', dataproviderId, 'resulthostingdatasourceid', result.id, 'false'])"
|
52
|
routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults"
|
53
|
(click)="onLinkClick()">
|
54
|
{{result.count | number}}
|
55
|
</a>
|
56
|
</td>
|
57
|
</tr>
|
58
|
</ng-container>
|
59
|
</ng-container>
|
60
|
</tbody>
|
61
|
</table>
|
62
|
<no-load-paging *ngIf="results.length >pageSize"
|
63
|
[type]="'content providers'"
|
64
|
(pageChange)="updatePage($event)"
|
65
|
[page]="page" [pageSize]="pageSize"
|
66
|
[totalResults]="results.length">
|
67
|
</no-load-paging>
|
68
|
</div>
|
69
|
`
|
70
|
})
|
71
|
|
72
|
export class RelatedDatasourcesTabComponent {
|
73
|
@Input() dataproviderId: string;
|
74
|
// @Input() fetchPublications : FetchResearchResults;
|
75
|
// @Input() fetchDatasets : FetchResearchResults;
|
76
|
// @Input() fetchSoftware : FetchResearchResults;
|
77
|
// @Input() fetchOrps: FetchResearchResults;
|
78
|
@Input() fetchResults: FetchResearchResults;
|
79
|
|
80
|
// true: preprocessing is not over
|
81
|
@Input() loading: boolean = true;
|
82
|
// Εvery content provider's id is a single key of a map
|
83
|
//@Input() results: Map<string, {"name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string}>;
|
84
|
@Input() results: {"id": string, "name": string, "count": number}[];
|
85
|
@Input() properties:EnvProperties ;
|
86
|
@Input() collectedFromName: string ="[no title available]";
|
87
|
@Input() modal: AlertModal;
|
88
|
|
89
|
public routerHelper:RouterHelper = new RouterHelper();
|
90
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
91
|
|
92
|
public page: number = 1;
|
93
|
public pageSize: number = 10;
|
94
|
public dataProviderUrl;
|
95
|
|
96
|
constructor () {}
|
97
|
|
98
|
ngOnInit() {
|
99
|
this.dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
|
100
|
}
|
101
|
|
102
|
ngOnDestroy() {}
|
103
|
|
104
|
totalPages(totalResults: number): number {
|
105
|
let totalPages:any = totalResults/this.pageSize;
|
106
|
if(!(Number.isInteger(totalPages))) {
|
107
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
108
|
}
|
109
|
return totalPages;
|
110
|
}
|
111
|
|
112
|
updatePage($event) {
|
113
|
this.page = $event.value;
|
114
|
}
|
115
|
|
116
|
public getKeys( map) {
|
117
|
return Array.from(map.keys());
|
118
|
}
|
119
|
|
120
|
public onLinkClick() {
|
121
|
if(this.modal) {
|
122
|
this.modal.cancel();
|
123
|
}
|
124
|
}
|
125
|
}
|