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:

fetchDataproviders.class.ts
3 3
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
4 4

  
5 5
export class FetchDataproviders {
6
  private errorCodes: ErrorCodes;
7

  
6 8
  public results =[];
7 9
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
8 10
  public sub: any; public subResults: any;
......
14 16

  
15 17

  
16 18
  constructor ( private _searchDataprovidersService: SearchDataprovidersService ) {
17
    var errorCodes:ErrorCodes = new ErrorCodes();
18
    this.searchUtils.status =errorCodes.LOADING;
19
    this.errorCodes = new ErrorCodes();
20
    this.searchUtils.status = this.errorCodes.LOADING;
19 21
   }
20 22

  
21 23

  
......
34 36
      parameters = "q=" + keyword;
35 37
    }
36 38

  
37
    var errorCodes:ErrorCodes = new ErrorCodes();
38
    this.searchUtils.status = errorCodes.LOADING;
39
    //var errorCodes:ErrorCodes = new ErrorCodes();
40
    this.searchUtils.status = this.errorCodes.LOADING;
39 41

  
40 42

  
41 43
    this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,null, page, size,[]).subscribe(
......
44 46
            console.info("search Content Providers: [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
45 47
            this.results = data[1];
46 48

  
47
            var errorCodes:ErrorCodes = new ErrorCodes();
48
            this.searchUtils.status = errorCodes.DONE;
49
            //ar errorCodes:ErrorCodes = new ErrorCodes();
50
            this.searchUtils.status = this.errorCodes.DONE;
49 51
            if(this.searchUtils.totalResults == 0 ){
50
              this.searchUtils.status = errorCodes.NONE;
52
              this.searchUtils.status = this.errorCodes.NONE;
51 53
            }
52 54
        },
53 55
        err => {
......
56 58
            // if( ){
57 59
            //   this.searchUtils.status = ErrorCodes.ERROR;
58 60
            // }
59
            var errorCodes:ErrorCodes = new ErrorCodes();
60
            this.searchUtils.status = errorCodes.ERROR;
61
            //var errorCodes:ErrorCodes = new ErrorCodes();
62
            //this.searchUtils.status = errorCodes.ERROR;
63
            if(err.status == '404') {
64
              this.searchUtils.status = this.errorCodes.NOT_FOUND;
65
            } else if(err.status == '500') {
66
              this.searchUtils.status = this.errorCodes.ERROR;
67
            } else {
68
              this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
69
            }
61 70
        }
62 71
    );
63 72
  }
64 73

  
65 74
  public getNumForEntity(entity: string, id:string) {
66
      var errorCodes:ErrorCodes = new ErrorCodes();
67
      this.searchUtils.status = errorCodes.LOADING;
75
      //var errorCodes:ErrorCodes = new ErrorCodes();
76
      this.searchUtils.status = this.errorCodes.LOADING;
68 77

  
69 78
      if(id != "" && entity != "") {
70 79

  
......
72 81
              data => {
73 82
                  this.searchUtils.totalResults = data;
74 83

  
75
                  var errorCodes:ErrorCodes = new ErrorCodes();
76
                  this.searchUtils.status = errorCodes.DONE;
84
                  //var errorCodes:ErrorCodes = new ErrorCodes();
85
                  this.searchUtils.status = this.errorCodes.DONE;
77 86
                  if(this.searchUtils.totalResults == 0 ){
78
                    this.searchUtils.status = errorCodes.NONE;
87
                    this.searchUtils.status = this.errorCodes.NONE;
79 88
                  }
80 89
              },
81 90
              err => {
......
84 93
                  // if( ){
85 94
                  //   this.searchUtils.status = ErrorCodes.ERROR;
86 95
                  // }
87
                  var errorCodes:ErrorCodes = new ErrorCodes();
88
                  this.searchUtils.status = errorCodes.ERROR;
96
                  //var errorCodes:ErrorCodes = new ErrorCodes();
97
                  //this.searchUtils.status = errorCodes.ERROR;
98
                  if(err.status == '404') {
99
                    this.searchUtils.status = this.errorCodes.NOT_FOUND;
100
                  } else if(err.status == '500') {
101
                    this.searchUtils.status = this.errorCodes.ERROR;
102
                  } else {
103
                    this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
104
                  }
89 105
              }
90 106
          );
91 107
      }
92 108
  }
