Revision 44262
Added by Argiro Kokogiannaki over 7 years ago
searchDatasets.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input, ViewChild} from '@angular/core'; |
2 | 2 |
import { ActivatedRoute} from '@angular/router'; |
3 |
|
|
3 |
import {Location} from '@angular/common'; |
|
4 | 4 |
import { Filter, Value} from './searchUtils/searchHelperClasses.class'; |
5 | 5 |
|
6 | 6 |
import {RefineResultsService} from '../services/servicesUtils/refineResuts.service'; |
... | ... | |
31 | 31 |
private page :number = 1; |
32 | 32 |
private size :number = 10; |
33 | 33 |
private sub: any; |
34 |
private refineFields = []; |
|
35 |
private searchFields:SearchFields = new SearchFields(); |
|
36 |
private _location:Location; |
|
34 | 37 |
|
38 |
|
|
35 | 39 |
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; |
36 |
constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService, private _refineResultsService:RefineResultsService ) {
|
|
40 |
constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService, private _refineResultsService:RefineResultsService ) { |
|
37 | 41 |
|
38 | 42 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
39 | 43 |
this.status =errorCodes.LOADING; |
40 | 44 |
this.baseUrl = OpenaireProperties.getLinkToSearchDatasets(); |
45 |
this.refineFields = this.searchFields.DATASET_FIELDS; |
|
46 |
if(!this.searchPage){ |
|
47 |
this.searchPage = new SearchPageComponent(this._location); |
|
48 |
} |
|
41 | 49 |
} |
42 | 50 |
|
43 | 51 |
private ngOnInit() { |
52 |
this.searchPage.refineFields = this.refineFields; |
|
44 | 53 |
|
45 | 54 |
this.sub = this.route.queryParams.subscribe(params => { |
46 |
this.keyword = (params['keyword']?params['keyword']:''); |
|
47 |
this.page = (params['page']=== undefined)?1:+params['page']; |
|
48 |
this.getRefineResults(); |
|
49 |
this.getResults(this.keyword, this.page, this.size, "searchPage"); |
|
55 |
this.keyword = (params['keyword']?params['keyword']:'');
|
|
56 |
this.page = (params['page']=== undefined)?1:+params['page'];
|
|
57 |
// this.getRefineResults();
|
|
58 |
this.getResults(this.keyword, this.page, this.size, "searchPage");
|
|
50 | 59 |
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 | 60 |
}); |
57 | 61 |
} |
58 | 62 |
|
... | ... | |
80 | 84 |
} |
81 | 85 |
public getResults(parameters:string, page: number, size: number, flag: string){ |
82 | 86 |
console.info("Search Datasets: Execute search query "+parameters); |
83 |
this._searchDatasetsService.searchDatasets(parameters, page, size, flag).subscribe(
|
|
87 |
this._searchDatasetsService.searchDatasets(parameters+this.searchPage.getRefineFieldsQuery(), page, size,'searchPage', this.searchPage.getFields()).subscribe(
|
|
84 | 88 |
data => { |
85 | 89 |
this.totalResults = data[0]; |
86 | 90 |
console.info("Search Datasets: results="+this.totalResults); |
87 | 91 |
this.results = data[1]; |
92 |
this.filters = data[2]; |
|
88 | 93 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
89 | 94 |
this.status = errorCodes.DONE; |
90 | 95 |
if(this.totalResults == 0 ){ |
Also available in: Unified diff
In Projects search component and search PAge: create the proper query using url parameters, mark as checked the proper filters after getting the results from search, apply changes in other components so they can work too.