Revision 49174
Added by Konstantina Galouni over 6 years ago
advancedSearchProjects.component.ts | ||
---|---|---|
19 | 19 |
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" |
20 | 20 |
(queryChange)="queryChanged($event)" |
21 | 21 |
[csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/projects" |
22 |
[disableForms]="disableForms"> |
|
22 |
[disableForms]="disableForms" |
|
23 |
[loadPaging]="loadPaging" |
|
24 |
[oldTotalResults]="oldTotalResults"> |
|
23 | 25 |
</advanced-search-page> |
24 | 26 |
|
25 | 27 |
` |
26 | 28 |
}) |
27 | 29 |
|
28 | 30 |
export class AdvancedSearchProjectsComponent { |
31 |
private errorCodes: ErrorCodes; |
|
32 |
|
|
29 | 33 |
public results =[]; |
30 | 34 |
public filters =[]; |
31 | 35 |
|
32 | 36 |
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); |
37 |
public searchFields:SearchFields = new SearchFields(); |
|
33 | 38 |
|
34 |
public searchFields:SearchFields = new SearchFields(); |
|
35 |
|
|
36 | 39 |
public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS; |
37 | 40 |
public fieldIdsMap = this.searchFields.PROJECT_FIELDS; |
38 | 41 |
public selectedFields:AdvancedField[] = []; |
... | ... | |
41 | 44 |
public resourcesQuery = "(oaftype exact project)"; |
42 | 45 |
public csvParams: string; |
43 | 46 |
public disableForms: boolean = false; |
47 |
public loadPaging: boolean = true; |
|
48 |
public oldTotalResults: number = 0; |
|
44 | 49 |
|
45 | 50 |
constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) { |
46 | 51 |
|
47 | 52 |
this.results =[]; |
48 |
var errorCodes:ErrorCodes = new ErrorCodes();
|
|
49 |
this.searchUtils.status =errorCodes.LOADING; |
|
53 |
this.errorCodes = new ErrorCodes();
|
|
54 |
this.searchUtils.status = this.errorCodes.LOADING;
|
|
50 | 55 |
this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedProjects; |
51 | 56 |
|
52 | 57 |
|
53 | 58 |
|
54 | 59 |
} |
55 | 60 |
ngOnInit() { |
56 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
57 |
this.searchUtils.status =errorCodes.LOADING; |
|
58 |
this.sub = this.route.queryParams.subscribe(params => { |
|
61 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
|
62 |
this.searchUtils.status = this.errorCodes.LOADING; |
|
63 |
this.sub = this.route.queryParams.subscribe(params => { |
|
64 |
if(params['page'] && this.searchUtils.page != params['page']) { |
|
65 |
this.loadPaging = false; |
|
66 |
this.oldTotalResults = this.searchUtils.totalResults; |
|
67 |
} |
|
68 |
|
|
59 | 69 |
let page = (params['page']=== undefined)?1:+params['page']; |
60 | 70 |
this.searchUtils.page = ( page <= 0 ) ? 1 : page; |
61 | 71 |
this.searchPage.fieldIds = this.fieldIds; |
... | ... | |
78 | 88 |
this.csvParams ="&type=projects&query="+this.resourcesQuery; |
79 | 89 |
} |
80 | 90 |
|
81 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
82 |
this.searchUtils.status = errorCodes.LOADING; |
|
91 |
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
92 |
this.searchUtils.status = this.errorCodes.LOADING;
|
|
83 | 93 |
//this.searchPage.openLoading(); |
84 | 94 |
this.disableForms = true; |
85 | 95 |
this.results = []; |
... | ... | |
92 | 102 |
console.info("Advanced Search for Projects total="+this.searchUtils.totalResults); |
93 | 103 |
this.results = data[1]; |
94 | 104 |
this.searchPage.updateBaseUrlWithParameters(); |
95 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
96 |
this.searchUtils.status = errorCodes.DONE;
|
|
105 |
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
106 |
this.searchUtils.status = this.errorCodes.DONE;
|
|
97 | 107 |
if(this.searchUtils.totalResults == 0 ){ |
98 |
this.searchUtils.status = errorCodes.NONE; |
|
108 |
this.searchUtils.status = this.errorCodes.NONE;
|
|
99 | 109 |
} |
100 | 110 |
//this.searchPage.closeLoading(); |
101 | 111 |
this.disableForms = false; |
102 | 112 |
|
103 |
if(this.searchUtils.status == errorCodes.DONE) { |
|
113 |
if(this.searchUtils.status == this.errorCodes.DONE) {
|
|
104 | 114 |
// Page out of limit!!! |
105 | 115 |
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); |
106 | 116 |
if(!(Number.isInteger(totalPages))) { |
... | ... | |
108 | 118 |
} |
109 | 119 |
if(totalPages < page) { |
110 | 120 |
this.searchUtils.totalResults = 0; |
111 |
this.searchUtils.status = errorCodes.OUT_OF_BOUND; |
|
121 |
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
|
112 | 122 |
} |
113 | 123 |
} |
114 | 124 |
}, |
... | ... | |
119 | 129 |
// if( ){ |
120 | 130 |
// this.searchUtils.status = errorCodes.ERROR; |
121 | 131 |
// } |
122 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
123 |
this.searchUtils.status = errorCodes.NOT_AVAILABLE; |
|
132 |
//var errorCodes:ErrorCodes = new ErrorCodes(); |
|
133 |
//this.searchUtils.status = errorCodes.NOT_AVAILABLE; |
|
134 |
if(err.status == '404') { |
|
135 |
this.searchUtils.status = this.errorCodes.NOT_FOUND; |
|
136 |
} else if(err.status == '500') { |
|
137 |
this.searchUtils.status = this.errorCodes.ERROR; |
|
138 |
} else { |
|
139 |
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; |
|
140 |
} |
|
141 |
|
|
124 | 142 |
//this.searchPage.closeLoading(); |
125 | 143 |
this.disableForms = false; |
126 | 144 |
|
... | ... | |
132 | 150 |
} |
133 | 151 |
|
134 | 152 |
public queryChanged($event) { |
153 |
this.loadPaging = true; |
|
154 |
|
|
135 | 155 |
var parameters = $event.value; |
136 | 156 |
this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); |
137 | 157 |
console.info("queryChanged: Execute search query "+parameters); |
Also available in: Unified diff
Utils of landing pages moved to 'landing-utils' folder | errorMessages.component created to centralize errorMessages according to ErrorCodes in openaireProperties.ts file | http service returning errorCodes and proper display fixed in search and fetch subscriptions (claims, home component, html project report page, csv files, basic info in landing pages, helper component, staticAutocomplete do not return errorCodes yet) | simple searchPages: paging remains when page changes while results load, filters on the left do not change position according to paging