93 109

  
94 110
  public getNumForSearch(keyword: string) {
95
      var errorCodes:ErrorCodes = new ErrorCodes();
96
      this.searchUtils.status = errorCodes.LOADING;
111
      //var errorCodes:ErrorCodes = new ErrorCodes();
112
      this.searchUtils.status = this.errorCodes.LOADING;
97 113

  
98 114
      this._searchDataprovidersService.numOfSearchDataproviders(keyword).subscribe(
99 115
          data => {
100 116
              this.searchUtils.totalResults = data;
101
              this.searchUtils.status = errorCodes.DONE;
117
              this.searchUtils.status = this.errorCodes.DONE;
102 118

  
103 119
              if(this.searchUtils.totalResults == 0) {
104
                this.searchUtils.status = errorCodes.NONE;
120
                this.searchUtils.status = this.errorCodes.NONE;
105 121
              }
106 122
          },
107 123
          err => {
......
110 126
              // if( ){
111 127
              //   this.searchUtils.status = ErrorCodes.ERROR;
112 128
              // }
113
              var errorCodes:ErrorCodes = new ErrorCodes();
114
              this.searchUtils.status = errorCodes.ERROR;
129
              //var errorCodes:ErrorCodes = new ErrorCodes();
130
              //this.searchUtils.status = errorCodes.ERROR;
131
              if(err.status == '404') {
132
                this.searchUtils.status = this.errorCodes.NOT_FOUND;
133
              } else if(err.status == '500') {
134
                this.searchUtils.status = this.errorCodes.ERROR;
135
              } else {
136
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
137
              }
115 138
          }
116 139
      );
117 140
  }
118 141

  
119 142
public getResultsForDeposit(id:string, type:string, page: number,  size: number){
120
    var errorCodes:ErrorCodes = new ErrorCodes();
121
    this.searchUtils.status = errorCodes.LOADING;
143
    //var errorCodes:ErrorCodes = new ErrorCodes();
144
    this.searchUtils.status = this.errorCodes.LOADING;
122 145

  
123 146
  if(id != "") {
124 147

  
......
128 151
              console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ]  [total results:"+this.searchUtils.totalResults+"]");
129 152
              this.results = data[1];
130 153

  
131
              var errorCodes:ErrorCodes = new ErrorCodes();
132
              this.searchUtils.status = errorCodes.DONE;
154
              //var errorCodes:ErrorCodes = new ErrorCodes();
155
              this.searchUtils.status = this.errorCodes.DONE;
133 156
              if(this.searchUtils.totalResults == 0 ){
134
                this.searchUtils.status = errorCodes.NONE;
157
                this.searchUtils.status = this.errorCodes.NONE;
135 158
              }
136 159
          },
137 160
          err => {
......
140 163
              // if( ){
141 164
              //   this.searchUtils.status = ErrorCodes.ERROR;
142 165
              // }
143
              var errorCodes:ErrorCodes = new ErrorCodes();
144
              this.searchUtils.status = errorCodes.ERROR;
166
              //var errorCodes:ErrorCodes = new ErrorCodes();
167
              //this.searchUtils.status = errorCodes.ERROR;
168
              if(err.status == '404') {
169
                this.searchUtils.status = this.errorCodes.NOT_FOUND;
170
              } else if(err.status == '500') {
171
                this.searchUtils.status = this.errorCodes.ERROR;
172
              } else {
173
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
174
              }
145 175
          }
146 176
      );
147 177
  }
