From 0953785bfd6a3af5e506f8a55a8520c0fb7ef358 Mon Sep 17 00:00:00 2001 From: Talio Date: Thu, 31 Jan 2019 18:00:36 +0200 Subject: Add property mapping feature to ONAP Add service property assignment Change-Id: I29748ce12bacab06b8bc27f8875b39d80ffe5af7 Issue-ID: SDC-1988 Signed-off-by: Talio --- .../component-services/component.service.ts | 43 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'catalog-ui/src/app/ng2/services/component-services') 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 97e62daba7..69871abe04 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 @@ -24,7 +24,7 @@ import {Observable} from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/toPromise'; import {Response, URLSearchParams} from '@angular/http'; -import { Component, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, OperationModel, BEOperationModel, CreateOperationResponse} from "app/models"; +import { Component, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, PropertyBEModel, OperationModel, BEOperationModel, CreateOperationResponse} from "app/models"; import {downgradeInjectable} from '@angular/upgrade/static'; import {COMPONENT_FIELDS, CommonUtils} from "app/utils"; import {ComponentGenericResponse} from "../responses/component-generic-response"; @@ -205,8 +205,9 @@ export class ComponentServiceNg2 { return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_RELATION, COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_GROUPS]); } - createInput(component:Component, inputsToCreate:InstancePropertiesAPIMap):Observable { - return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/inputs', inputsToCreate) + createInput(component:Component, inputsToCreate:InstancePropertiesAPIMap, isSelf:boolean):Observable { + let inputs = isSelf ? { serviceProperties: inputsToCreate.componentInstanceProperties } : inputsToCreate; + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/inputs', inputs) .map(res => { return res.json(); }) @@ -247,6 +248,42 @@ export class ComponentServiceNg2 { }); } + createServiceProperty(component: Component, propertyModel:PropertyBEModel): Observable { + let serverObject = {}; + serverObject[propertyModel.name] = propertyModel; + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/properties', serverObject) + .map(res => { + let property:PropertyBEModel = new PropertyBEModel(res.json()); + return property; + }) + } + + getServiceProperties(component: Component): Observable> { + return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/properties') + .map((res: Response) => { + if (!res.text()){ + return new Array(); + } + return CommonUtils.initBeProperties(res.json()); + }); + } + + updateServiceProperties(component: Component, properties: PropertyBEModel[]) { + return this.http.put( this.baseUrl + component.getTypeUrl() + component.uniqueId + '/properties', properties) + .map((res: Response) => { + const resJson = res.json(); + return _.map(resJson, + (resValue:PropertyBEModel) => new PropertyBEModel(resValue)); + }); + } + + deleteServiceProperty(component:Component, property:PropertyBEModel):Observable { + return this.http.delete(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/properties/' + property.uniqueId ) + .map((res:Response) => { + return property.uniqueId; + }) + } + getDependencies(componentType:string, componentId: string):Observable> { return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/dependencies') .map((res:Response) => { -- cgit 1.2.3-korg