diff options
author | Stone, Avi (as206k) <as206k@att.com> | 2018-06-03 13:12:12 +0300 |
---|---|---|
committer | Avi Stone <as206k@att.com> | 2018-06-03 11:56:49 +0000 |
commit | 548c5a220333c7cd666b861e737bff0b45461f18 (patch) | |
tree | 13c60b67291bd8bada498ad73c02a9e35afb5c9e /public/src/app/api/rest-api.service.ts | |
parent | 193095b01daf094c78f7fafacdf1c1cc31f290fe (diff) |
Update FE project
Update FE to latest version so that fe can run on docker
Change-Id: I9c5dee756b567dbe64fac6d3d6fd89362813bdcc
Issue-ID: SDC-1359
Signed-off-by: Stone, Avi (as206k) <as206k@att.com>
Diffstat (limited to 'public/src/app/api/rest-api.service.ts')
-rw-r--r-- | public/src/app/api/rest-api.service.ts | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/public/src/app/api/rest-api.service.ts b/public/src/app/api/rest-api.service.ts index ba5cc54..cd55a6d 100644 --- a/public/src/app/api/rest-api.service.ts +++ b/public/src/app/api/rest-api.service.ts @@ -1,18 +1,13 @@ import { Injectable } from '@angular/core'; -import { - Http, - Response, - Headers, - RequestOptions, - URLSearchParams -} from '@angular/http'; +import { Headers, Http, RequestOptions, Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/throw'; +import 'rxjs/add/operator/catch'; // Import RxJs required methods import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/observable/throw'; -import { environment } from '../../environments/environment'; import { v4 as uuidGenarator } from 'uuid'; +import { environment } from '../../environments/environment'; +import { Store } from '../store/store'; @Injectable() export class RestApiService { @@ -20,16 +15,24 @@ export class RestApiService { headers: Headers; baseUrl: string; - constructor(private http: Http) { + constructor(private http: Http, public store: Store) { this.baseUrl = `${environment.apiBaseUrl}`; + } + + addHeaders() { + const userID = + this.store.sdcParmas === undefined + ? 'ym903w' + : this.store.sdcParmas.userId; this.headers = new Headers({ 'Content-Type': 'application/json', - USER_ID: 'ym903w' + USER_ID: userID }); this.options = new RequestOptions({ headers: this.headers }); } getVfcmtsForMigration(params) { + this.addHeaders(); const { contextType, uuid, version } = params; const url = `${ this.baseUrl @@ -44,6 +47,7 @@ export class RestApiService { } getVfcmtReferenceData(vfcmtUUID) { + this.addHeaders(); const url = `${this.baseUrl}/getVfcmtReferenceData/${vfcmtUUID}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -53,6 +57,7 @@ export class RestApiService { } getFlowType() { + this.addHeaders(); const url = `${this.baseUrl}/conf/composition`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -62,6 +67,7 @@ export class RestApiService { } createNewVFCMT(params) { + this.addHeaders(); const url = `${this.baseUrl}/createMC`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -73,6 +79,7 @@ export class RestApiService { } importVFCMT(params) { + this.addHeaders(); const url = `${this.baseUrl}/importMC`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -84,6 +91,7 @@ export class RestApiService { } getServiceInstances(serviceID) { + this.addHeaders(); const url = `${this.baseUrl}/service/${serviceID}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -95,6 +103,7 @@ export class RestApiService { } getTemplateResources() { + this.addHeaders(); const url = `${this.baseUrl}/getResourcesByMonitoringTemplateCategory`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -104,6 +113,7 @@ export class RestApiService { } getMonitoringComponents(params) { + this.addHeaders(); const { contextType, uuid, version } = params; const url = `${ this.baseUrl @@ -116,6 +126,7 @@ export class RestApiService { } deleteMonitoringComponent(params, vfcmtUuid, vfiName) { + this.addHeaders(); const { contextType, uuid } = params; const url = `${ this.baseUrl @@ -123,7 +134,7 @@ export class RestApiService { this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http .delete(url, this.options) - .map((res: Response) => res.json()) + .map((res: Response) => res) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } @@ -133,6 +144,7 @@ export class RestApiService { vfcmtUuid, vfiName ) { + this.addHeaders(); const { contextType, uuid } = params; const url = `${ this.baseUrl @@ -140,11 +152,12 @@ export class RestApiService { this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http .delete(url, this.options) - .map((res: Response) => res.json()) + .map((res: Response) => res) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } getCompositionMonitoringComponent(vfcmtUuid) { + this.addHeaders(); const url = `${this.baseUrl}/getMC/${vfcmtUuid}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -154,18 +167,20 @@ export class RestApiService { } saveMonitoringComponent(params) { + this.addHeaders(); const { contextType, serviceUuid, vfiName, vfcmtUuid, cdump } = params; const url = `${ this.baseUrl }/${contextType}/${serviceUuid}/${vfiName}/saveComposition/${vfcmtUuid}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http - .post(url, cdump, this.options) + .post(url, JSON.stringify(cdump), this.options) .map((res: Response) => res.json()) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } submitMonitoringComponent(params) { + this.addHeaders(); const { contextType, serviceUuid, vfiName, vfcmtUuid, flowType } = params; const url = `${ this.baseUrl |