aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/component-instance-services
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/component-instance-services
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/component-instance-services')
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts35
1 files changed, 29 insertions, 6 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 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));
+ }
}