148 178
}
149 179
public getResultsBySubjectsForDeposit(subject:string, type:string, page: number,  size: number){
150
    var errorCodes:ErrorCodes = new ErrorCodes();
151
    this.searchUtils.status = errorCodes.LOADING;
180
    //var errorCodes:ErrorCodes = new ErrorCodes();
181
    this.searchUtils.status = this.errorCodes.LOADING;
152 182
      this._searchDataprovidersService.searchDataProvidersBySubjects(subject,type, page, size).subscribe(
153 183
          data => {
154 184
              this.searchUtils.totalResults = data[0];
155 185
              console.info("search Dataproviders forDeposit: [subject:"+subject+", type:"+type+" ]  [total results:"+this.searchUtils.totalResults+"]");
156 186
              this.results = data[1];
157 187

  
158
              var errorCodes:ErrorCodes = new ErrorCodes();
159
              this.searchUtils.status = errorCodes.DONE;
188
              //var errorCodes:ErrorCodes = new ErrorCodes();
189
              this.searchUtils.status = this.errorCodes.DONE;
160 190
              if(this.searchUtils.totalResults == 0 ){
161
                this.searchUtils.status = errorCodes.NONE;
191
                this.searchUtils.status = this.errorCodes.NONE;
162 192
              }
163 193
          },
164 194
          err => {
......
167 197
              // if( ){
168 198
              //   this.searchUtils.status = ErrorCodes.ERROR;
169 199
              // }
170
              var errorCodes:ErrorCodes = new ErrorCodes();
171
              this.searchUtils.status = errorCodes.ERROR;
200
              //var errorCodes:ErrorCodes = new ErrorCodes();
201
              //this.searchUtils.status = errorCodes.ERROR;
202
              if(err.status == '404') {
203
                this.searchUtils.status = this.errorCodes.NOT_FOUND;
204
              } else if(err.status == '500') {
205
                this.searchUtils.status = this.errorCodes.ERROR;
206
              } else {
207
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
208
              }
172 209
          }
173 210
      );
174 211

  
175 212
}
176 213
  public getResultsForEntity(entity:string, id:string, page: number, size: number){
177
      var errorCodes:ErrorCodes = new ErrorCodes();
178
      this.searchUtils.status = errorCodes.LOADING;
214
      //var errorCodes:ErrorCodes = new ErrorCodes();
215
      this.searchUtils.status = this.errorCodes.LOADING;
179 216

  
180 217
    var parameters = "";
181 218

  
......
191 228
                console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
192 229
                this.results = data[1];
193 230

  
194
                var errorCodes:ErrorCodes = new ErrorCodes();
195
                this.searchUtils.status = errorCodes.DONE;
231
                //var errorCodes:ErrorCodes = new ErrorCodes();
232
                this.searchUtils.status = this.errorCodes.DONE;
196 233
                if(this.searchUtils.totalResults == 0 ){
197
                  this.searchUtils.status = errorCodes.NONE;
234
                  this.searchUtils.status = this.errorCodes.NONE;
198 235
                }
199 236
            },
200 237
            err => {
......
203 240
                // if( ){
204 241
                //   this.searchUtils.status = ErrorCodes.ERROR;
205 242
                // }
206
                var errorCodes:ErrorCodes = new ErrorCodes();
207
                this.searchUtils.status = errorCodes.ERROR;
243
                //var errorCodes:ErrorCodes = new ErrorCodes();
244
                //this.searchUtils.status = errorCodes.ERROR;
245
                if(err.status == '404') {
246
                  this.searchUtils.status = this.errorCodes.NOT_FOUND;
247
                } else if(err.status == '500') {
248
                  this.searchUtils.status = this.errorCodes.ERROR;
249
                } else {
250
                  this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
251
                }
208 252
            }
209 253
        );
210 254
    }
211 255
  }
212 256

  
213 257
  public getResultsForDataproviders(id:string, page: number, size: number){
214
      var errorCodes:ErrorCodes = new ErrorCodes();
215
      this.searchUtils.status = errorCodes.LOADING;
258
      //var errorCodes:ErrorCodes = new ErrorCodes();
259
      this.searchUtils.status = this.errorCodes.LOADING;
216 260

  
217 261
    this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size).subscribe(
218 262
        data => {
......
220 264
            console.info("search Dataproviders for Entity Registry: [Id:"+id+" ]  [total results:"+this.searchUtils.totalResults+"]");
221 265
            this.results = data[1];
222 266

  
223
            var errorCodes:ErrorCodes = new ErrorCodes();
224
            this.searchUtils.status = errorCodes.DONE;
267
            //var errorCodes:ErrorCodes = new ErrorCodes();
268
            this.searchUtils.status = this.errorCodes.DONE;
225 269
            if(this.searchUtils.totalResults == 0 ){
226
              this.searchUtils.status = errorCodes.NONE;
270
              this.searchUtils.status = this.errorCodes.NONE;
227 271
            }
228 272
        },
229 273
        err => {
......
232 276
            // if( ){
233 277
            //   this.searchUtils.status = ErrorCodes.ERROR;
234 278
            // }
235
            var errorCodes:ErrorCodes = new ErrorCodes();
236
            this.searchUtils.status = errorCodes.ERROR;
279
            //var errorCodes:ErrorCodes = new ErrorCodes();
280
            //this.searchUtils.status = errorCodes.ERROR;
281
            if(err.status == '404') {
282
              this.searchUtils.status = this.errorCodes.NOT_FOUND;
283
            } else if(err.status == '500') {
284
              this.searchUtils.status = this.errorCodes.ERROR;
285
            } else {
286
              this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
287
            }
237 288
        }
238 289
    );
239 290
  }

Also available in: Unified diff