GUI -- Topo View: define SVG layer; inject (sample) key bindings and install glyph definitions.
Change-Id: I1c063b0484a9cedcf8e57a35cc51c3c4b35c9329
Showing
5 changed files
with
84 additions
and
28 deletions
... | @@ -40,6 +40,12 @@ | ... | @@ -40,6 +40,12 @@ |
40 | 40 | ||
41 | <script src="fw/mast/mast.js"></script> | 41 | <script src="fw/mast/mast.js"></script> |
42 | 42 | ||
43 | + <script src="fw/svg/svg.js"></script> | ||
44 | + <script src="fw/svg/glyph.js"></script> | ||
45 | + <script src="fw/svg/icon.js"></script> | ||
46 | + <script src="fw/svg/map.js"></script> | ||
47 | + <script src="fw/svg/zoom.js"></script> | ||
48 | + | ||
43 | <!-- Framework and library stylesheets included here --> | 49 | <!-- Framework and library stylesheets included here --> |
44 | <!-- TODO: use a single catenated-minified file here --> | 50 | <!-- TODO: use a single catenated-minified file here --> |
45 | <link rel="stylesheet" href="onos.css"> | 51 | <link rel="stylesheet" href="onos.css"> | ... | ... |
... | @@ -23,43 +23,43 @@ | ... | @@ -23,43 +23,43 @@ |
23 | (function () { | 23 | (function () { |
24 | 'use strict'; | 24 | 'use strict'; |
25 | 25 | ||
26 | - var coreDependencies = [ | 26 | + var moduleDependencies = [ |
27 | - 'ngRoute', | 27 | + // view modules... |
28 | - 'onosUtil', | ||
29 | - 'onosMast' | ||
30 | - ]; | ||
31 | - | ||
32 | - var viewDependencies = [ | ||
33 | // TODO: inject view dependencies server side | 28 | // TODO: inject view dependencies server side |
34 | - // NOTE: 'ov' == 'Onos View'... | ||
35 | // {INJECTED-VIEW-MODULE-DEPENDENCIES} | 29 | // {INJECTED-VIEW-MODULE-DEPENDENCIES} |
30 | + // NOTE: 'ov' == 'Onos View'... | ||
36 | 'ovSample', | 31 | 'ovSample', |
37 | 'ovTopo', | 32 | 'ovTopo', |
38 | - // NOTE: dummy element allows all previous entries to end with comma | 33 | + // (end of view modules) |
39 | - '___dummy___' | 34 | + |
35 | + // core modules... | ||
36 | + 'ngRoute', | ||
37 | + 'onosUtil', | ||
38 | + 'onosSvg', | ||
39 | + 'onosMast' | ||
40 | ]; | 40 | ]; |
41 | 41 | ||
42 | - var dependencies = coreDependencies.concat(viewDependencies); | 42 | + var $log; |
43 | - dependencies.pop(); // remove dummy | ||
44 | 43 | ||
45 | - angular.module('onosApp', dependencies) | 44 | + angular.module('onosApp', moduleDependencies) |
46 | 45 | ||
47 | .controller('OnosCtrl', [ | 46 | .controller('OnosCtrl', [ |
48 | '$log', '$route', '$routeParams', '$location', | 47 | '$log', '$route', '$routeParams', '$location', |
49 | - 'KeyService', 'ThemeService', | 48 | + 'KeyService', 'ThemeService', 'GlyphService', |
50 | 49 | ||
51 | - function (_$log_, $route, $routeParams, $location, ks, ts) { | 50 | + function (_$log_, $route, $routeParams, $location, ks, ts, gs) { |
52 | - var $log = _$log_, | 51 | + var self = this; |
53 | - self = this; | ||
54 | 52 | ||
53 | + $log = _$log_; | ||
55 | self.$route = $route; | 54 | self.$route = $route; |
56 | self.$routeParams = $routeParams; | 55 | self.$routeParams = $routeParams; |
57 | self.$location = $location; | 56 | self.$location = $location; |
58 | self.version = '1.1.0'; | 57 | self.version = '1.1.0'; |
59 | 58 | ||
60 | - // initialize onos (main app) controller here... | 59 | + // initialize services... |
61 | ts.init(); | 60 | ts.init(); |
62 | ks.installOn(d3.select('body')); | 61 | ks.installOn(d3.select('body')); |
62 | + gs.init(); | ||
63 | 63 | ||
64 | $log.log('OnosCtrl has been created'); | 64 | $log.log('OnosCtrl has been created'); |
65 | 65 | ... | ... |
1 | <!-- Topology View partial HTML --> | 1 | <!-- Topology View partial HTML --> |
2 | <div id="ov-topo"> | 2 | <div id="ov-topo"> |
3 | - <h2> Topology View </h2> | 3 | + <svg viewBox="0 0 1000 1000"></svg> |
4 | - | ||
5 | - <p> | ||
6 | - This is a place-holder for the topology viewer. | ||
7 | - </p> | ||
8 | - | ||
9 | - <div class="msg"> {{ctrl.message}} </div> | ||
10 | </div> | 4 | </div> | ... | ... |
... | @@ -22,13 +22,65 @@ | ... | @@ -22,13 +22,65 @@ |
22 | 22 | ||
23 | (function () { | 23 | (function () { |
24 | 'use strict'; | 24 | 'use strict'; |
25 | - angular.module('ovTopo', ['onosUtil']) | 25 | + |
26 | - .controller('OvTopoCtrl', ['$log', function (_$log_) { | 26 | + var moduleDependencies = [ |
27 | - var self = this, | 27 | + 'onosUtil', |
28 | + 'onosSvg' | ||
29 | + ]; | ||
30 | + | ||
31 | + // references to injected services etc. | ||
32 | + var $log, ks, gs; | ||
33 | + | ||
34 | + // DOM elements | ||
35 | + var defs; | ||
36 | + | ||
37 | + // Internal state | ||
38 | + // ... | ||
39 | + | ||
40 | + // Note: "exported" state should be properties on 'self' variable | ||
41 | + | ||
42 | + var keyBindings = { | ||
43 | + W: [logWarning, 'log a warning'], | ||
44 | + E: [logError, 'log an error'] | ||
45 | + }; | ||
46 | + | ||
47 | + // ----------------- | ||
48 | + // these functions are necessarily temporary examples.... | ||
49 | + function logWarning() { | ||
50 | + $log.warn('You have been warned!'); | ||
51 | + } | ||
52 | + function logError() { | ||
53 | + $log.error('You are erroneous!'); | ||
54 | + } | ||
55 | + // ----------------- | ||
56 | + | ||
57 | + function setUpKeys() { | ||
58 | + ks.keyBindings(keyBindings); | ||
59 | + } | ||
60 | + | ||
61 | + function setUpDefs() { | ||
62 | + defs = d3.select('#ov-topo svg').append('defs'); | ||
63 | + gs.loadDefs(defs); | ||
64 | + } | ||
65 | + | ||
66 | + | ||
67 | + angular.module('ovTopo', moduleDependencies) | ||
68 | + | ||
69 | + .controller('OvTopoCtrl', [ | ||
70 | + '$log', 'KeyService', 'GlyphService', | ||
71 | + | ||
72 | + function (_$log_, _ks_, _gs_) { | ||
73 | + var self = this; | ||
74 | + | ||
28 | $log = _$log_; | 75 | $log = _$log_; |
76 | + ks = _ks_; | ||
77 | + gs = _gs_; | ||
29 | 78 | ||
30 | self.message = 'Topo View Rocks!'; | 79 | self.message = 'Topo View Rocks!'; |
31 | 80 | ||
81 | + setUpKeys(); | ||
82 | + setUpDefs(); | ||
83 | + | ||
32 | $log.log('OvTopoCtrl has been created'); | 84 | $log.log('OvTopoCtrl has been created'); |
33 | }]); | 85 | }]); |
34 | }()); | 86 | }()); | ... | ... |
-
Please register or login to post a comment