Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 28 | 'onosRemote', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 29 | ]; |
| 30 | |
Simon Hunt | a428124 | 2016-02-26 20:18:45 -0800 | [diff] [blame] | 31 | // references to injected services |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 32 | var $scope, $log, $loc, $timeout, |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 33 | fs, ks, zs, gs, ms, sus, flash, wss, ps, th, tds, t3s, tes, tfs, tps, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 34 | tis, tms, tss, tls, tos, fltr, ttbs, tspr, tov; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 35 | |
| 36 | // DOM elements |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 37 | var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 38 | |
| 39 | // Internal state |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 40 | var zoomer, |
| 41 | actionMap, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 42 | topoLion = function (x) { return '#' + x + '#'; }; // func replaced later |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 43 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 44 | // --- Short Cut Keys ------------------------------------------------ |
| 45 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 46 | function setUpKeys(overlayKeys) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 47 | // key bindings need to be made after the services have been injected |
| 48 | // thus, deferred to here... |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 49 | |
| 50 | // we need functions that can be invoked after LION bundle loaded |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 51 | function togInst() { return topoLion('tbtt_tog_instances'); } |
| 52 | function togSumm() { return topoLion('tbtt_tog_summary'); } |
| 53 | function togUseDet() { return topoLion('tbtt_tog_use_detail'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 54 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 55 | function togHost() { return topoLion('tbtt_tog_host'); } |
| 56 | function togOff() { return topoLion('tbtt_tog_offline'); } |
| 57 | function togPortHi() { return topoLion('tbtt_tog_porthi'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 58 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 59 | function showBad() { return topoLion('tbtt_bad_links'); } |
| 60 | function togMap() { return topoLion('tbtt_tog_map'); } |
| 61 | function selMap() { return topoLion('tbtt_sel_map'); } |
| 62 | function togSpr() { return topoLion('tbtt_tog_sprite'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 63 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 64 | function rstLoc() { return topoLion('tbtt_reset_loc'); } |
| 65 | function togOb() { return topoLion('tbtt_tog_oblique'); } |
| 66 | function cycLayer() { return topoLion('tbtt_cyc_layers'); } |
| 67 | function cycDev() { return topoLion('tbtt_cyc_dev_labs'); } |
| 68 | function cycHost() { return topoLion('tbtt_cyc_host_labs'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 69 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 70 | function unpin() { return topoLion('tbtt_unpin_node'); } |
| 71 | function rzoom() { return topoLion('tbtt_reset_zoom'); } |
| 72 | function togtb() { return topoLion('tbtt_tog_toolbar'); } |
| 73 | function eqmaster() { return topoLion('tbtt_eq_master'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 74 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 75 | function uiClick() { return topoLion('click'); } |
| 76 | function uiShClick() { return topoLion('shift_click'); } |
| 77 | function uiDrag() { return topoLion('drag'); } |
| 78 | function uiCmdScr() { return topoLion('cmd_scroll'); } |
| 79 | function uiCmdDrag() { return topoLion('cmd_drag'); } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 80 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 81 | function uiClickTxt() { return topoLion('qh_gest_click'); } |
| 82 | function uiShClickTxt() { return topoLion('qh_gest_shift_click'); } |
| 83 | function uiDragTxt() { return topoLion('qh_gest_drag'); } |
| 84 | function uiCmdScrTxt() { return topoLion('qh_gest_cmd_scroll'); } |
| 85 | function uiCmdDragTxt() { return topoLion('qh_gest_cmd_drag'); } |
Thomas Vachuska | c8c8f46 | 2021-03-01 11:22:56 -0800 | [diff] [blame] | 86 | function quiet() { return ""; } |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 87 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 88 | actionMap = { |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 89 | I: [toggleInstances, togInst], |
| 90 | O: [toggleSummary, togSumm], |
| 91 | D: [toggleUseDetailsFlag, togUseDet], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 92 | |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 93 | H: [toggleHosts, togHost], |
| 94 | M: [toggleOffline, togOff], |
| 95 | P: [togglePorts, togPortHi], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 96 | |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 97 | dash: [tfs.showBadLinks, showBad], |
| 98 | B: [toggleMap, togMap], |
| 99 | G: [openMapSelection, selMap], |
| 100 | S: [toggleSprites, togSpr], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 101 | |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 102 | X: [tfs.resetAllLocations, rstLoc], |
| 103 | Z: [tos.toggleOblique, togOb], |
| 104 | N: [fltr.clickAction, cycLayer], |
| 105 | L: [tfs.cycleDeviceLabels, cycDev], |
| 106 | 'shift-L': [tfs.cycleHostLabels, cycHost], |
Thomas Vachuska | a4eac6a | 2021-03-01 15:11:59 -0800 | [diff] [blame^] | 107 | 'alt-L': [tfs.cycleLinkLabels, quiet], |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 108 | |
| 109 | U: [tfs.unpin, unpin], |
| 110 | R: [resetZoom, rzoom], |
| 111 | dot: [ttbs.toggleToolbar, togtb], |
| 112 | E: [equalizeMasters, eqmaster], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 113 | |
Thomas Vachuska | c8c8f46 | 2021-03-01 11:22:56 -0800 | [diff] [blame] | 114 | "shift-openBracket": [tfs.toggleHostTextSize, quiet], |
| 115 | "shift-closeBracket": [tfs.toggleHostIconSize, quiet], |
| 116 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 117 | // -- instance color palette debug |
Simon Hunt | a976134 | 2016-06-10 18:02:53 -0700 | [diff] [blame] | 118 | // 9: function () { sus.cat7().testCard(svg); }, |
| 119 | |
Simon Hunt | 5b024d7 | 2016-01-29 11:02:43 -0800 | [diff] [blame] | 120 | // topology overlay selections |
| 121 | F1: function () { ttbs.fnkey(0); }, |
| 122 | F2: function () { ttbs.fnkey(1); }, |
| 123 | F3: function () { ttbs.fnkey(2); }, |
| 124 | F4: function () { ttbs.fnkey(3); }, |
| 125 | F5: function () { ttbs.fnkey(4); }, |
| 126 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 127 | esc: handleEscape, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 128 | |
Simon Hunt | 0906014 | 2015-03-18 20:23:32 -0700 | [diff] [blame] | 129 | _keyListener: ttbs.keyListener, |
| 130 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 131 | _helpFormat: [ |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 132 | ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B', 'G', 'S'], |
Simon Hunt | 10618f6 | 2017-06-15 19:30:52 -0700 | [diff] [blame] | 133 | ['X', 'Z', 'N', 'L', 'shift-L', 'U', 'R', '-', 'E', '-', 'dot'], |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 134 | [], // this column reserved for overlay actions |
| 135 | ], |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 138 | if (fs.isO(overlayKeys)) { |
| 139 | mergeKeys(overlayKeys); |
| 140 | } |
| 141 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 142 | ks.keyBindings(actionMap); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 143 | |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 144 | ks.gestureNotes([ |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 145 | [uiClick, uiClickTxt], |
| 146 | [uiShClick, uiShClickTxt], |
| 147 | [uiDrag, uiDragTxt], |
| 148 | [uiCmdScr, uiCmdScrTxt], |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 149 | [uiCmdDrag, uiCmdDragTxt], |
Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -0800 | [diff] [blame] | 150 | ]); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 151 | } |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 152 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 153 | // when a topology overlay is activated, we need to bind their keystrokes |
| 154 | // and include them in the quick-help panel |
| 155 | function mergeKeys(extra) { |
| 156 | var _hf = actionMap._helpFormat[2]; |
Simon Hunt | 7189222 | 2015-09-29 13:39:40 -0700 | [diff] [blame] | 157 | |
| 158 | ks.checkNotGlobal(extra); |
| 159 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 160 | extra._keyOrder.forEach(function (k) { |
| 161 | var d = extra[k], |
| 162 | cb = d && d.cb, |
| 163 | tt = d && d.tt; |
| 164 | // NOTE: ignore keys that are already defined |
| 165 | if (d && !actionMap[k]) { |
| 166 | actionMap[k] = [cb, tt]; |
| 167 | _hf.push(k); |
| 168 | } |
| 169 | }); |
| 170 | } |
| 171 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 172 | // --- Keystroke functions ------------------------------------------- |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 173 | |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 174 | function toggleInstances(x) { |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 175 | updatePrefsState('insts', tis.toggle(x)); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 176 | tfs.updateDeviceColors(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 177 | } |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 178 | |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 179 | function toggleSummary(x) { |
| 180 | updatePrefsState('summary', tps.toggleSummary(x)); |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 181 | } |
| 182 | |
Simon Hunt | 239e588 | 2015-04-23 15:07:04 -0700 | [diff] [blame] | 183 | function toggleUseDetailsFlag(x) { |
| 184 | updatePrefsState('detail', tps.toggleUseDetailsFlag(x)); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 187 | function toggleHosts(x) { |
| 188 | updatePrefsState('hosts', tfs.toggleHosts(x)); |
| 189 | } |
| 190 | |
| 191 | function toggleOffline(x) { |
| 192 | updatePrefsState('offdev', tfs.toggleOffline(x)); |
| 193 | } |
| 194 | |
| 195 | function togglePorts(x) { |
| 196 | updatePrefsState('porthl', tfs.togglePorts(x)); |
| 197 | } |
| 198 | |
| 199 | function _togSvgLayer(x, G, tag, what) { |
| 200 | var on = (x === 'keyev') ? !sus.visible(G) : !!x, |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 201 | verb = on ? topoLion('show') : topoLion('hide'); |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 202 | sus.visible(G, on); |
| 203 | updatePrefsState(tag, on); |
| 204 | flash.flash(verb + ' ' + what); |
| 205 | } |
| 206 | |
| 207 | function toggleMap(x) { |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 208 | _togSvgLayer(x, mapG, 'bg', topoLion('fl_background_map')); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 209 | } |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 210 | |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 211 | function openMapSelection() { |
| 212 | tms.openMapSelection(); |
| 213 | } |
| 214 | |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 215 | function toggleSprites(x) { |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 216 | _togSvgLayer(x, spriteG, 'spr', topoLion('fl_sprite_layer')); |
Simon Hunt | 2052e5d | 2015-04-13 17:40:44 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 219 | function resetZoom() { |
| 220 | zoomer.reset(); |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 221 | flash.flash(topoLion('fl_pan_zoom_reset')); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 224 | function equalizeMasters() { |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 225 | wss.sendEvent('equalizeMasters'); |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 226 | flash.flash(topoLion('fl_eq_masters')); |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 229 | function handleEscape() { |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 230 | if (tis.showMaster()) { |
| 231 | // if an instance is selected, cancel the affinity mapping |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 232 | tis.cancelAffinity(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 233 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 234 | } else if (tov.hooks.escape()) { |
| 235 | // else if the overlay consumed the ESC event... |
| 236 | // (work already done) |
| 237 | |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 238 | } else if (tss.deselectAll()) { |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 239 | // else if we have node selections, deselect them all |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 240 | // (work already done) |
| 241 | |
Prince Pereira | 46c82d4 | 2016-09-19 13:30:50 +0530 | [diff] [blame] | 242 | } else if (tls.deselectAllLinks()) { |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 243 | // else if we have a link selected, deselect it |
| 244 | // (work already done) |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 245 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 246 | } else if (tis.isVisible()) { |
| 247 | // else if the Instance Panel is visible, hide it |
| 248 | tis.hide(); |
| 249 | tfs.updateDeviceColors(); |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 250 | |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 251 | } else if (tps.summaryVisible()) { |
| 252 | // else if the Summary Panel is visible, hide it |
Simon Hunt | 356da76 | 2016-05-27 11:54:02 -0700 | [diff] [blame] | 253 | tps.hideSummary(); |
Simon Hunt | a0eb0a8 | 2015-02-11 12:30:06 -0800 | [diff] [blame] | 254 | } |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 255 | } |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 256 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 257 | // --- Toolbar Functions --------------------------------------------- |
| 258 | |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 259 | function notValid(what) { |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 260 | $log.warn('topo.js getActionEntry(): Not a valid ' + what); |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 261 | } |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 262 | |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 263 | function getActionEntry(key) { |
Bri Prebilic Cole | 2efc715 | 2015-04-29 15:47:06 -0700 | [diff] [blame] | 264 | var entry; |
| 265 | |
| 266 | if (!key) { |
| 267 | notValid('key'); |
| 268 | return null; |
| 269 | } |
| 270 | |
| 271 | entry = actionMap[key]; |
| 272 | |
| 273 | if (!entry) { |
| 274 | notValid('actionMap entry'); |
| 275 | return null; |
| 276 | } |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 277 | return fs.isA(entry) || [entry, '']; |
| 278 | } |
| 279 | |
| 280 | function setUpToolbar() { |
| 281 | ttbs.init({ |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 282 | getActionEntry: getActionEntry, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 283 | setUpKeys: setUpKeys, |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 284 | }); |
| 285 | ttbs.createToolbar(); |
| 286 | } |
| 287 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 288 | // --- Glyphs, Icons, and the like ----------------------------------- |
| 289 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 290 | function setUpDefs() { |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 291 | defs = svg.append('defs'); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 292 | gs.loadDefs(defs); |
Simon Hunt | 0ee2868 | 2015-02-12 20:48:11 -0800 | [diff] [blame] | 293 | sus.loadGlowDefs(defs); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 297 | // --- Pan and Zoom -------------------------------------------------- |
| 298 | |
| 299 | // zoom enabled predicate. ev is a D3 source event. |
| 300 | function zoomEnabled(ev) { |
Simon Hunt | d552ee9 | 2015-04-02 17:06:35 -0700 | [diff] [blame] | 301 | return fs.isMobile() || (ev.metaKey || ev.altKey); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | function zoomCallback() { |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 305 | var sc = zoomer.scale(), |
| 306 | tr = zoomer.translate(); |
| 307 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 308 | ps.setPrefs('topo_zoom', { tx: tr[0], ty: tr[1], sc: sc }); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 309 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 310 | // keep the map lines constant width while zooming |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 311 | mapG.style('stroke-width', (2.0 / sc) + 'px'); |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 312 | |
Thomas Vachuska | c8c8f46 | 2021-03-01 11:22:56 -0800 | [diff] [blame] | 313 | tfs.adjustNodeScale(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | function setUpZoom() { |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 317 | zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer'); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 318 | zoomer = zs.createZoomer({ |
| 319 | svg: svg, |
| 320 | zoomLayer: zoomLayer, |
| 321 | zoomEnabled: zoomEnabled, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 322 | zoomCallback: zoomCallback, |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 323 | }); |
| 324 | } |
| 325 | |
| 326 | |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 327 | // callback invoked when the SVG view has been resized.. |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 328 | function svgResized(s) { |
| 329 | tfs.newDim([s.width, s.height]); |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 330 | } |
| 331 | |
Simon Hunt | a7b6a6b | 2015-01-13 19:53:09 -0800 | [diff] [blame] | 332 | // --- Background Map ------------------------------------------------ |
| 333 | |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 334 | function recenterLabel(g) { |
| 335 | var box = g.node().getBBox(); |
| 336 | |
| 337 | box.x -= box.width/2; |
| 338 | box.y -= box.height/2; |
| 339 | g.attr('transform', sus.translate(box.x, box.y)); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 342 | function setUpNoDevs() { |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 343 | var g; |
| 344 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 345 | noDevsLayer = svg.append('g').attr({ |
| 346 | id: 'topo-noDevsLayer', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 347 | transform: sus.translate(500, 500), |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 348 | }); |
| 349 | // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html. |
| 350 | // We are translating this layer to have its origin at the center |
| 351 | |
| 352 | g = noDevsLayer.append('g'); |
| 353 | gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird'); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 354 | g.append('text').text('').attr({ x: 120, y: 80 }); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 355 | recenterLabel(g); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 356 | showNoDevs(true); |
| 357 | } |
| 358 | |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 359 | function lionNoDevs() { |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 360 | var g = d3.select('#topo-noDevsLayer g'); |
| 361 | |
| 362 | g.select('text').text(topoLion('no_devices_are_connected')); |
| 363 | recenterLabel(g); |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 366 | function showNoDevs(b) { |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 367 | sus.visible(noDevsLayer, b); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 370 | |
| 371 | var countryFilters = { |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 372 | s_america: function (c) { |
| 373 | return c.properties.continent === 'South America'; |
| 374 | }, |
| 375 | |
Simon Hunt | ac099e8 | 2015-12-03 09:17:47 -0800 | [diff] [blame] | 376 | ns_america: function (c) { |
| 377 | return c.properties.custom === 'US-cont' || |
| 378 | c.properties.subregion === 'Central America' || |
Simon Hunt | d471262 | 2015-12-02 11:19:50 -0800 | [diff] [blame] | 379 | c.properties.continent === 'South America'; |
| 380 | }, |
| 381 | |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 382 | japan: function (c) { |
| 383 | return c.properties.geounit === 'Japan'; |
| 384 | }, |
| 385 | |
| 386 | europe: function (c) { |
| 387 | return c.properties.continent === 'Europe'; |
| 388 | }, |
| 389 | |
| 390 | italy: function (c) { |
| 391 | return c.properties.geounit === 'Italy'; |
| 392 | }, |
| 393 | |
| 394 | uk: function (c) { |
| 395 | // technically, Ireland is not part of the United Kingdom, |
| 396 | // but the map looks weird without it showing. |
| 397 | return c.properties.adm0_a3 === 'GBR' || |
| 398 | c.properties.adm0_a3 === 'IRL'; |
Simon Hunt | 1178d5b | 2015-09-02 17:02:37 -0700 | [diff] [blame] | 399 | }, |
| 400 | |
| 401 | s_korea: function (c) { |
| 402 | return c.properties.adm0_a3 === 'KOR'; |
| 403 | }, |
| 404 | |
| 405 | australia: function (c) { |
| 406 | return c.properties.adm0_a3 === 'AUS'; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 407 | }, |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 408 | }; |
| 409 | |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 410 | var tintOn = 0, |
| 411 | shadeFlip = 0, |
| 412 | shadePalette = { |
| 413 | light: { |
| 414 | sea: 'aliceblue', |
| 415 | land: 'white', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 416 | outline: '#ddd', |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 417 | }, |
| 418 | dark: { |
| 419 | sea: '#001830', |
| 420 | land: '#232331', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 421 | outline: '#3a3a3a', |
| 422 | }, |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 423 | }; |
| 424 | |
| 425 | function shading() { |
| 426 | return tintOn ? { |
| 427 | palette: shadePalette[th.theme()], |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 428 | flip: shadeFlip, |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 429 | } : ''; |
| 430 | } |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 431 | |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 432 | function setMap(map) { |
| 433 | ps.setPrefs('topo_mapid', map); |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 434 | setUpMap(); |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 435 | opacifyMap(true); |
| 436 | } |
| 437 | |
| 438 | function currentMap() { |
| 439 | return ps.getPrefs( |
| 440 | 'topo_mapid', |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 441 | { |
| 442 | mapid: 'usa', |
| 443 | mapscale: 1, |
| 444 | mapfilepath: '*continental_us', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 445 | tint: 'off', |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 446 | }, |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 447 | $loc.search() |
| 448 | ); |
| 449 | } |
| 450 | |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 451 | function setUpMap() { |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 452 | var prefs = currentMap(), |
Simon Hunt | 8a119b0 | 2016-03-29 16:00:32 -0700 | [diff] [blame] | 453 | mapId = prefs.mapid, |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 454 | mapFilePath = prefs.mapfilepath, |
Simon Hunt | 8a119b0 | 2016-03-29 16:00:32 -0700 | [diff] [blame] | 455 | mapScale = prefs.mapscale, |
| 456 | tint = prefs.tint, |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 457 | promise, |
Simon Hunt | facad99 | 2016-02-25 09:58:33 -0800 | [diff] [blame] | 458 | cfilter; |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 459 | |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 460 | tintOn = tint === 'on' ? 1 : 0; |
| 461 | |
Simon Hunt | 1849136 | 2016-03-04 11:09:42 -0800 | [diff] [blame] | 462 | $log.debug('setUpMap() mapId:', mapId, ', mapScale:', mapScale, |
| 463 | ', tint:', tint); |
| 464 | |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 465 | mapG = d3.select('#topo-map'); |
| 466 | if (mapG.empty()) { |
| 467 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); |
| 468 | } else { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 469 | mapG.each(function (d, i) { |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 470 | d3.selectAll(this.childNodes).remove(); |
| 471 | }); |
| 472 | } |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 473 | |
| 474 | if (mapFilePath === '*countries') { |
| 475 | |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 476 | cfilter = countryFilters[mapId] || countryFilters.uk; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 477 | |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 478 | promise = ms.loadMapRegionInto(mapG, { |
| 479 | countryFilter: cfilter, |
| 480 | adjustScale: mapScale, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 481 | shading: shading(), |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 482 | }); |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 483 | } else { |
| 484 | |
| 485 | promise = ms.loadMapInto(mapG, mapFilePath, mapId, { |
| 486 | adjustScale: mapScale, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 487 | shading: shading(), |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 488 | }); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 489 | } |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 490 | |
Simon Hunt | 8a119b0 | 2016-03-29 16:00:32 -0700 | [diff] [blame] | 491 | ps.setPrefs('topo_mapid', prefs); |
Simon Hunt | 2362b07 | 2015-06-11 20:08:22 -0700 | [diff] [blame] | 492 | return promise; |
Simon Hunt | 0541fb8 | 2015-01-14 18:59:57 -0800 | [diff] [blame] | 493 | } |
| 494 | |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 495 | function mapReshader() { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 496 | $log.debug('... Re-shading map ...'); |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 497 | ms.reshade(shading()); |
| 498 | } |
| 499 | |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 500 | // set up theme listener to re-shade the map when required. |
| 501 | function mapShader(on) { |
| 502 | if (on) { |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 503 | th.addListener(mapReshader); |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 504 | } else { |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 505 | th.removeListener(mapReshader); |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 506 | } |
| 507 | } |
| 508 | |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 509 | function opacifyMap(b) { |
| 510 | mapG.transition() |
| 511 | .duration(1000) |
| 512 | .attr('opacity', b ? 1 : 0); |
| 513 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 514 | |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 515 | function setUpSprites() { |
Simon Hunt | 8a119b0 | 2016-03-29 16:00:32 -0700 | [diff] [blame] | 516 | var prefs = ps.getPrefs('topo_sprites', { sprites: '' }, $loc.search()), |
| 517 | sprId = prefs.sprites; |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 518 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 519 | spriteG = zoomLayer.append('g').attr('id', 'topo-sprites'); |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 520 | if (sprId) { |
Simon Hunt | 8a119b0 | 2016-03-29 16:00:32 -0700 | [diff] [blame] | 521 | ps.setPrefs('topo_sprites', prefs); |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 522 | tspr.loadSprites(spriteG, defs, sprId); |
| 523 | } |
| 524 | } |
Simon Hunt | 9c1c45e | 2015-04-10 13:38:27 -0700 | [diff] [blame] | 525 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 526 | // --- User Preferemces ---------------------------------------------- |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 527 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 528 | var prefsState = {}; |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 529 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 530 | function updatePrefsState(what, b) { |
| 531 | prefsState[what] = b ? 1 : 0; |
| 532 | ps.setPrefs('topo_prefs', prefsState); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Thomas Vachuska | c616e17 | 2018-04-17 16:57:12 -0700 | [diff] [blame] | 535 | function applyPreferences(evt) { |
Thomas Vachuska | e4a75a1 | 2018-04-20 15:44:17 -0700 | [diff] [blame] | 536 | // var zoomPrefs = ps.getPrefs('topo_zoom', null); |
Thomas Vachuska | bf5d1fe | 2018-04-25 15:49:00 -0400 | [diff] [blame] | 537 | // if (ps.getPrefs('topo_prefs', null)) { |
| 538 | // restoreConfigFromPrefs(); |
| 539 | // } |
Thomas Vachuska | e4a75a1 | 2018-04-20 15:44:17 -0700 | [diff] [blame] | 540 | // if (zoomPrefs) { |
| 541 | // $log.debug('TOPO- Zoom State:', zoomPrefs); |
| 542 | // zoomer.panZoom([zoomPrefs.tx, zoomPrefs.ty], zoomPrefs.sc, 100); |
| 543 | // } |
Thomas Vachuska | c616e17 | 2018-04-17 16:57:12 -0700 | [diff] [blame] | 544 | } |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 545 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 546 | function restoreConfigFromPrefs() { |
| 547 | // NOTE: toolbar will have set this for us.. |
Simon Hunt | fc5c584 | 2017-02-01 23:32:18 -0800 | [diff] [blame] | 548 | prefsState = ps.asNumbers( |
| 549 | ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true |
| 550 | ); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 551 | |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 552 | $log.debug('TOPO- Prefs State:', prefsState); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 553 | |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 554 | flash.enable(false); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 555 | toggleInstances(prefsState.insts); |
Simon Hunt | ee7a3ce | 2015-04-09 13:28:37 -0700 | [diff] [blame] | 556 | toggleSummary(prefsState.summary); |
Simon Hunt | 239e588 | 2015-04-23 15:07:04 -0700 | [diff] [blame] | 557 | toggleUseDetailsFlag(prefsState.detail); |
Bri Prebilic Cole | 9b80ca0 | 2015-08-03 11:26:54 -0700 | [diff] [blame] | 558 | toggleHosts(prefsState.hosts); |
| 559 | toggleOffline(prefsState.offdev); |
| 560 | togglePorts(prefsState.porthl); |
| 561 | toggleMap(prefsState.bg); |
Simon Hunt | f9fc0e7 | 2015-04-16 15:10:57 -0700 | [diff] [blame] | 562 | toggleSprites(prefsState.spr); |
Thomas Vachuska | c616e17 | 2018-04-17 16:57:12 -0700 | [diff] [blame] | 563 | ttbs.setToolbar(prefsState.toolbar); |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 564 | t3s.setDevLabIndex(prefsState.dlbls); |
Simon Hunt | 10618f6 | 2017-06-15 19:30:52 -0700 | [diff] [blame] | 565 | t3s.setHostLabIndex(prefsState.hlbls); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 566 | flash.enable(true); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 570 | // somewhat hackish, because summary update cannot happen until we |
| 571 | // have opened the websocket to the server; hence this extra function |
| 572 | // invoked after tes.start() |
| 573 | function restoreSummaryFromPrefs() { |
Simon Hunt | fc5c584 | 2017-02-01 23:32:18 -0800 | [diff] [blame] | 574 | prefsState = ps.asNumbers( |
| 575 | ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true |
| 576 | ); |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 577 | $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary); |
| 578 | |
| 579 | flash.enable(false); |
| 580 | toggleSummary(prefsState.summary); |
| 581 | flash.enable(true); |
| 582 | } |
| 583 | |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 584 | // initial set of topo events received, now do post-processing |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 585 | function topoStartDone() { |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 586 | // give a small delay before attempting to reselect node(s) and |
| 587 | // highlight elements, since they have to be re-added to the DOM first... |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 588 | $timeout(function () { |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 589 | $log.debug('^^ topo.topoStartDone() ^^'); |
| 590 | |
| 591 | // reselect the previous selection... |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 592 | tss.reselect(); |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 593 | |
| 594 | // if an intent should be shown, invoke the appropriate callback |
| 595 | if ($scope.intentData) { |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 596 | tov.hooks.showIntent($scope.intentData); |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 597 | } |
Simon Hunt | 8419efd | 2017-01-12 12:36:28 -0800 | [diff] [blame] | 598 | |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 599 | }, 200); |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 600 | } |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 601 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 602 | // --- Controller Definition ----------------------------------------- |
| 603 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 604 | angular.module('ovTopo', moduleDependencies) |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 605 | .controller('OvTopoCtrl', |
| 606 | ['$scope', '$log', '$location', '$timeout', '$cookies', |
| 607 | 'FnService', 'MastService', 'KeyService', 'ZoomService', |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 608 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 609 | 'WebSocketService', 'PrefsService', 'ThemeService', |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 610 | 'TopoDialogService', 'TopoD3Service', 'TopoEventService', |
| 611 | 'TopoForceService', 'TopoPanelService', 'TopoInstService', |
| 612 | 'TopoSelectService', 'TopoLinkService', 'TopoTrafficService', |
| 613 | 'TopoObliqueService', 'TopoFilterService', 'TopoToolbarService', |
| 614 | 'TopoMapService', 'TopoSpriteService', 'TooltipService', |
| 615 | 'TopoOverlayService', 'LionService', |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 616 | |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 617 | function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_, |
| 618 | _fs_, mast, _ks_, _zs_, |
| 619 | _gs_, _ms_, _sus_, _flash_, |
| 620 | _wss_, _ps_, _th_, |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 621 | _tds_, _t3s_, _tes_, |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 622 | _tfs_, _tps_, _tis_, |
| 623 | _tss_, _tls_, _tts_, |
| 624 | _tos_, _fltr_, _ttbs_, |
| 625 | _tms_, _tspr_, _ttip_, |
| 626 | _tov_, lion) { |
Simon Hunt | fc5c584 | 2017-02-01 23:32:18 -0800 | [diff] [blame] | 627 | |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 628 | var params = _$loc_.search(), |
Simon Hunt | fc5c584 | 2017-02-01 23:32:18 -0800 | [diff] [blame] | 629 | selOverlay = params.overlayId, |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 630 | projection, |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 631 | dim, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 632 | uplink = { |
| 633 | // provides function calls back into this space |
| 634 | showNoDevs: showNoDevs, |
| 635 | projection: function () { return projection; }, |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 636 | zoomLayer: function () { return zoomLayer; }, |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 637 | zoomer: function () { return zoomer; }, |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 638 | opacifyMap: opacifyMap, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 639 | topoStartDone: topoStartDone, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 640 | }; |
| 641 | |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 642 | $scope = _$scope_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 643 | $log = _$log_; |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 644 | $loc = _$loc_; |
Simon Hunt | 7faabd5 | 2016-08-18 16:16:19 -0700 | [diff] [blame] | 645 | $timeout = _$timeout_; |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 646 | fs = _fs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 647 | ks = _ks_; |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 648 | zs = _zs_; |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 649 | gs = _gs_; |
Simon Hunt | 1e8eff4 | 2015-01-08 17:19:02 -0800 | [diff] [blame] | 650 | ms = _ms_; |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 651 | sus = _sus_; |
Simon Hunt | 0e48c29 | 2015-02-19 16:11:37 -0800 | [diff] [blame] | 652 | flash = _flash_; |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 653 | wss = _wss_; |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 654 | ps = _ps_; |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 655 | th = _th_; |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 656 | tds = _tds_; |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 657 | t3s = _t3s_; |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 658 | tes = _tes_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 659 | tfs = _tfs_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 660 | // TODO: consider funnelling actions through TopoForceService... |
| 661 | // rather than injecting references to these 'sub-modules', |
| 662 | // just so we can invoke functions on them. |
Simon Hunt | c252aa6 | 2015-02-10 16:45:39 -0800 | [diff] [blame] | 663 | tps = _tps_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 664 | tis = _tis_; |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 665 | tms = _tms_; |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 666 | tls = _tls_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 667 | tos = _tos_; |
Bri Prebilic Cole | b5f2b15 | 2015-04-07 14:58:09 -0700 | [diff] [blame] | 668 | fltr = _fltr_; |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 669 | ttbs = _ttbs_; |
Simon Hunt | a428124 | 2016-02-26 20:18:45 -0800 | [diff] [blame] | 670 | tspr = _tspr_; |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 671 | tov = _tov_; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 672 | tss = _tss_; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 673 | |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 674 | tms.start({ |
| 675 | toggleMap: toggleMap, |
| 676 | currentMap: currentMap, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 677 | setMap: setMap, |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 678 | }); |
| 679 | |
Simon Hunt | 441c9ae | 2017-02-03 18:22:31 -0800 | [diff] [blame] | 680 | // pull intent data from the query string... |
Viswanath KSP | 0f29770 | 2016-08-13 18:02:43 +0530 | [diff] [blame] | 681 | if (params.key && params.appId && params.appName) { |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 682 | $scope.intentData = { |
Viswanath KSP | 0f29770 | 2016-08-13 18:02:43 +0530 | [diff] [blame] | 683 | key: params.key, |
| 684 | appId: params.appId, |
Simon Hunt | 441c9ae | 2017-02-03 18:22:31 -0800 | [diff] [blame] | 685 | appName: params.appName, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 686 | intentType: params.intentType, |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 687 | }; |
| 688 | } |
| 689 | |
Bri Prebilic Cole | 068814d | 2015-05-14 16:06:38 -0700 | [diff] [blame] | 690 | $scope.notifyResize = function () { |
Simon Hunt | b0ec1e5 | 2015-01-28 18:13:49 -0800 | [diff] [blame] | 691 | svgResized(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 692 | }; |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 693 | |
Simon Hunt | 54442fa | 2015-01-26 14:17:38 -0800 | [diff] [blame] | 694 | // Cleanup on destroyed scope.. |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 695 | $scope.$on('$destroy', function () { |
| 696 | $log.log('OvTopoCtrl is saying Buh-Bye!'); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 697 | tes.stop(); |
Thomas Vachuska | 26be4f3 | 2016-03-31 01:10:27 -0700 | [diff] [blame] | 698 | tms.stop(); |
Bri Prebilic Cole | 9dcaea5 | 2015-07-21 14:39:48 -0700 | [diff] [blame] | 699 | ks.unbindKeys(); |
Simon Hunt | 626d210 | 2015-01-29 11:54:50 -0800 | [diff] [blame] | 700 | tps.destroyPanels(); |
Simon Hunt | a211f7f | 2015-11-09 12:48:23 -0800 | [diff] [blame] | 701 | tds.closeDialog(); |
Simon Hunt | 4b66859 | 2015-01-29 17:33:53 -0800 | [diff] [blame] | 702 | tis.destroyInst(); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 703 | tfs.destroyForce(); |
Bri Prebilic Cole | d621905 | 2015-03-19 14:34:02 -0700 | [diff] [blame] | 704 | ttbs.destroyToolbar(); |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 705 | mapShader(false); |
Simon Hunt | 584122a | 2015-01-21 15:32:40 -0800 | [diff] [blame] | 706 | }); |
| 707 | |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 708 | // svg layer and initialization of components |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 709 | ovtopo = d3.select('#ov-topo'); |
| 710 | svg = ovtopo.select('svg'); |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 711 | // set the svg size to match that of the window, less the masthead |
| 712 | svg.attr(fs.windowSize(mast.mastHeight())); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 713 | dim = [svg.attr('width'), svg.attr('height')]; |
Simon Hunt | 426bd86 | 2015-01-14 16:48:41 -0800 | [diff] [blame] | 714 | |
Thomas Vachuska | c616e17 | 2018-04-17 16:57:12 -0700 | [diff] [blame] | 715 | ps.addListener(applyPreferences); |
| 716 | |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 717 | setUpKeys(); |
Bri Prebilic Cole | 4db8dce | 2015-03-18 13:57:24 -0700 | [diff] [blame] | 718 | setUpToolbar(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 719 | setUpDefs(); |
Simon Hunt | cacce34 | 2015-01-07 16:13:05 -0800 | [diff] [blame] | 720 | setUpZoom(); |
Simon Hunt | 7c8ab8d | 2015-02-03 15:05:15 -0800 | [diff] [blame] | 721 | setUpNoDevs(); |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 722 | setUpMap().then( |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 723 | function (proj) { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 724 | var z = ps.getPrefs('topo_zoom', { tx: 0, ty: 0, sc: 1 }); |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 725 | zoomer.panZoom([z.tx, z.ty], z.sc); |
| 726 | $log.debug('** Zoom restored:', z); |
| 727 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 728 | projection = proj; |
Simon Hunt | bb5e0d8 | 2015-04-16 14:25:46 -0700 | [diff] [blame] | 729 | $log.debug('** We installed the projection:', proj); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 730 | flash.enable(false); |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 731 | toggleMap(prefsState.bg); |
Simon Hunt | f41f309 | 2015-04-16 10:33:26 -0700 | [diff] [blame] | 732 | flash.enable(true); |
Simon Hunt | a34fcb5 | 2016-02-25 16:27:32 -0800 | [diff] [blame] | 733 | mapShader(true); |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 734 | |
Simon Hunt | 5989ddf | 2017-08-02 20:38:12 -0700 | [diff] [blame] | 735 | // piggyback off the deferred map loading to load the |
| 736 | // localization bundle after the uber bundle has arrived... |
| 737 | $scope.lion = lion.bundle('core.view.Topo'); |
| 738 | topoLion = $scope.lion; |
| 739 | $log.debug('Loaded Topo LION Bundle:', topoLion); |
| 740 | |
Simon Hunt | 3f89cb4 | 2017-08-10 13:32:00 -0700 | [diff] [blame] | 741 | // insert localized text into already established |
| 742 | // DOM elements... |
| 743 | lionNoDevs(); |
| 744 | |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 745 | // pass lion bundle function ref to other topo modules |
| 746 | tfs.setLionBundle(topoLion); |
| 747 | tis.setLionBundle(topoLion); |
Simon Hunt | 1603c69 | 2017-08-10 19:53:35 -0700 | [diff] [blame] | 748 | tms.setLionBundle(topoLion); |
Simon Hunt | 879ce45 | 2017-08-10 23:32:00 -0700 | [diff] [blame] | 749 | tps.setLionBundle(topoLion); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame] | 750 | ttbs.setLionBundle(topoLion); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 751 | |
Simon Hunt | e1ce429 | 2015-06-12 13:07:02 -0700 | [diff] [blame] | 752 | // now we have the map projection, we are ready for |
| 753 | // the server to send us device/host data... |
| 754 | tes.start(); |
| 755 | // need to do the following so we immediately get |
| 756 | // the summary panel data back from the server |
| 757 | restoreSummaryFromPrefs(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 758 | } |
| 759 | ); |
Simon Hunt | a428124 | 2016-02-26 20:18:45 -0800 | [diff] [blame] | 760 | tes.bindHandlers(); |
Simon Hunt | 90053ed | 2016-04-06 12:49:02 -0700 | [diff] [blame] | 761 | setUpSprites(); |
Simon Hunt | fd1231a | 2015-01-26 22:14:51 -0800 | [diff] [blame] | 762 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 763 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 764 | tfs.initForce(svg, forceG, uplink, dim); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 765 | tis.initInst({ showMastership: tfs.showMastership }); |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 766 | tps.initPanels(); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 767 | |
Simon Hunt | c7ae795 | 2015-04-08 18:59:27 -0700 | [diff] [blame] | 768 | restoreConfigFromPrefs(); |
Simon Hunt | fc5c584 | 2017-02-01 23:32:18 -0800 | [diff] [blame] | 769 | |
| 770 | ttbs.selectOverlay(selOverlay || prefsState.ovid); |
Simon Hunt | 36a58c6 | 2015-04-08 11:00:07 -0700 | [diff] [blame] | 771 | |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 772 | $log.debug('registered overlays...', tov.list()); |
Simon Hunt | 6cc5369 | 2015-01-07 11:33:45 -0800 | [diff] [blame] | 773 | $log.log('OvTopoCtrl has been created'); |
Simon Hunt | ef31fb2 | 2014-12-19 13:16:44 -0800 | [diff] [blame] | 774 | }]); |
| 775 | }()); |