From 008518dc35ded3bb6dc3e6352472b5816271f583 Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Thu, 11 Jan 2018 10:22:16 +0800 Subject: adjust folder change fold menu to menus Issue-ID: SDC-900 Change-Id: Ifce180badf4f468a3291b118bfd4f631483541ec Signed-off-by: Lvbo163 --- .../src/app/util/http.service.ts | 33 ++++++++++++++-------- .../src/app/util/rxjs-operators.ts | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'sdc-workflow-designer-ui/src/app/util') diff --git a/sdc-workflow-designer-ui/src/app/util/http.service.ts b/sdc-workflow-designer-ui/src/app/util/http.service.ts index 32669555..f754d38e 100644 --- a/sdc-workflow-designer-ui/src/app/util/http.service.ts +++ b/sdc-workflow-designer-ui/src/app/util/http.service.ts @@ -16,13 +16,13 @@ import './rxjs-operators'; @Injectable() export class HttpService { - constructor(private http: Http) {} + constructor(private http: Http) { } - public get(uri: string): Observable { - return this.getHttp('get', uri); + public get(uri: string, options?: RequestOptionsArgs): Observable { + return this.getHttp('get', uri, options); } - public post(uri: string, data: any): Observable { + public post(uri: string, data: any, options?: RequestOptionsArgs): Observable { return this.getHttp('post', uri, data); } @@ -37,22 +37,31 @@ export class HttpService { public getHttp(type: string, uri: string, data?: any, options?: RequestOptionsArgs): Observable { if (data) { return this.http[type](uri, data, options) - .map(response => - response.json() - ) + .map(response => { + if (response.text() === '') { + return {}; + } + + return response.json(); + }) .catch(this.handleError); } else { return this.http[type](uri, options) - .map(response => - response.json() - ) + .map(response => response.json()) .catch(this.handleError); } } private handleError(error: any) { - const errMsg = (error.message) ? error.message : - error.status ? `${error.status}-${error.statusText}` : 'Server error'; + let errMsg = ''; + try { + errMsg = error.json().message; + if (!errMsg) { + errMsg = error.json().msg; + } + } catch (e) { + errMsg = error.status ? `${error.status}-${error.statusText}` : 'Server error'; + } return Observable.throw(errMsg); } } diff --git a/sdc-workflow-designer-ui/src/app/util/rxjs-operators.ts b/sdc-workflow-designer-ui/src/app/util/rxjs-operators.ts index 00fa50b8..1a8f11c0 100644 --- a/sdc-workflow-designer-ui/src/app/util/rxjs-operators.ts +++ b/sdc-workflow-designer-ui/src/app/util/rxjs-operators.ts @@ -9,6 +9,7 @@ * Contributors: * ZTE - initial API and implementation and/or initial documentation */ +import 'rxjs/add/observable/forkJoin'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/debounceTime'; -- cgit 1.2.3-korg