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