Matteo Scandolo | 7547f04 | 2016-02-09 09:13:30 -0800 | [diff] [blame] | 1 | (function () { |
| 2 | 'use strict'; |
| 3 | angular.module('xos.serviceTopology') |
| 4 | .directive('logicTopology', function(){ |
| 5 | return { |
| 6 | restrict: 'E', |
| 7 | scope: { |
Matteo Scandolo | 219b1a7 | 2016-02-09 11:19:22 -0800 | [diff] [blame] | 8 | subscribers: '=', |
| 9 | selected: '=' |
Matteo Scandolo | 7547f04 | 2016-02-09 09:13:30 -0800 | [diff] [blame] | 10 | }, |
| 11 | bindToController: true, |
| 12 | controllerAs: 'vm', |
| 13 | template: '', |
Matteo Scandolo | 219b1a7 | 2016-02-09 11:19:22 -0800 | [diff] [blame] | 14 | controller: function($element, $log, $scope, d3, LogicTopologyHelper){ |
Matteo Scandolo | 7547f04 | 2016-02-09 09:13:30 -0800 | [diff] [blame] | 15 | $log.info('Logic Plane'); |
| 16 | |
Matteo Scandolo | 219b1a7 | 2016-02-09 11:19:22 -0800 | [diff] [blame] | 17 | var svg; |
| 18 | |
| 19 | $scope.$watch(() => this.subscribers, (subscribers) => { |
| 20 | if(subscribers){ |
Matteo Scandolo | af28637 | 2016-02-09 14:46:14 -0800 | [diff] [blame] | 21 | LogicTopologyHelper.addSubscribers(svg, angular.copy(subscribers)); |
Matteo Scandolo | 219b1a7 | 2016-02-09 11:19:22 -0800 | [diff] [blame] | 22 | } |
| 23 | }); |
| 24 | |
| 25 | $scope.$watch(() => this.selected, (selected) => { |
| 26 | if(selected){ |
| 27 | $log.info(`Update logic layer for subscriber ${selected.humanReadableName}`); |
| 28 | } |
| 29 | }); |
| 30 | |
| 31 | const handleSvg = (el) => { |
| 32 | |
| 33 | svg = d3.select(el) |
| 34 | .append('svg') |
| 35 | .style('width', `${el.clientWidth}px`) |
| 36 | .style('height', `${el.clientHeight}px`); |
| 37 | } |
| 38 | |
| 39 | handleSvg($element[0]); |
Matteo Scandolo | af28637 | 2016-02-09 14:46:14 -0800 | [diff] [blame] | 40 | LogicTopologyHelper.drawTree(svg); |
Matteo Scandolo | 7547f04 | 2016-02-09 09:13:30 -0800 | [diff] [blame] | 41 | } |
| 42 | }; |
| 43 | }); |
| 44 | })(); |