Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 1 | /* |
Simon Hunt | 8ead3a2 | 2015-01-06 11:00:15 -0800 | [diff] [blame] | 2 | * Copyright 2014,2015 Open Networking Laboratory |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | ONOS GUI -- Topology View Module |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | (function () { |
| 22 | 'use strict'; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 23 | |
| 24 | var moduleDependencies = [ |
| 25 | 'onosUtil', |
Simon Hunt | 1e4a001 | 2015-01-21 11:36:08 -0800 | [diff] [blame] | 26 | 'onosSvg', |
| 27 | 'onosRemote' |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 28 | ]; |
| 29 | |
| 30 | // references to injected services etc. |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 31 | var $log, fs, ks, zs, gs, ms, sus, flash, tes, tfs, tps, tis, tss, tts, tos; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 32 | |
| 33 | // DOM elements |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 34 | var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 35 | |
| 36 | // Internal state |
Simon Hunt | edf5c0e | 2015-01-29 15:00:53 -0800 | [diff] [blame] | 37 | var zoomer; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 38 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 39 | // --- Short Cut Keys ------------------------------------------------ |
| 40 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 41 | function setUpKeys() { |
| 42 | // key bindings need to be made after the services have been injected |
| 43 | // thus, deferred to here... |
| 44 | ks.keyBindings({ |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 45 | O: [tps.toggleSummary, 'Toggle ONOS summary pane'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 46 | I: [toggleInstances, 'Toggle ONOS instances pane'], |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 47 | D: [tss.toggleDetails, 'Disable / enable details pane'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 48 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 49 | H: [tfs.toggleHosts, 'Toggle host visibility'], |
| 50 | M: [tfs.toggleOffline, 'Toggle offline visibility'], |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 51 | B: [toggleMap, 'Toggle background map'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 52 | //P: togglePorts, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 53 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 54 | //X: [toggleNodeLock, 'Lock / unlock node positions'], |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 55 | Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 56 | L: [tfs.cycleDeviceLabels, 'Cycle device labels'], |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 57 | U: [tfs.unpin, 'Unpin node (hover mouse over)'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 58 | R: [resetZoom, 'Reset pan / zoom'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 59 | |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 60 | V: [tts.showRelatedIntentsAction, 'Show all related intents'], |
| 61 | rightArrow: [tts.showNextIntentAction, 'Show next related intent'], |
| 62 | leftArrow: [tts.showPrevIntentAction, 'Show previous related intent'], |
| 63 | W: [tts.showSelectedIntentTrafficAction, 'Monitor traffic of selected intent'], |
| 64 | A: [tts.showAllTrafficAction, 'Monitor all traffic'], |
| 65 | F: [tts.showDeviceLinkFlowsAction, 'Show device link flows'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 66 | |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 67 | E: [equalizeMasters, 'Equalize mastership roles'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 68 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 69 | esc: handleEscape, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 70 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 71 | _helpFormat: [ |
| 72 | ['O', 'I', 'D', '-', 'H', 'M', 'B', 'P' ], |
| 73 | ['X', 'Z', 'L', 'U', 'R' ], |
| 74 | ['V', 'rightArrow', 'leftArrow', 'W', 'A', 'F', '-', 'E' ] |
| 75 | ] |
| 76 | }); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 77 | |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 78 | ks.gestureNotes([ |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 79 | ['click', 'Select the item and show details'], |
| 80 | ['shift-click', 'Toggle selection state'], |
| 81 | ['drag', 'Reposition (and pin) device / host'], |
| 82 | ['cmd-scroll', 'Zoom in / out'], |
| 83 | ['cmd-drag', 'Pan'] |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 84 | ]); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 85 | } |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 86 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 87 | // --- Keystroke functions ------------------------------------------- |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 88 | |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 89 | // NOTE: this really belongs in the TopoPanelService -- but how to |
| 90 | // cleanly link in the updateDeviceColors() call? To be fixed later. |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 91 | function toggleInstances() { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 92 | tis.toggle(); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 93 | tfs.updateDeviceColors(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 94 | } |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 95 | |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 96 | function toggleMap() { |
| 97 | sus.visible(mapG, !sus.visible(mapG)); |
| 98 | } |
| 99 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 100 | function resetZoom() { |
| 101 | zoomer.reset(); |
| 102 | } |
| 103 | |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 104 | function equalizeMasters() { |
| 105 | tes.sendEvent('equalizeMasters'); |
| 106 | flash.flash('Equalizing master roles'); |
| 107 | } |
| 108 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 109 | function handleEscape() { |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 110 | if (tis.showMaster()) { |
| 111 | // if an instance is selected, cancel the affinity mapping |
| 112 | tis.cancelAffinity() |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 113 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 114 | } else if (tss.haveDetails()) { |
| 115 | // else if we have node selections, deselect them all |
| 116 | tss.deselectAll(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 117 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 118 | } else if (tis.isVisible()) { |
| 119 | // else if the Instance Panel is visible, hide it |
| 120 | tis.hide(); |
| 121 | tfs.updateDeviceColors(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 122 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 123 | } else if (tps.summaryVisible()) { |
| 124 | // else if the Summary Panel is visible, hide it |
| 125 | tps.hideSummaryPanel(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 126 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 127 | } else { |
| 128 | // TODO: set hover mode to hoverModeNone |
Simon Hunt | 62c2f8f | 2015-02-19 14:19:10 -0800 | [diff] [blame] | 129 | // talk to Thomas about this: shouldn't it be done |
| 130 | // when we deselect the node (if tss.haveDetails()...) |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 131 | } |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 132 | } |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 133 | |
| 134 | // --- Glyphs, Icons, and the like ----------------------------------- |
| 135 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 136 | function setUpDefs() { |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 137 | defs = svg.append('defs'); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 138 | gs.loadDefs(defs); |
Simon Hunt | 0ee2868 | 2015-02-12 20:48:11 -0800 | [diff] [blame] | 139 | sus.loadGlowDefs(defs); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 143 | // --- Pan and Zoom -------------------------------------------------- |
| 144 | |
| 145 | // zoom enabled predicate. ev is a D3 source event. |
| 146 | function zoomEnabled(ev) { |
| 147 | return (ev.metaKey || ev.altKey); |
| 148 | } |
| 149 | |
| 150 | function zoomCallback() { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 151 | var sc = zoomer.scale(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 152 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 153 | // keep the map lines constant width while zooming |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 154 | mapG.style('stroke-width', (2.0 / sc) + 'px'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | function setUpZoom() { |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 158 | zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 159 | zoomer = zs.createZoomer({ |
| 160 | svg: svg, |
| 161 | zoomLayer: zoomLayer, |
| 162 | zoomEnabled: zoomEnabled, |
| 163 | zoomCallback: zoomCallback |
| 164 | }); |
| 165 | } |
| 166 | |
| 167 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 168 | // callback invoked when the SVG view has been resized.. |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 169 | function svgResized(s) { |
| 170 | tfs.newDim([s.width, s.height]); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 171 | } |
| 172 | |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 173 | // --- Background Map ------------------------------------------------ |
| 174 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 175 | function setUpNoDevs() { |
| 176 | var g, box; |
| 177 | noDevsLayer = svg.append('g').attr({ |
| 178 | id: 'topo-noDevsLayer', |
| 179 | transform: sus.translate(500,500) |
| 180 | }); |
| 181 | // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html. |
| 182 | // We are translating this layer to have its origin at the center |
| 183 | |
| 184 | g = noDevsLayer.append('g'); |
| 185 | gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird'); |
| 186 | g.append('text').text('No devices are connected') |
| 187 | .attr({ x: 120, y: 80}); |
| 188 | |
| 189 | box = g.node().getBBox(); |
| 190 | box.x -= box.width/2; |
| 191 | box.y -= box.height/2; |
| 192 | g.attr('transform', sus.translate(box.x, box.y)); |
| 193 | |
| 194 | showNoDevs(true); |
| 195 | } |
| 196 | |
| 197 | function showNoDevs(b) { |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 198 | sus.visible(noDevsLayer, b); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 201 | function setUpMap() { |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 202 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 203 | // returns a promise for the projection... |
| 204 | return ms.loadMapInto(mapG, '*continental_us'); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 205 | } |
| 206 | |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 207 | function opacifyMap(b) { |
| 208 | mapG.transition() |
| 209 | .duration(1000) |
| 210 | .attr('opacity', b ? 1 : 0); |
| 211 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 212 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 213 | // --- Controller Definition ----------------------------------------- |
| 214 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 215 | angular.module('ovTopo', moduleDependencies) |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 216 | .controller('OvTopoCtrl', [ |
Simon Hunt | 54442fa | 2015-01-26 14:17:38 -0800 | [diff] [blame] | 217 | '$scope', '$log', '$location', '$timeout', |
Simon Hunt | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 218 | 'FnService', 'MastService', 'KeyService', 'ZoomService', |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 219 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 220 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 221 | 'TopoInstService', 'TopoSelectService', 'TopoTrafficService', |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 222 | 'TopoObliqueService', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 223 | |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 224 | function ($scope, _$log_, $loc, $timeout, _fs_, mast, |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 225 | _ks_, _zs_, _gs_, _ms_, _sus_, _flash_, |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 226 | _tes_, _tfs_, _tps_, _tis_, _tss_, _tts_, _tos_) { |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 227 | var self = this, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 228 | projection, |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 229 | dim, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 230 | uplink = { |
| 231 | // provides function calls back into this space |
| 232 | showNoDevs: showNoDevs, |
| 233 | projection: function () { return projection; }, |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 234 | zoomLayer: function () { return zoomLayer; }, |
| 235 | opacifyMap: opacifyMap, |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 236 | sendEvent: _tes_.sendEvent |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 237 | }; |
| 238 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 239 | $log = _$log_; |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 240 | fs = _fs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 241 | ks = _ks_; |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 242 | zs = _zs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 243 | gs = _gs_; |
Simon Hunt | 1e8eff4 | 2015-01-08 17:19:02 -0800 | [diff] [blame] | 244 | ms = _ms_; |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 245 | sus = _sus_; |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 246 | flash = _flash_; |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 247 | tes = _tes_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 248 | tfs = _tfs_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 249 | // TODO: consider funnelling actions through TopoForceService... |
| 250 | // rather than injecting references to these 'sub-modules', |
| 251 | // just so we can invoke functions on them. |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 252 | tps = _tps_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 253 | tis = _tis_; |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 254 | tss = _tss_; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 255 | tts = _tts_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 256 | tos = _tos_; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 257 | |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 258 | self.notifyResize = function () { |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 259 | svgResized(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 260 | }; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 261 | |
Simon Hunt | 54442fa | 2015-01-26 14:17:38 -0800 | [diff] [blame] | 262 | // Cleanup on destroyed scope.. |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 263 | $scope.$on('$destroy', function () { |
| 264 | $log.log('OvTopoCtrl is saying Buh-Bye!'); |
Simon Hunt | fd1231a | 2015-01-26 22:14:51 -0800 | [diff] [blame] | 265 | tes.closeSock(); |
Simon Hunt | 626d210 | 2015-01-29 11:54:50 -0800 | [diff] [blame] | 266 | tps.destroyPanels(); |
Simon Hunt | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 267 | tis.destroyInst(); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 268 | tfs.destroyForce(); |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 269 | }); |
| 270 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 271 | // svg layer and initialization of components |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 272 | ovtopo = d3.select('#ov-topo'); |
| 273 | svg = ovtopo.select('svg'); |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 274 | // set the svg size to match that of the window, less the masthead |
| 275 | svg.attr(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 276 | dim = [svg.attr('width'), svg.attr('height')]; |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 277 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 278 | setUpKeys(); |
| 279 | setUpDefs(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 280 | setUpZoom(); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 281 | setUpNoDevs(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 282 | setUpMap().then( |
| 283 | function (proj) { |
| 284 | projection = proj; |
| 285 | $log.debug('** We installed the projection: ', proj); |
| 286 | } |
| 287 | ); |
Simon Hunt | fd1231a | 2015-01-26 22:14:51 -0800 | [diff] [blame] | 288 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 289 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 290 | tfs.initForce(forceG, uplink, dim); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 291 | tis.initInst({ showMastership: tfs.showMastership }); |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 292 | tps.initPanels({ sendEvent: tes.sendEvent }); |
Simon Hunt | fd1231a | 2015-01-26 22:14:51 -0800 | [diff] [blame] | 293 | tes.openSock(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 294 | |
| 295 | $log.log('OvTopoCtrl has been created'); |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 296 | }]); |
| 297 | }()); |