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 = [ |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 25 | 'ngCookies', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 26 | 'onosUtil', |
Simon Hunt | 1e4a001 | 2015-01-21 11:36:08 -0800 | [diff] [blame] | 27 | 'onosSvg', |
| 28 | 'onosRemote' |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 29 | ]; |
| 30 | |
| 31 | // references to injected services etc. |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 32 | var $scope, $log, $cookies, fs, ks, zs, gs, ms, sus, flash, wss, ps, |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 33 | tds, tes, tfs, tps, tis, tss, tls, tts, tos, fltr, ttbs, ttip, tov; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 34 | |
| 35 | // DOM elements |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 36 | var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 37 | |
| 38 | // Internal state |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 39 | var zoomer, actionMap; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 40 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 41 | // --- Short Cut Keys ------------------------------------------------ |
| 42 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 43 | function setUpKeys(overlayKeys) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 44 | // key bindings need to be made after the services have been injected |
| 45 | // thus, deferred to here... |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 46 | actionMap = { |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 47 | I: [toggleInstances, 'Toggle ONOS instances panel'], |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 48 | O: [toggleSummary, 'Toggle ONOS summary panel'], |
Simon Hunt | 239e588 | 2015-04-23 15:07:04 -0700 | [diff] [blame] | 49 | D: [toggleUseDetailsFlag, 'Disable / enable details panel'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 50 | |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 51 | H: [toggleHosts, 'Toggle host visibility'], |
| 52 | M: [toggleOffline, 'Toggle offline visibility'], |
| 53 | P: [togglePorts, 'Toggle Port Highlighting'], |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 54 | dash: [tfs.showBadLinks, 'Show bad links'], |
| 55 | B: [toggleMap, 'Toggle background map'], |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 56 | S: [toggleSprites, 'Toggle sprite layer'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 57 | |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 58 | X: [tfs.resetAllLocations, 'Reset node locations'], |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 59 | Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'], |
Bri Prebilic Cole | b5f2b15 | 2015-04-07 14:58:09 -0700 | [diff] [blame] | 60 | N: [fltr.clickAction, 'Cycle node layers'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 61 | L: [tfs.cycleDeviceLabels, 'Cycle device labels'], |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 62 | U: [tfs.unpin, 'Unpin node (hover mouse over)'], |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 63 | R: [resetZoom, 'Reset pan / zoom'], |
Simon Hunt | 90dcc3e | 2015-03-25 15:01:27 -0700 | [diff] [blame] | 64 | dot: [ttbs.toggleToolbar, 'Toggle Toolbar'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 65 | |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 66 | E: [equalizeMasters, 'Equalize mastership roles'], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 67 | |
Simon Hunt | 5b024d7 | 2016-01-29 11:02:43 -0800 | [diff] [blame] | 68 | // topology overlay selections |
| 69 | F1: function () { ttbs.fnkey(0); }, |
| 70 | F2: function () { ttbs.fnkey(1); }, |
| 71 | F3: function () { ttbs.fnkey(2); }, |
| 72 | F4: function () { ttbs.fnkey(3); }, |
| 73 | F5: function () { ttbs.fnkey(4); }, |
| 74 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 75 | esc: handleEscape, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 76 | |
Simon Hunt | 0906014 | 2015-03-18 20:23:32 -0700 | [diff] [blame] | 77 | _keyListener: ttbs.keyListener, |
| 78 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 79 | _helpFormat: [ |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 80 | ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B', 'S' ], |
| 81 | ['X', 'Z', 'N', 'L', 'U', 'R', '-', 'E', '-', 'dot'], |
| 82 | [] // this column reserved for overlay actions |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 83 | ] |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 86 | if (fs.isO(overlayKeys)) { |
| 87 | mergeKeys(overlayKeys); |
| 88 | } |
| 89 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 90 | ks.keyBindings(actionMap); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 91 | |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 92 | ks.gestureNotes([ |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 93 | ['click', 'Select the item and show details'], |
| 94 | ['shift-click', 'Toggle selection state'], |
| 95 | ['drag', 'Reposition (and pin) device / host'], |
| 96 | ['cmd-scroll', 'Zoom in / out'], |
| 97 | ['cmd-drag', 'Pan'] |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 98 | ]); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 99 | } |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 100 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 101 | // when a topology overlay is activated, we need to bind their keystrokes |
| 102 | // and include them in the quick-help panel |
| 103 | function mergeKeys(extra) { |
| 104 | var _hf = actionMap._helpFormat[2]; |
Simon Hunt | 7189222 | 2015-09-29 13:39:40 -0700 | [diff] [blame] | 105 | |
| 106 | ks.checkNotGlobal(extra); |
| 107 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 108 | extra._keyOrder.forEach(function (k) { |
| 109 | var d = extra[k], |
| 110 | cb = d && d.cb, |
| 111 | tt = d && d.tt; |
| 112 | // NOTE: ignore keys that are already defined |
| 113 | if (d && !actionMap[k]) { |
| 114 | actionMap[k] = [cb, tt]; |
| 115 | _hf.push(k); |
| 116 | } |
| 117 | }); |
| 118 | } |
| 119 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 120 | // --- Keystroke functions ------------------------------------------- |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 121 | |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 122 | function toggleInstances(x) { |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 123 | updatePrefsState('insts', tis.toggle(x)); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 124 | tfs.updateDeviceColors(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 125 | } |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 126 | |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 127 | function toggleSummary(x) { |
| 128 | updatePrefsState('summary', tps.toggleSummary(x)); |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 129 | } |
| 130 | |
Simon Hunt | 239e588 | 2015-04-23 15:07:04 -0700 | [diff] [blame] | 131 | function toggleUseDetailsFlag(x) { |
| 132 | updatePrefsState('detail', tps.toggleUseDetailsFlag(x)); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 135 | function toggleHosts(x) { |
| 136 | updatePrefsState('hosts', tfs.toggleHosts(x)); |
| 137 | } |
| 138 | |
| 139 | function toggleOffline(x) { |
| 140 | updatePrefsState('offdev', tfs.toggleOffline(x)); |
| 141 | } |
| 142 | |
| 143 | function togglePorts(x) { |
| 144 | updatePrefsState('porthl', tfs.togglePorts(x)); |
| 145 | } |
| 146 | |
| 147 | function _togSvgLayer(x, G, tag, what) { |
| 148 | var on = (x === 'keyev') ? !sus.visible(G) : !!x, |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 149 | verb = on ? 'Show' : 'Hide'; |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 150 | sus.visible(G, on); |
| 151 | updatePrefsState(tag, on); |
| 152 | flash.flash(verb + ' ' + what); |
| 153 | } |
| 154 | |
| 155 | function toggleMap(x) { |
| 156 | _togSvgLayer(x, mapG, 'bg', 'background map'); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 157 | } |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 158 | |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 159 | function toggleSprites(x) { |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 160 | _togSvgLayer(x, spriteG, 'spr', 'sprite layer'); |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 163 | function resetZoom() { |
| 164 | zoomer.reset(); |
Bri Prebilic Cole | 9cf1a8d | 2015-04-21 13:15:29 -0700 | [diff] [blame] | 165 | flash.flash('Pan and zoom reset'); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 168 | function equalizeMasters() { |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 169 | wss.sendEvent('equalizeMasters'); |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 170 | flash.flash('Equalizing master roles'); |
| 171 | } |
| 172 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 173 | function handleEscape() { |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 174 | if (tis.showMaster()) { |
| 175 | // if an instance is selected, cancel the affinity mapping |
| 176 | tis.cancelAffinity() |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 177 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 178 | } else if (tov.hooks.escape()) { |
| 179 | // else if the overlay consumed the ESC event... |
| 180 | // (work already done) |
| 181 | |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 182 | } else if (tss.deselectAll()) { |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 183 | // else if we have node selections, deselect them all |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 184 | // (work already done) |
| 185 | |
| 186 | } else if (tls.deselectLink()) { |
| 187 | // else if we have a link selected, deselect it |
| 188 | // (work already done) |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 189 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 190 | } else if (tis.isVisible()) { |
| 191 | // else if the Instance Panel is visible, hide it |
| 192 | tis.hide(); |
| 193 | tfs.updateDeviceColors(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 194 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 195 | } else if (tps.summaryVisible()) { |
| 196 | // else if the Summary Panel is visible, hide it |
| 197 | tps.hideSummaryPanel(); |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 198 | } |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 199 | } |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 200 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 201 | // --- Toolbar Functions --------------------------------------------- |
| 202 | |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 203 | function notValid(what) { |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 204 | $log.warn('topo.js getActionEntry(): Not a valid ' + what); |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 205 | } |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 206 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 207 | function getActionEntry(key) { |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 208 | var entry; |
| 209 | |
| 210 | if (!key) { |
| 211 | notValid('key'); |
| 212 | return null; |
| 213 | } |
| 214 | |
| 215 | entry = actionMap[key]; |
| 216 | |
| 217 | if (!entry) { |
| 218 | notValid('actionMap entry'); |
| 219 | return null; |
| 220 | } |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 221 | return fs.isA(entry) || [entry, '']; |
| 222 | } |
| 223 | |
| 224 | function setUpToolbar() { |
| 225 | ttbs.init({ |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 226 | getActionEntry: getActionEntry, |
| 227 | setUpKeys: setUpKeys |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 228 | }); |
| 229 | ttbs.createToolbar(); |
| 230 | } |
| 231 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 232 | // --- Glyphs, Icons, and the like ----------------------------------- |
| 233 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 234 | function setUpDefs() { |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 235 | defs = svg.append('defs'); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 236 | gs.loadDefs(defs); |
Simon Hunt | 0ee2868 | 2015-02-12 20:48:11 -0800 | [diff] [blame] | 237 | sus.loadGlowDefs(defs); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 241 | // --- Pan and Zoom -------------------------------------------------- |
| 242 | |
| 243 | // zoom enabled predicate. ev is a D3 source event. |
| 244 | function zoomEnabled(ev) { |
Simon Hunt | d552ee9 | 2015-04-02 17:06:35 -0700 | [diff] [blame] | 245 | return fs.isMobile() || (ev.metaKey || ev.altKey); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | function zoomCallback() { |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 249 | var sc = zoomer.scale(), |
| 250 | tr = zoomer.translate(); |
| 251 | |
| 252 | ps.setPrefs('topo_zoom', {tx:tr[0], ty:tr[1], sc:sc}); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 253 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 254 | // keep the map lines constant width while zooming |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 255 | mapG.style('stroke-width', (2.0 / sc) + 'px'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | function setUpZoom() { |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 259 | zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 260 | zoomer = zs.createZoomer({ |
| 261 | svg: svg, |
| 262 | zoomLayer: zoomLayer, |
| 263 | zoomEnabled: zoomEnabled, |
| 264 | zoomCallback: zoomCallback |
| 265 | }); |
| 266 | } |
| 267 | |
| 268 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 269 | // callback invoked when the SVG view has been resized.. |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 270 | function svgResized(s) { |
| 271 | tfs.newDim([s.width, s.height]); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 274 | // --- Background Map ------------------------------------------------ |
| 275 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 276 | function setUpNoDevs() { |
| 277 | var g, box; |
| 278 | noDevsLayer = svg.append('g').attr({ |
| 279 | id: 'topo-noDevsLayer', |
| 280 | transform: sus.translate(500,500) |
| 281 | }); |
| 282 | // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html. |
| 283 | // We are translating this layer to have its origin at the center |
| 284 | |
| 285 | g = noDevsLayer.append('g'); |
| 286 | gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird'); |
| 287 | g.append('text').text('No devices are connected') |
| 288 | .attr({ x: 120, y: 80}); |
| 289 | |
| 290 | box = g.node().getBBox(); |
| 291 | box.x -= box.width/2; |
| 292 | box.y -= box.height/2; |
| 293 | g.attr('transform', sus.translate(box.x, box.y)); |
| 294 | |
| 295 | showNoDevs(true); |
| 296 | } |
| 297 | |
| 298 | function showNoDevs(b) { |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 299 | sus.visible(noDevsLayer, b); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 300 | } |
| 301 | |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 302 | |
| 303 | var countryFilters = { |
| 304 | world: function (c) { |
| 305 | return c.properties.continent !== 'Antarctica'; |
| 306 | }, |
| 307 | |
| 308 | // NOTE: for "usa" we are using our hand-crafted topojson file |
| 309 | |
| 310 | s_america: function (c) { |
| 311 | return c.properties.continent === 'South America'; |
| 312 | }, |
| 313 | |
Simon Hunt | ac099e8 | 2015-12-03 09:17:47 -0800 | [diff] [blame] | 314 | ns_america: function (c) { |
| 315 | return c.properties.custom === 'US-cont' || |
| 316 | c.properties.subregion === 'Central America' || |
Simon Hunt | d471262 | 2015-12-02 11:19:50 -0800 | [diff] [blame] | 317 | c.properties.continent === 'South America'; |
| 318 | }, |
| 319 | |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 320 | japan: function (c) { |
| 321 | return c.properties.geounit === 'Japan'; |
| 322 | }, |
| 323 | |
| 324 | europe: function (c) { |
| 325 | return c.properties.continent === 'Europe'; |
| 326 | }, |
| 327 | |
| 328 | italy: function (c) { |
| 329 | return c.properties.geounit === 'Italy'; |
| 330 | }, |
| 331 | |
| 332 | uk: function (c) { |
| 333 | // technically, Ireland is not part of the United Kingdom, |
| 334 | // but the map looks weird without it showing. |
| 335 | return c.properties.adm0_a3 === 'GBR' || |
| 336 | c.properties.adm0_a3 === 'IRL'; |
Simon Hunt | 1178d5b | 2015-09-02 17:02:37 -0700 | [diff] [blame] | 337 | }, |
| 338 | |
| 339 | s_korea: function (c) { |
| 340 | return c.properties.adm0_a3 === 'KOR'; |
| 341 | }, |
| 342 | |
| 343 | australia: function (c) { |
| 344 | return c.properties.adm0_a3 === 'AUS'; |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 345 | } |
| 346 | }; |
| 347 | |
| 348 | |
| 349 | function setUpMap($loc) { |
| 350 | var s1 = $loc.search().mapid, |
| 351 | s2 = ps.getPrefs('topo_mapid'), |
Simon Hunt | f65c378 | 2015-06-12 13:33:48 -0700 | [diff] [blame] | 352 | mapId = s1 || (s2 && s2.id) || 'usa', |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 353 | promise, |
| 354 | cfilter, |
| 355 | opts; |
| 356 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 357 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 358 | if (mapId === 'usa') { |
| 359 | promise = ms.loadMapInto(mapG, '*continental_us'); |
Simon Hunt | e1bef6e | 2016-02-24 22:16:04 -0800 | [diff] [blame^] | 360 | } else if (mapId === 'bayarea') { |
| 361 | promise = ms.loadMapInto(mapG, '*bayarea', {objectTag: 'bayareaGEO'}); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 362 | } else { |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 363 | cfilter = countryFilters[mapId] || countryFilters.world; |
| 364 | opts = { countryFilter: cfilter }; |
| 365 | promise = ms.loadMapRegionInto(mapG, opts); |
| 366 | } |
Simon Hunt | e1bef6e | 2016-02-24 22:16:04 -0800 | [diff] [blame^] | 367 | ps.setPrefs('topo_mapid', {id:mapId}); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 368 | return promise; |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 371 | function opacifyMap(b) { |
| 372 | mapG.transition() |
| 373 | .duration(1000) |
| 374 | .attr('opacity', b ? 1 : 0); |
| 375 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 376 | |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 377 | function setUpSprites($loc, tspr) { |
| 378 | var s1 = $loc.search().sprites, |
| 379 | s2 = ps.getPrefs('topo_sprites'), |
| 380 | sprId = s1 || (s2 && s2.id); |
| 381 | |
| 382 | spriteG = zoomLayer.append ('g').attr('id', 'topo-sprites'); |
| 383 | if (sprId) { |
| 384 | ps.setPrefs('topo_sprites', {id:sprId}); |
| 385 | tspr.loadSprites(spriteG, defs, sprId); |
| 386 | } |
| 387 | } |
Simon Hunt | 9c1c45e | 2015-04-10 13:38:27 -0700 | [diff] [blame] | 388 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 389 | // --- User Preferemces ---------------------------------------------- |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 390 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 391 | var prefsState = {}; |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 392 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 393 | function updatePrefsState(what, b) { |
| 394 | prefsState[what] = b ? 1 : 0; |
| 395 | ps.setPrefs('topo_prefs', prefsState); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 396 | } |
| 397 | |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 398 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 399 | function restoreConfigFromPrefs() { |
| 400 | // NOTE: toolbar will have set this for us.. |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 401 | prefsState = ps.asNumbers(ps.getPrefs('topo_prefs')); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 402 | |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 403 | $log.debug('TOPO- Prefs State:', prefsState); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 404 | |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 405 | flash.enable(false); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 406 | toggleInstances(prefsState.insts); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 407 | toggleSummary(prefsState.summary); |
Simon Hunt | 239e588 | 2015-04-23 15:07:04 -0700 | [diff] [blame] | 408 | toggleUseDetailsFlag(prefsState.detail); |
Bri Prebilic Cole | 9b80ca0 | 2015-08-03 11:26:54 -0700 | [diff] [blame] | 409 | toggleHosts(prefsState.hosts); |
| 410 | toggleOffline(prefsState.offdev); |
| 411 | togglePorts(prefsState.porthl); |
| 412 | toggleMap(prefsState.bg); |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 413 | toggleSprites(prefsState.spr); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 414 | flash.enable(true); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 418 | // somewhat hackish, because summary update cannot happen until we |
| 419 | // have opened the websocket to the server; hence this extra function |
| 420 | // invoked after tes.start() |
| 421 | function restoreSummaryFromPrefs() { |
| 422 | prefsState = ps.asNumbers(ps.getPrefs('topo_prefs')); |
| 423 | $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary); |
| 424 | |
| 425 | flash.enable(false); |
| 426 | toggleSummary(prefsState.summary); |
| 427 | flash.enable(true); |
| 428 | } |
| 429 | |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 430 | function topoStartDone() { |
| 431 | var d = $scope.intentData; |
| 432 | if (d) { |
| 433 | tts.selectIntent(d); |
| 434 | } |
| 435 | } |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 436 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 437 | // --- Controller Definition ----------------------------------------- |
| 438 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 439 | angular.module('ovTopo', moduleDependencies) |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 440 | .controller('OvTopoCtrl', ['$scope', '$log', '$location', '$timeout', |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 441 | '$cookies', 'FnService', 'MastService', 'KeyService', 'ZoomService', |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 442 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 443 | 'WebSocketService', 'PrefsService', 'TopoDialogService', |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 444 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 445 | 'TopoInstService', 'TopoSelectService', 'TopoLinkService', |
Bri Prebilic Cole | b5f2b15 | 2015-04-07 14:58:09 -0700 | [diff] [blame] | 446 | 'TopoTrafficService', 'TopoObliqueService', 'TopoFilterService', |
Bri Prebilic Cole | 8f07f0d | 2015-04-23 13:28:43 -0700 | [diff] [blame] | 447 | 'TopoToolbarService', 'TopoSpriteService', 'TooltipService', |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 448 | 'TopoOverlayService', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 449 | |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 450 | function (_$scope_, _$log_, $loc, $timeout, _$cookies_, _fs_, mast, _ks_, |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 451 | _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _tds_, _tes_, |
| 452 | _tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, |
| 453 | _ttbs_, tspr, _ttip_, _tov_) { |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 454 | var params = $loc.search(), |
| 455 | projection, |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 456 | dim, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 457 | uplink = { |
| 458 | // provides function calls back into this space |
| 459 | showNoDevs: showNoDevs, |
| 460 | projection: function () { return projection; }, |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 461 | zoomLayer: function () { return zoomLayer; }, |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 462 | zoomer: function () { return zoomer; }, |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 463 | opacifyMap: opacifyMap, |
| 464 | topoStartDone: topoStartDone |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 465 | }; |
| 466 | |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 467 | $scope = _$scope_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 468 | $log = _$log_; |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 469 | $cookies = _$cookies_; |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 470 | fs = _fs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 471 | ks = _ks_; |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 472 | zs = _zs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 473 | gs = _gs_; |
Simon Hunt | 1e8eff4 | 2015-01-08 17:19:02 -0800 | [diff] [blame] | 474 | ms = _ms_; |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 475 | sus = _sus_; |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 476 | flash = _flash_; |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 477 | wss = _wss_; |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 478 | ps = _ps_; |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 479 | tds = _tds_; |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 480 | tes = _tes_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 481 | tfs = _tfs_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 482 | // TODO: consider funnelling actions through TopoForceService... |
| 483 | // rather than injecting references to these 'sub-modules', |
| 484 | // just so we can invoke functions on them. |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 485 | tps = _tps_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 486 | tis = _tis_; |
Simon Hunt | 6036b19 | 2015-02-11 11:20:26 -0800 | [diff] [blame] | 487 | tss = _tss_; |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 488 | tls = _tls_; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 489 | tts = _tts_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 490 | tos = _tos_; |
Bri Prebilic Cole | b5f2b15 | 2015-04-07 14:58:09 -0700 | [diff] [blame] | 491 | fltr = _fltr_; |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 492 | ttbs = _ttbs_; |
Bri Prebilic Cole | 8f07f0d | 2015-04-23 13:28:43 -0700 | [diff] [blame] | 493 | ttip = _ttip_; |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 494 | tov = _tov_; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 495 | |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 496 | if (params.intentKey && params.intentAppId && params.intentAppName) { |
| 497 | $scope.intentData = { |
| 498 | key: params.intentKey, |
| 499 | appId: params.intentAppId, |
| 500 | appName: params.intentAppName |
| 501 | }; |
| 502 | } |
| 503 | |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 504 | $scope.notifyResize = function () { |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 505 | svgResized(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 506 | }; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 507 | |
Simon Hunt | 54442fa | 2015-01-26 14:17:38 -0800 | [diff] [blame] | 508 | // Cleanup on destroyed scope.. |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 509 | $scope.$on('$destroy', function () { |
| 510 | $log.log('OvTopoCtrl is saying Buh-Bye!'); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 511 | tes.stop(); |
Bri Prebilic Cole | 9dcaea5 | 2015-07-21 14:39:48 -0700 | [diff] [blame] | 512 | ks.unbindKeys(); |
Simon Hunt | 626d210 | 2015-01-29 11:54:50 -0800 | [diff] [blame] | 513 | tps.destroyPanels(); |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 514 | tds.closeDialog(); |
Simon Hunt | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 515 | tis.destroyInst(); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 516 | tfs.destroyForce(); |
Bri Prebilic Cole | d621905 | 2015-03-19 14:34:02 -0700 | [diff] [blame] | 517 | ttbs.destroyToolbar(); |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 518 | }); |
| 519 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 520 | // svg layer and initialization of components |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 521 | ovtopo = d3.select('#ov-topo'); |
| 522 | svg = ovtopo.select('svg'); |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 523 | // set the svg size to match that of the window, less the masthead |
| 524 | svg.attr(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 525 | dim = [svg.attr('width'), svg.attr('height')]; |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 526 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 527 | setUpKeys(); |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 528 | setUpToolbar(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 529 | setUpDefs(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 530 | setUpZoom(); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 531 | setUpNoDevs(); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 532 | setUpMap($loc).then( |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 533 | function (proj) { |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 534 | var z = ps.getPrefs('topo_zoom') || {tx:0, ty:0, sc:1}; |
| 535 | zoomer.panZoom([z.tx, z.ty], z.sc); |
| 536 | $log.debug('** Zoom restored:', z); |
| 537 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 538 | projection = proj; |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 539 | $log.debug('** We installed the projection:', proj); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 540 | flash.enable(false); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 541 | toggleMap(prefsState.bg); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 542 | flash.enable(true); |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 543 | |
| 544 | // now we have the map projection, we are ready for |
| 545 | // the server to send us device/host data... |
| 546 | tes.start(); |
| 547 | // need to do the following so we immediately get |
| 548 | // the summary panel data back from the server |
| 549 | restoreSummaryFromPrefs(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 550 | } |
| 551 | ); |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 552 | setUpSprites($loc, tspr); |
Simon Hunt | fd1231a | 2015-01-26 22:14:51 -0800 | [diff] [blame] | 553 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 554 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 555 | tfs.initForce(svg, forceG, uplink, dim); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 556 | tis.initInst({ showMastership: tfs.showMastership }); |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 557 | tps.initPanels(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 558 | |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 559 | // temporary solution for persisting user settings |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 560 | restoreConfigFromPrefs(); |
Simon Hunt | a5b53af | 2015-10-12 15:56:40 -0700 | [diff] [blame] | 561 | ttbs.setDefaultOverlay(); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 562 | |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 563 | $log.debug('registered overlays...', tov.list()); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 564 | $log.log('OvTopoCtrl has been created'); |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 565 | }]); |
| 566 | }()); |