diff options
author | 2022-01-04 14:15:06 +0000 | |
---|---|---|
committer | 2022-02-02 11:34:41 +0000 | |
commit | d76c30d1156c7fa52fa9ab8a8df9562181ecacba (patch) | |
tree | ed197c4dc5d5e8c09d482706add241a91a97acd7 /catalog-ui/src/app/ng2/pages/composition/graph | |
parent | 17862485d3475a81aa836f84609ec1a2b69b1d64 (diff) |
fix policy and group drag and drop bug
Issue-ID: SDC-3864
Signed-off-by: stasys10 <stasys.jurgaitis@est.tech>
Change-Id: Ib45b4a1b650a7d5959e4a6ff70d46d6dee0586c2
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/composition/graph')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.component.ts | 13 | ||||
-rw-r--r-- | catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts | 41 |
2 files changed, 12 insertions, 42 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.component.ts b/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.component.ts index 1328747f88..6bbf1afab9 100644 --- a/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.component.ts @@ -184,6 +184,10 @@ export class CompositionGraphComponent implements AfterViewInit { } public onDrop = (dndEvent: DndDropEvent) => { + if (dndEvent.data.categoryType=="POLICY" || dndEvent.data.categoryType=="GROUP"){ + this.compositionGraphPaletteUtils.addPolicyOrGroupFromPalette(dndEvent); + return; + } this.compositionGraphPaletteUtils.addNodeFromPalette(this._cy, dndEvent); } @@ -600,10 +604,6 @@ export class CompositionGraphComponent implements AfterViewInit { this.notificationService.push(new NotificationSettings('success', 'Policy Updated', 'Success')); }); - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, (leftPaletteComponent: LeftPaletteComponent) => { - this.compositionGraphPaletteUtils.onComponentHoverIn(leftPaletteComponent, this._cy); - }); - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_ADD_ZONE_INSTANCE_FROM_PALETTE, (component: TopologyTemplate, paletteComponent: LeftPaletteComponent, startPosition: Point) => { @@ -620,11 +620,6 @@ export class CompositionGraphComponent implements AfterViewInit { }); }); - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT, () => { - this._cy.emit('hidehandles'); - this.matchCapabilitiesRequirementsUtils.resetFadedNodes(this._cy); - }); - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_START, (dragElement, dragComponent) => { this.dragElement = dragElement; this.dragComponent = ComponentInstanceFactory.createComponentInstanceFromComponent(dragComponent, this.workspaceService.metadata.categories[0].useServiceSubstitutionForNestedServices); diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts index 72780ec0e5..8383c24f26 100644 --- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts +++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import {Injectable} from "@angular/core"; +import {Component, Injectable} from "@angular/core"; import {CompositionGraphGeneralUtils, RequirementAndCapabilities} from "./composition-graph-general-utils"; import {CommonGraphUtils} from "../common/common-graph-utils"; import {EventListenerService} from "../../../../../services/event-listener-service"; @@ -54,38 +54,6 @@ export class CompositionGraphPaletteUtils { } /** - * - * @param Calculate matching nodes, highlight the matching nodes and fade the non matching nodes - * @param leftPaletteComponent - * @param _cy - * @returns void - * @private - */ - - public onComponentHoverIn = (leftPaletteComponent: LeftPaletteComponent, _cy: Cy.Instance) => { - const nodesData = this.nodesGraphUtils.getAllNodesData(_cy.nodes()); - const nodesLinks = this.generalGraphUtils.getAllCompositionCiLinks(_cy); - - if (this.generalGraphUtils.componentRequirementsAndCapabilitiesCaching.containsKey(leftPaletteComponent.uniqueId)) { - const reqAndCap: RequirementAndCapabilities = this.generalGraphUtils.componentRequirementsAndCapabilitiesCaching.getValue(leftPaletteComponent.uniqueId); - const filteredNodesData = this.matchCapabilitiesRequirementsUtils.findMatchingNodesToComponentInstance( - { uniqueId: leftPaletteComponent.uniqueId, requirements: reqAndCap.requirements, capabilities: reqAndCap.capabilities} as ComponentInstance, nodesData, nodesLinks); - - this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, _cy); - this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, _cy); - } else { - - this.topologyTemplateService.getCapabilitiesAndRequirements(leftPaletteComponent.componentType, leftPaletteComponent.uniqueId).subscribe((response: ComponentGenericResponse) => { - let reqAndCap: RequirementAndCapabilities = { - capabilities: response.capabilities, - requirements: response.requirements - } - this.generalGraphUtils.componentRequirementsAndCapabilitiesCaching.setValue(leftPaletteComponent.uniqueId, reqAndCap); - }); - } - } - - /** * Calculate the dragged element (html element) position on canvas * @param cy * @param event @@ -228,5 +196,12 @@ export class CompositionGraphPaletteUtils { }); } } + + addPolicyOrGroupFromPalette(dndEvent: DndDropEvent) { + let draggedComponent:LeftPaletteComponent = dndEvent.data; + let dropPosition:Point = dndEvent.event; + let component:Component = dndEvent.data; + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_ADD_ZONE_INSTANCE_FROM_PALETTE, draggedComponent, component, dropPosition); + } } |