blob: 4c87f86aeaacd2b46f75c19282991f31adbeaf96 [file] [log] [blame]
Simon Huntef31fb22014-12-19 13:16:44 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Simon Huntef31fb22014-12-19 13:16:44 -08003 *
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 Huntef31fb22014-12-19 13:16:44 -080019 */
20
21(function () {
22 'use strict';
Simon Hunt6cc53692015-01-07 11:33:45 -080023
24 var moduleDependencies = [
Simon Hunt36a58c62015-04-08 11:00:07 -070025 'ngCookies',
Simon Hunt6cc53692015-01-07 11:33:45 -080026 'onosUtil',
Simon Hunt1e4a0012015-01-21 11:36:08 -080027 'onosSvg',
Steven Burrows1c2a9682017-07-14 16:52:46 +010028 'onosRemote',
Simon Hunt6cc53692015-01-07 11:33:45 -080029 ];
30
Simon Hunta4281242016-02-26 20:18:45 -080031 // references to injected services
Steven Burrows1c2a9682017-07-14 16:52:46 +010032 var $scope, $log, $loc, $timeout,
Simon Hunt7faabd52016-08-18 16:16:19 -070033 fs, ks, zs, gs, ms, sus, flash, wss, ps, th, tds, t3s, tes, tfs, tps,
Steven Burrows1c2a9682017-07-14 16:52:46 +010034 tis, tms, tss, tls, tos, fltr, ttbs, tspr, tov;
Simon Hunt6cc53692015-01-07 11:33:45 -080035
36 // DOM elements
Simon Hunt2052e5d2015-04-13 17:40:44 -070037 var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer;
Simon Hunt6cc53692015-01-07 11:33:45 -080038
39 // Internal state
Simon Hunt5989ddf2017-08-02 20:38:12 -070040 var zoomer,
41 actionMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +010042 topoLion = function (x) { return '#' + x + '#'; }; // func replaced later
Simon Hunt6cc53692015-01-07 11:33:45 -080043
Simon Huntcacce342015-01-07 16:13:05 -080044 // --- Short Cut Keys ------------------------------------------------
45
Simon Hunt8d22c4b2015-08-06 16:24:43 -070046 function setUpKeys(overlayKeys) {
Simon Hunt5724fb42015-02-05 16:59:40 -080047 // key bindings need to be made after the services have been injected
48 // thus, deferred to here...
Simon Hunt5989ddf2017-08-02 20:38:12 -070049
50 // we need functions that can be invoked after LION bundle loaded
Steven Burrows1c2a9682017-07-14 16:52:46 +010051 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 Hunt5989ddf2017-08-02 20:38:12 -070054
Steven Burrows1c2a9682017-07-14 16:52:46 +010055 function togHost() { return topoLion('tbtt_tog_host'); }
56 function togOff() { return topoLion('tbtt_tog_offline'); }
57 function togPortHi() { return topoLion('tbtt_tog_porthi'); }
Simon Hunt5989ddf2017-08-02 20:38:12 -070058
Steven Burrows1c2a9682017-07-14 16:52:46 +010059 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 Hunt5989ddf2017-08-02 20:38:12 -070063
Steven Burrows1c2a9682017-07-14 16:52:46 +010064 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 Hunt5989ddf2017-08-02 20:38:12 -070069
Steven Burrows1c2a9682017-07-14 16:52:46 +010070 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 Hunt5989ddf2017-08-02 20:38:12 -070074
Steven Burrows1c2a9682017-07-14 16:52:46 +010075 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 Hunt5989ddf2017-08-02 20:38:12 -070080
Steven Burrows1c2a9682017-07-14 16:52:46 +010081 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 Vachuskac8c8f462021-03-01 11:22:56 -080086 function quiet() { return ""; }
Simon Hunt5989ddf2017-08-02 20:38:12 -070087
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -070088 actionMap = {
Simon Hunt5989ddf2017-08-02 20:38:12 -070089 I: [toggleInstances, togInst],
90 O: [toggleSummary, togSumm],
91 D: [toggleUseDetailsFlag, togUseDet],
Simon Huntac4c6f72015-02-03 19:50:53 -080092
Simon Hunt5989ddf2017-08-02 20:38:12 -070093 H: [toggleHosts, togHost],
94 M: [toggleOffline, togOff],
95 P: [togglePorts, togPortHi],
Simon Huntac4c6f72015-02-03 19:50:53 -080096
Simon Hunt5989ddf2017-08-02 20:38:12 -070097 dash: [tfs.showBadLinks, showBad],
98 B: [toggleMap, togMap],
99 G: [openMapSelection, selMap],
100 S: [toggleSprites, togSpr],
Simon Huntac4c6f72015-02-03 19:50:53 -0800101
Simon Hunt5989ddf2017-08-02 20:38:12 -0700102 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 Vachuskaa4eac6a2021-03-01 15:11:59 -0800107 'alt-L': [tfs.cycleLinkLabels, quiet],
Simon Hunt5989ddf2017-08-02 20:38:12 -0700108
109 U: [tfs.unpin, unpin],
110 R: [resetZoom, rzoom],
111 dot: [ttbs.toggleToolbar, togtb],
112 E: [equalizeMasters, eqmaster],
Simon Huntac4c6f72015-02-03 19:50:53 -0800113
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800114 "shift-openBracket": [tfs.toggleHostTextSize, quiet],
115 "shift-closeBracket": [tfs.toggleHostIconSize, quiet],
116
Steven Burrows1c2a9682017-07-14 16:52:46 +0100117 // -- instance color palette debug
Simon Hunta9761342016-06-10 18:02:53 -0700118 // 9: function () { sus.cat7().testCard(svg); },
119
Simon Hunt5b024d72016-01-29 11:02:43 -0800120 // 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 Hunt08f841d02015-02-10 14:39:20 -0800127 esc: handleEscape,
Simon Huntac4c6f72015-02-03 19:50:53 -0800128
Simon Hunt09060142015-03-18 20:23:32 -0700129 _keyListener: ttbs.keyListener,
130
Simon Hunt5724fb42015-02-05 16:59:40 -0800131 _helpFormat: [
Steven Burrows1c2a9682017-07-14 16:52:46 +0100132 ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B', 'G', 'S'],
Simon Hunt10618f62017-06-15 19:30:52 -0700133 ['X', 'Z', 'N', 'L', 'shift-L', 'U', 'R', '-', 'E', '-', 'dot'],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100134 [], // this column reserved for overlay actions
135 ],
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700136 };
137
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700138 if (fs.isO(overlayKeys)) {
139 mergeKeys(overlayKeys);
140 }
141
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700142 ks.keyBindings(actionMap);
Simon Huntac4c6f72015-02-03 19:50:53 -0800143
Simon Hunt639dc662015-02-18 14:19:20 -0800144 ks.gestureNotes([
Simon Hunt5989ddf2017-08-02 20:38:12 -0700145 [uiClick, uiClickTxt],
146 [uiShClick, uiShClickTxt],
147 [uiDrag, uiDragTxt],
148 [uiCmdScr, uiCmdScrTxt],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100149 [uiCmdDrag, uiCmdDragTxt],
Simon Hunt639dc662015-02-18 14:19:20 -0800150 ]);
Simon Hunt5724fb42015-02-05 16:59:40 -0800151 }
Simon Hunt6cc53692015-01-07 11:33:45 -0800152
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700153 // 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 Hunt71892222015-09-29 13:39:40 -0700157
158 ks.checkNotGlobal(extra);
159
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700160 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 Hunt08f841d02015-02-10 14:39:20 -0800172 // --- Keystroke functions -------------------------------------------
Simon Huntac4c6f72015-02-03 19:50:53 -0800173
Simon Hunt36a58c62015-04-08 11:00:07 -0700174 function toggleInstances(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700175 updatePrefsState('insts', tis.toggle(x));
Simon Huntac4c6f72015-02-03 19:50:53 -0800176 tfs.updateDeviceColors();
Simon Hunt6cc53692015-01-07 11:33:45 -0800177 }
Simon Huntac4c6f72015-02-03 19:50:53 -0800178
Simon Huntee7a3ce2015-04-09 13:28:37 -0700179 function toggleSummary(x) {
180 updatePrefsState('summary', tps.toggleSummary(x));
Simon Hunt18bf9822015-02-12 17:35:45 -0800181 }
182
Simon Hunt239e5882015-04-23 15:07:04 -0700183 function toggleUseDetailsFlag(x) {
184 updatePrefsState('detail', tps.toggleUseDetailsFlag(x));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700185 }
186
Simon Huntfcbde892015-04-16 12:05:28 -0700187 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 Hunt3f89cb42017-08-10 13:32:00 -0700201 verb = on ? topoLion('show') : topoLion('hide');
Simon Huntfcbde892015-04-16 12:05:28 -0700202 sus.visible(G, on);
203 updatePrefsState(tag, on);
204 flash.flash(verb + ' ' + what);
205 }
206
207 function toggleMap(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700208 _togSvgLayer(x, mapG, 'bg', topoLion('fl_background_map'));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700209 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700210
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700211 function openMapSelection() {
212 tms.openMapSelection();
213 }
214
Simon Hunt2052e5d2015-04-13 17:40:44 -0700215 function toggleSprites(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700216 _togSvgLayer(x, spriteG, 'spr', topoLion('fl_sprite_layer'));
Simon Hunt2052e5d2015-04-13 17:40:44 -0700217 }
218
Simon Hunt08f841d02015-02-10 14:39:20 -0800219 function resetZoom() {
220 zoomer.reset();
Simon Hunt3f89cb42017-08-10 13:32:00 -0700221 flash.flash(topoLion('fl_pan_zoom_reset'));
Simon Hunt08f841d02015-02-10 14:39:20 -0800222 }
223
Simon Hunt0e48c292015-02-19 16:11:37 -0800224 function equalizeMasters() {
Simon Hunt237676b52015-03-10 19:04:26 -0700225 wss.sendEvent('equalizeMasters');
Simon Hunt3f89cb42017-08-10 13:32:00 -0700226 flash.flash(topoLion('fl_eq_masters'));
Simon Hunt0e48c292015-02-19 16:11:37 -0800227 }
228
Simon Hunt08f841d02015-02-10 14:39:20 -0800229 function handleEscape() {
Simon Hunta142dd22015-02-12 22:07:51 -0800230 if (tis.showMaster()) {
231 // if an instance is selected, cancel the affinity mapping
Steven Burrows1c2a9682017-07-14 16:52:46 +0100232 tis.cancelAffinity();
Simon Hunt08f841d02015-02-10 14:39:20 -0800233
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700234 } else if (tov.hooks.escape()) {
235 // else if the overlay consumed the ESC event...
236 // (work already done)
237
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700238 } else if (tss.deselectAll()) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800239 // else if we have node selections, deselect them all
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700240 // (work already done)
241
Prince Pereira46c82d42016-09-19 13:30:50 +0530242 } else if (tls.deselectAllLinks()) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700243 // else if we have a link selected, deselect it
244 // (work already done)
Simon Hunt08f841d02015-02-10 14:39:20 -0800245
Simon Hunta0eb0a82015-02-11 12:30:06 -0800246 } else if (tis.isVisible()) {
247 // else if the Instance Panel is visible, hide it
248 tis.hide();
249 tfs.updateDeviceColors();
Simon Hunt08f841d02015-02-10 14:39:20 -0800250
Simon Hunta0eb0a82015-02-11 12:30:06 -0800251 } else if (tps.summaryVisible()) {
252 // else if the Summary Panel is visible, hide it
Simon Hunt356da762016-05-27 11:54:02 -0700253 tps.hideSummary();
Simon Hunta0eb0a82015-02-11 12:30:06 -0800254 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800255 }
Simon Huntcacce342015-01-07 16:13:05 -0800256
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700257 // --- Toolbar Functions ---------------------------------------------
258
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700259 function notValid(what) {
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700260 $log.warn('topo.js getActionEntry(): Not a valid ' + what);
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700261 }
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700262
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700263 function getActionEntry(key) {
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700264 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 Cole4db8dce2015-03-18 13:57:24 -0700277 return fs.isA(entry) || [entry, ''];
278 }
279
280 function setUpToolbar() {
281 ttbs.init({
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700282 getActionEntry: getActionEntry,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100283 setUpKeys: setUpKeys,
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700284 });
285 ttbs.createToolbar();
286 }
287
Simon Huntcacce342015-01-07 16:13:05 -0800288 // --- Glyphs, Icons, and the like -----------------------------------
289
Simon Hunt6cc53692015-01-07 11:33:45 -0800290 function setUpDefs() {
Simon Huntcacce342015-01-07 16:13:05 -0800291 defs = svg.append('defs');
Simon Hunt6cc53692015-01-07 11:33:45 -0800292 gs.loadDefs(defs);
Simon Hunt0ee28682015-02-12 20:48:11 -0800293 sus.loadGlowDefs(defs);
Simon Hunt6cc53692015-01-07 11:33:45 -0800294 }
295
296
Simon Huntcacce342015-01-07 16:13:05 -0800297 // --- Pan and Zoom --------------------------------------------------
298
299 // zoom enabled predicate. ev is a D3 source event.
300 function zoomEnabled(ev) {
Simon Huntd552ee92015-04-02 17:06:35 -0700301 return fs.isMobile() || (ev.metaKey || ev.altKey);
Simon Huntcacce342015-01-07 16:13:05 -0800302 }
303
304 function zoomCallback() {
Simon Huntbb5e0d82015-04-16 14:25:46 -0700305 var sc = zoomer.scale(),
306 tr = zoomer.translate();
307
Steven Burrows1c2a9682017-07-14 16:52:46 +0100308 ps.setPrefs('topo_zoom', { tx: tr[0], ty: tr[1], sc: sc });
Simon Huntcacce342015-01-07 16:13:05 -0800309
Simon Hunt0541fb82015-01-14 18:59:57 -0800310 // keep the map lines constant width while zooming
Simon Hunt737c89f2015-01-28 12:23:19 -0800311 mapG.style('stroke-width', (2.0 / sc) + 'px');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700312
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800313 tfs.adjustNodeScale();
Simon Huntcacce342015-01-07 16:13:05 -0800314 }
315
316 function setUpZoom() {
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800317 zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer');
Simon Huntcacce342015-01-07 16:13:05 -0800318 zoomer = zs.createZoomer({
319 svg: svg,
320 zoomLayer: zoomLayer,
321 zoomEnabled: zoomEnabled,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100322 zoomCallback: zoomCallback,
Simon Huntcacce342015-01-07 16:13:05 -0800323 });
324 }
325
326
Simon Hunt0541fb82015-01-14 18:59:57 -0800327 // callback invoked when the SVG view has been resized..
Simon Hunt3a6eec02015-02-09 21:16:43 -0800328 function svgResized(s) {
329 tfs.newDim([s.width, s.height]);
Simon Hunt0541fb82015-01-14 18:59:57 -0800330 }
331
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800332 // --- Background Map ------------------------------------------------
333
Simon Hunte2d9dc72017-08-10 15:21:04 -0700334 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 Hunte2d9dc72017-08-10 15:21:04 -0700340 }
341
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800342 function setUpNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700343 var g;
344
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800345 noDevsLayer = svg.append('g').attr({
346 id: 'topo-noDevsLayer',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100347 transform: sus.translate(500, 500),
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800348 });
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 Huntcaed0412017-08-12 13:49:17 -0700354 g.append('text').text('').attr({ x: 120, y: 80 });
Simon Hunte2d9dc72017-08-10 15:21:04 -0700355 recenterLabel(g);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800356 showNoDevs(true);
357 }
358
Simon Hunt3f89cb42017-08-10 13:32:00 -0700359 function lionNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700360 var g = d3.select('#topo-noDevsLayer g');
361
362 g.select('text').text(topoLion('no_devices_are_connected'));
363 recenterLabel(g);
Simon Hunt3f89cb42017-08-10 13:32:00 -0700364 }
365
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800366 function showNoDevs(b) {
Simon Hunt18bf9822015-02-12 17:35:45 -0800367 sus.visible(noDevsLayer, b);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800368 }
369
Simon Hunt2362b072015-06-11 20:08:22 -0700370
371 var countryFilters = {
Simon Hunt2362b072015-06-11 20:08:22 -0700372 s_america: function (c) {
373 return c.properties.continent === 'South America';
374 },
375
Simon Huntac099e82015-12-03 09:17:47 -0800376 ns_america: function (c) {
377 return c.properties.custom === 'US-cont' ||
378 c.properties.subregion === 'Central America' ||
Simon Huntd4712622015-12-02 11:19:50 -0800379 c.properties.continent === 'South America';
380 },
381
Simon Hunt2362b072015-06-11 20:08:22 -0700382 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 Hunt1178d5b2015-09-02 17:02:37 -0700399 },
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 Burrows1c2a9682017-07-14 16:52:46 +0100407 },
Simon Hunt2362b072015-06-11 20:08:22 -0700408 };
409
Simon Hunta34fcb52016-02-25 16:27:32 -0800410 var tintOn = 0,
411 shadeFlip = 0,
412 shadePalette = {
413 light: {
414 sea: 'aliceblue',
415 land: 'white',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100416 outline: '#ddd',
Simon Hunta34fcb52016-02-25 16:27:32 -0800417 },
418 dark: {
419 sea: '#001830',
420 land: '#232331',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100421 outline: '#3a3a3a',
422 },
Simon Hunta34fcb52016-02-25 16:27:32 -0800423 };
424
425 function shading() {
426 return tintOn ? {
427 palette: shadePalette[th.theme()],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100428 flip: shadeFlip,
Simon Hunta34fcb52016-02-25 16:27:32 -0800429 } : '';
430 }
Simon Hunt2362b072015-06-11 20:08:22 -0700431
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700432 function setMap(map) {
433 ps.setPrefs('topo_mapid', map);
Simon Hunt90053ed2016-04-06 12:49:02 -0700434 setUpMap();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700435 opacifyMap(true);
436 }
437
438 function currentMap() {
439 return ps.getPrefs(
440 'topo_mapid',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100441 {
442 mapid: 'usa',
443 mapscale: 1,
444 mapfilepath: '*continental_us',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100445 tint: 'off',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100446 },
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700447 $loc.search()
448 );
449 }
450
Simon Hunt90053ed2016-04-06 12:49:02 -0700451 function setUpMap() {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700452 var prefs = currentMap(),
Simon Hunt8a119b02016-03-29 16:00:32 -0700453 mapId = prefs.mapid,
Steven Burrows3a9a6442016-05-05 15:31:16 +0100454 mapFilePath = prefs.mapfilepath,
Simon Hunt8a119b02016-03-29 16:00:32 -0700455 mapScale = prefs.mapscale,
456 tint = prefs.tint,
Simon Hunt2362b072015-06-11 20:08:22 -0700457 promise,
Simon Huntfacad992016-02-25 09:58:33 -0800458 cfilter;
Simon Hunt2362b072015-06-11 20:08:22 -0700459
Simon Hunta34fcb52016-02-25 16:27:32 -0800460 tintOn = tint === 'on' ? 1 : 0;
461
Simon Hunt18491362016-03-04 11:09:42 -0800462 $log.debug('setUpMap() mapId:', mapId, ', mapScale:', mapScale,
463 ', tint:', tint);
464
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700465 mapG = d3.select('#topo-map');
466 if (mapG.empty()) {
467 mapG = zoomLayer.append('g').attr('id', 'topo-map');
468 } else {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100469 mapG.each(function (d, i) {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700470 d3.selectAll(this.childNodes).remove();
471 });
472 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100473
474 if (mapFilePath === '*countries') {
475
Simon Hunt90053ed2016-04-06 12:49:02 -0700476 cfilter = countryFilters[mapId] || countryFilters.uk;
Steven Burrows3a9a6442016-05-05 15:31:16 +0100477
Simon Hunta34fcb52016-02-25 16:27:32 -0800478 promise = ms.loadMapRegionInto(mapG, {
479 countryFilter: cfilter,
480 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100481 shading: shading(),
Simon Hunta34fcb52016-02-25 16:27:32 -0800482 });
Steven Burrows3a9a6442016-05-05 15:31:16 +0100483 } else {
484
485 promise = ms.loadMapInto(mapG, mapFilePath, mapId, {
486 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100487 shading: shading(),
Steven Burrows3a9a6442016-05-05 15:31:16 +0100488 });
Simon Hunt2362b072015-06-11 20:08:22 -0700489 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100490
Simon Hunt8a119b02016-03-29 16:00:32 -0700491 ps.setPrefs('topo_mapid', prefs);
Simon Hunt2362b072015-06-11 20:08:22 -0700492 return promise;
Simon Hunt0541fb82015-01-14 18:59:57 -0800493 }
494
Simon Huntf51bf462016-06-29 16:22:57 -0700495 function mapReshader() {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100496 $log.debug('... Re-shading map ...');
Simon Huntf51bf462016-06-29 16:22:57 -0700497 ms.reshade(shading());
498 }
499
Simon Hunta34fcb52016-02-25 16:27:32 -0800500 // set up theme listener to re-shade the map when required.
501 function mapShader(on) {
502 if (on) {
Simon Huntf51bf462016-06-29 16:22:57 -0700503 th.addListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800504 } else {
Simon Huntf51bf462016-06-29 16:22:57 -0700505 th.removeListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800506 }
507 }
508
Simon Huntc3c5b672015-02-20 11:32:13 -0800509 function opacifyMap(b) {
510 mapG.transition()
511 .duration(1000)
512 .attr('opacity', b ? 1 : 0);
513 }
Simon Hunt737c89f2015-01-28 12:23:19 -0800514
Simon Hunt90053ed2016-04-06 12:49:02 -0700515 function setUpSprites() {
Simon Hunt8a119b02016-03-29 16:00:32 -0700516 var prefs = ps.getPrefs('topo_sprites', { sprites: '' }, $loc.search()),
517 sprId = prefs.sprites;
Simon Huntf9fc0e72015-04-16 15:10:57 -0700518
Steven Burrows1c2a9682017-07-14 16:52:46 +0100519 spriteG = zoomLayer.append('g').attr('id', 'topo-sprites');
Simon Huntf9fc0e72015-04-16 15:10:57 -0700520 if (sprId) {
Simon Hunt8a119b02016-03-29 16:00:32 -0700521 ps.setPrefs('topo_sprites', prefs);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700522 tspr.loadSprites(spriteG, defs, sprId);
523 }
524 }
Simon Hunt9c1c45e2015-04-10 13:38:27 -0700525
Simon Huntc7ae7952015-04-08 18:59:27 -0700526 // --- User Preferemces ----------------------------------------------
Simon Hunt36a58c62015-04-08 11:00:07 -0700527
Simon Huntc7ae7952015-04-08 18:59:27 -0700528 var prefsState = {};
Simon Hunt36a58c62015-04-08 11:00:07 -0700529
Simon Huntc7ae7952015-04-08 18:59:27 -0700530 function updatePrefsState(what, b) {
531 prefsState[what] = b ? 1 : 0;
532 ps.setPrefs('topo_prefs', prefsState);
Simon Hunt36a58c62015-04-08 11:00:07 -0700533 }
534
Thomas Vachuskac616e172018-04-17 16:57:12 -0700535 function applyPreferences(evt) {
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700536// var zoomPrefs = ps.getPrefs('topo_zoom', null);
Thomas Vachuskabf5d1fe2018-04-25 15:49:00 -0400537// if (ps.getPrefs('topo_prefs', null)) {
538// restoreConfigFromPrefs();
539// }
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700540// if (zoomPrefs) {
541// $log.debug('TOPO- Zoom State:', zoomPrefs);
542// zoomer.panZoom([zoomPrefs.tx, zoomPrefs.ty], zoomPrefs.sc, 100);
543// }
Thomas Vachuskac616e172018-04-17 16:57:12 -0700544 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700545
Simon Huntc7ae7952015-04-08 18:59:27 -0700546 function restoreConfigFromPrefs() {
547 // NOTE: toolbar will have set this for us..
Simon Huntfc5c5842017-02-01 23:32:18 -0800548 prefsState = ps.asNumbers(
549 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
550 );
Simon Hunt36a58c62015-04-08 11:00:07 -0700551
Simon Hunte1ce4292015-06-12 13:07:02 -0700552 $log.debug('TOPO- Prefs State:', prefsState);
Simon Huntc7ae7952015-04-08 18:59:27 -0700553
Simon Huntf41f3092015-04-16 10:33:26 -0700554 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700555 toggleInstances(prefsState.insts);
Simon Huntee7a3ce2015-04-09 13:28:37 -0700556 toggleSummary(prefsState.summary);
Simon Hunt239e5882015-04-23 15:07:04 -0700557 toggleUseDetailsFlag(prefsState.detail);
Bri Prebilic Cole9b80ca02015-08-03 11:26:54 -0700558 toggleHosts(prefsState.hosts);
559 toggleOffline(prefsState.offdev);
560 togglePorts(prefsState.porthl);
561 toggleMap(prefsState.bg);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700562 toggleSprites(prefsState.spr);
Thomas Vachuskac616e172018-04-17 16:57:12 -0700563 ttbs.setToolbar(prefsState.toolbar);
Thomas Vachuska0af26912016-03-21 21:37:30 -0700564 t3s.setDevLabIndex(prefsState.dlbls);
Simon Hunt10618f62017-06-15 19:30:52 -0700565 t3s.setHostLabIndex(prefsState.hlbls);
Simon Huntf41f3092015-04-16 10:33:26 -0700566 flash.enable(true);
Simon Hunt36a58c62015-04-08 11:00:07 -0700567 }
568
569
Simon Hunte1ce4292015-06-12 13:07:02 -0700570 // 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 Huntfc5c5842017-02-01 23:32:18 -0800574 prefsState = ps.asNumbers(
575 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
576 );
Simon Hunte1ce4292015-06-12 13:07:02 -0700577 $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary);
578
579 flash.enable(false);
580 toggleSummary(prefsState.summary);
581 flash.enable(true);
582 }
583
Simon Hunt8419efd2017-01-12 12:36:28 -0800584 // initial set of topo events received, now do post-processing
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700585 function topoStartDone() {
Simon Hunt8419efd2017-01-12 12:36:28 -0800586 // 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 Hunt7faabd52016-08-18 16:16:19 -0700588 $timeout(function () {
Simon Hunt8419efd2017-01-12 12:36:28 -0800589 $log.debug('^^ topo.topoStartDone() ^^');
590
591 // reselect the previous selection...
Simon Hunt7faabd52016-08-18 16:16:19 -0700592 tss.reselect();
Simon Hunt8419efd2017-01-12 12:36:28 -0800593
594 // if an intent should be shown, invoke the appropriate callback
595 if ($scope.intentData) {
Simon Hunt8419efd2017-01-12 12:36:28 -0800596 tov.hooks.showIntent($scope.intentData);
Simon Hunt7faabd52016-08-18 16:16:19 -0700597 }
Simon Hunt8419efd2017-01-12 12:36:28 -0800598
Simon Hunt7faabd52016-08-18 16:16:19 -0700599 }, 200);
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700600 }
Simon Hunte1ce4292015-06-12 13:07:02 -0700601
Simon Huntcacce342015-01-07 16:13:05 -0800602 // --- Controller Definition -----------------------------------------
603
Simon Hunt6cc53692015-01-07 11:33:45 -0800604 angular.module('ovTopo', moduleDependencies)
Simon Hunt5989ddf2017-08-02 20:38:12 -0700605 .controller('OvTopoCtrl',
606 ['$scope', '$log', '$location', '$timeout', '$cookies',
607 'FnService', 'MastService', 'KeyService', 'ZoomService',
Simon Hunt0e48c292015-02-19 16:11:37 -0800608 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService',
Simon Hunta34fcb52016-02-25 16:27:32 -0800609 'WebSocketService', 'PrefsService', 'ThemeService',
Simon Hunt5989ddf2017-08-02 20:38:12 -0700610 'TopoDialogService', 'TopoD3Service', 'TopoEventService',
611 'TopoForceService', 'TopoPanelService', 'TopoInstService',
612 'TopoSelectService', 'TopoLinkService', 'TopoTrafficService',
613 'TopoObliqueService', 'TopoFilterService', 'TopoToolbarService',
614 'TopoMapService', 'TopoSpriteService', 'TooltipService',
615 'TopoOverlayService', 'LionService',
Simon Hunt6cc53692015-01-07 11:33:45 -0800616
Simon Hunt5989ddf2017-08-02 20:38:12 -0700617 function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_,
618 _fs_, mast, _ks_, _zs_,
619 _gs_, _ms_, _sus_, _flash_,
620 _wss_, _ps_, _th_,
Thomas Vachuska0af26912016-03-21 21:37:30 -0700621 _tds_, _t3s_, _tes_,
Simon Hunt5989ddf2017-08-02 20:38:12 -0700622 _tfs_, _tps_, _tis_,
623 _tss_, _tls_, _tts_,
624 _tos_, _fltr_, _ttbs_,
625 _tms_, _tspr_, _ttip_,
626 _tov_, lion) {
Simon Huntfc5c5842017-02-01 23:32:18 -0800627
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700628 var params = _$loc_.search(),
Simon Huntfc5c5842017-02-01 23:32:18 -0800629 selOverlay = params.overlayId,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700630 projection,
Simon Hunt3a6eec02015-02-09 21:16:43 -0800631 dim,
Simon Hunt1894d792015-02-04 17:09:20 -0800632 uplink = {
633 // provides function calls back into this space
634 showNoDevs: showNoDevs,
635 projection: function () { return projection; },
Simon Huntc3c5b672015-02-20 11:32:13 -0800636 zoomLayer: function () { return zoomLayer; },
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800637 zoomer: function () { return zoomer; },
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700638 opacifyMap: opacifyMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100639 topoStartDone: topoStartDone,
Simon Huntac4c6f72015-02-03 19:50:53 -0800640 };
641
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700642 $scope = _$scope_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800643 $log = _$log_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700644 $loc = _$loc_;
Simon Hunt7faabd52016-08-18 16:16:19 -0700645 $timeout = _$timeout_;
Simon Hunta11b4eb2015-01-28 16:20:50 -0800646 fs = _fs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800647 ks = _ks_;
Simon Huntcacce342015-01-07 16:13:05 -0800648 zs = _zs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800649 gs = _gs_;
Simon Hunt1e8eff42015-01-08 17:19:02 -0800650 ms = _ms_;
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800651 sus = _sus_;
Simon Hunt0e48c292015-02-19 16:11:37 -0800652 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700653 wss = _wss_;
Simon Huntc7ae7952015-04-08 18:59:27 -0700654 ps = _ps_;
Simon Hunta34fcb52016-02-25 16:27:32 -0800655 th = _th_;
Simon Hunta211f7f2015-11-09 12:48:23 -0800656 tds = _tds_;
Thomas Vachuska0af26912016-03-21 21:37:30 -0700657 t3s = _t3s_;
Simon Huntc252aa62015-02-10 16:45:39 -0800658 tes = _tes_;
Simon Hunt737c89f2015-01-28 12:23:19 -0800659 tfs = _tfs_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800660 // 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 Huntc252aa62015-02-10 16:45:39 -0800663 tps = _tps_;
Simon Huntac4c6f72015-02-03 19:50:53 -0800664 tis = _tis_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700665 tms = _tms_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700666 tls = _tls_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800667 tos = _tos_;
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -0700668 fltr = _fltr_;
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700669 ttbs = _ttbs_;
Simon Hunta4281242016-02-26 20:18:45 -0800670 tspr = _tspr_;
Simon Hunt72e44bf2015-07-21 21:34:20 -0700671 tov = _tov_;
Steven Burrows1c2a9682017-07-14 16:52:46 +0100672 tss = _tss_;
Simon Huntef31fb22014-12-19 13:16:44 -0800673
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700674 tms.start({
675 toggleMap: toggleMap,
676 currentMap: currentMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100677 setMap: setMap,
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700678 });
679
Simon Hunt441c9ae2017-02-03 18:22:31 -0800680 // pull intent data from the query string...
Viswanath KSP0f297702016-08-13 18:02:43 +0530681 if (params.key && params.appId && params.appName) {
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700682 $scope.intentData = {
Viswanath KSP0f297702016-08-13 18:02:43 +0530683 key: params.key,
684 appId: params.appId,
Simon Hunt441c9ae2017-02-03 18:22:31 -0800685 appName: params.appName,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100686 intentType: params.intentType,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700687 };
688 }
689
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700690 $scope.notifyResize = function () {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800691 svgResized(fs.windowSize(mast.mastHeight()));
Simon Hunt426bd862015-01-14 16:48:41 -0800692 };
Simon Huntef31fb22014-12-19 13:16:44 -0800693
Simon Hunt54442fa2015-01-26 14:17:38 -0800694 // Cleanup on destroyed scope..
Simon Hunt584122a2015-01-21 15:32:40 -0800695 $scope.$on('$destroy', function () {
696 $log.log('OvTopoCtrl is saying Buh-Bye!');
Thomas Vachuska329af532015-03-10 02:08:33 -0700697 tes.stop();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700698 tms.stop();
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700699 ks.unbindKeys();
Simon Hunt626d2102015-01-29 11:54:50 -0800700 tps.destroyPanels();
Simon Hunta211f7f2015-11-09 12:48:23 -0800701 tds.closeDialog();
Simon Hunt4b668592015-01-29 17:33:53 -0800702 tis.destroyInst();
Simon Hunt3a6eec02015-02-09 21:16:43 -0800703 tfs.destroyForce();
Bri Prebilic Coled6219052015-03-19 14:34:02 -0700704 ttbs.destroyToolbar();
Simon Hunta34fcb52016-02-25 16:27:32 -0800705 mapShader(false);
Simon Hunt584122a2015-01-21 15:32:40 -0800706 });
707
Simon Huntcacce342015-01-07 16:13:05 -0800708 // svg layer and initialization of components
Simon Hunt426bd862015-01-14 16:48:41 -0800709 ovtopo = d3.select('#ov-topo');
710 svg = ovtopo.select('svg');
Simon Hunta11b4eb2015-01-28 16:20:50 -0800711 // set the svg size to match that of the window, less the masthead
712 svg.attr(fs.windowSize(mast.mastHeight()));
Simon Hunt3a6eec02015-02-09 21:16:43 -0800713 dim = [svg.attr('width'), svg.attr('height')];
Simon Hunt426bd862015-01-14 16:48:41 -0800714
Thomas Vachuskac616e172018-04-17 16:57:12 -0700715 ps.addListener(applyPreferences);
716
Simon Hunt6cc53692015-01-07 11:33:45 -0800717 setUpKeys();
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700718 setUpToolbar();
Simon Hunt6cc53692015-01-07 11:33:45 -0800719 setUpDefs();
Simon Huntcacce342015-01-07 16:13:05 -0800720 setUpZoom();
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800721 setUpNoDevs();
Simon Hunt90053ed2016-04-06 12:49:02 -0700722 setUpMap().then(
Simon Hunt1894d792015-02-04 17:09:20 -0800723 function (proj) {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100724 var z = ps.getPrefs('topo_zoom', { tx: 0, ty: 0, sc: 1 });
Simon Huntbb5e0d82015-04-16 14:25:46 -0700725 zoomer.panZoom([z.tx, z.ty], z.sc);
726 $log.debug('** Zoom restored:', z);
727
Simon Hunt1894d792015-02-04 17:09:20 -0800728 projection = proj;
Simon Huntbb5e0d82015-04-16 14:25:46 -0700729 $log.debug('** We installed the projection:', proj);
Simon Huntf41f3092015-04-16 10:33:26 -0700730 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700731 toggleMap(prefsState.bg);
Simon Huntf41f3092015-04-16 10:33:26 -0700732 flash.enable(true);
Simon Hunta34fcb52016-02-25 16:27:32 -0800733 mapShader(true);
Simon Hunte1ce4292015-06-12 13:07:02 -0700734
Simon Hunt5989ddf2017-08-02 20:38:12 -0700735 // 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 Hunt3f89cb42017-08-10 13:32:00 -0700741 // insert localized text into already established
742 // DOM elements...
743 lionNoDevs();
744
Simon Hunte2d9dc72017-08-10 15:21:04 -0700745 // pass lion bundle function ref to other topo modules
746 tfs.setLionBundle(topoLion);
747 tis.setLionBundle(topoLion);
Simon Hunt1603c692017-08-10 19:53:35 -0700748 tms.setLionBundle(topoLion);
Simon Hunt879ce452017-08-10 23:32:00 -0700749 tps.setLionBundle(topoLion);
Simon Huntcaed0412017-08-12 13:49:17 -0700750 ttbs.setLionBundle(topoLion);
Simon Hunte2d9dc72017-08-10 15:21:04 -0700751
Simon Hunte1ce4292015-06-12 13:07:02 -0700752 // 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 Hunt1894d792015-02-04 17:09:20 -0800758 }
759 );
Simon Hunta4281242016-02-26 20:18:45 -0800760 tes.bindHandlers();
Simon Hunt90053ed2016-04-06 12:49:02 -0700761 setUpSprites();
Simon Huntfd1231a2015-01-26 22:14:51 -0800762
Simon Hunt1894d792015-02-04 17:09:20 -0800763 forceG = zoomLayer.append('g').attr('id', 'topo-force');
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800764 tfs.initForce(svg, forceG, uplink, dim);
Simon Hunta142dd22015-02-12 22:07:51 -0800765 tis.initInst({ showMastership: tfs.showMastership });
Simon Hunt237676b52015-03-10 19:04:26 -0700766 tps.initPanels();
Simon Hunt6cc53692015-01-07 11:33:45 -0800767
Simon Huntc7ae7952015-04-08 18:59:27 -0700768 restoreConfigFromPrefs();
Simon Huntfc5c5842017-02-01 23:32:18 -0800769
770 ttbs.selectOverlay(selOverlay || prefsState.ovid);
Simon Hunt36a58c62015-04-08 11:00:07 -0700771
Simon Hunt72e44bf2015-07-21 21:34:20 -0700772 $log.debug('registered overlays...', tov.list());
Simon Hunt6cc53692015-01-07 11:33:45 -0800773 $log.log('OvTopoCtrl has been created');
Simon Huntef31fb22014-12-19 13:16:44 -0800774 }]);
775}());