Support for selection of capabilities
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / graph / composition-graph.component.ts
index c48231f..8d2357d 100644 (file)
@@ -24,7 +24,9 @@ import {
     ZoneInstance,
     ZoneInstanceAssignmentType,
     ZoneInstanceMode,
-    ZoneInstanceType
+    ZoneInstanceType,
+    Requirement,
+    Capability
 } from 'app/models';
 import { ForwardingPath } from 'app/models/forwarding-path';
 import { CompositionCiServicePathLink } from 'app/models/graph/graph-links/composition-graph-links/composition-ci-service-path-link';
@@ -643,6 +645,19 @@ export class CompositionGraphComponent implements AfterViewInit {
             selectedNode.data('displayName', selectedNode.data().getDisplayName()); // abbreviated
         });
 
+        this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_COMPONENT_INSTANCE_REQUIREMENT_EXTERNAL_CHANGED, (uniqueId:string, requirement:Requirement) => {
+            this._cy.getElementById(uniqueId).data().componentInstance.requirements[requirement.capability]
+                .find(r => r.uniqueId === requirement.uniqueId).external = requirement.external;
+        });
+
+        this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_COMPONENT_INSTANCE_CAPABILITY_EXTERNAL_CHANGED,
+            (uniqueId: string, capability: Capability) => {
+                const graphCapability = this._cy.getElementById(uniqueId).data()
+                    .componentInstance.capabilities[capability.type].find(cap => cap.uniqueId === capability.uniqueId);
+                graphCapability.external = capability.external;
+            }
+        );
+
         this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, (componentInstanceId: string) => {
             const nodeToDelete = this._cy.getElementById(componentInstanceId);
             this.nodesGraphUtils.deleteNode(this._cy, this.topologyTemplate, nodeToDelete);