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