This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit 17d8f6cf6b4247c9e84bee1fe2332c2aaa83f9f9 Author: Alex Heneveld <[email protected]> AuthorDate: Mon May 31 23:13:29 2021 +0100 allow callback on layer activation/disactivation --- .../app/components/designer/designer.directive.js | 2 +- ui-modules/blueprint-composer/app/components/util/d3-blueprint.js | 1 + ui-modules/blueprint-composer/app/views/main/main.controller.js | 8 ++++++++ ui-modules/blueprint-composer/app/views/main/main.template.html | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ui-modules/blueprint-composer/app/components/designer/designer.directive.js b/ui-modules/blueprint-composer/app/components/designer/designer.directive.js index a7ae56f..c6bf370 100644 --- a/ui-modules/blueprint-composer/app/components/designer/designer.directive.js +++ b/ui-modules/blueprint-composer/app/components/designer/designer.directive.js @@ -63,7 +63,7 @@ export function designerDirective($log, $state, $q, iconGenerator, catalogApi, b $scope.selectedEntity = null; $scope.$on('d3.redraw', (event, initial)=> { - $log.debug(TAG + 'Re-draw blueprint, triggered by ' + event.name, $scope.blueprint); + $log.debug(TAG + 'Re-draw blueprint, triggered by ' + event.name, initial, $scope.blueprint); blueprintService.refreshBlueprintMetadata().then(()=>{ redrawGraph(); diff --git a/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js b/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js index e65507f..e90c1bb 100755 --- a/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js +++ b/ui-modules/blueprint-composer/app/components/util/d3-blueprint.js @@ -690,6 +690,7 @@ export function D3Blueprint(container, options) { .attr('y2', (d)=>(d.target.y)); link.exit() .transition() + .duration(_configHolder.transition) // doesn't seem to work, links just disappear immediately .attr('opacity', 0) .remove(); } diff --git a/ui-modules/blueprint-composer/app/views/main/main.controller.js b/ui-modules/blueprint-composer/app/views/main/main.controller.js index 90f97b6..261e294 100644 --- a/ui-modules/blueprint-composer/app/views/main/main.controller.js +++ b/ui-modules/blueprint-composer/app/views/main/main.controller.js @@ -76,6 +76,14 @@ export function MainController($scope, $element, $log, $state, $stateParams, brB if (layersL) layersL.forEach(l => { if (layersM[l.id]) layersM[l.id] = Object.assign({}, layersM[l.id], l); }); vm.layers = Object.values(layersM); + vm.onLayerActive = (layer, value) => { + if (layer.onLayerActive) { + layer.onLayerActive(value, $scope); + } + layer.active = value; + }; + vm.layers.forEach(l => vm.onLayerActive(l, l.active)); + $scope.$watch('vm.layers', ()=> { vm.layers.forEach(layer => { document.querySelectorAll(layer.selector).forEach(node => { diff --git a/ui-modules/blueprint-composer/app/views/main/main.template.html b/ui-modules/blueprint-composer/app/views/main/main.template.html index caed095..feed230 100644 --- a/ui-modules/blueprint-composer/app/views/main/main.template.html +++ b/ui-modules/blueprint-composer/app/views/main/main.template.html @@ -42,7 +42,7 @@ <li role="menuitem" class="layer" ng-repeat="layer in vm.layers track by layer.id" ng-class="{'active': layer.active}"> - <a ng-click="layer.active = !layer.active"><i class="fa fa-fw fa-circle"></i> {{layer.label}}</a> + <a ng-click="vm.onLayerActive(layer, !layer.active)"><i class="fa fa-fw fa-circle"></i> {{layer.label}}</a> </li> </ul> </li>
