blob: afe61a83f975792a8d3324a7692375e1a721b5be [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
Matteo Scandolo594dfbc2016-02-11 17:37:08 -080019
20 const handleSvg = (el) => {
21
22 svg = d3.select(el)
23 .append('svg')
24 .style('width', `${el.clientWidth}px`)
25 .style('height', `${el.clientHeight}px`);
26 }
27
Matteo Scandoloeeb9c082016-02-09 11:19:22 -080028 $scope.$watch(() => this.subscribers, (subscribers) => {
29 if(subscribers){
Matteo Scandolo594dfbc2016-02-11 17:37:08 -080030
31 // TODO
32 // build here the full data structure
33
Matteo Scandolo11dc8c42016-02-09 14:46:14 -080034 LogicTopologyHelper.addSubscribers(svg, angular.copy(subscribers));
Matteo Scandoloeeb9c082016-02-09 11:19:22 -080035 }
36 });
37
38 $scope.$watch(() => this.selected, (selected) => {
39 if(selected){
40 $log.info(`Update logic layer for subscriber ${selected.humanReadableName}`);
41 }
42 });
43
Matteo Scandoloeeb9c082016-02-09 11:19:22 -080044 handleSvg($element[0]);
Matteo Scandolo11dc8c42016-02-09 14:46:14 -080045 LogicTopologyHelper.drawTree(svg);
Matteo Scandolo735606c2016-02-09 09:13:30 -080046 }
47 };
48 });
49})();