blob: 0a9215e0f0e0ef69782d4a9cf78b3e0fcd6a0b54 [file] [log] [blame]
Matteo Scandolo735606c2016-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 Scandoloeeb9c082016-02-09 11:19:22 -08008 subscribers: '=',
9 selected: '='
Matteo Scandolo735606c2016-02-09 09:13:30 -080010 },
11 bindToController: true,
12 controllerAs: 'vm',
13 template: '',
Matteo Scandoloeeb9c082016-02-09 11:19:22 -080014 controller: function($element, $log, $scope, d3, LogicTopologyHelper){
Matteo Scandolo735606c2016-02-09 09:13:30 -080015 $log.info('Logic Plane');
16
Matteo Scandoloeeb9c082016-02-09 11:19:22 -080017 var svg;
18
19 $scope.$watch(() => this.subscribers, (subscribers) => {
20 if(subscribers){
21 LogicTopologyHelper.handleSubscribers(svg, subscribers);
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 Scandolo735606c2016-02-09 09:13:30 -080040 }
41 };
42 });
43})();