Project

General

Profile

1 50169 argiro.kok
import {Component, Input} from '@angular/core';
2
3 57027 konstantin
import { FetchResearchResults } from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
4 50169 argiro.kok
5 50761 argiro.kok
import { ErrorCodes} from '../../utils/properties/errorCodes';
6 57027 konstantin
import { RouterHelper } from '../../utils/routerHelper.class';
7
import { EnvProperties } from '../../utils/properties/env-properties';
8 50169 argiro.kok
9
@Component({
10
    selector: 'relatedDatasourcesTab',
11
    template: `
12 52828 konstantin
        <errorMessages  [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status, fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]"
13 52692 konstantin
                        [type]="'related content providers'" tab_error_class=true>
14
        </errorMessages>
15 50169 argiro.kok
16 52828 konstantin
        <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 58201 konstantin
<!--            <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 58208 konstantin
            <no-load-paging *ngIf="results.size >pageSize"
24 58201 konstantin
                            [type]="'content providers'"
25
                            (pageChange)="updatePage($event)"
26 58208 konstantin
                            [page]="page" [pageSize]="pageSize"
27 58201 konstantin
                            [totalResults]="results.size">
28
            </no-load-paging>
29
30 50169 argiro.kok
            <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 52692 konstantin
                        <th *ngIf="fetchSoftware.results.length > 0 || fetchSoftware.searchUtils.status == errorCodes.ERROR"
43
                            class="uk-text-center">
44
                          Number of Software
45
                        </th>
46 52828 konstantin
                        <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 50169 argiro.kok
                    </tr>
51
                </thead>
52
                <tbody>
53
                  <ng-container *ngIf="results">
54 52828 konstantin
                      <ng-container *ngFor="let id of getKeys(results); let i=index">
55 50169 argiro.kok
                        <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 58208 konstantin
<!--                            *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 50169 argiro.kok
                          </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 58208 konstantin
<!--                            *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 50169 argiro.kok
                          </td>
81
                          <td *ngIf="fetchDatasets.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
82 52692 konstantin
83
                          <td *ngIf="fetchSoftware.results.length > 0" class="uk-text-center">
84 58208 konstantin
<!--                            *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 52692 konstantin
                          </td>
92
                          <td *ngIf="fetchSoftware.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
93 52828 konstantin
94
                          <td *ngIf="fetchOrps.results.length > 0" class="uk-text-center">
95 58208 konstantin
<!--                            *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 52828 konstantin
                          </td>
103
                          <td *ngIf="fetchOrps.searchUtils.status == errorCodes.ERROR" class="uk-text-center">-</td>
104 50169 argiro.kok
                        </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 57027 konstantin
    @Input() fetchPublications : FetchResearchResults;
116
    @Input() fetchDatasets : FetchResearchResults;
117
    @Input() fetchSoftware : FetchResearchResults;
118
    @Input() fetchOrps: FetchResearchResults;
119 52692 konstantin
120 50169 argiro.kok
    // true: preprocessing is not over
121
    @Input() loading: boolean = true;
122
    // Εvery content provider's id is a single key of a map
123 52828 konstantin
    @Input() results: Map<string, {"name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string}>;
124 50586 argiro.kok
    @Input() properties:EnvProperties ;
125 50169 argiro.kok
126
    public linkToSearchPublications: string = "";
127
    public linkToSearchResearchData: string = "";
128 52692 konstantin
    public linkToSearchSoftware: string = "";
129 52828 konstantin
    public linkToSearchOrps: string = "";
130 50169 argiro.kok
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 50586 argiro.kok
      this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;
141
      this.linkToSearchResearchData = this.properties.searchLinkToAdvancedDatasets;
142 52692 konstantin
      this.linkToSearchSoftware     = this.properties.searchLinkToAdvancedSoftware;
143 52828 konstantin
      this.linkToSearchOrps         = this.properties.searchLinkToAdvancedOrps;
144 50169 argiro.kok
    }
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 52828 konstantin
160
    public getKeys( map) {
161
      return Array.from(map.keys());
162
    }
163 50169 argiro.kok
}