1
|
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
2
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
3
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
4
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
5
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
6
|
import {properties} from '../../../../environments/environment';
|
7
|
import {NumberUtils} from '../../utils/number-utils.class';
|
8
|
import {Subscription, zip} from 'rxjs';
|
9
|
|
10
|
@Component({
|
11
|
selector: 'numbers',
|
12
|
template: `
|
13
|
<ng-container *ngIf="!loading">
|
14
|
<div class="uk-container uk-section uk-padding-remove-bottom uk-text-center">
|
15
|
<div class="uk-grid uk-grid-large uk-child-width-1-3@m" uk-grid>
|
16
|
<div *ngIf="fundersSize">
|
17
|
<h3>
|
18
|
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
|
19
|
{{fundersSize.number|number}}<span class="number-size">{{fundersSize.size}}</span>
|
20
|
</a>
|
21
|
</h3>
|
22
|
<span class="uk-text-uppercase uk-text-large">Funders</span>
|
23
|
</div>
|
24
|
<div *ngIf="datasourcesSize">
|
25
|
<h3>
|
26
|
<a href="https://explore.openaire.eu/search/find/dataproviders" target="_blank"
|
27
|
class="uk-text-bold number">
|
28
|
{{datasourcesSize.number|number}}<span class="number-size">{{datasourcesSize.size}}</span>
|
29
|
</a>
|
30
|
</h3>
|
31
|
<span class="uk-text-uppercase uk-text-large">Content providers</span>
|
32
|
</div>
|
33
|
<div *ngIf="projectsSize">
|
34
|
<h3>
|
35
|
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
|
36
|
{{projectsSize.number|number}}<span class="number-size">{{projectsSize.size}}</span>
|
37
|
</a>
|
38
|
</h3>
|
39
|
<span class="uk-text-uppercase uk-text-large">Projects</span>
|
40
|
</div>
|
41
|
</div>
|
42
|
</div>
|
43
|
<div class="uk-section" [ngClass]="backgroundClass">
|
44
|
<div class="uk-container">
|
45
|
<div class="uk-grid uk-flex-center uk-margin-auto-left@m uk-margin-auto-right@m uk-grid-large" uk-grid>
|
46
|
<div *ngIf="publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
47
|
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
|
48
|
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=publications&qf=false"
|
49
|
target="_blank" class="number uk-text-bold uk-margin-bottom">{{publicationsSize.count|number}} </a>
|
50
|
<div class="uk-text-uppercase uk-flex uk-flex-middle">
|
51
|
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
52
|
<span>publications</span>
|
53
|
</div>
|
54
|
</div>
|
55
|
</div>
|
56
|
<div *ngIf="datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
57
|
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
|
58
|
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=datasets&qf=false"
|
59
|
target="_blank" class="number uk-text-bold uk-margin-bottom">{{datasetsSize.count|number}} </a>
|
60
|
<div class="uk-text-uppercase uk-flex uk-flex-middle">
|
61
|
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
62
|
<span>research data</span>
|
63
|
</div>
|
64
|
</div>
|
65
|
</div>
|
66
|
<div *ngIf="softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
67
|
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
|
68
|
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=software&qf=false"
|
69
|
target="_blank" class="number uk-text-bold uk-margin-bottom">{{softwareSize.count|number}} </a>
|
70
|
<div class="uk-text-uppercase uk-flex uk-flex-middle">
|
71
|
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
72
|
<span>software</span>
|
73
|
</div>
|
74
|
</div>
|
75
|
</div>
|
76
|
<div *ngIf="otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
77
|
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
|
78
|
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=other&qf=false"
|
79
|
target="_blank" class="number uk-text-bold uk-margin-bottom">{{otherSize.count|number}} </a>
|
80
|
<div class="uk-text-uppercase uk-flex uk-flex-middle">
|
81
|
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
82
|
<span>other research products</span>
|
83
|
</div>
|
84
|
</div>
|
85
|
</div>
|
86
|
</div>
|
87
|
</div>
|
88
|
</div>
|
89
|
</ng-container>
|
90
|
<div *ngIf="loading" class="uk-container uk-section uk-text-center">
|
91
|
<loading [color]="colorClass"></loading>
|
92
|
</div>
|
93
|
`,
|
94
|
})
|
95
|
export class NumbersComponent implements OnInit, OnDestroy {
|
96
|
@Input() colorClass = 'portal-color';
|
97
|
@Input() backgroundClass = null;
|
98
|
@Input() refineQuery = null;
|
99
|
public properties: EnvProperties = properties;
|
100
|
public publicationsSize: any = null;
|
101
|
public datasetsSize: any = null;
|
102
|
public softwareSize: any = null;
|
103
|
public otherSize: any = null;
|
104
|
public fundersSize: any = null;
|
105
|
public projectsSize: any = null;
|
106
|
public datasourcesSize: any = null;
|
107
|
public loading: boolean = true;
|
108
|
private subs: any[] = [];
|
109
|
|
110
|
constructor(private searchResearchResultsService: SearchResearchResultsService,
|
111
|
private searchDataprovidersService: SearchDataprovidersService,
|
112
|
private refineFieldResultsService: RefineFieldResultsService) {
|
113
|
}
|
114
|
|
115
|
ngOnInit() {
|
116
|
this.subs.push(zip(
|
117
|
this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery),
|
118
|
this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery),
|
119
|
this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, this.refineQuery),
|
120
|
this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, this.refineQuery),
|
121
|
this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery),
|
122
|
this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery)
|
123
|
).subscribe((data: any[]) => {
|
124
|
if (data[0] && data[0] > 0) {
|
125
|
this.publicationsSize = NumberUtils.roundNumber(data[0]);
|
126
|
}
|
127
|
if (data[1] && data[1] > 0) {
|
128
|
this.datasetsSize = NumberUtils.roundNumber(data[1]);
|
129
|
}
|
130
|
if (data[2] && data[2] > 0) {
|
131
|
this.softwareSize = NumberUtils.roundNumber(data[2]);
|
132
|
}
|
133
|
if (data[3] && data[3] > 0) {
|
134
|
this.otherSize = NumberUtils.roundNumber(data[3]);
|
135
|
}
|
136
|
if (data[4][0] && data[4][0] > 0) {
|
137
|
this.projectsSize = NumberUtils.roundNumber(data[4][0]);
|
138
|
}
|
139
|
if (data[4][1] && data[4][1].length > 0 && data[4][1][0].filterId == 'funder' && data[4][1][0].values) {
|
140
|
this.fundersSize = NumberUtils.roundNumber(data[4][1][0].values.length);
|
141
|
}
|
142
|
if (data[5] && data[5] > 0) {
|
143
|
this.datasourcesSize = NumberUtils.roundNumber(data[5]);
|
144
|
}
|
145
|
this.loading = false;
|
146
|
}, err => {
|
147
|
this.handleError('Error getting numbers', err);
|
148
|
this.loading = false;
|
149
|
}));
|
150
|
}
|
151
|
|
152
|
ngOnDestroy() {
|
153
|
this.subs.forEach(sub => {
|
154
|
if (sub instanceof Subscription) {
|
155
|
sub.unsubscribe();
|
156
|
}
|
157
|
});
|
158
|
}
|
159
|
|
160
|
private handleError(message: string, error) {
|
161
|
console.error('Numbers: ' + message, error);
|
162
|
}
|
163
|
}
|