diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2018-01-11 10:22:16 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2018-01-11 10:22:16 +0800 |
commit | 008518dc35ded3bb6dc3e6352472b5816271f583 (patch) | |
tree | 773453bb816e2c1fd15d74f308eab32f6da7bfe0 /sdc-workflow-designer-ui/src/app/util | |
parent | ccaa7ff4383e127b9c61d1e511ec6741c42dd37a (diff) |
adjust folder
change fold menu to menus
Issue-ID: SDC-900
Change-Id: Ifce180badf4f468a3291b118bfd4f631483541ec
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/util')
-rw-r--r-- | sdc-workflow-designer-ui/src/app/util/http.service.ts | 33 | ||||
-rw-r--r-- | sdc-workflow-designer-ui/src/app/util/rxjs-operators.ts | 1 |
2 files changed, 22 insertions, 12 deletions
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<any> { - return this.getHttp('get', uri); + public get(uri: string, options?: RequestOptionsArgs): Observable<any> { + return this.getHttp('get', uri, options); } - public post(uri: string, data: any): Observable<any> { + public post(uri: string, data: any, options?: RequestOptionsArgs): Observable<any> { return this.getHttp('post', uri, data); } @@ -37,22 +37,31 @@ export class HttpService { public getHttp(type: string, uri: string, data?: any, options?: RequestOptionsArgs): Observable<any> { 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'; |