aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/http.service.ts
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-ui/src/app/ng2/services/http.service.ts
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.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.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/catalog-ui/src/app/ng2/services/http.service.ts b/catalog-ui/src/app/ng2/services/http.service.ts
index 21fe09023a..2785688ace 100644
--- a/catalog-ui/src/app/ng2/services/http.service.ts
+++ b/catalog-ui/src/app/ng2/services/http.service.ts
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-import {Injectable} from '@angular/core';
+import {Injectable, Inject} from '@angular/core';
import {Http, XHRBackend, RequestOptions, Request, RequestOptionsArgs, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {UUID} from 'angular2-uuid';
@@ -27,15 +27,15 @@ 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';
+import {ErrorMessageComponent} from "../components/ui/modal/error-message/error-message.component";
+import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
@Injectable()
export class HttpService extends Http {
- constructor(backend: XHRBackend, options: RequestOptions, private sharingService: SharingService, private cookieService: CookieService, private modalService: ModalService) {
+ constructor(backend: XHRBackend, options: RequestOptions, private sharingService: SharingService, private cookieService: CookieService, private modalService: ModalService, @Inject(SdcConfigToken) private sdcConfig:ISdcConfig) {
super(backend, options);
this._defaultOptions.withCredentials = true;
this._defaultOptions.headers.append(cookieService.getUserIdSuffix(), cookieService.getUserId());
@@ -73,7 +73,7 @@ export class HttpService extends Http {
private getUuidValue = (url: string) :string => {
let map:Dictionary<string, string> = this.sharingService.getUuidMap();
- if (map && url.indexOf(sdc2Config.api.root) > 0) {
+ if (map && url.indexOf(this.sdcConfig.api.root) > 0) {
map.forEach((key:string) => {
if (url.indexOf(key) !== -1) {
return this.sharingService.getUuidValue(key);
@@ -93,4 +93,8 @@ export class HttpService extends Http {
return Observable.throw(response);
};
+ public static replaceUrlParams(url:string, urlParams:{[index:string]:any}):string {
+ return url.replace(/:(\w+)/g, (m, p1):string => urlParams[p1] || '');
+ }
+
}