1
|
import {ChangeDetectorRef, Component, Input, ViewChild} from '@angular/core';
|
2
|
import {ChangeDetectionStrategy} from '@angular/core';
|
3
|
import {ViewEncapsulation} from '@angular/core';
|
4
|
import {ActivatedRoute, Router} from '@angular/router';
|
5
|
import {Location} from '@angular/common';
|
6
|
import {Title, Meta} from '@angular/platform-browser';
|
7
|
|
8
|
import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
|
9
|
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
10
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
11
|
import {FetchOrganizations} from '../../utils/fetchEntitiesClasses/fetchOrganizations.class';
|
12
|
|
13
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
14
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
15
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
16
|
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
|
17
|
|
18
|
import {SearchFields} from '../../utils/properties/searchFields';
|
19
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
20
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
21
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
22
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
23
|
import {ConfigurationService} from '../../utils/configuration/configuration.service';
|
24
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
25
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
26
|
import {StringUtils} from '../../utils/string-utils.class';
|
27
|
import {SearchCustomFilter} from "../searchUtils/searchUtils.class";
|
28
|
import {Observable} from "rxjs";
|
29
|
import {AdvancedField, Filter} from "../searchUtils/searchHelperClasses.class";
|
30
|
import {SearchResearchResultsComponent} from "../searchResearchResults.component";
|
31
|
import {SearchProjectsComponent} from "../searchProjects.component";
|
32
|
import {SearchOrganizationsComponent} from "../searchOrganizations.component";
|
33
|
import {SearchDataProvidersComponent} from "../searchDataProviders.component";
|
34
|
import {NewSearchPageComponent} from "../searchUtils/newSearchPage.component";
|
35
|
|
36
|
@Component({
|
37
|
changeDetection: ChangeDetectionStrategy.Default,
|
38
|
encapsulation: ViewEncapsulation.Emulated,
|
39
|
selector: 'search-all',
|
40
|
templateUrl: 'searchAll.component.html'
|
41
|
})
|
42
|
export class SearchAllComponent {
|
43
|
public sub: any;
|
44
|
piwiksub: any;
|
45
|
// public reloadResults: boolean;
|
46
|
// public reloadPublications: boolean;
|
47
|
// public reloadDatasets: boolean;
|
48
|
// public reloadSoftware: boolean;
|
49
|
// public reloadOrps: boolean;
|
50
|
// public reloadProjects: boolean;
|
51
|
// public reloadDataproviders: boolean;
|
52
|
// public reloadOrganizations: boolean;
|
53
|
reload:{result:boolean, projects:boolean, datasources: boolean, organizations:boolean} = {result:true, projects:true, datasources: true, organizations:true};
|
54
|
|
55
|
public pageTitle = "Search in OpenAIRE"
|
56
|
public keyword: string = "";
|
57
|
public publications: string[];
|
58
|
public datasets: string[];
|
59
|
public software: string[];
|
60
|
public orps: string[];
|
61
|
public projectsTab: string[];
|
62
|
public dataproviders: string[];
|
63
|
public organizations: string[];
|
64
|
|
65
|
public activeEntity = null;
|
66
|
public linkToSearchPublications = "";
|
67
|
public linkToSearchProjects = "";
|
68
|
public linkToSearchDataproviders = "";
|
69
|
public linkToSearchOrganizations = "";
|
70
|
|
71
|
public fetchPublications: FetchResearchResults;
|
72
|
public fetchDataproviders: FetchDataproviders;
|
73
|
public fetchProjects: FetchProjects;
|
74
|
public fetchDatasets: FetchResearchResults;
|
75
|
public fetchSoftware: FetchResearchResults;
|
76
|
public fetchOrps: FetchResearchResults;
|
77
|
public fetchOrganizations: FetchOrganizations;
|
78
|
|
79
|
public searchFields: SearchFields = new SearchFields();
|
80
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
81
|
public routerHelper: RouterHelper = new RouterHelper();
|
82
|
|
83
|
showPublications: boolean = false;
|
84
|
showDatasets: boolean = false;
|
85
|
showSoftware: boolean = false;
|
86
|
showOrps: boolean = false;
|
87
|
showProjects: boolean = false;
|
88
|
showDataProviders: boolean = false;
|
89
|
showOrganizations: boolean = false;
|
90
|
advancedSearchLink: string = "/search/advanced/publications";
|
91
|
properties: EnvProperties;
|
92
|
@Input() logoURL;
|
93
|
@Input() name;
|
94
|
@Input() customFilter: SearchCustomFilter = null;
|
95
|
@Input() piwikSiteId = null;
|
96
|
@Input() formPlaceholderText = "Search for research results, projects, content providers & organizations in OpenAIRE";
|
97
|
|
98
|
|
99
|
public subPub;
|
100
|
public subData;
|
101
|
public subSoftware;
|
102
|
public subOrps;
|
103
|
public subProjects;
|
104
|
public subOrg;
|
105
|
public subDataPr;
|
106
|
|
107
|
|
108
|
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
109
|
filter: null,
|
110
|
selected: true,
|
111
|
filterId: "resultbestaccessright",
|
112
|
value: "Open Access"
|
113
|
};
|
114
|
|
115
|
resultTypes = {publication: true, dataset: true, software: true, other: true};
|
116
|
|
117
|
//adv Search Form
|
118
|
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
119
|
public fieldIdsMap = this.searchFields.RESULT_FIELDS;
|
120
|
public selectedFields: AdvancedField[] = [];
|
121
|
|
122
|
//new
|
123
|
parameters = {};
|
124
|
disableForms: boolean = true;
|
125
|
@ViewChild (SearchResearchResultsComponent) searchResearchResultsComponent : SearchResearchResultsComponent ;
|
126
|
@ViewChild (SearchProjectsComponent) searchProjectsComponent : SearchProjectsComponent ;
|
127
|
@ViewChild (SearchDataProvidersComponent) searchDataprovidersComponent : SearchDataProvidersComponent ;
|
128
|
@ViewChild (SearchOrganizationsComponent) searchOrganizationsComponent : SearchOrganizationsComponent ;
|
129
|
constructor(private route: ActivatedRoute,
|
130
|
private _router: Router,
|
131
|
private _searchResearchResultsService: SearchResearchResultsService,
|
132
|
private _searchDataprovidersService: SearchDataprovidersService,
|
133
|
private _searchProjectsService: SearchProjectsService,
|
134
|
private _searchOrganizationsService: SearchOrganizationsService,
|
135
|
private _refineFieldResultsService: RefineFieldResultsService,
|
136
|
private location: Location,
|
137
|
private _meta: Meta,
|
138
|
private _title: Title,
|
139
|
private _piwikService: PiwikService,
|
140
|
private config: ConfigurationService,
|
141
|
private seoService: SEOService, private router: Router, private cdr:ChangeDetectorRef) {
|
142
|
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
|
143
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
144
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
145
|
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
|
146
|
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
|
147
|
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
|
148
|
this.fetchOrganizations = new FetchOrganizations(this._searchOrganizationsService);
|
149
|
this.selectedFields.push(new AdvancedField(this.fieldIds[0], this.fieldIdsMap[this.fieldIds[0]].param, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, '', "and"));
|
150
|
|
151
|
}
|
152
|
|
153
|
public ngOnInit() {
|
154
|
this.route.data
|
155
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
156
|
|
157
|
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
|
158
|
var title = "OpenAIRE | Search publications, research data, projects... | OpenAIRE";
|
159
|
this.properties = data.envSpecific;
|
160
|
var url = data.envSpecific.baseLink + this._router.url;
|
161
|
this._title.setTitle(title);
|
162
|
this._meta.updateTag({content: description}, "name='description'");
|
163
|
this._meta.updateTag({content: description}, "property='og:description'");
|
164
|
this._meta.updateTag({content: title}, "property='og:title'");
|
165
|
this._meta.updateTag({content: url}, "property='og:url'");
|
166
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
|
167
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
168
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
|
169
|
|
170
|
}
|
171
|
|
172
|
|
173
|
if ((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity) {
|
174
|
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
175
|
var showEntity = {};
|
176
|
for (var i = 0; i < data['entities'].length; i++) {
|
177
|
|
178
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
179
|
}
|
180
|
this.showPublications = showEntity["publication"];
|
181
|
this.showDatasets = showEntity["dataset"];
|
182
|
this.showProjects = showEntity["project"];
|
183
|
this.showOrganizations = showEntity["organization"];
|
184
|
this.showDataProviders = showEntity["datasource"];
|
185
|
this.showSoftware = showEntity["software"];
|
186
|
this.showOrps = showEntity["orp"];
|
187
|
if (this.customFilter && this.customFilter.queryFieldName == "communityId") {
|
188
|
this.showProjects = false;
|
189
|
this.showOrganizations = false;
|
190
|
this.showDataProviders = false;
|
191
|
}
|
192
|
this.loadAll();
|
193
|
|
194
|
});
|
195
|
} else {
|
196
|
if ((this.customFilter && this.customFilter.queryFieldName == "country")) {
|
197
|
this.showPublications = true;
|
198
|
this.showDatasets = true;
|
199
|
this.showDataProviders = true;
|
200
|
this.showSoftware = true;
|
201
|
this.showOrps = true;
|
202
|
this.showProjects = true;
|
203
|
this.showOrganizations = true;
|
204
|
this.showDataProviders = true;
|
205
|
}
|
206
|
}
|
207
|
this.loadAll();
|
208
|
});
|
209
|
}
|
210
|
|
211
|
loadAll() {
|
212
|
this.reloadTabs();
|
213
|
this.sub = this.route.queryParams.subscribe(params => {
|
214
|
this.parameters = Object.assign({}, params);
|
215
|
this.keyword = (params['keyword']) ? params['keyword'] : (params["q"] ? params["q"] : (params["f0"] && params["f0"] == "q" && params["fv0"]?params["fv0"]:""));
|
216
|
this.selectedFields[0].value = StringUtils.URIDecode(this.keyword);
|
217
|
this.quickFilter.selected = ((params['qf']== undefined || params["qf"] == "true") == true);
|
218
|
if (params["type"] && params["type"].length > 0) {
|
219
|
this.resultTypes['publication'] = (params["type"].split(",").indexOf("publications") != -1);
|
220
|
this.resultTypes['dataset'] = (params["type"].split(",").indexOf("datasets") != -1);
|
221
|
this.resultTypes['software'] = (params["type"].split(",").indexOf("software") != -1);
|
222
|
this.resultTypes['other'] = (params["type"].split(",").indexOf("other") != -1);
|
223
|
}
|
224
|
if(this.activeEntity == null && (!params["active"] || params["active"].length ==0)){
|
225
|
this.activeEntity = this.getDefaultEntityToShow();
|
226
|
}else if(params["active"] && params["active"].length >0 ){
|
227
|
this.activeEntity = ((["result","projects","organizations","datasources"]).indexOf(params["active"])!= -1)?params["active"]:this.getDefaultEntityToShow();
|
228
|
}else if (this.activeEntity !=null && (!params["active"] || params["active"].length ==0)){
|
229
|
this.parameters["active"]=this.activeEntity;
|
230
|
if(location.search && location.search.indexOf("active=") == -1){
|
231
|
this.location.go(location.pathname, ((location.search)?(location.search+"&"):("?")) +"active=" + this.activeEntity);
|
232
|
}
|
233
|
}
|
234
|
if (this.activeEntity == "result") {
|
235
|
this.searchResults();
|
236
|
} else if (this.activeEntity == "projects") {
|
237
|
this.searchProjects();
|
238
|
} else if (this.activeEntity == "datasources") {
|
239
|
this.searchDataProviders();
|
240
|
} else if (this.activeEntity == "organizations") {
|
241
|
this.searchOrganizations();
|
242
|
}
|
243
|
this.count();
|
244
|
});
|
245
|
}
|
246
|
|
247
|
getDefaultEntityToShow(){
|
248
|
if (this.showPublications || this.showDatasets || this.showSoftware || this.showOrps) {
|
249
|
return "result";
|
250
|
} else if (this.showProjects) {
|
251
|
return "projects";
|
252
|
} else if (this.showDataProviders) {
|
253
|
return "content providers";
|
254
|
} else if (this.showOrganizations) {
|
255
|
return "organizations";
|
256
|
}
|
257
|
}
|
258
|
|
259
|
public ngOnDestroy() {
|
260
|
if (this.sub) {
|
261
|
this.sub.unsubscribe();
|
262
|
}
|
263
|
if (this.piwiksub) {
|
264
|
this.piwiksub.unsubscribe();
|
265
|
}
|
266
|
if (this.keyword != null && this.keyword.length > 0) {
|
267
|
if (this.subPub) {
|
268
|
this.subPub.unsubscribe();
|
269
|
}
|
270
|
if (this.subData) {
|
271
|
this.subData.unsubscribe();
|
272
|
}
|
273
|
if (this.subSoftware) {
|
274
|
this.subSoftware.unsubscribe();
|
275
|
}
|
276
|
if (this.subOrps) {
|
277
|
this.subOrps.unsubscribe();
|
278
|
}
|
279
|
if (this.subProjects) {
|
280
|
this.subProjects.unsubscribe();
|
281
|
}
|
282
|
if (this.subOrg) {
|
283
|
this.subOrg.unsubscribe();
|
284
|
}
|
285
|
if (this.subDataPr) {
|
286
|
this.subDataPr.unsubscribe();
|
287
|
}
|
288
|
|
289
|
}
|
290
|
}
|
291
|
|
292
|
public searchResults() {
|
293
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedPublications;//"/search/advanced/publications";
|
294
|
if (this.reload[this.activeEntity] &&
|
295
|
this.fetchPublications.searchUtils.status != this.errorCodes.NONE) {
|
296
|
this.reload[this.activeEntity] = false;
|
297
|
this.linkToSearchPublications = this.properties.searchLinkToPublications;// + "?keyword=" + this.keyword;
|
298
|
}
|
299
|
}
|
300
|
|
301
|
|
302
|
public searchProjects() {
|
303
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;//"/search/advanced/projects";
|
304
|
if (this.reload[this.activeEntity] &&
|
305
|
this.fetchProjects.searchUtils.status != this.errorCodes.NONE ) {
|
306
|
this.reload[this.activeEntity] = false;
|
307
|
this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword;
|
308
|
}
|
309
|
}
|
310
|
|
311
|
public searchDataProviders() {
|
312
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders;//"/search/advanced/dataproviders";
|
313
|
if ( this.reload[this.activeEntity] &&
|
314
|
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE) {
|
315
|
this.reload[this.activeEntity] = false;
|
316
|
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword;
|
317
|
}
|
318
|
}
|
319
|
|
320
|
public searchOrganizations() {
|
321
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations;//"/search/advanced/organizations";
|
322
|
if (this.reload[this.activeEntity] &&
|
323
|
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE) {
|
324
|
this.reload[this.activeEntity] = false;
|
325
|
this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword;
|
326
|
}
|
327
|
}
|
328
|
private prepareKeywordParam(keyword){
|
329
|
if (this.parameters["q"]) {
|
330
|
delete this.parameters['q'];
|
331
|
delete this.parameters['op'];
|
332
|
}
|
333
|
if(keyword.length > 0){
|
334
|
this.parameters["fv0"] = keyword;
|
335
|
this.parameters["f0"] = "q";
|
336
|
}else if(keyword.length ==0 && this.parameters["f0"]=="q"){
|
337
|
delete this.parameters['f0'];
|
338
|
delete this.parameters['fv0'];
|
339
|
}
|
340
|
}
|
341
|
private prepareResultParameters() {
|
342
|
//quickSelections
|
343
|
if (this.resultTypes && this.activeEntity == "result") {
|
344
|
let values = [];
|
345
|
if (this.resultTypes.publication) {
|
346
|
values.push("publications");
|
347
|
}
|
348
|
if (this.resultTypes.dataset) {
|
349
|
values.push("datasets");
|
350
|
}
|
351
|
if (this.resultTypes.software) {
|
352
|
values.push("software");
|
353
|
}
|
354
|
if (this.resultTypes.other) {
|
355
|
values.push("other");
|
356
|
}
|
357
|
if (values.length > 0) {
|
358
|
this.parameters["type"] = values.join(",");
|
359
|
}
|
360
|
}
|
361
|
if (this.quickFilter && this.activeEntity == "result") {
|
362
|
this.parameters["qf"] = this.quickFilter.selected;
|
363
|
}
|
364
|
}
|
365
|
|
366
|
public quickSelectionsChanged() {
|
367
|
this.prepareResultParameters();
|
368
|
this.parameters["page"] = 1;
|
369
|
this.reload[this.activeEntity] = true;
|
370
|
this.router.navigate([location.pathname], {queryParams: this.parameters});
|
371
|
}
|
372
|
|
373
|
|
374
|
public keywordChanged($event) {
|
375
|
this.prepareKeywordParam(this.selectedFields[0].value);
|
376
|
this.parameters["page"] = 1;
|
377
|
this.reloadTabs();
|
378
|
this.router.navigate([location.pathname], {queryParams: this.parameters});
|
379
|
}
|
380
|
|
381
|
private count() {
|
382
|
var refineParams = null;
|
383
|
if (this.customFilter) {
|
384
|
refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)));
|
385
|
}
|
386
|
if (this.activeEntity != "result" && this.reload["result"] && (this.showPublications || this.showSoftware || this.datasets || this.showOrps)) {
|
387
|
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
|
388
|
this.reload["result"] = false;
|
389
|
this.fetchPublications.results = [];
|
390
|
//Add Open Access Filter
|
391
|
this.subPub = this.numOfSearchResults(this.fetchPublications, (refineParams ? (refineParams + '&') : '') + "&fq=resultbestaccessright%20exact%20%22Open%20Access%22");
|
392
|
}
|
393
|
|
394
|
if (this.activeEntity != "projects" && this.reload["projects"] && this.showProjects) {
|
395
|
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
396
|
this.fetchProjects.results = [];
|
397
|
this.reload["projects"] = false;
|
398
|
this.subProjects = this._searchProjectsService.numOfSearchProjects2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("project",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
399
|
data => {
|
400
|
this.fetchProjects.searchUtils.totalResults = data;
|
401
|
this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
|
402
|
if (this.fetchProjects.searchUtils.totalResults == 0) {
|
403
|
this.fetchProjects.searchUtils.status = this.errorCodes.NONE;
|
404
|
}
|
405
|
},
|
406
|
err => {
|
407
|
//console.log(err);
|
408
|
this.handleError("Error getting number of Projects", err);
|
409
|
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
|
410
|
}
|
411
|
);
|
412
|
}
|
413
|
if (this.activeEntity != "datasources" && this.reload["datasources"] && this.showDataProviders) {
|
414
|
this.fetchDataproviders.results = [];
|
415
|
this.reload["datasources"] = false;
|
416
|
// this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams);
|
417
|
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("datasources",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
418
|
data => {
|
419
|
this.fetchDataproviders.searchUtils.totalResults = data;
|
420
|
this.fetchDataproviders.searchUtils.status = this.errorCodes.DONE;
|
421
|
if (this.fetchDataproviders.searchUtils.totalResults == 0) {
|
422
|
this.fetchDataproviders.searchUtils.status = this.errorCodes.NONE;
|
423
|
}
|
424
|
},
|
425
|
err => {
|
426
|
//console.log(err);
|
427
|
this.handleError("Error getting number of Projects", err);
|
428
|
this.fetchDataproviders.searchUtils.status = this.errorCodes.ERROR;
|
429
|
}
|
430
|
);
|
431
|
}
|
432
|
if (this.activeEntity != "organizations" && this.reload["organizations"] && this.showOrganizations) {
|
433
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
|
434
|
this.fetchOrganizations.results = [];
|
435
|
this.reload["organizations"] = false;
|
436
|
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("organizations",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
437
|
data => {
|
438
|
this.fetchOrganizations.searchUtils.totalResults = data;
|
439
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
|
440
|
if (this.fetchOrganizations.searchUtils.totalResults == 0) {
|
441
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.NONE;
|
442
|
}
|
443
|
},
|
444
|
err => {
|
445
|
//console.log(err);
|
446
|
this.handleError("Error getting number of Organizations", err);
|
447
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR;
|
448
|
|
449
|
}
|
450
|
);
|
451
|
}
|
452
|
|
453
|
|
454
|
}
|
455
|
|
456
|
private numOfSearchResults(fetchClass: FetchResearchResults, refineParams): Observable<any> {
|
457
|
return this._searchResearchResultsService.numOfResearchOutcomes(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("result",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
458
|
data => {
|
459
|
fetchClass.searchUtils.totalResults = data;
|
460
|
fetchClass.searchUtils.status = this.errorCodes.DONE;
|
461
|
if (fetchClass.searchUtils.totalResults == 0) {
|
462
|
fetchClass.searchUtils.status = this.errorCodes.NONE;
|
463
|
}
|
464
|
},
|
465
|
err => {
|
466
|
this.handleError("Error getting number of research results", err);
|
467
|
fetchClass.searchUtils.status = this.errorCodes.ERROR;
|
468
|
}
|
469
|
);
|
470
|
}
|
471
|
|
472
|
private reloadTabs() {
|
473
|
this.reload = {result:true, projects:true, datasources: true, organizations:true};
|
474
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
|
475
|
this.fetchDataproviders.searchUtils.status = this.errorCodes.LOADING;
|
476
|
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
477
|
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
|
478
|
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
|
479
|
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
|
480
|
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
|
481
|
}
|
482
|
|
483
|
private handleError(message: string, error) {
|
484
|
console.error("General Search Page: " + message, error);
|
485
|
}
|
486
|
|
487
|
activeEntityUpdate($event) {
|
488
|
this.disableForms = $event.disableForms;
|
489
|
let updated = true;
|
490
|
if (this.activeEntity == "result") {
|
491
|
if($event.searchUtils.status!=this.errorCodes.LOADING) {
|
492
|
this.fetchPublications.searchUtils.totalResults = $event.searchUtils.totalResults;
|
493
|
}
|
494
|
this.fetchPublications.searchUtils.status = $event.searchUtils.status;
|
495
|
}else if (this.activeEntity == "projects"){
|
496
|
if($event.searchUtils.status!=this.errorCodes.LOADING) {
|
497
|
this.fetchProjects.searchUtils.totalResults = $event.searchUtils.totalResults;
|
498
|
}
|
499
|
this.fetchProjects.searchUtils.status = $event.searchUtils.status;
|
500
|
}else if (this.activeEntity == "datasources"){
|
501
|
if($event.searchUtils.status!=this.errorCodes.LOADING) {
|
502
|
this.fetchDataproviders.searchUtils.totalResults = $event.searchUtils.totalResults;
|
503
|
}
|
504
|
this.fetchDataproviders.searchUtils.status = $event.searchUtils.status;
|
505
|
}else if (this.activeEntity == "organizations") {
|
506
|
if($event.searchUtils.status!=this.errorCodes.LOADING) {
|
507
|
this.fetchOrganizations.searchUtils.totalResults = $event.searchUtils.totalResults;
|
508
|
}
|
509
|
this.fetchOrganizations.searchUtils.status = $event.searchUtils.status;
|
510
|
}else{
|
511
|
updated = false;
|
512
|
}
|
513
|
if(updated) {
|
514
|
this.cdr.detectChanges();
|
515
|
}
|
516
|
}
|
517
|
|
518
|
entityChanged(entity){
|
519
|
if(this.activeEntity == "result") {
|
520
|
this.resultTypes = {publication: true, dataset: true, software: true, other: true};
|
521
|
}
|
522
|
if(this.activeEntity == "result" && this.searchResearchResultsComponent){
|
523
|
this.searchResearchResultsComponent.ngOnDestroy();
|
524
|
}else if(this.activeEntity == "projects" && this.searchProjectsComponent){
|
525
|
this.searchProjectsComponent.ngOnDestroy();
|
526
|
}else if(this.activeEntity == "datasources" && this.searchDataprovidersComponent){
|
527
|
this.searchDataprovidersComponent.ngOnDestroy();
|
528
|
}else if(this.activeEntity == "organizations" && this.searchOrganizationsComponent){
|
529
|
this.searchOrganizationsComponent.ngOnDestroy();
|
530
|
}
|
531
|
this.activeEntity = entity;
|
532
|
this.parameters = {};
|
533
|
this.reload[entity]= true;
|
534
|
this.parameters["active"] = entity;
|
535
|
if ( this.keyword.length > 0) {
|
536
|
this.parameters["fv0"] = this.keyword;
|
537
|
this.parameters["f0"] = "q";
|
538
|
}
|
539
|
this.router.navigate(["/search/find"], {queryParams: this.parameters});
|
540
|
}
|
541
|
|
542
|
}
|