summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/component-instance-services
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/ng2/services/component-instance-services
parent51157f92c21976cba4914c378aaa3cba49826931 (diff)
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/services/component-instance-services')
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts49
1 files changed, 25 insertions, 24 deletions
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 b852539edd..0947b2aa7f 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
@@ -23,10 +23,9 @@ import {Response, RequestOptions, Headers} from '@angular/http';
import { Observable } from 'rxjs/Observable';
import {PropertyFEModel, PropertyBEModel} from "app/models";
import {CommonUtils} from "app/utils";
-import {Component, ComponentInstance, InputModel} from "app/models";
+import {Component, ComponentInstance, Capability, PropertyModel} from "app/models";
import { HttpService } from '../http.service';
import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config";
-import {isEqual} from "lodash";
@Injectable()
export class ComponentInstanceServiceNg2 {
@@ -52,43 +51,45 @@ export class ComponentInstanceServiceNg2 {
})
}
- updateInstanceProperty(component: Component, componentInstanceId: string, property: PropertyBEModel): Observable<PropertyBEModel> {
+ updateInstanceProperties(component: Component, componentInstanceId: string, properties: PropertyBEModel[]) {
- return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/property', property)
+ return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/properties', properties)
.map((res: Response) => {
- return new PropertyBEModel(res.json());
- })
+ return res.json().map((resProperty) => new PropertyBEModel(resProperty));
+ });
}
- getInstanceCapabilityProperties(component: Component, componentInstanceId: string, capabilityType: string, capabilityName: string): Observable<Array<PropertyBEModel>> {
+ getInstanceCapabilityProperties(component: Component, componentInstanceId: string, capability: Capability): Observable<Array<PropertyModel>> {
- return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capabilityType +
- '/capabilityName/' + capabilityName + '/properties')
+ return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capability.type +
+ '/capabilityName/' + capability.name + '/ownerId/' + capability.ownerId + '/properties')
.map((res: Response) => {
- return CommonUtils.initBeProperties(res.json());
+ capability.properties = res.json().map((capProp) => new PropertyModel(capProp)); // update capability properties
+ return capability.properties;
})
}
- updateInstanceCapabilityProperties(component: Component, componentInstanceId: string, capabilityType: string, capabilityName: string, properties: PropertyBEModel[]): Observable<PropertyBEModel[]> {
+ updateInstanceCapabilityProperties(component: Component, componentInstanceId: string, capability: Capability, properties: PropertyBEModel[]): Observable<Array<PropertyModel>> {
- return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capabilityType +
- '/capabilityName/' + capabilityName +'/properties', properties)
+ return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/capability/' + capability.type +
+ '/capabilityName/' + capability.name + '/ownerId/' + capability.ownerId + '/properties', properties)
.map((res: Response) => {
- return res.json().map((resProperty) => new PropertyBEModel(resProperty));
+ const savedProperties: PropertyModel[] = res.json().map((resProperty) => new PropertyModel(resProperty));
+ savedProperties.forEach((savedProperty) => {
+ const propIdx = capability.properties.findIndex((p) => p.uniqueId === savedProperty.uniqueId);
+ if (propIdx !== -1) {
+ capability.properties.splice(propIdx, 1, savedProperty);
+ }
+ });
+ return savedProperties;
})
}
- updateInstanceInput(component: Component, componentInstanceId: string, input: PropertyBEModel): Observable<PropertyBEModel> {
+ updateInstanceInputs(component: Component, componentInstanceId: string, inputs: PropertyBEModel[]): Observable<PropertyBEModel[]> {
- return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/input', input)
+ return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/inputs', inputs)
.map((res: Response) => {
- return new PropertyBEModel(res.json());
- })
- }
-
- hasPropertyChanged(property: PropertyFEModel) {
- let oldValue: any = property.value;
- const newValue = property.getJSONValue();
- return ((oldValue || newValue) && !isEqual(oldValue, newValue));
+ return res.json().map((resInput) => new PropertyBEModel(resInput));
+ });
}
}