1
|
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
2
|
import {Observable} from 'rxjs';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Location} from '@angular/common';
|
5
|
import "rxjs/add/observable/zip";
|
6
|
import {Title, Meta} from '@angular/platform-browser';
|
7
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
8
|
import { FetchDataproviders} from '../openaireLibrary/utils/fetchEntitiesClasses/fetchDataproviders.class';
|
9
|
import { SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
|
10
|
import { SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
|
11
|
import { SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
|
12
|
import { RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
|
13
|
import { SearchFields} from '../openaireLibrary/utils/properties/searchFields';
|
14
|
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class';
|
15
|
|
16
|
import { RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
|
17
|
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
18
|
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
19
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
20
|
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
21
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
22
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
23
|
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
24
|
|
25
|
@Component({
|
26
|
selector: 'home',
|
27
|
templateUrl: 'home.component.html',
|
28
|
})
|
29
|
export class HomeComponent {
|
30
|
public piwiksub: any;
|
31
|
public subfunders: any;
|
32
|
|
33
|
// MAX 12 logos in every slide
|
34
|
public logos = {
|
35
|
"publication": [
|
36
|
[
|
37
|
"logo-pubmed.png",
|
38
|
"logo-arxiv.png",
|
39
|
"logo-base.png",
|
40
|
"logo-scielo.png",
|
41
|
"logo-la-referencia.png",
|
42
|
"logo-soar.png",
|
43
|
"logo-repec.png",
|
44
|
"logo-core.png",
|
45
|
"logo-zenodo.png",
|
46
|
"logo-narcis.png"
|
47
|
],
|
48
|
[
|
49
|
"logo-crossref.png",
|
50
|
"logo-unpaywall.png",
|
51
|
"logo-elsevier.png",
|
52
|
"logo-spring-nature.png",
|
53
|
"logo-frontiers.png",
|
54
|
"logo-opencitations.png",
|
55
|
"logo-doaj.png",
|
56
|
"logo-microsoft.png",
|
57
|
"logo-plos.png",
|
58
|
"logo-f1000.png",
|
59
|
"logo-copernicus.png"
|
60
|
]
|
61
|
],
|
62
|
"software": [
|
63
|
[
|
64
|
"logo-software-heritage.png",
|
65
|
"logo-github.png",
|
66
|
"logo-doecode.png",
|
67
|
"logo-bitbucket.png",
|
68
|
"logo-elixir-bio-tools.png",
|
69
|
"logo-google-code.png",
|
70
|
"logo-sourceforge.png",
|
71
|
"logo-zenodo.png"
|
72
|
]
|
73
|
],
|
74
|
"dataset": [
|
75
|
[
|
76
|
"logo-scholexplorer.png",
|
77
|
"logo-zenodo.png",
|
78
|
"logo-datacite.png",
|
79
|
"logo-pangea.png",
|
80
|
"logo-figshare.png",
|
81
|
"logo-protocols.png",
|
82
|
"logo-opentrials.png",
|
83
|
"logo-kaggle.png",
|
84
|
"logo-reactome.png",
|
85
|
"logo-easy.png",
|
86
|
"logo-dryad.png"
|
87
|
]
|
88
|
],
|
89
|
//"other": [],
|
90
|
"persistent": [
|
91
|
[
|
92
|
"logo-re3data.png",
|
93
|
"logo-orcid.png",
|
94
|
"logo-opendoar.png",
|
95
|
"logo-grid.png"
|
96
|
]
|
97
|
],
|
98
|
"funder": [
|
99
|
[
|
100
|
"logo-european-commision.png",
|
101
|
"logo-nsf.png",
|
102
|
"logo-miur.png",
|
103
|
"logo-nhmrc.png",
|
104
|
"logo-sfi.png",
|
105
|
"logo-nwo.png",
|
106
|
"logo-welcome-trust.png",
|
107
|
"logo-fct.png",
|
108
|
"logo-gsrt.png",
|
109
|
"logo-fnsnf.png"
|
110
|
]
|
111
|
]
|
112
|
};
|
113
|
|
114
|
public pageTitle = "OpenAIRE";
|
115
|
public keyword:string = "";
|
116
|
|
117
|
public searchFields:SearchFields = new SearchFields();
|
118
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
119
|
public routerHelper:RouterHelper = new RouterHelper();
|
120
|
|
121
|
public publicationsSize:any = null;
|
122
|
public datasetsSize:any = null;
|
123
|
public datasetsLinkedSize:any = null;
|
124
|
public softwareLinkedSize:any = null;
|
125
|
public softwareSize: any = null;
|
126
|
public otherSize: any = null;
|
127
|
public fundersSize:any = null;
|
128
|
public projectsSize:any = null;
|
129
|
public datasourcesSize:any = null;
|
130
|
|
131
|
private numResults: number = 2;
|
132
|
public fetchDataproviders : FetchDataproviders;
|
133
|
|
134
|
showPublications:boolean= false;
|
135
|
showDatasets:boolean= false;
|
136
|
showSoftware: boolean = false;
|
137
|
showOrp: boolean = false;
|
138
|
showProjects:boolean= false;
|
139
|
showDataProviders:boolean= false;
|
140
|
properties: EnvProperties;
|
141
|
public readMore: boolean = false;
|
142
|
public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
143
|
public subSoft;public subDataLinked; public subSoftLinked;
|
144
|
public subOrp;
|
145
|
trelloImg: string = 'trello.svg';
|
146
|
trelloImg2: string = 'trello.svg';
|
147
|
|
148
|
resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
149
|
filter: null,
|
150
|
selected: true,
|
151
|
filterId: "resultbestaccessright",
|
152
|
value: "Open Access"
|
153
|
};
|
154
|
selectedEntity = "all";
|
155
|
selectedEntitySimpleUrl;
|
156
|
selectedEntityAdvancedUrl;
|
157
|
resultTypes = {publication:true, dataset:true, software:true, other:true};
|
158
|
public pageContents = null;
|
159
|
|
160
|
constructor (
|
161
|
private route: ActivatedRoute,
|
162
|
private _router: Router,
|
163
|
private _searchResearchResultsService: SearchResearchResultsService,
|
164
|
private _searchDataprovidersService: SearchDataprovidersService,
|
165
|
private _searchProjectsService: SearchProjectsService,
|
166
|
private _searchOrganizationsService: SearchOrganizationsService,
|
167
|
private _refineFieldResultsService:RefineFieldResultsService,
|
168
|
private location: Location, private _piwikService:PiwikService,
|
169
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
170
|
private helper: HelperService, private router: Router
|
171
|
) {
|
172
|
|
173
|
var description = "openAIRE explore, open access, publications, research results, European commission, search";
|
174
|
|
175
|
var title = "OpenAIRE | Explore";
|
176
|
|
177
|
this._title.setTitle(title);
|
178
|
this._meta.updateTag({content:description},"name='description'");
|
179
|
this._meta.updateTag({content:description},"property='og:description'");
|
180
|
this._meta.updateTag({content:title},"property='og:title'");
|
181
|
|
182
|
|
183
|
//this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
184
|
}
|
185
|
|
186
|
private getPageContents() {
|
187
|
this.helper.getPageHelpContents(this.properties, 'openaire', this._router.url).subscribe(contents => {
|
188
|
this.pageContents = contents;
|
189
|
})
|
190
|
}
|
191
|
|
192
|
public getKeys(obj: {}) {
|
193
|
return Object.keys(obj);
|
194
|
}
|
195
|
|
196
|
createRange(number){
|
197
|
var items: number[] = [];
|
198
|
for(var i = 1; i <= number; i++){
|
199
|
items.push(i);
|
200
|
}
|
201
|
return items;
|
202
|
}
|
203
|
|
204
|
public ceil(num: number) {
|
205
|
return Math.ceil(num);
|
206
|
}
|
207
|
|
208
|
public ngOnInit() {
|
209
|
this.route.data
|
210
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
211
|
this.properties = data.envSpecific;
|
212
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
213
|
this.getPageContents();
|
214
|
|
215
|
if(this.properties!=null){
|
216
|
var url = this.properties.baseLink+this._router.url;
|
217
|
this._meta.updateTag({content:url},"property='og:url'");
|
218
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
219
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
|
220
|
}
|
221
|
|
222
|
this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
223
|
var showEntity = {};
|
224
|
for(var i=0; i< data['entities'].length; i++){
|
225
|
|
226
|
showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
|
227
|
}
|
228
|
this.showPublications = showEntity["publication"];
|
229
|
this.showDatasets = showEntity["dataset"];
|
230
|
this.showSoftware = showEntity["software"];
|
231
|
this.showOrp = showEntity["orp"];
|
232
|
this.showProjects = showEntity["project"];
|
233
|
this.showDataProviders = showEntity["datasource"];
|
234
|
this.getNumbers();
|
235
|
// if(this.showDataProviders) {
|
236
|
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
237
|
// }
|
238
|
},
|
239
|
error => {
|
240
|
this.handleError("Error getting community information", error);
|
241
|
}
|
242
|
);
|
243
|
}
|
244
|
});
|
245
|
|
246
|
}
|
247
|
public ngOnDestroy() {
|
248
|
if(this.piwiksub){
|
249
|
this.piwiksub.unsubscribe();
|
250
|
}
|
251
|
if(this.subfunders){
|
252
|
this.subfunders.unsubscribe();
|
253
|
}
|
254
|
if(this.subPub){
|
255
|
this.subPub.unsubscribe();
|
256
|
}
|
257
|
if(this.subData){
|
258
|
this.subData.unsubscribe();
|
259
|
}
|
260
|
if(this.subDataLinked){
|
261
|
this.subDataLinked.unsubscribe();
|
262
|
}
|
263
|
if(this.subSoftLinked){
|
264
|
this.subSoftLinked.unsubscribe();
|
265
|
}
|
266
|
// if(this.subProjects){
|
267
|
// this.subProjects.unsubscribe();
|
268
|
// }
|
269
|
// if(this.subOrg){
|
270
|
// this.subOrg.unsubscribe();
|
271
|
// }
|
272
|
if(this.subDataPr){
|
273
|
this.subDataPr.unsubscribe();
|
274
|
}
|
275
|
|
276
|
}
|
277
|
|
278
|
private getNumbers() {
|
279
|
if(this.showPublications){
|
280
|
this.subPub = this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
|
281
|
data => {
|
282
|
if(data && data != null && data > 0 ){
|
283
|
this.publicationsSize = NumberUtils.roundNumber(data);
|
284
|
|
285
|
}
|
286
|
},
|
287
|
err => {
|
288
|
//console.log(err);
|
289
|
this.handleError("Error getting number of publications", err);
|
290
|
}
|
291
|
);
|
292
|
}
|
293
|
if(this.showDatasets){
|
294
|
this.subData = this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
295
|
data => {
|
296
|
if(data && data != null && data > 0 ){
|
297
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
298
|
}
|
299
|
},
|
300
|
err => {
|
301
|
//console.log(err);
|
302
|
this.handleError("Error getting number of research data", err);
|
303
|
}
|
304
|
);
|
305
|
this.subDataLinked = this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties).subscribe(
|
306
|
data => {
|
307
|
if(data && data != null && data > 0 ){
|
308
|
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
|
309
|
}
|
310
|
},
|
311
|
err => {
|
312
|
//console.log(err);
|
313
|
this.handleError("Error getting number of linkedresearch data", err);
|
314
|
}
|
315
|
);
|
316
|
|
317
|
}
|
318
|
if (this.showSoftware) {
|
319
|
this.subSoft = this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
320
|
data => {
|
321
|
if (data && data > 0) {
|
322
|
this.softwareSize = NumberUtils.roundNumber(data);
|
323
|
}else{
|
324
|
this.showSoftware = false;
|
325
|
}
|
326
|
},
|
327
|
err => {
|
328
|
this.handleError("Error getting number of software data", err);
|
329
|
}
|
330
|
);
|
331
|
this.subSoftLinked = this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties).subscribe(
|
332
|
data => {
|
333
|
if(data && data != null && data > 0 ){
|
334
|
this.softwareLinkedSize = NumberUtils.roundNumber(data);
|
335
|
}
|
336
|
},
|
337
|
err => {
|
338
|
//console.log(err);
|
339
|
this.handleError("Error getting number of linked software", err);
|
340
|
}
|
341
|
);
|
342
|
}
|
343
|
if (this.showOrp) {
|
344
|
this.subOrp = this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
345
|
data => {
|
346
|
if (data && data > 0) {
|
347
|
this.otherSize = NumberUtils.roundNumber(data);
|
348
|
}else{
|
349
|
this.showOrp = false;
|
350
|
}
|
351
|
},
|
352
|
err => {
|
353
|
this.handleError("Error getting number of software data", err);
|
354
|
}
|
355
|
);
|
356
|
}
|
357
|
if(this.showProjects){
|
358
|
this.subfunders = this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe(
|
359
|
data => {
|
360
|
|
361
|
|
362
|
if(data[0] && data[0] > 0 ){
|
363
|
this.projectsSize = NumberUtils.roundNumber(data[0]);
|
364
|
}
|
365
|
if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){
|
366
|
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
|
367
|
}
|
368
|
|
369
|
},
|
370
|
err => {
|
371
|
//console.log(err);
|
372
|
this.handleError("Error getting 'funder' field results of projects", err);
|
373
|
});
|
374
|
}
|
375
|
if(this.showDataProviders){
|
376
|
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
|
377
|
data => {
|
378
|
if(data && data != null && data > 0 ){
|
379
|
this.datasourcesSize = NumberUtils.roundNumber(data);
|
380
|
}
|
381
|
|
382
|
},
|
383
|
err => {
|
384
|
//console.log(err);
|
385
|
this.handleError("Error getting number of content providers", err);
|
386
|
}
|
387
|
);
|
388
|
}
|
389
|
}
|
390
|
|
391
|
private handleError(message: string, error) {
|
392
|
console.error("Home Page: "+message, error);
|
393
|
}
|
394
|
entityChanged($event){
|
395
|
this.selectedEntity = $event.entity;
|
396
|
this.selectedEntitySimpleUrl = $event.simpleUrl;
|
397
|
this.selectedEntityAdvancedUrl = $event.advancedUrl;
|
398
|
}
|
399
|
goTo(simple:boolean){
|
400
|
let url = (simple)?this.selectedEntitySimpleUrl:this.selectedEntityAdvancedUrl;
|
401
|
let parameterNames = [];
|
402
|
let parameterValues = [];
|
403
|
if (this.selectedEntity == "result") {
|
404
|
if (this.resultTypes) {
|
405
|
let values = [];
|
406
|
if (this.resultTypes.publication) {
|
407
|
values.push("publications");
|
408
|
}
|
409
|
if (this.resultTypes.dataset) {
|
410
|
values.push("datasets");
|
411
|
}
|
412
|
if (this.resultTypes.software) {
|
413
|
values.push("software");
|
414
|
}
|
415
|
if (this.resultTypes.other) {
|
416
|
values.push("other");
|
417
|
}
|
418
|
if (values.length > 0 && values.length !=4) {
|
419
|
parameterNames.push("type");
|
420
|
parameterValues.push(values.join(","));
|
421
|
}
|
422
|
if (this.resultsQuickFilter) {
|
423
|
parameterNames.push("qf");
|
424
|
parameterValues.push("" + this.resultsQuickFilter.selected);
|
425
|
}
|
426
|
}
|
427
|
}
|
428
|
if(this.keyword.length > 0) {
|
429
|
parameterNames.push("q");
|
430
|
parameterValues.push(this.keyword);
|
431
|
parameterNames.push("op");
|
432
|
parameterValues.push("and");
|
433
|
}
|
434
|
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
|
435
|
}
|
436
|
}
|