diff options
author | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-31 15:50:46 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-08-02 21:18:34 +0300 |
commit | f5854fd32c19c44d32a3e6739b30271d4dccd393 (patch) | |
tree | 6e7420dd3d82200849e51c2af3f2696f11815d12 /catalog-ui/src/app/ng2/services/http.service.ts | |
parent | e280d7229f42210719b76775cd47bddb675c3c53 (diff) |
[SDC] code rebase for sdc resync to LF
Change-Id: If6d87c9e324f508a8a6b80b10a03d1843901472e
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/services/http.service.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/services/http.service.ts | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/catalog-ui/src/app/ng2/services/http.service.ts b/catalog-ui/src/app/ng2/services/http.service.ts index 5cd5a10000..21fe09023a 100644 --- a/catalog-ui/src/app/ng2/services/http.service.ts +++ b/catalog-ui/src/app/ng2/services/http.service.ts @@ -24,14 +24,18 @@ import {Observable} from 'rxjs/Observable'; import {UUID} from 'angular2-uuid'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; import {Dictionary} from "../../utils/dictionary/dictionary"; import {SharingService, CookieService} from "app/services"; import {sdc2Config} from './../../../main'; +import { ModalService } from "app/ng2/services/modal.service"; +import { ServerErrorResponse } from "app/models"; +import { ErrorMessageComponent } from 'app/ng2/components/modal/error-message/error-message.component'; @Injectable() export class HttpService extends Http { - constructor(backend:XHRBackend, options:RequestOptions, private sharingService:SharingService, private cookieService: CookieService) { + constructor(backend: XHRBackend, options: RequestOptions, private sharingService: SharingService, private cookieService: CookieService, private modalService: ModalService) { super(backend, options); this._defaultOptions.withCredentials = true; this._defaultOptions.headers.append(cookieService.getUserIdSuffix(), cookieService.getUserId()); @@ -64,7 +68,7 @@ export class HttpService extends Http { } request.headers.set('X-ECOMP-RequestID', UUID.UUID()); } - return super.request(request, options).catch(this.catchAuthError(this)); + return super.request(request, options).catch((err) => this.catchError(err)); } private getUuidValue = (url: string) :string => { @@ -79,15 +83,14 @@ export class HttpService extends Http { return ''; } - private catchAuthError(self:HttpService) { - // we have to pass HttpService's own instance here as `self` - return (res:Response) => { - console.log(res); - if (res.status === 401 || res.status === 403) { - // if not authenticated - console.log(res); - } - return Observable.throw(res); - }; - } + private catchError = (response: Response): Observable<any> => { + + let modalInstance = this.modalService.createErrorModal("OK"); + let errorResponse: ServerErrorResponse = new ServerErrorResponse(response); + this.modalService.addDynamicContentToModal(modalInstance, ErrorMessageComponent, errorResponse); + modalInstance.instance.open(); + + return Observable.throw(response); + }; + } |