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 | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 31 | var $log, fs, ks, zs, gs, ms, sus, tes, tfs, tps, tis, tss, tts; |
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'], |
| 55 | //Z: [toggleOblique, 'Toggle oblique view (Experimental)'], |
| 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 | 5724fb4 | 2015-02-05 16:59:40 -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 | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 78 | // TODO: // mouse gestures |
| 79 | var gestures = [ |
| 80 | ['click', 'Select the item and show details'], |
| 81 | ['shift-click', 'Toggle selection state'], |
| 82 | ['drag', 'Reposition (and pin) device / host'], |
| 83 | ['cmd-scroll', 'Zoom in / out'], |
| 84 | ['cmd-drag', 'Pan'] |
| 85 | ]; |
| 86 | } |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 87 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 88 | // --- Keystroke functions ------------------------------------------- |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 89 | |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 90 | // NOTE: this really belongs in the TopoPanelService -- but how to |
| 91 | // cleanly link in the updateDeviceColors() call? To be fixed later. |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 92 | function toggleInstances() { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 93 | tis.toggle(); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 94 | tfs.updateDeviceColors(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 95 | } |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 96 | |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 97 | function toggleMap() { |
| 98 | sus.visible(mapG, !sus.visible(mapG)); |
| 99 | } |
| 100 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 101 | function resetZoom() { |
| 102 | zoomer.reset(); |
| 103 | } |
| 104 | |
| 105 | function handleEscape() { |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 106 | if (false) { |
| 107 | // TODO: if an instance is selected, cancel the affinity mapping |
| 108 | // tis.cancelAffinity() |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 109 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 110 | } else if (tss.haveDetails()) { |
| 111 | // else if we have node selections, deselect them all |
| 112 | tss.deselectAll(); |
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 (tis.isVisible()) { |
| 115 | // else if the Instance Panel is visible, hide it |
| 116 | tis.hide(); |
| 117 | tfs.updateDeviceColors(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 118 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 119 | } else if (tps.summaryVisible()) { |
| 120 | // else if the Summary Panel is visible, hide it |
| 121 | tps.hideSummaryPanel(); |
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 { |
| 124 | // TODO: set hover mode to hoverModeNone |
| 125 | } |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 126 | } |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 127 | |
| 128 | // --- Glyphs, Icons, and the like ----------------------------------- |
| 129 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 130 | function setUpDefs() { |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 131 | defs = svg.append('defs'); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 132 | gs.loadDefs(defs); |
Simon Hunt | 0ee2868 | 2015-02-12 20:48:11 -0800 | [diff] [blame^] | 133 | sus.loadGlowDefs(defs); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 137 | // --- Pan and Zoom -------------------------------------------------- |
| 138 | |
| 139 | // zoom enabled predicate. ev is a D3 source event. |
| 140 | function zoomEnabled(ev) { |
| 141 | return (ev.metaKey || ev.altKey); |
| 142 | } |
| 143 | |
| 144 | function zoomCallback() { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 145 | var sc = zoomer.scale(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 146 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 147 | // keep the map lines constant width while zooming |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 148 | mapG.style('stroke-width', (2.0 / sc) + 'px'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | function setUpZoom() { |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 152 | zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 153 | zoomer = zs.createZoomer({ |
| 154 | svg: svg, |
| 155 | zoomLayer: zoomLayer, |
| 156 | zoomEnabled: zoomEnabled, |
| 157 | zoomCallback: zoomCallback |
| 158 | }); |
| 159 | } |
| 160 | |
| 161 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 162 | // callback invoked when the SVG view has been resized.. |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 163 | function svgResized(s) { |
| 164 | tfs.newDim([s.width, s.height]); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 165 | } |
| 166 | |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 167 | // --- Background Map ------------------------------------------------ |
| 168 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 169 | function setUpNoDevs() { |
| 170 | var g, box; |
| 171 | noDevsLayer = svg.append('g').attr({ |
| 172 | id: 'topo-noDevsLayer', |
| 173 | transform: sus.translate(500,500) |
| 174 | }); |
| 175 | // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html. |
| 176 | // We are translating this layer to have its origin at the center |
| 177 | |
| 178 | g = noDevsLayer.append('g'); |
| 179 | gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird'); |
| 180 | g.append('text').text('No devices are connected') |
| 181 | .attr({ x: 120, y: 80}); |
| 182 | |
| 183 | box = g.node().getBBox(); |
| 184 | box.x -= box.width/2; |
| 185 | box.y -= box.height/2; |
| 186 | g.attr('transform', sus.translate(box.x, box.y)); |
| 187 | |
| 188 | showNoDevs(true); |
| 189 | } |
| 190 | |
| 191 | function showNoDevs(b) { |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 192 | sus.visible(noDevsLayer, b); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 195 | function showCallibrationPoints() { |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 196 | // temp code for calibration |
| 197 | var points = [ |
| 198 | [0, 0], [0, 1000], [1000, 0], [1000, 1000] |
| 199 | ]; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 200 | mapG.selectAll('circle') |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 201 | .data(points) |
| 202 | .enter() |
| 203 | .append('circle') |
| 204 | .attr('cx', function (d) { return d[0]; }) |
| 205 | .attr('cy', function (d) { return d[1]; }) |
| 206 | .attr('r', 5) |
| 207 | .style('fill', 'red'); |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 210 | function setUpMap() { |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 211 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 212 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 213 | //showCallibrationPoints(); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 214 | //return ms.loadMapInto(map, '*continental_us', {mapFillScale:0.5}); |
| 215 | |
| 216 | // returns a promise for the projection... |
| 217 | return ms.loadMapInto(mapG, '*continental_us'); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 220 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 221 | // --- Controller Definition ----------------------------------------- |
| 222 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 223 | angular.module('ovTopo', moduleDependencies) |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 224 | .controller('OvTopoCtrl', [ |
Simon Hunt | 54442fa | 2015-01-26 14:17:38 -0800 | [diff] [blame] | 225 | '$scope', '$log', '$location', '$timeout', |
Simon Hunt | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 226 | 'FnService', 'MastService', 'KeyService', 'ZoomService', |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 227 | 'GlyphService', 'MapService', 'SvgUtilService', |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 228 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 229 | 'TopoInstService', 'TopoSelectService', 'TopoTrafficService', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 230 | |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 231 | function ($scope, _$log_, $loc, $timeout, _fs_, mast, |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 232 | _ks_, _zs_, _gs_, _ms_, _sus_, |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 233 | _tes_, _tfs_, _tps_, _tis_, _tss_, _tts_) { |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 234 | var self = this, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 235 | projection, |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 236 | dim, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 237 | uplink = { |
| 238 | // provides function calls back into this space |
| 239 | showNoDevs: showNoDevs, |
| 240 | projection: function () { return projection; }, |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 241 | sendEvent: _tes_.sendEvent |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 242 | }; |
| 243 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 244 | $log = _$log_; |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 245 | fs = _fs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 246 | ks = _ks_; |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 247 | zs = _zs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 248 | gs = _gs_; |
Simon Hunt | 1e8eff4 | 2015-01-08 17:19:02 -0800 | [diff] [blame] | 249 | ms = _ms_; |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 250 | sus = _sus_; |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 251 | tes = _tes_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 252 | tfs = _tfs_; |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 253 | tps = _tps_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 254 | tis = _tis_; |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 255 | tss = _tss_; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 256 | tts = _tts_; |
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 | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 291 | tis.initInst(); |
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 | }()); |