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