Project

General

Profile

« Previous | Next » 

Revision 54825

[trunk]: Library:
1. Fix error logs in Landing, Deposit and Search Pages.
2. errorMessages.component: Add method to check status of response and return error code according to 'ErrorCodes' class.

View differences:

journals.component.ts
6 6
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
7 7
import {SearchResult}     from '../../utils/entities/searchResult';
8 8
import {ErrorCodes} from '../../utils/properties/errorCodes';
9
import {ErrorMessagesComponent}    from '../../utils/errorMessages.component';
9 10
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
10 11
import {SearchPageComponent } from '../searchUtils/searchPage.component';
11 12
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
......
33 34
})
34 35
export class SearchJournalsComponent {
35 36
  private errorCodes: ErrorCodes;
36

  
37
  private errorMessages: ErrorMessagesComponent;
37 38
  public results =[];
38 39
  public filters =[];
39 40
  public baseUrl:string;
......
61 62

  
62 63
  constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
63 64
    this.errorCodes = new ErrorCodes();
65
    this.errorMessages = new ErrorMessagesComponent();
64 66
    this.searchUtils.status = this.errorCodes.LOADING;
65 67
    for(var i = 0; i < this._prefixQueryFields.length; i++ ){
66 68
      for(var j =0; j < this._prefixQueryFields[i].values.length; j++){
......
131 133

  
132 134
          },
133 135
          err => {
134
              console.log(err);
136
              //console.log(err);
137
              this.handleError("Error getting journals", err);
138
              this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
139

  
135 140
               //TODO check erros (service not available, bad request)
136 141
              // if( ){
137 142
              //   this.searchUtils.status = ErrorCodes.ERROR;
138 143
              // }
139 144
              //var errorCodes:ErrorCodes = new ErrorCodes();
140 145
              //this.searchUtils.status = errorCodes.ERROR;
141
              if(err.status == '404') {
146
              /*if(err.status == '404') {
142 147
                this.searchUtils.status = this.errorCodes.NOT_FOUND;
143 148
              } else if(err.status == '500') {
144 149
                this.searchUtils.status = this.errorCodes.ERROR;
145 150
              } else {
146 151
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
147
              }
152
              }*/
148 153

  
149 154
              //this.searchPage.closeLoading();
150 155
              this.disableForms = false;
......
196 201
    }
197 202
    return filters;
198 203
    }
204

  
205
    private handleError(message: string, error) {
206
      console.error("Journals Search Page: "+message, error);
207
    }
199 208
}

Also available in: Unified diff