summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d3ce0c5)
* NG-UI should send header request for all the request.
Change-Id: I91ed6f001cd233d19f6512859e929623fdff89c0
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
this.restService.getResource(environment.NSDESCRIPTORSCONTENT_URL + '/' + this.identifier).subscribe((nsData: NSDDetails) => {
delete nsData._admin;
delete nsData._id;
this.restService.getResource(environment.NSDESCRIPTORSCONTENT_URL + '/' + this.identifier).subscribe((nsData: NSDDetails) => {
delete nsData._admin;
delete nsData._id;
this.nsData = nsData;
this.vnfdPackageDetails.shortName = nsData['short-name'];
this.vnfdPackageDetails.vendor = nsData.vendor;
this.nsData = nsData;
this.vnfdPackageDetails.shortName = nsData['short-name'];
this.vnfdPackageDetails.vendor = nsData.vendor;
vld: VLD[];
_admin: VNFDAdminDetails;
_id: string;
vld: VLD[];
_admin: VNFDAdminDetails;
_id: string;
'constituent-vnfr-ref': string[];
}
'constituent-vnfr-ref': string[];
}
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
-import { ERRORDATA } from 'CommonModel';
+import { APIURLHEADER, ERRORDATA } from 'CommonModel';
import * as HttpStatus from 'http-status-codes';
import { Observable } from 'rxjs';
import * as HttpStatus from 'http-status-codes';
import { Observable } from 'rxjs';
+import { isNullOrUndefined } from 'util';
/**
* An Injectable is a class adorned with the @Injectable decorator function.
/**
* An Injectable is a class adorned with the @Injectable decorator function.
*/
public getResource(apiURL: string, httpHeaders?: { headers: HttpHeaders }): Observable<{}> {
*/
public getResource(apiURL: string, httpHeaders?: { headers: HttpHeaders }): Observable<{}> {
- return this.http.get(apiURL, httpHeaders);
+ const getRequest: APIURLHEADER = this.getHttpoptions(apiURL);
+ if (!isNullOrUndefined(httpHeaders)) {
+ return this.http.get(apiURL, httpHeaders);
+ } else {
+ return this.http.get(getRequest.url, getRequest.httpOptions);
+ }
*/
public postResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<{}> {
*/
public postResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<{}> {
- return this.http.post(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ const getRequest: APIURLHEADER = this.getHttpoptions(apiURLHeader.url);
+ if (!isNullOrUndefined(apiURLHeader.httpOptions)) {
+ return this.http.post(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ } else {
+ return this.http.post(getRequest.url, payload, getRequest.httpOptions);
+ }
*/
public patchResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<object> {
*/
public patchResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<object> {
- return this.http.patch(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ const getRequest: APIURLHEADER = this.getHttpoptions(apiURLHeader.url);
+ if (!isNullOrUndefined(apiURLHeader.httpOptions)) {
+ return this.http.patch(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ } else {
+ return this.http.patch(getRequest.url, payload, getRequest.httpOptions);
+ }
*/
public putResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<object> {
*/
public putResource(apiURLHeader: { url: string, httpOptions?: { headers: HttpHeaders } }, payload: {}): Observable<object> {
- return this.http.put(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ const getRequest: APIURLHEADER = this.getHttpoptions(apiURLHeader.url);
+ if (!isNullOrUndefined(apiURLHeader.httpOptions)) {
+ return this.http.put(apiURLHeader.url, payload, apiURLHeader.httpOptions);
+ } else {
+ return this.http.put(getRequest.url, payload, getRequest.httpOptions);
+ }
*/
public deleteResource(apiURL: string, httpHeaders?: { headers: HttpHeaders }): Observable<object> {
*/
public deleteResource(apiURL: string, httpHeaders?: { headers: HttpHeaders }): Observable<object> {
- return this.http.delete(apiURL, httpHeaders);
+ const getRequest: APIURLHEADER = this.getHttpoptions(apiURL);
+ if (!isNullOrUndefined(httpHeaders)) {
+ return this.http.delete(apiURL, httpHeaders);
+ } else {
+ return this.http.delete(getRequest.url, getRequest.httpOptions);
+ }
}
/**
* Handle Error response based on the status.
}
/**
* Handle Error response based on the status.
err.error.detail : this.translateService.instant('ERROR'));
}
}
err.error.detail : this.translateService.instant('ERROR'));
}
}
+
+ /** Set headers for get Methods @public */
+ private getHttpoptions(apiURL: string): APIURLHEADER {
+ const apiHeaders: HttpHeaders = new HttpHeaders({
+ 'Content-Type': 'application/json; charset=UTF-8',
+ Accept: 'application/json',
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+ });
+ return {
+ url: apiURL,
+ httpOptions: {headers : apiHeaders}
+ };
+ }