| angular.module('xos.serviceTopology') |
| .directive('serviceTopology', function(){ |
| controller: function($element, $window, $scope, d3, serviceTopologyConfig, ServiceRelation, Slice, Instances, Subscribers, ServiceTopologyHelper){ |
| // TODO update instead clear and redraw |
| d3.select($element[0]).select('svg').remove(); |
| const width = el.clientWidth - (serviceTopologyConfig.widthMargin * 2); |
| const height = el.clientHeight - (serviceTopologyConfig.heightMargin * 2); |
| const treeLayout = d3.layout.tree() |
| svg = d3.select($element[0]) |
| .style('width', `${el.clientWidth}px`) |
| .style('height', `${el.clientHeight}px`) |
| const treeContainer = svg.append('g') |
| .attr('transform', `translate(${serviceTopologyConfig.widthMargin * 4},${serviceTopologyConfig.heightMargin})`); |
| ServiceTopologyHelper.drawLegend(svg); |
| ServiceTopologyHelper.updateTree(treeContainer, treeLayout, root); |
| this.getInstances = (slice) => { |
| Instances.query({slice: slice.id}).$promise |
| this.selectedSlice = slice; |
| this.instances = instances; |
| $scope.$watch(() => this.serviceChain, (chain) => { |