blob: b689b89b9427c73a6b861281a4c8789bda9a0266 [file] [log] [blame]
Matteo Scandolo7547f042016-02-09 09:13:30 -08001(function () {
2 'use strict';
3 angular.module('xos.serviceTopology')
4 .directive('logicTopology', function(){
5 return {
6 restrict: 'E',
7 scope: {
Matteo Scandolo219b1a72016-02-09 11:19:22 -08008 subscribers: '=',
9 selected: '='
Matteo Scandolo7547f042016-02-09 09:13:30 -080010 },
11 bindToController: true,
12 controllerAs: 'vm',
13 template: '',
Matteo Scandolo219b1a72016-02-09 11:19:22 -080014 controller: function($element, $log, $scope, d3, LogicTopologyHelper){
Matteo Scandolo7547f042016-02-09 09:13:30 -080015 $log.info('Logic Plane');
16
Matteo Scandolo219b1a72016-02-09 11:19:22 -080017 var svg;
18
19 $scope.$watch(() => this.subscribers, (subscribers) => {
20 if(subscribers){
Matteo Scandoloaf286372016-02-09 14:46:14 -080021 LogicTopologyHelper.addSubscribers(svg, angular.copy(subscribers));
Matteo Scandolo219b1a72016-02-09 11:19:22 -080022 }
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 Scandoloaf286372016-02-09 14:46:14 -080040 LogicTopologyHelper.drawTree(svg);
Matteo Scandolo7547f042016-02-09 09:13:30 -080041 }
42 };
43 });
44})();