Project

General

Profile

« Previous | Next » 

Revision 49174

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

View differences:

searchPublications.component.ts
25 25
                 [csvParams]="csvParams" csvPath="publications"
26 26
                 advancedSearchLink="/search/advanced/publications"
27 27
                 [disableForms]="disableForms"
28
                 [loadPaging]="loadPaging"
29
                 [oldTotalResults]="oldTotalResults"
28 30
                 searchFormClass="publicationsSearchForm">
29 31
    </search-page>
30 32

  
......
32 34

  
33 35
})
34 36
export class SearchPublicationsComponent {
37
  private errorCodes: ErrorCodes;
38

  
35 39
  public results =[];
36 40
  public filters =[];
37 41
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
......
54 58
  public CSVDownloaded = false;
55 59
  public csvParams: string;
56 60
  public disableForms: boolean = false;
61
  public loadPaging: boolean = true;
62
  public oldTotalResults: number = 0;
57 63

  
58 64
  constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) {
59
    var errorCodes:ErrorCodes = new ErrorCodes();
60
    this.searchUtils.status =errorCodes.LOADING;
65
    this.errorCodes = new ErrorCodes();
66
    this.searchUtils.status = this.errorCodes.LOADING;
61 67
    this.searchUtils.page =1;
62 68
    this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
63 69

  
......
69 75
    this.searchPage.type = "publications";
70 76
    var firstLoad =true;
71 77
    this.sub =  this.route.queryParams.subscribe(params => {
78
        if(params['page'] && this.searchUtils.page != params['page']) {
79
          this.loadPaging = false;
80
          this.oldTotalResults = this.searchUtils.totalResults;
81
        }
82

  
72 83
        this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
73 84
        var refine = true;
74 85
        if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
......
106 117
              console.info("search Publications for "+entity+": [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
107 118
              this.results = data[1];
108 119

  
109
              var errorCodes:ErrorCodes = new ErrorCodes();
110
              this.searchUtils.status = errorCodes.DONE;
120
              //var errorCodes:ErrorCodes = new ErrorCodes();
121
              this.searchUtils.status = this.errorCodes.DONE;
111 122
              if(this.searchUtils.totalResults == 0 ){
112
                this.searchUtils.status = errorCodes.NONE;
123
                this.searchUtils.status = this.errorCodes.NONE;
113 124
              }
114 125
          },
115 126
          err => {
......
118 129
              // if( ){
119 130
              //   this.searchUtils.status = ErrorCodes.ERROR;
120 131
              // }
121
              var errorCodes:ErrorCodes = new ErrorCodes();
122
              this.searchUtils.status = errorCodes.ERROR;
132
              //var errorCodes:ErrorCodes = new ErrorCodes();
133
              //this.searchUtils.status = errorCodes.ERROR;
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
              }
123 141
          }
124 142
      );
125 143
  }
......
141 159
              console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
142 160
              this.results = data[1];
143 161

  
144
              var errorCodes:ErrorCodes = new ErrorCodes();
145
              this.searchUtils.status = errorCodes.DONE;
162
              //var errorCodes:ErrorCodes = new ErrorCodes();
163
              this.searchUtils.status = this.errorCodes.DONE;
146 164
              if(this.searchUtils.totalResults == 0 ){
147
                this.searchUtils.status = errorCodes.NONE;
165
                this.searchUtils.status = this.errorCodes.NONE;
148 166
              }
149 167
          },
150 168
          err => {
......
153 171
              // if( ){
154 172
              //   this.searchUtils.status = ErrorCodes.ERROR;
155 173
              // }
156
              var errorCodes:ErrorCodes = new ErrorCodes();
157
              this.searchUtils.status = errorCodes.ERROR;
174
              //var errorCodes:ErrorCodes = new ErrorCodes();
175
              //this.searchUtils.status = errorCodes.ERROR;
176
              if(err.status == '404') {
177
                this.searchUtils.status = this.errorCodes.NOT_FOUND;
178
              } else if(err.status == '500') {
179
                this.searchUtils.status = this.errorCodes.ERROR;
180
              } else {
181
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
182
              }
158 183
          }
159 184
      );
160 185
  }
......
185 210
  //     this.searchPage = new SearchPageComponent(this._location);
186 211
  // }
187 212

  
188
  var errorCodes:ErrorCodes = new ErrorCodes();
189
  this.searchUtils.status = errorCodes.LOADING;
213
  //var errorCodes:ErrorCodes = new ErrorCodes();
214
  this.searchUtils.status = this.errorCodes.LOADING;
190 215
  //this.searchPage.openLoading();
191 216
  this.disableForms = true;
192 217
  this.results = [];
......
203 228
          this.searchPage.checkSelectedFilters(this.filters);
204 229
          this.searchPage.updateBaseUrlWithParameters(this.filters);
205 230

  
206
          var errorCodes:ErrorCodes = new ErrorCodes();
231
          //var errorCodes:ErrorCodes = new ErrorCodes();
207 232

  
208
          this.searchUtils.status = errorCodes.DONE;
233
          this.searchUtils.status = this.errorCodes.DONE;
209 234
          if(this.searchUtils.totalResults == 0 ){
210
            this.searchUtils.status = errorCodes.NONE;
235
            this.searchUtils.status = this.errorCodes.NONE;
211 236
          }
212 237
          //this.searchPage.closeLoading();
213 238
          this.disableForms = false;
214 239

  
215
          if(this.searchUtils.status == errorCodes.DONE) {
240
          if(this.searchUtils.status == this.errorCodes.DONE) {
216 241
            // Page out of limit!!!
217 242
            let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
218 243
            if(!(Number.isInteger(totalPages))) {
......
220 245
            }
221 246
            if(totalPages < page) {
222 247
              this.searchUtils.totalResults = 0;
223
              this.searchUtils.status = errorCodes.OUT_OF_BOUND;
248
              this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
224 249
            }
225 250
          }
226 251
      },
......
230 255
          // if( ){
231 256
          //   this.searchUtils.status = ErrorCodes.ERROR;
232 257
          // }
233
          var errorCodes:ErrorCodes = new ErrorCodes();
234
          this.searchUtils.status = errorCodes.ERROR;
258
          //var errorCodes:ErrorCodes = new ErrorCodes();
259
          //this.searchUtils.status = errorCodes.ERROR;
260
          if(err.status == '404') {
261
            this.searchUtils.status = this.errorCodes.NOT_FOUND;
262
          } else if(err.status == '500') {
263
            this.searchUtils.status = this.errorCodes.ERROR;
264
          } else {
265
            this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
266
          }
267

  
235 268
          //this.searchPage.closeLoading();
236 269
          this.disableForms = false;
237 270

  
......
263 296
}*/
264 297

  
265 298
  public queryChanged($event) {
299
    this.loadPaging = true;
300

  
266 301
    var parameters = $event.value;
267 302
    console.info("queryChanged: Execute search query "+parameters);
268 303
    console.info("Search Pubs::page "+this.searchUtils.page);

Also available in: Unified diff