1
|
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Location} from '@angular/common';
|
5
|
|
6
|
import { SearchPublicationsComponent } from '../simple/searchPublications.component';
|
7
|
import { SearchDataprovidersComponent } from '../simple/searchDataproviders.component';
|
8
|
import { SearchProjectsComponent } from '../simple/searchProjects.component';
|
9
|
import { SearchDatasetsComponent } from '../simple/searchDatasets.component';
|
10
|
import { SearchOrganizationsComponent } from '../simple/searchOrganizations.component';
|
11
|
import { SearchPeopleComponent } from '../simple/searchPeople.component';
|
12
|
|
13
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
14
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
15
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
16
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
17
|
import {SearchPeopleService} from '../../services/searchPeople.service';
|
18
|
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
|
19
|
|
20
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
21
|
import {SearchFields} from '../../utils/properties/searchFields';
|
22
|
|
23
|
@Component({
|
24
|
selector: 'search-find',
|
25
|
template: `
|
26
|
|
27
|
<div class="uk-margin-top">
|
28
|
<div class="page-header">
|
29
|
<h1>{{pageTitle}}</h1>
|
30
|
</div>
|
31
|
<div class="uk-grid">
|
32
|
<div class="uk-width-1-1 uk-margin uk-panel uk-panel-box uk-panel-box-default">
|
33
|
|
34
|
<search-form [(keyword)]=keyword (keywordChange)="keywordChanged($event)"></search-form>
|
35
|
</div>
|
36
|
<div class=" uk-grid uk-margin-top uk-width-1-1">
|
37
|
|
38
|
<ul class="uk-tab uk-tab-left uk-width-large-1-5 uk-width-small-1-1 " data-uk-tab="{connect:'#searchtabs'}">
|
39
|
<li (click)="searchPublications()" >
|
40
|
<a href="#pubsTab">
|
41
|
Publications {{((keyword.length > 0)?'('+searchPublicationsComponent.searchUtils.totalResults+')':'')}}
|
42
|
</a>
|
43
|
</li>
|
44
|
<li (click)="searchDatasets()">
|
45
|
<a href="#dataTab" (click)="searchDatasets()">
|
46
|
Datasets {{((keyword.length > 0)?'('+searchDatasetsComponent.searchUtils.totalResults+')':'')}}
|
47
|
</a>
|
48
|
</li>
|
49
|
<li (click)="searchProjects()" >
|
50
|
<a href="#projectsTab">
|
51
|
Projects {{((keyword.length > 0)?'('+searchProjectsComponent.searchUtils.totalResults+')':'')}}
|
52
|
</a>
|
53
|
</li>
|
54
|
<li (click)="searchDataProviders()" >
|
55
|
<a href="#dataProviderTab">
|
56
|
Data Providers {{((keyword.length > 0)?'('+searchDataProvidersComponent.searchUtils.totalResults+')':'')}}
|
57
|
</a>
|
58
|
</li>
|
59
|
<li (click)="searchOrganizations()" >
|
60
|
<a href="#organizationsTab" >
|
61
|
Organizations {{((keyword.length > 0)?'('+searchOrganizationsComponent.searchUtils.totalResults+')':'')}}
|
62
|
</a>
|
63
|
</li>
|
64
|
<li (click)="searchPeople()" >
|
65
|
<a href="#peopleTab" >
|
66
|
People {{((keyword.length > 0)?'('+searchPeopleComponent.searchUtils.totalResults+')':'')}}
|
67
|
</a>
|
68
|
</li>
|
69
|
|
70
|
|
71
|
|
72
|
</ul>
|
73
|
|
74
|
<ul id="searchtabs" class="uk-switcher uk-margin-left uk-width-large-3-4 uk-width-small-1-1">
|
75
|
<li id="pubsTab" class="uk-active">
|
76
|
<div *ngIf = "keyword.length > 0">
|
77
|
<div class = "uk-text-right" *ngIf = "searchPublicationsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchPublications" >View all {{searchPublicationsComponent.searchUtils.totalResults}} results</a></div>
|
78
|
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result>
|
79
|
</div>
|
80
|
<div *ngIf = "keyword.length == 0 && activeTab=='publications'" >
|
81
|
<browse-entities entityName="publication" baseUrl="/search/find/publications" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
|
82
|
</div>
|
83
|
</li>
|
84
|
<li id="dataTab">
|
85
|
<div *ngIf = "keyword.length > 0">
|
86
|
<div class = "uk-text-right" *ngIf = "searchDatasetsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchDatasets" >View all {{searchDatasetsComponent.searchUtils.totalResults}} results</a></div>
|
87
|
<search-result [(results)]="searchDatasetsComponent.results" [(status)]= "searchDatasetsComponent.status"></search-result>
|
88
|
</div>
|
89
|
<div *ngIf = "keyword.length == 0 && activeTab=='datasets'" >
|
90
|
<browse-entities entityName="dataset" baseUrl="/search/find/datasets" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
|
91
|
</div>
|
92
|
</li>
|
93
|
<li id="projectsTab" >
|
94
|
<div *ngIf = "keyword.length > 0">
|
95
|
<div class = "uk-text-right" *ngIf = "searchProjectsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchProjects" >View all {{searchProjectsComponent.searchUtils.totalResults}} results</a></div>
|
96
|
<search-result [(results)]="searchProjectsComponent.results" [(status)]= "searchProjectsComponent.status"></search-result>
|
97
|
</div>
|
98
|
<div *ngIf = "keyword.length == 0 && activeTab=='projects'" >
|
99
|
<browse-entities entityName="project" baseUrl="/search/find/projects" [refineFields]=searchFields.PROJECT_REFINE_FIELDS></browse-entities>
|
100
|
</div>
|
101
|
</li>
|
102
|
<li id="dataProviderTab">
|
103
|
<div *ngIf = "keyword.length > 0">
|
104
|
<div class = "uk-text-right" *ngIf = "searchDataProvidersComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchDataproviders" >View all {{searchDataProvidersComponent.searchUtils.totalResults}} results</a></div>
|
105
|
<search-result [(results)]="searchDataProvidersComponent.results" [(status)]= "searchDataProvidersComponent.status"></search-result>
|
106
|
</div>
|
107
|
<div *ngIf = "keyword.length == 0 && activeTab=='dataproviders'" >
|
108
|
<browse-entities entityName="dataprovider" baseUrl="/search/find/dataproviders" [refineFields]=searchFields.DATASOURCE_REFINE_FIELDS></browse-entities>
|
109
|
</div>
|
110
|
</li>
|
111
|
<li id="organizationsTab" >
|
112
|
<div *ngIf = "keyword.length > 0">
|
113
|
<div class = "uk-text-right" *ngIf = "searchOrganizationsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchOrganizations" >View all {{searchOrganizationsComponent.searchUtils.totalResults}} results</a></div>
|
114
|
<search-result [(results)]="searchOrganizationsComponent.results" [(status)]= "searchOrganizationsComponent.status"></search-result>
|
115
|
</div>
|
116
|
<div *ngIf = "keyword.length == 0 && activeTab=='organizations'" >
|
117
|
<browse-entities entityName="organization" baseUrl="/search/find/organizations" [refineFields]=searchFields.ORGANIZATION_REFINE_FIELDS></browse-entities>
|
118
|
</div>
|
119
|
</li>
|
120
|
<li id="peopleTab">
|
121
|
<div *ngIf = "keyword.length > 0">
|
122
|
<div class = "uk-text-right" *ngIf = "searchPeopleComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchPeople" >View all {{searchPeopleComponent.searchUtils.totalResults}} results</a></div>
|
123
|
<search-result [(results)]="searchPeopleComponent.results" [(status)]= "searchPeopleComponent.status"></search-result>
|
124
|
</div>
|
125
|
<div *ngIf = "keyword.length == 0 && activeTab=='people'" >
|
126
|
<div class="uk-alert uk-alert-info" role="alert">No person statistics found</div>
|
127
|
|
128
|
</div>
|
129
|
</li>
|
130
|
</ul>
|
131
|
</div>
|
132
|
|
133
|
|
134
|
</div>
|
135
|
`
|
136
|
})
|
137
|
export class SearchComponent {
|
138
|
public sub: any;
|
139
|
public subPublicationsCount: any;
|
140
|
public subDatasetsCount: any;
|
141
|
public subProjectsCount: any;
|
142
|
public subDataprovidersCount: any;
|
143
|
public subOrganizationsCount: any;
|
144
|
public subPeopleCount: any;
|
145
|
|
146
|
public reloadPublications: boolean;
|
147
|
public reloadDatasets: boolean;
|
148
|
public reloadProjects: boolean;
|
149
|
public reloadDataproviders: boolean;
|
150
|
public reloadOrganizations: boolean;
|
151
|
public reloadPeople: boolean;
|
152
|
|
153
|
|
154
|
public pageTitle = "Search in OpenAIRE"
|
155
|
public keyword:string = "";
|
156
|
public publications:string[];
|
157
|
public datasets:string[];
|
158
|
public projectsTab:string[];
|
159
|
public dataproviders:string[];
|
160
|
public organizations:string[];
|
161
|
public people:string[];
|
162
|
|
163
|
public activeTab = "publications";
|
164
|
public linkToSearchPublications = "";
|
165
|
public linkToSearchProjects = "";
|
166
|
public linkToSearchDataproviders = "";
|
167
|
public linkToSearchDatasets = "";
|
168
|
public linkToSearchOrganizations = "";
|
169
|
public linkToSearchPeople = "";
|
170
|
|
171
|
public searchPublicationsComponent : SearchPublicationsComponent;
|
172
|
public searchDataProvidersComponent : SearchDataprovidersComponent;
|
173
|
public searchProjectsComponent : SearchProjectsComponent;
|
174
|
public searchDatasetsComponent: SearchDatasetsComponent;
|
175
|
public searchOrganizationsComponent: SearchOrganizationsComponent;
|
176
|
public searchPeopleComponent: SearchPeopleComponent;
|
177
|
public searchFields:SearchFields = new SearchFields();
|
178
|
|
179
|
public subPub;public subData;public subProjects;public subOrg;public subPeople; public subDataPr;
|
180
|
constructor ( private route: ActivatedRoute,
|
181
|
private _searchPublicationsService: SearchPublicationsService,
|
182
|
private _searchDataprovidersService: SearchDataprovidersService,
|
183
|
private _searchProjectsService: SearchProjectsService,
|
184
|
private _searchDatasetsService: SearchDatasetsService,
|
185
|
private _searchOrganizationsService: SearchOrganizationsService,
|
186
|
private _searchPeopleService: SearchPeopleService,
|
187
|
private location: Location ) {
|
188
|
this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);
|
189
|
this.searchDataProvidersComponent = new SearchDataprovidersComponent(this.route,this._searchDataprovidersService);
|
190
|
this.searchProjectsComponent = new SearchProjectsComponent(this.route, this._searchProjectsService);
|
191
|
this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService);
|
192
|
this.searchOrganizationsComponent = new SearchOrganizationsComponent(this.route, this._searchOrganizationsService);
|
193
|
this.searchPeopleComponent = new SearchPeopleComponent(this.route, this._searchPeopleService);
|
194
|
}
|
195
|
|
196
|
public ngOnInit() {
|
197
|
this.sub = this.route.queryParams.subscribe(params => {
|
198
|
this.keyword = (params['keyword'])?params['keyword']:"";
|
199
|
if(this.keyword !=null && this.keyword.length > 0){
|
200
|
this.reloadTabs();
|
201
|
this.searchPublications();
|
202
|
this.count();
|
203
|
}
|
204
|
});
|
205
|
}
|
206
|
public ngOnDestroy() {
|
207
|
this.sub.unsubscribe();
|
208
|
if(this.keyword !=null && this.keyword.length > 0){
|
209
|
if(this.subPub){
|
210
|
this.subPub.unsubscribe();
|
211
|
}
|
212
|
if(this.subData){
|
213
|
this.subData.unsubscribe();
|
214
|
}
|
215
|
if(this.subProjects){
|
216
|
this.subProjects.unsubscribe();
|
217
|
}
|
218
|
if(this.subOrg){
|
219
|
this.subOrg.unsubscribe();
|
220
|
}
|
221
|
if(this.subPeople){
|
222
|
this.subPeople.unsubscribe();
|
223
|
}
|
224
|
if(this.subDataPr){
|
225
|
this.subDataPr.unsubscribe();
|
226
|
}
|
227
|
this.subPublicationsCount.unsubscribe();
|
228
|
this.subDatasetsCount.unsubscribe();
|
229
|
this.subProjectsCount.unsubscribe();
|
230
|
//this.subDataprovidersCount.unsubscribe();
|
231
|
this.subOrganizationsCount.unsubscribe();
|
232
|
this.subPeopleCount.unsubscribe();
|
233
|
}
|
234
|
}
|
235
|
public searchPublications() {
|
236
|
this.activeTab = "publications";
|
237
|
if(this.reloadPublications) {
|
238
|
this.reloadPublications = false;
|
239
|
this.searchPublicationsComponent.getResults(this.keyword, false, 1, 10);
|
240
|
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications() + "?keyword=" + this.keyword;
|
241
|
}
|
242
|
}
|
243
|
public searchDatasets() {
|
244
|
this.activeTab = "datasets";
|
245
|
if(this.reloadDatasets) {
|
246
|
this.reloadDatasets = false;
|
247
|
this.searchDatasetsComponent.getResults(this.keyword, false, 1, 10);
|
248
|
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets() + "?keyword=" + this.keyword;
|
249
|
}
|
250
|
}
|
251
|
public searchProjects() {
|
252
|
this.activeTab = "projects";
|
253
|
if(this.reloadProjects) {
|
254
|
this.reloadProjects = false;
|
255
|
this.searchProjectsComponent.getResults(this.keyword, false, 1, 10);
|
256
|
this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects() + "?keyword=" + this.keyword;
|
257
|
}
|
258
|
}
|
259
|
public searchDataProviders() {
|
260
|
this.activeTab = "dataproviders";
|
261
|
if(this.reloadDataproviders) {
|
262
|
this.reloadDataproviders = false;
|
263
|
this.searchDataProvidersComponent.getResults(this.keyword, false, 1, 10);
|
264
|
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders() + "?keyword=" + this.keyword;
|
265
|
}
|
266
|
}
|
267
|
public searchOrganizations() {
|
268
|
this.activeTab = "organizations";
|
269
|
if(this.reloadOrganizations) {
|
270
|
this.reloadOrganizations = false;
|
271
|
this.searchOrganizationsComponent.getResults(this.keyword, false, 1, 10);
|
272
|
this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations() + "?keyword=" + this.keyword;
|
273
|
}
|
274
|
}
|
275
|
public searchPeople() {
|
276
|
this.activeTab = "people";
|
277
|
if(this.reloadPeople) {
|
278
|
this.reloadPeople = false;
|
279
|
this.searchPeopleComponent.getResults(this.keyword, false, 1, 10);
|
280
|
this.linkToSearchPeople = OpenaireProperties.getLinkToSearchPeople() + "?keyword=" + this.keyword;
|
281
|
}
|
282
|
}
|
283
|
|
284
|
public keywordChanged($event){
|
285
|
this.keyword = $event.value;
|
286
|
console.info("Search Find: search with keyword \"" + this.keyword + "\"" );
|
287
|
if(location.pathname.indexOf("search/find") ==-1){
|
288
|
this.location.go(location.pathname+"search/find","?keyword=" + this.keyword);
|
289
|
}else{
|
290
|
this.location.go(location.pathname,"?keyword=" + this.keyword);
|
291
|
}
|
292
|
|
293
|
//unsubscribeSearch();
|
294
|
|
295
|
this.reloadTabs();
|
296
|
if(this.activeTab == "publications") {
|
297
|
this.searchPublications();
|
298
|
}
|
299
|
if(this.activeTab == "projects") {
|
300
|
this.searchProjects();
|
301
|
}
|
302
|
if(this.activeTab == "dataproviders") {
|
303
|
this.searchDataProviders();
|
304
|
}
|
305
|
if(this.activeTab == "datasets") {
|
306
|
this.searchDatasets();
|
307
|
}
|
308
|
if(this.activeTab == "organizations") {
|
309
|
this.searchOrganizations();
|
310
|
}
|
311
|
if(this.activeTab == "people") {
|
312
|
this.searchPeople();
|
313
|
}
|
314
|
this.count();
|
315
|
}
|
316
|
|
317
|
private count() {
|
318
|
this.subPublicationsCount = this.route.queryParams.subscribe(params => {
|
319
|
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe(
|
320
|
data => {
|
321
|
this.searchPublicationsComponent.searchUtils.totalResults = data;
|
322
|
},
|
323
|
err => {
|
324
|
console.log(err);
|
325
|
}
|
326
|
);
|
327
|
})
|
328
|
|
329
|
this.subDatasetsCount = this.route.queryParams.subscribe(params => {
|
330
|
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe(
|
331
|
data => {
|
332
|
this.searchDatasetsComponent.searchUtils.totalResults = data;
|
333
|
},
|
334
|
err => {
|
335
|
console.log(err);
|
336
|
}
|
337
|
);
|
338
|
})
|
339
|
|
340
|
this.subProjectsCount = this.route.queryParams.subscribe(params => {
|
341
|
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe(
|
342
|
data => {
|
343
|
this.searchProjectsComponent.searchUtils.totalResults = data;
|
344
|
},
|
345
|
err => {
|
346
|
console.log(err);
|
347
|
}
|
348
|
);
|
349
|
})
|
350
|
|
351
|
this.searchDataProvidersComponent.getNumForSearch(this.keyword);
|
352
|
|
353
|
this.subOrganizationsCount = this.route.queryParams.subscribe(params => {
|
354
|
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe(
|
355
|
data => {
|
356
|
this.searchOrganizationsComponent.searchUtils.totalResults = data;
|
357
|
},
|
358
|
err => {
|
359
|
console.log(err);
|
360
|
}
|
361
|
);
|
362
|
})
|
363
|
|
364
|
this.subPeopleCount = this.route.queryParams.subscribe(params => {
|
365
|
this.subPeople = this._searchPeopleService.numOfSearchPeople(this.keyword).subscribe(
|
366
|
data => {
|
367
|
this.searchPeopleComponent.searchUtils.totalResults = data;
|
368
|
},
|
369
|
err => {
|
370
|
console.log(err);
|
371
|
}
|
372
|
);
|
373
|
})
|
374
|
}
|
375
|
|
376
|
private reloadTabs() {
|
377
|
this.reloadPublications = true;
|
378
|
this.reloadDatasets = true;
|
379
|
this.reloadProjects = true;
|
380
|
this.reloadDataproviders = true;
|
381
|
this.reloadOrganizations = true;
|
382
|
this.reloadPeople = true;
|
383
|
}
|
384
|
|
385
|
}
|