summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/services')
-rw-r--r--catalog-ui/src/app/ng2/services/authentication.service.ts13
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts35
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component-mode.service.ts (renamed from catalog-ui/src/app/ng2/services/component-mode.service.ts)2
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts19
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/service.service.ts10
-rw-r--r--catalog-ui/src/app/ng2/services/config.service.ts12
-rw-r--r--catalog-ui/src/app/ng2/services/cookie.service.ts8
-rw-r--r--catalog-ui/src/app/ng2/services/hierarchy-nav.service.ts83
-rw-r--r--catalog-ui/src/app/ng2/services/http.service.ts14
-rw-r--r--catalog-ui/src/app/ng2/services/modal.service.ts41
-rw-r--r--catalog-ui/src/app/ng2/services/properties.service.ts8
-rw-r--r--catalog-ui/src/app/ng2/services/user.service.ts98
12 files changed, 193 insertions, 150 deletions
diff --git a/catalog-ui/src/app/ng2/services/authentication.service.ts b/catalog-ui/src/app/ng2/services/authentication.service.ts
index 876385c832..1c6502dd0d 100644
--- a/catalog-ui/src/app/ng2/services/authentication.service.ts
+++ b/catalog-ui/src/app/ng2/services/authentication.service.ts
@@ -18,26 +18,23 @@
* ============LICENSE_END=========================================================
*/
-import { Injectable } from '@angular/core';
-import { sdc2Config } from './../../../main';
+import {Injectable, Inject} from '@angular/core';
import {IAppConfigurtaion, ICookie} from "../../models/app-config";
import {Response, Headers, RequestOptions, Http} from '@angular/http';
import {Cookie2Service} from "./cookie.service";
import { Observable } from 'rxjs/Observable';
+import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
@Injectable()
export class AuthenticationService {
- private cookieService:Cookie2Service;
- private http:Http;
-
- constructor(cookieService:Cookie2Service, http: Http) {
+ constructor(private cookieService:Cookie2Service, private http: Http, @Inject(SdcConfigToken) private sdcConfig:ISdcConfig) {
this.cookieService = cookieService;
this.http = http;
}
private getAuthHeaders():any {
- let cookie:ICookie = sdc2Config.cookie;
+ let cookie:ICookie = this.sdcConfig.cookie;
let authHeaders:any = {};
authHeaders[cookie.userFirstName] = this.cookieService.getFirstName();
authHeaders[cookie.userLastName] = this.cookieService.getLastName();
@@ -51,7 +48,7 @@ export class AuthenticationService {
headers: new Headers(this.getAuthHeaders())
});
- let authUrl = sdc2Config.api.root + sdc2Config.api.GET_user_authorize;
+ let authUrl = this.sdcConfig.api.root + this.sdcConfig.api.GET_user_authorize;
return this.http
.get(authUrl, options)
.map((res: Response) => res.json());
diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
index 27de59de82..b852539edd 100644
--- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
@@ -18,22 +18,23 @@
* ============LICENSE_END=========================================================
*/
-import {Injectable} from '@angular/core';
+import {Injectable, Inject} from '@angular/core';
import {Response, RequestOptions, Headers} from '@angular/http';
import { Observable } from 'rxjs/Observable';
-import {sdc2Config} from "../../../../main";
-import {PropertyBEModel} from "app/models";
+import {PropertyFEModel, PropertyBEModel} from "app/models";
import {CommonUtils} from "app/utils";
import {Component, ComponentInstance, InputModel} from "app/models";
import { HttpService } from '../http.service';
+import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config";
+import {isEqual} from "lodash";
@Injectable()
export class ComponentInstanceServiceNg2 {
protected baseUrl;
- constructor(private http: HttpService) {
- this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
+ constructor(private http: HttpService, @Inject(SdcConfigToken) sdcConfig:ISdcConfig) {
+ this.baseUrl = sdcConfig.api.root + sdcConfig.api.component_api_root;
}
getComponentInstanceProperties(component: Component, componentInstanceId: string): Observable<Array<PropertyBEModel>> {
@@ -59,6 +60,24 @@ export class ComponentInstanceServiceNg2 {
})
}
+ getInstanceCapabilityProperties(component: Component, componentInstanceId: string, capabilityType: string, capabilityName: string): Observable<Array<PropertyBEModel>> {
+
+ return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capabilityType +
+ '/capabilityName/' + capabilityName + '/properties')
+ .map((res: Response) => {
+ return CommonUtils.initBeProperties(res.json());
+ })
+ }
+
+ updateInstanceCapabilityProperties(component: Component, componentInstanceId: string, capabilityType: string, capabilityName: string, properties: PropertyBEModel[]): Observable<PropertyBEModel[]> {
+
+ return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capabilityType +
+ '/capabilityName/' + capabilityName +'/properties', properties)
+ .map((res: Response) => {
+ return res.json().map((resProperty) => new PropertyBEModel(resProperty));
+ })
+ }
+
updateInstanceInput(component: Component, componentInstanceId: string, input: PropertyBEModel): Observable<PropertyBEModel> {
return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/input', input)
@@ -67,5 +86,9 @@ export class ComponentInstanceServiceNg2 {
})
}
-
+ hasPropertyChanged(property: PropertyFEModel) {
+ let oldValue: any = property.value;
+ const newValue = property.getJSONValue();
+ return ((oldValue || newValue) && !isEqual(oldValue, newValue));
+ }
}
diff --git a/catalog-ui/src/app/ng2/services/component-mode.service.ts b/catalog-ui/src/app/ng2/services/component-services/component-mode.service.ts
index 2e60f6ac57..b0cc1b8f1a 100644
--- a/catalog-ui/src/app/ng2/services/component-mode.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component-mode.service.ts
@@ -22,7 +22,7 @@
* Created by rc2122 on 5/23/2017.
*/
import { Injectable } from '@angular/core';
-import {WorkspaceMode, ComponentState, Role} from "../../utils/constants";
+import {WorkspaceMode, ComponentState, Role} from "../../../utils/constants";
import { Component as ComponentData } from "app/models";
import { CacheService } from "app/services/cache-service"
diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
index c648711d5d..ba1cb15561 100644
--- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-import {Injectable} from '@angular/core';
+import {Injectable, Inject} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
@@ -27,11 +27,11 @@ import { Component, PropertyBEModel, InstancePropertiesAPIMap, FilterPropertiesA
import {downgradeInjectable} from '@angular/upgrade/static';
import {COMPONENT_FIELDS} from "app/utils";
import {ComponentGenericResponse} from "../responses/component-generic-response";
-import {sdc2Config} from "../../../../main";
import {InstanceBePropertiesMap} from "../../../models/properties-inputs/property-fe-map";
import {API_QUERY_PARAMS} from "app/utils";
import { ComponentType, ServerTypeUrl } from "../../../utils/constants";
import { HttpService } from '../http.service';
+import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config";
declare var angular:angular.IAngularStatic;
@@ -40,8 +40,8 @@ export class ComponentServiceNg2 {
protected baseUrl;
- constructor(private http:HttpService) {
- this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
+ constructor(private http:HttpService, @Inject(SdcConfigToken) sdcConfig:ISdcConfig) {
+ this.baseUrl = sdcConfig.api.root + sdcConfig.api.component_api_root;
}
private getComponentDataByFieldsName(componentType:string, componentId: string, fields:Array<string>):Observable<ComponentGenericResponse> {
@@ -151,17 +151,6 @@ export class ComponentServiceNg2 {
.map((res: Response) => {
return res.json();
});
-
- // return {'ExtVL 0':[{definition: false,name:"network_assignments",password:false,required:true,type:"org.openecomp.datatypes.network.NetworkAssignments",uniqueId:"623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_assignments"},
- // {definition: false,name: "exVL_naming",password: false,required: true,type: "org.openecomp.datatypes.Naming",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.exVL_naming"},
- // {definition: false,name: "network_flows",password: false,required: false,type: "org.openecomp.datatypes.network.NetworkFlows",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_flows"},
- // {definition: false,name: "provider_network",password: false,required: true,type: "org.openecomp.datatypes.network.ProviderNetwork",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.provider_network"},
- // {definition: false,name: "network_homing",password: false,required: true,type: "org.openecomp.datatypes.EcompHoming",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_homing"}],
- // 'NetworkCP 0':[{definition: false,description: "identifies MAC address assignments to the CP",name: "mac_requirements",password: false,required: false,type: "org.openecomp.datatypes.network.MacRequirements",uniqueId: "26ec2bfd-b904-46c7-87ed-b32775120f2c.mac_requirements"}],
- // 'NetworkCP 1':[{definition: false,description: "identifies MAC address assignments to the CP",name: "mac_requirements",password: false,required: false,type: "org.openecomp.datatypes.network.MacRequirements",uniqueId: "26ec2bfd-b904-46c7-87ed-b32775120f2c.mac_requirements"}]};
-
-
}
}
-angular.module('Sdc.Services').factory('ComponentServiceNg2', downgradeInjectable(ComponentServiceNg2)); // This is in order to use the service in angular1 till we finish remove all angular1 code
diff --git a/catalog-ui/src/app/ng2/services/component-services/service.service.ts b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
index ec912bbcf5..f38dbef595 100644
--- a/catalog-ui/src/app/ng2/services/component-services/service.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-import { Injectable } from '@angular/core';
+import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import { Response } from '@angular/http';
import {Service} from "app/models";
import { downgradeInjectable } from '@angular/upgrade/static';
-import {sdc2Config} from "../../../../main";
import { HttpService } from '../http.service';
+import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config";
@Injectable()
@@ -34,8 +34,8 @@ export class ServiceServiceNg2 {
protected baseUrl = "";
- constructor(private http: HttpService) {
- this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
+ constructor(private http: HttpService, @Inject(SdcConfigToken) sdcConfig:ISdcConfig) {
+ this.baseUrl = sdcConfig.api.root + sdcConfig.api.component_api_root;
}
validateConformanceLevel(service: Service): Observable<boolean> {
@@ -47,5 +47,3 @@ export class ServiceServiceNg2 {
}
}
-
-angular.module('Sdc.Services').factory('ServiceServiceNg2', downgradeInjectable(ServiceServiceNg2)); // This is in order to use the service in angular1 till we finish remove all angular1 code
diff --git a/catalog-ui/src/app/ng2/services/config.service.ts b/catalog-ui/src/app/ng2/services/config.service.ts
index cac850e91c..9bb7b7a075 100644
--- a/catalog-ui/src/app/ng2/services/config.service.ts
+++ b/catalog-ui/src/app/ng2/services/config.service.ts
@@ -22,13 +22,11 @@
* Created by ob0695 on 4/9/2017.
*/
-import { Injectable } from '@angular/core';
+import { Injectable, Inject } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import {IAppConfigurtaion, ValidationConfiguration, Validations} from "app/models";
-import {sdc2Config} from './../../../main';
-
-declare var __ENV__: string;
+import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
@Injectable()
export class ConfigService {
@@ -36,12 +34,12 @@ export class ConfigService {
private baseUrl;
public configuration: IAppConfigurtaion;
- constructor(private http: Http) {
- this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
+ constructor(private http: Http, @Inject(SdcConfigToken) private sdcConfig:ISdcConfig) {
+ this.baseUrl = this.sdcConfig.api.root + this.sdcConfig.api.component_api_root;
}
loadValidationConfiguration(): Promise<ValidationConfiguration> {
- let url: string = sdc2Config.validationConfigPath;
+ let url: string = this.sdcConfig.validationConfigPath;
let promise: Promise<ValidationConfiguration> = this.http.get(url).map((res: Response) => res.json()).toPromise();
promise.then((validationData: Validations) => {
ValidationConfiguration.validation = validationData;
diff --git a/catalog-ui/src/app/ng2/services/cookie.service.ts b/catalog-ui/src/app/ng2/services/cookie.service.ts
index e5f04f7afd..2a783fdd48 100644
--- a/catalog-ui/src/app/ng2/services/cookie.service.ts
+++ b/catalog-ui/src/app/ng2/services/cookie.service.ts
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-import { Injectable } from '@angular/core';
+import {Injectable, Inject} from '@angular/core';
import {IAppConfigurtaion, ICookie} from "../../models/app-config";
-import {sdc2Config} from './../../../main';
+import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
@Injectable()
export class Cookie2Service {
@@ -28,8 +28,8 @@ export class Cookie2Service {
private cookie:ICookie;
private cookiePrefix:string;
- constructor() {
- this.cookie = sdc2Config.cookie;
+ constructor(@Inject(SdcConfigToken) sdcConfig:ISdcConfig) {
+ this.cookie = sdcConfig.cookie;
this.cookiePrefix = '';
let junctionName:string = this.getCookieByName(this.cookie.junctionName);
diff --git a/catalog-ui/src/app/ng2/services/hierarchy-nav.service.ts b/catalog-ui/src/app/ng2/services/hierarchy-nav.service.ts
deleted file mode 100644
index 016b04788e..0000000000
--- a/catalog-ui/src/app/ng2/services/hierarchy-nav.service.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-import { Injectable } from '@angular/core';
-import { SimpleFlatProperty, PropertyFEModel, DerivedFEProperty } from 'app/models';
-
-
-@Injectable()
-export class HierarchyNavService {
- /**
- * Build hirarchy structure for the tree when user selects on table row.
- * First create Array<SimpleFlatProperty> and insert also the parent (PropertyFEModel) to this array.
- * The Array is flat and contains SimpleFlatProperty that has parentName and uniqueId.
- * Now we build hirarchy from this Array (that includes childrens) and return it for the tree
- *
- * @argument property: PropertyFEModel - property contains flattenedChildren array of DerivedFEProperty
- * @returns Array<SimpleFlatProperty> - containing childrens Array<SimpleFlatProperty>, augmantin childrens to SimpleFlatProperty.
- */
- public getSimplePropertiesTree(property: PropertyFEModel, instanceName: string): Array<SimpleFlatProperty> {
- // Build Array of SimpleFlatProperty before unflatten function
- let flattenProperties: Array<SimpleFlatProperty> = [];
- flattenProperties.push(this.createSimpleFlatProperty(property, instanceName)); // Push the root property
- _.each(property.flattenedChildren, (child: DerivedFEProperty): void => {
- if (child.isChildOfListOrMap && child.schema.property.isSimpleType) return; //do not display non-complex children of list or map
- flattenProperties.push(this.createSimpleFlatProperty(child, instanceName));
- });
-
- let tree = this.unflatten(flattenProperties, '', []);
- return tree[0].childrens; // Return the childrens without the root.
- }
-
- public createSimpleFlatProperty = (property: PropertyFEModel | DerivedFEProperty, instanceName:string): SimpleFlatProperty => {
- if (property instanceof PropertyFEModel) {
- return new SimpleFlatProperty(property.uniqueId, property.name, property.name, '', instanceName);
- } else {
- let propName: string = (property.isChildOfListOrMap) ? property.mapKey : property.name;
- return new SimpleFlatProperty(property.uniqueId, property.propertiesName, propName, property.parentName, instanceName);
- }
-
- }
-
- /**
- * Unflatten Array<SimpleFlatProperty> and build hirarchy.
- * The result will be Array<SimpleFlatProperty> that augmantin with childrens for each SimpleFlatProperty.
- */
- private unflatten(array: Array<SimpleFlatProperty>, parent: any, tree?: any): any {
- tree = typeof tree !== 'undefined' ? tree : [];
- parent = typeof parent !== 'undefined' && parent !== '' ? parent : { path: '' };
-
- var childrens = _.filter(array, (child: SimpleFlatProperty): boolean => {
- return child.parentName == parent.path;
- });
-
- if (!_.isEmpty(childrens)) {
- if (parent.path == '') {
- tree = childrens;
- } else {
- parent['childrens'] = childrens;
- }
- _.each(childrens, (child): void => {
- this.unflatten(array, child);
- });
- }
- return tree;
- }
-}
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] || '');
+ }
+
}
diff --git a/catalog-ui/src/app/ng2/services/modal.service.ts b/catalog-ui/src/app/ng2/services/modal.service.ts
index 65ff870769..22b56c7004 100644
--- a/catalog-ui/src/app/ng2/services/modal.service.ts
+++ b/catalog-ui/src/app/ng2/services/modal.service.ts
@@ -1,6 +1,11 @@
-import { Injectable, Type, ViewContainerRef, ApplicationRef, ComponentFactory, ComponentFactoryResolver, ComponentRef } from '@angular/core';
-import { ModalModel, ButtonModel } from 'app/models';
-import { ModalComponent } from 'app/ng2/components/modal/modal.component';
+import {
+ Injectable, Type, ViewContainerRef, ApplicationRef, ComponentFactory, ComponentFactoryResolver, ComponentRef,
+
+} from '@angular/core';
+import { ModalModel, ButtonModel, StepModel } from 'app/models';
+import {MultiStepsWizardComponent} from "../components/ui/multi-steps-wizard/multi-steps-wizard.component";
+import {ModalComponent} from "../components/ui/modal/modal.component";
+import {WizardHeaderBaseComponent} from "app/ng2/components/ui/multi-steps-wizard/multi-steps-wizard-header-base.component";
@Injectable()
@@ -54,6 +59,23 @@ export class ModalService {
return customModal;
}
+ public createMultiStepsWizard = (title: string, steps:Array<StepModel>, callback: Function, dynamicHeaderType?: Type<WizardHeaderBaseComponent>): ComponentRef<MultiStepsWizardComponent> => {
+ let cancelButton: ButtonModel = new ButtonModel('Cancel', 'outline blue', this.closeCurrentModal);
+ let modalModel: ModalModel = new ModalModel('xl', title, '', [cancelButton]);
+ let wizardInstance: ComponentRef<MultiStepsWizardComponent> = this.createDynamicComponent(MultiStepsWizardComponent);
+ wizardInstance.instance.input = modalModel;
+ wizardInstance.instance.steps = steps;
+ wizardInstance.instance.callback = callback;
+ if(dynamicHeaderType){
+ let dynamicHeader = this.createDynamicComponent(dynamicHeaderType, wizardInstance.instance.dynamicHeaderContainer);
+ wizardInstance.instance.dynamicHeader = dynamicHeader;
+ wizardInstance.instance.dynamicHeader.instance.currentStepIndex = 0;
+ }
+ this.addDynamicContentToModal(wizardInstance, steps[0].component);
+ this.currentModal = wizardInstance;
+ return wizardInstance;
+ }
+
public closeCurrentModal = () => {
if (!this.currentModal) return;
@@ -62,7 +84,7 @@ export class ModalService {
}
- public addDynamicContentToModal = (modalInstance: ComponentRef<ModalComponent>, dynamicComponentType: Type<any>, dynamicComponentInput: any) => {
+ public addDynamicContentToModal = (modalInstance: ComponentRef<ModalComponent>, dynamicComponentType: Type<any>, dynamicComponentInput?: any) => {
let dynamicContent = this.createDynamicComponent(dynamicComponentType, modalInstance.instance.dynamicContentContainer);
dynamicContent.instance.input = dynamicComponentInput;
@@ -72,14 +94,13 @@ export class ModalService {
//Creates a component dynamically (aka during runtime). If a view container is not specified, it will append the new component to the app root.
//To subscribe to an event from invoking component: componentRef.instance.clicked.subscribe((m) => console.log(m.name));
- private createDynamicComponent<T>(componentType: Type<T>, viewContainerRef?:ViewContainerRef): ComponentRef<any> {
+ private createDynamicComponent<T>(componentType: Type<T>, viewContainerRef?:ViewContainerRef): ComponentRef<T> {
viewContainerRef = viewContainerRef || this.getRootViewContainerRef();
viewContainerRef.clear();
- let factory: ComponentFactory<any> = this.componentFactoryResolver.resolveComponentFactory(componentType); //Ref: https://angular.io/guide/dynamic-component-loader
- let componentRef = viewContainerRef.createComponent(factory);
-
+ let factory: ComponentFactory<T> = this.componentFactoryResolver.resolveComponentFactory(componentType); //Ref: https://angular.io/guide/dynamic-component-loader
+ let componentRef: ComponentRef<T> = viewContainerRef.createComponent(factory);
return componentRef;
}
@@ -87,4 +108,6 @@ export class ModalService {
private getRootViewContainerRef(): ViewContainerRef {
return this.applicationRef.components[0].instance.viewContainerRef;
}
-} \ No newline at end of file
+}
+
+
diff --git a/catalog-ui/src/app/ng2/services/properties.service.ts b/catalog-ui/src/app/ng2/services/properties.service.ts
index 6f15de858a..86cd2f5c72 100644
--- a/catalog-ui/src/app/ng2/services/properties.service.ts
+++ b/catalog-ui/src/app/ng2/services/properties.service.ts
@@ -19,16 +19,12 @@
*/
import { Injectable } from '@angular/core';
-import { DataTypeModel, PropertyFEModel, PropertyBEModel, SchemaProperty, PropertyDeclareAPIModel, DerivedFEProperty, DerivedFEPropertyMap, DerivedPropertyType, InputFEModel} from "app/models";
-import { DataTypeService } from "./data-type.service";
-import { PROPERTY_TYPES } from "app/utils";
-import { ContentAfterLastDotPipe } from "../pipes/contentAfterLastDot.pipe";
-import { UUID } from "angular2-uuid";
+import { PropertyFEModel, PropertyBEModel, PropertyDeclareAPIModel, DerivedFEProperty} from "app/models";
@Injectable()
export class PropertiesService {
- constructor(private dataTypeService: DataTypeService, private contentAfterLastDotPipe: ContentAfterLastDotPipe) {
+ constructor() {
}
public getParentPropertyFEModelFromPath = (properties: Array<PropertyFEModel>, path: string) => {
diff --git a/catalog-ui/src/app/ng2/services/user.service.ts b/catalog-ui/src/app/ng2/services/user.service.ts
new file mode 100644
index 0000000000..87e90432dc
--- /dev/null
+++ b/catalog-ui/src/app/ng2/services/user.service.ts
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import { Injectable, Inject } from "@angular/core";
+import { Headers } from "@angular/http";
+import { Observable } from "rxjs/Observable";
+import { HttpService } from "./http.service";
+import { Cookie2Service } from "./cookie.service";
+import { IUserProperties } from "../../models/user";
+
+import {ICookie} from "../../models/app-config";
+import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
+
+@Injectable()
+export class UserService {
+ private url:string;
+ private authorizeUrl:string;
+
+ private _loggedinUser:IUserProperties;
+
+ constructor(private httpService:HttpService,
+ private cookieService:Cookie2Service,
+ @Inject(SdcConfigToken) private sdcConfig:ISdcConfig) {
+ this.url = this.sdcConfig.api.root + this.sdcConfig.api.GET_user;
+ this.authorizeUrl = this.sdcConfig.api.root + this.sdcConfig.api.GET_user_authorize;
+ }
+
+ public authorize() :Observable<IUserProperties> {
+ let cookie:ICookie = this.sdcConfig.cookie;
+ let authorizeHeaders:Headers = new Headers();
+ authorizeHeaders.set(cookie.userFirstName, this.cookieService.getFirstName());
+ authorizeHeaders.set(cookie.userLastName, this.cookieService.getLastName());
+ authorizeHeaders.set(cookie.userEmail, this.cookieService.getEmail());
+ authorizeHeaders.set(cookie.userIdSuffix, this.cookieService.getUserId());
+
+ return this.httpService.get(
+ this.authorizeUrl,
+ { headers: authorizeHeaders }
+ ).map(resp => resp.json());
+ }
+
+ public getAllUsers() :Observable<IUserProperties[]> {
+ return this.httpService.get(
+ this.sdcConfig.api.root + this.sdcConfig.api.GET_all_users
+ ).map(resp => resp.json());
+ }
+
+ public getUser(userId:string) :Observable<IUserProperties> {
+ return this.httpService.get(
+ HttpService.replaceUrlParams(this.url, { id: userId })
+ ).map(resp => resp.json());
+ }
+
+ public createUser(userData:{[index:string]: any}) :Observable<IUserProperties> {
+ return this.httpService.post(
+ this.sdcConfig.api.root + this.sdcConfig.api.POST_create_user,
+ userData
+ ).map(resp => resp.json());
+ }
+
+ public deleteUser(userId:string) :Observable<IUserProperties> {
+ return this.httpService.delete(
+ HttpService.replaceUrlParams(this.sdcConfig.api.root + this.sdcConfig.api.DELETE_delete_user, { id: userId })
+ ).map(resp => resp.json());
+ }
+
+ public editUserRole(userId:string, role:string) :Observable<IUserProperties> {
+ return this.httpService.post(
+ HttpService.replaceUrlParams(this.sdcConfig.api.root + this.sdcConfig.api.POST_edit_user_role, { id: userId }),
+ { role: role }
+ ).map(resp => resp.json());
+ }
+
+ public getLoggedinUser():IUserProperties {
+ return this._loggedinUser;
+ }
+
+ public setLoggedinUser(loggedinUser:IUserProperties) {
+ this._loggedinUser = loggedinUser;
+ };
+}