blob: 1348eec2be31872c592105cd1d60abb0a8438a55 [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],
107
108 U: [tfs.unpin, unpin],
109 R: [resetZoom, rzoom],
110 dot: [ttbs.toggleToolbar, togtb],
111 E: [equalizeMasters, eqmaster],
Simon Huntac4c6f72015-02-03 19:50:53 -0800112
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800113 "shift-openBracket": [tfs.toggleHostTextSize, quiet],
114 "shift-closeBracket": [tfs.toggleHostIconSize, quiet],
115
Steven Burrows1c2a9682017-07-14 16:52:46 +0100116 // -- instance color palette debug
Simon Hunta9761342016-06-10 18:02:53 -0700117 // 9: function () { sus.cat7().testCard(svg); },
118
Simon Hunt5b024d72016-01-29 11:02:43 -0800119 // topology overlay selections
120 F1: function () { ttbs.fnkey(0); },
121 F2: function () { ttbs.fnkey(1); },
122 F3: function () { ttbs.fnkey(2); },
123 F4: function () { ttbs.fnkey(3); },
124 F5: function () { ttbs.fnkey(4); },
125
Simon Hunt08f841d02015-02-10 14:39:20 -0800126 esc: handleEscape,
Simon Huntac4c6f72015-02-03 19:50:53 -0800127
Simon Hunt09060142015-03-18 20:23:32 -0700128 _keyListener: ttbs.keyListener,
129
Simon Hunt5724fb42015-02-05 16:59:40 -0800130 _helpFormat: [
Steven Burrows1c2a9682017-07-14 16:52:46 +0100131 ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B', 'G', 'S'],
Simon Hunt10618f62017-06-15 19:30:52 -0700132 ['X', 'Z', 'N', 'L', 'shift-L', 'U', 'R', '-', 'E', '-', 'dot'],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100133 [], // this column reserved for overlay actions
134 ],
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700135 };
136
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700137 if (fs.isO(overlayKeys)) {
138 mergeKeys(overlayKeys);
139 }
140
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700141 ks.keyBindings(actionMap);
Simon Huntac4c6f72015-02-03 19:50:53 -0800142
Simon Hunt639dc662015-02-18 14:19:20 -0800143 ks.gestureNotes([
Simon Hunt5989ddf2017-08-02 20:38:12 -0700144 [uiClick, uiClickTxt],
145 [uiShClick, uiShClickTxt],
146 [uiDrag, uiDragTxt],
147 [uiCmdScr, uiCmdScrTxt],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100148 [uiCmdDrag, uiCmdDragTxt],
Simon Hunt639dc662015-02-18 14:19:20 -0800149 ]);
Simon Hunt5724fb42015-02-05 16:59:40 -0800150 }
Simon Hunt6cc53692015-01-07 11:33:45 -0800151
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700152 // when a topology overlay is activated, we need to bind their keystrokes
153 // and include them in the quick-help panel
154 function mergeKeys(extra) {
155 var _hf = actionMap._helpFormat[2];
Simon Hunt71892222015-09-29 13:39:40 -0700156
157 ks.checkNotGlobal(extra);
158
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700159 extra._keyOrder.forEach(function (k) {
160 var d = extra[k],
161 cb = d && d.cb,
162 tt = d && d.tt;
163 // NOTE: ignore keys that are already defined
164 if (d && !actionMap[k]) {
165 actionMap[k] = [cb, tt];
166 _hf.push(k);
167 }
168 });
169 }
170
Simon Hunt08f841d02015-02-10 14:39:20 -0800171 // --- Keystroke functions -------------------------------------------
Simon Huntac4c6f72015-02-03 19:50:53 -0800172
Simon Hunt36a58c62015-04-08 11:00:07 -0700173 function toggleInstances(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700174 updatePrefsState('insts', tis.toggle(x));
Simon Huntac4c6f72015-02-03 19:50:53 -0800175 tfs.updateDeviceColors();
Simon Hunt6cc53692015-01-07 11:33:45 -0800176 }
Simon Huntac4c6f72015-02-03 19:50:53 -0800177
Simon Huntee7a3ce2015-04-09 13:28:37 -0700178 function toggleSummary(x) {
179 updatePrefsState('summary', tps.toggleSummary(x));
Simon Hunt18bf9822015-02-12 17:35:45 -0800180 }
181
Simon Hunt239e5882015-04-23 15:07:04 -0700182 function toggleUseDetailsFlag(x) {
183 updatePrefsState('detail', tps.toggleUseDetailsFlag(x));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700184 }
185
Simon Huntfcbde892015-04-16 12:05:28 -0700186 function toggleHosts(x) {
187 updatePrefsState('hosts', tfs.toggleHosts(x));
188 }
189
190 function toggleOffline(x) {
191 updatePrefsState('offdev', tfs.toggleOffline(x));
192 }
193
194 function togglePorts(x) {
195 updatePrefsState('porthl', tfs.togglePorts(x));
196 }
197
198 function _togSvgLayer(x, G, tag, what) {
199 var on = (x === 'keyev') ? !sus.visible(G) : !!x,
Simon Hunt3f89cb42017-08-10 13:32:00 -0700200 verb = on ? topoLion('show') : topoLion('hide');
Simon Huntfcbde892015-04-16 12:05:28 -0700201 sus.visible(G, on);
202 updatePrefsState(tag, on);
203 flash.flash(verb + ' ' + what);
204 }
205
206 function toggleMap(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700207 _togSvgLayer(x, mapG, 'bg', topoLion('fl_background_map'));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700208 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700209
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700210 function openMapSelection() {
211 tms.openMapSelection();
212 }
213
Simon Hunt2052e5d2015-04-13 17:40:44 -0700214 function toggleSprites(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700215 _togSvgLayer(x, spriteG, 'spr', topoLion('fl_sprite_layer'));
Simon Hunt2052e5d2015-04-13 17:40:44 -0700216 }
217
Simon Hunt08f841d02015-02-10 14:39:20 -0800218 function resetZoom() {
219 zoomer.reset();
Simon Hunt3f89cb42017-08-10 13:32:00 -0700220 flash.flash(topoLion('fl_pan_zoom_reset'));
Simon Hunt08f841d02015-02-10 14:39:20 -0800221 }
222
Simon Hunt0e48c292015-02-19 16:11:37 -0800223 function equalizeMasters() {
Simon Hunt237676b52015-03-10 19:04:26 -0700224 wss.sendEvent('equalizeMasters');
Simon Hunt3f89cb42017-08-10 13:32:00 -0700225 flash.flash(topoLion('fl_eq_masters'));
Simon Hunt0e48c292015-02-19 16:11:37 -0800226 }
227
Simon Hunt08f841d02015-02-10 14:39:20 -0800228 function handleEscape() {
Simon Hunta142dd22015-02-12 22:07:51 -0800229 if (tis.showMaster()) {
230 // if an instance is selected, cancel the affinity mapping
Steven Burrows1c2a9682017-07-14 16:52:46 +0100231 tis.cancelAffinity();
Simon Hunt08f841d02015-02-10 14:39:20 -0800232
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700233 } else if (tov.hooks.escape()) {
234 // else if the overlay consumed the ESC event...
235 // (work already done)
236
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700237 } else if (tss.deselectAll()) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800238 // else if we have node selections, deselect them all
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700239 // (work already done)
240
Prince Pereira46c82d42016-09-19 13:30:50 +0530241 } else if (tls.deselectAllLinks()) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700242 // else if we have a link selected, deselect it
243 // (work already done)
Simon Hunt08f841d02015-02-10 14:39:20 -0800244
Simon Hunta0eb0a82015-02-11 12:30:06 -0800245 } else if (tis.isVisible()) {
246 // else if the Instance Panel is visible, hide it
247 tis.hide();
248 tfs.updateDeviceColors();
Simon Hunt08f841d02015-02-10 14:39:20 -0800249
Simon Hunta0eb0a82015-02-11 12:30:06 -0800250 } else if (tps.summaryVisible()) {
251 // else if the Summary Panel is visible, hide it
Simon Hunt356da762016-05-27 11:54:02 -0700252 tps.hideSummary();
Simon Hunta0eb0a82015-02-11 12:30:06 -0800253 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800254 }
Simon Huntcacce342015-01-07 16:13:05 -0800255
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700256 // --- Toolbar Functions ---------------------------------------------
257
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700258 function notValid(what) {
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700259 $log.warn('topo.js getActionEntry(): Not a valid ' + what);
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700260 }
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700261
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700262 function getActionEntry(key) {
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700263 var entry;
264
265 if (!key) {
266 notValid('key');
267 return null;
268 }
269
270 entry = actionMap[key];
271
272 if (!entry) {
273 notValid('actionMap entry');
274 return null;
275 }
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700276 return fs.isA(entry) || [entry, ''];
277 }
278
279 function setUpToolbar() {
280 ttbs.init({
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700281 getActionEntry: getActionEntry,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100282 setUpKeys: setUpKeys,
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700283 });
284 ttbs.createToolbar();
285 }
286
Simon Huntcacce342015-01-07 16:13:05 -0800287 // --- Glyphs, Icons, and the like -----------------------------------
288
Simon Hunt6cc53692015-01-07 11:33:45 -0800289 function setUpDefs() {
Simon Huntcacce342015-01-07 16:13:05 -0800290 defs = svg.append('defs');
Simon Hunt6cc53692015-01-07 11:33:45 -0800291 gs.loadDefs(defs);
Simon Hunt0ee28682015-02-12 20:48:11 -0800292 sus.loadGlowDefs(defs);
Simon Hunt6cc53692015-01-07 11:33:45 -0800293 }
294
295
Simon Huntcacce342015-01-07 16:13:05 -0800296 // --- Pan and Zoom --------------------------------------------------
297
298 // zoom enabled predicate. ev is a D3 source event.
299 function zoomEnabled(ev) {
Simon Huntd552ee92015-04-02 17:06:35 -0700300 return fs.isMobile() || (ev.metaKey || ev.altKey);
Simon Huntcacce342015-01-07 16:13:05 -0800301 }
302
303 function zoomCallback() {
Simon Huntbb5e0d82015-04-16 14:25:46 -0700304 var sc = zoomer.scale(),
305 tr = zoomer.translate();
306
Steven Burrows1c2a9682017-07-14 16:52:46 +0100307 ps.setPrefs('topo_zoom', { tx: tr[0], ty: tr[1], sc: sc });
Simon Huntcacce342015-01-07 16:13:05 -0800308
Simon Hunt0541fb82015-01-14 18:59:57 -0800309 // keep the map lines constant width while zooming
Simon Hunt737c89f2015-01-28 12:23:19 -0800310 mapG.style('stroke-width', (2.0 / sc) + 'px');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700311
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800312 tfs.adjustNodeScale();
Simon Huntcacce342015-01-07 16:13:05 -0800313 }
314
315 function setUpZoom() {
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800316 zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer');
Simon Huntcacce342015-01-07 16:13:05 -0800317 zoomer = zs.createZoomer({
318 svg: svg,
319 zoomLayer: zoomLayer,
320 zoomEnabled: zoomEnabled,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100321 zoomCallback: zoomCallback,
Simon Huntcacce342015-01-07 16:13:05 -0800322 });
323 }
324
325
Simon Hunt0541fb82015-01-14 18:59:57 -0800326 // callback invoked when the SVG view has been resized..
Simon Hunt3a6eec02015-02-09 21:16:43 -0800327 function svgResized(s) {
328 tfs.newDim([s.width, s.height]);
Simon Hunt0541fb82015-01-14 18:59:57 -0800329 }
330
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800331 // --- Background Map ------------------------------------------------
332
Simon Hunte2d9dc72017-08-10 15:21:04 -0700333 function recenterLabel(g) {
334 var box = g.node().getBBox();
335
336 box.x -= box.width/2;
337 box.y -= box.height/2;
338 g.attr('transform', sus.translate(box.x, box.y));
Simon Hunte2d9dc72017-08-10 15:21:04 -0700339 }
340
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800341 function setUpNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700342 var g;
343
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800344 noDevsLayer = svg.append('g').attr({
345 id: 'topo-noDevsLayer',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100346 transform: sus.translate(500, 500),
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800347 });
348 // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html.
349 // We are translating this layer to have its origin at the center
350
351 g = noDevsLayer.append('g');
352 gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird');
Simon Huntcaed0412017-08-12 13:49:17 -0700353 g.append('text').text('').attr({ x: 120, y: 80 });
Simon Hunte2d9dc72017-08-10 15:21:04 -0700354 recenterLabel(g);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800355 showNoDevs(true);
356 }
357
Simon Hunt3f89cb42017-08-10 13:32:00 -0700358 function lionNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700359 var g = d3.select('#topo-noDevsLayer g');
360
361 g.select('text').text(topoLion('no_devices_are_connected'));
362 recenterLabel(g);
Simon Hunt3f89cb42017-08-10 13:32:00 -0700363 }
364
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800365 function showNoDevs(b) {
Simon Hunt18bf9822015-02-12 17:35:45 -0800366 sus.visible(noDevsLayer, b);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800367 }
368
Simon Hunt2362b072015-06-11 20:08:22 -0700369
370 var countryFilters = {
Simon Hunt2362b072015-06-11 20:08:22 -0700371 s_america: function (c) {
372 return c.properties.continent === 'South America';
373 },
374
Simon Huntac099e82015-12-03 09:17:47 -0800375 ns_america: function (c) {
376 return c.properties.custom === 'US-cont' ||
377 c.properties.subregion === 'Central America' ||
Simon Huntd4712622015-12-02 11:19:50 -0800378 c.properties.continent === 'South America';
379 },
380
Simon Hunt2362b072015-06-11 20:08:22 -0700381 japan: function (c) {
382 return c.properties.geounit === 'Japan';
383 },
384
385 europe: function (c) {
386 return c.properties.continent === 'Europe';
387 },
388
389 italy: function (c) {
390 return c.properties.geounit === 'Italy';
391 },
392
393 uk: function (c) {
394 // technically, Ireland is not part of the United Kingdom,
395 // but the map looks weird without it showing.
396 return c.properties.adm0_a3 === 'GBR' ||
397 c.properties.adm0_a3 === 'IRL';
Simon Hunt1178d5b2015-09-02 17:02:37 -0700398 },
399
400 s_korea: function (c) {
401 return c.properties.adm0_a3 === 'KOR';
402 },
403
404 australia: function (c) {
405 return c.properties.adm0_a3 === 'AUS';
Steven Burrows1c2a9682017-07-14 16:52:46 +0100406 },
Simon Hunt2362b072015-06-11 20:08:22 -0700407 };
408
Simon Hunta34fcb52016-02-25 16:27:32 -0800409 var tintOn = 0,
410 shadeFlip = 0,
411 shadePalette = {
412 light: {
413 sea: 'aliceblue',
414 land: 'white',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100415 outline: '#ddd',
Simon Hunta34fcb52016-02-25 16:27:32 -0800416 },
417 dark: {
418 sea: '#001830',
419 land: '#232331',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100420 outline: '#3a3a3a',
421 },
Simon Hunta34fcb52016-02-25 16:27:32 -0800422 };
423
424 function shading() {
425 return tintOn ? {
426 palette: shadePalette[th.theme()],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100427 flip: shadeFlip,
Simon Hunta34fcb52016-02-25 16:27:32 -0800428 } : '';
429 }
Simon Hunt2362b072015-06-11 20:08:22 -0700430
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700431 function setMap(map) {
432 ps.setPrefs('topo_mapid', map);
Simon Hunt90053ed2016-04-06 12:49:02 -0700433 setUpMap();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700434 opacifyMap(true);
435 }
436
437 function currentMap() {
438 return ps.getPrefs(
439 'topo_mapid',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100440 {
441 mapid: 'usa',
442 mapscale: 1,
443 mapfilepath: '*continental_us',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100444 tint: 'off',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100445 },
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700446 $loc.search()
447 );
448 }
449
Simon Hunt90053ed2016-04-06 12:49:02 -0700450 function setUpMap() {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700451 var prefs = currentMap(),
Simon Hunt8a119b02016-03-29 16:00:32 -0700452 mapId = prefs.mapid,
Steven Burrows3a9a6442016-05-05 15:31:16 +0100453 mapFilePath = prefs.mapfilepath,
Simon Hunt8a119b02016-03-29 16:00:32 -0700454 mapScale = prefs.mapscale,
455 tint = prefs.tint,
Simon Hunt2362b072015-06-11 20:08:22 -0700456 promise,
Simon Huntfacad992016-02-25 09:58:33 -0800457 cfilter;
Simon Hunt2362b072015-06-11 20:08:22 -0700458
Simon Hunta34fcb52016-02-25 16:27:32 -0800459 tintOn = tint === 'on' ? 1 : 0;
460
Simon Hunt18491362016-03-04 11:09:42 -0800461 $log.debug('setUpMap() mapId:', mapId, ', mapScale:', mapScale,
462 ', tint:', tint);
463
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700464 mapG = d3.select('#topo-map');
465 if (mapG.empty()) {
466 mapG = zoomLayer.append('g').attr('id', 'topo-map');
467 } else {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100468 mapG.each(function (d, i) {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700469 d3.selectAll(this.childNodes).remove();
470 });
471 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100472
473 if (mapFilePath === '*countries') {
474
Simon Hunt90053ed2016-04-06 12:49:02 -0700475 cfilter = countryFilters[mapId] || countryFilters.uk;
Steven Burrows3a9a6442016-05-05 15:31:16 +0100476
Simon Hunta34fcb52016-02-25 16:27:32 -0800477 promise = ms.loadMapRegionInto(mapG, {
478 countryFilter: cfilter,
479 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100480 shading: shading(),
Simon Hunta34fcb52016-02-25 16:27:32 -0800481 });
Steven Burrows3a9a6442016-05-05 15:31:16 +0100482 } else {
483
484 promise = ms.loadMapInto(mapG, mapFilePath, mapId, {
485 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100486 shading: shading(),
Steven Burrows3a9a6442016-05-05 15:31:16 +0100487 });
Simon Hunt2362b072015-06-11 20:08:22 -0700488 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100489
Simon Hunt8a119b02016-03-29 16:00:32 -0700490 ps.setPrefs('topo_mapid', prefs);
Simon Hunt2362b072015-06-11 20:08:22 -0700491 return promise;
Simon Hunt0541fb82015-01-14 18:59:57 -0800492 }
493
Simon Huntf51bf462016-06-29 16:22:57 -0700494 function mapReshader() {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100495 $log.debug('... Re-shading map ...');
Simon Huntf51bf462016-06-29 16:22:57 -0700496 ms.reshade(shading());
497 }
498
Simon Hunta34fcb52016-02-25 16:27:32 -0800499 // set up theme listener to re-shade the map when required.
500 function mapShader(on) {
501 if (on) {
Simon Huntf51bf462016-06-29 16:22:57 -0700502 th.addListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800503 } else {
Simon Huntf51bf462016-06-29 16:22:57 -0700504 th.removeListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800505 }
506 }
507
Simon Huntc3c5b672015-02-20 11:32:13 -0800508 function opacifyMap(b) {
509 mapG.transition()
510 .duration(1000)
511 .attr('opacity', b ? 1 : 0);
512 }
Simon Hunt737c89f2015-01-28 12:23:19 -0800513
Simon Hunt90053ed2016-04-06 12:49:02 -0700514 function setUpSprites() {
Simon Hunt8a119b02016-03-29 16:00:32 -0700515 var prefs = ps.getPrefs('topo_sprites', { sprites: '' }, $loc.search()),
516 sprId = prefs.sprites;
Simon Huntf9fc0e72015-04-16 15:10:57 -0700517
Steven Burrows1c2a9682017-07-14 16:52:46 +0100518 spriteG = zoomLayer.append('g').attr('id', 'topo-sprites');
Simon Huntf9fc0e72015-04-16 15:10:57 -0700519 if (sprId) {
Simon Hunt8a119b02016-03-29 16:00:32 -0700520 ps.setPrefs('topo_sprites', prefs);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700521 tspr.loadSprites(spriteG, defs, sprId);
522 }
523 }
Simon Hunt9c1c45e2015-04-10 13:38:27 -0700524
Simon Huntc7ae7952015-04-08 18:59:27 -0700525 // --- User Preferemces ----------------------------------------------
Simon Hunt36a58c62015-04-08 11:00:07 -0700526
Simon Huntc7ae7952015-04-08 18:59:27 -0700527 var prefsState = {};
Simon Hunt36a58c62015-04-08 11:00:07 -0700528
Simon Huntc7ae7952015-04-08 18:59:27 -0700529 function updatePrefsState(what, b) {
530 prefsState[what] = b ? 1 : 0;
531 ps.setPrefs('topo_prefs', prefsState);
Simon Hunt36a58c62015-04-08 11:00:07 -0700532 }
533
Thomas Vachuskac616e172018-04-17 16:57:12 -0700534 function applyPreferences(evt) {
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700535// var zoomPrefs = ps.getPrefs('topo_zoom', null);
Thomas Vachuskabf5d1fe2018-04-25 15:49:00 -0400536// if (ps.getPrefs('topo_prefs', null)) {
537// restoreConfigFromPrefs();
538// }
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700539// if (zoomPrefs) {
540// $log.debug('TOPO- Zoom State:', zoomPrefs);
541// zoomer.panZoom([zoomPrefs.tx, zoomPrefs.ty], zoomPrefs.sc, 100);
542// }
Thomas Vachuskac616e172018-04-17 16:57:12 -0700543 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700544
Simon Huntc7ae7952015-04-08 18:59:27 -0700545 function restoreConfigFromPrefs() {
546 // NOTE: toolbar will have set this for us..
Simon Huntfc5c5842017-02-01 23:32:18 -0800547 prefsState = ps.asNumbers(
548 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
549 );
Simon Hunt36a58c62015-04-08 11:00:07 -0700550
Simon Hunte1ce4292015-06-12 13:07:02 -0700551 $log.debug('TOPO- Prefs State:', prefsState);
Simon Huntc7ae7952015-04-08 18:59:27 -0700552
Simon Huntf41f3092015-04-16 10:33:26 -0700553 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700554 toggleInstances(prefsState.insts);
Simon Huntee7a3ce2015-04-09 13:28:37 -0700555 toggleSummary(prefsState.summary);
Simon Hunt239e5882015-04-23 15:07:04 -0700556 toggleUseDetailsFlag(prefsState.detail);
Bri Prebilic Cole9b80ca02015-08-03 11:26:54 -0700557 toggleHosts(prefsState.hosts);
558 toggleOffline(prefsState.offdev);
559 togglePorts(prefsState.porthl);
560 toggleMap(prefsState.bg);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700561 toggleSprites(prefsState.spr);
Thomas Vachuskac616e172018-04-17 16:57:12 -0700562 ttbs.setToolbar(prefsState.toolbar);
Thomas Vachuska0af26912016-03-21 21:37:30 -0700563 t3s.setDevLabIndex(prefsState.dlbls);
Simon Hunt10618f62017-06-15 19:30:52 -0700564 t3s.setHostLabIndex(prefsState.hlbls);
Simon Huntf41f3092015-04-16 10:33:26 -0700565 flash.enable(true);
Simon Hunt36a58c62015-04-08 11:00:07 -0700566 }
567
568
Simon Hunte1ce4292015-06-12 13:07:02 -0700569 // somewhat hackish, because summary update cannot happen until we
570 // have opened the websocket to the server; hence this extra function
571 // invoked after tes.start()
572 function restoreSummaryFromPrefs() {
Simon Huntfc5c5842017-02-01 23:32:18 -0800573 prefsState = ps.asNumbers(
574 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
575 );
Simon Hunte1ce4292015-06-12 13:07:02 -0700576 $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary);
577
578 flash.enable(false);
579 toggleSummary(prefsState.summary);
580 flash.enable(true);
581 }
582
Simon Hunt8419efd2017-01-12 12:36:28 -0800583 // initial set of topo events received, now do post-processing
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700584 function topoStartDone() {
Simon Hunt8419efd2017-01-12 12:36:28 -0800585 // give a small delay before attempting to reselect node(s) and
586 // highlight elements, since they have to be re-added to the DOM first...
Simon Hunt7faabd52016-08-18 16:16:19 -0700587 $timeout(function () {
Simon Hunt8419efd2017-01-12 12:36:28 -0800588 $log.debug('^^ topo.topoStartDone() ^^');
589
590 // reselect the previous selection...
Simon Hunt7faabd52016-08-18 16:16:19 -0700591 tss.reselect();
Simon Hunt8419efd2017-01-12 12:36:28 -0800592
593 // if an intent should be shown, invoke the appropriate callback
594 if ($scope.intentData) {
Simon Hunt8419efd2017-01-12 12:36:28 -0800595 tov.hooks.showIntent($scope.intentData);
Simon Hunt7faabd52016-08-18 16:16:19 -0700596 }
Simon Hunt8419efd2017-01-12 12:36:28 -0800597
Simon Hunt7faabd52016-08-18 16:16:19 -0700598 }, 200);
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700599 }
Simon Hunte1ce4292015-06-12 13:07:02 -0700600
Simon Huntcacce342015-01-07 16:13:05 -0800601 // --- Controller Definition -----------------------------------------
602
Simon Hunt6cc53692015-01-07 11:33:45 -0800603 angular.module('ovTopo', moduleDependencies)
Simon Hunt5989ddf2017-08-02 20:38:12 -0700604 .controller('OvTopoCtrl',
605 ['$scope', '$log', '$location', '$timeout', '$cookies',
606 'FnService', 'MastService', 'KeyService', 'ZoomService',
Simon Hunt0e48c292015-02-19 16:11:37 -0800607 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService',
Simon Hunta34fcb52016-02-25 16:27:32 -0800608 'WebSocketService', 'PrefsService', 'ThemeService',
Simon Hunt5989ddf2017-08-02 20:38:12 -0700609 'TopoDialogService', 'TopoD3Service', 'TopoEventService',
610 'TopoForceService', 'TopoPanelService', 'TopoInstService',
611 'TopoSelectService', 'TopoLinkService', 'TopoTrafficService',
612 'TopoObliqueService', 'TopoFilterService', 'TopoToolbarService',
613 'TopoMapService', 'TopoSpriteService', 'TooltipService',
614 'TopoOverlayService', 'LionService',
Simon Hunt6cc53692015-01-07 11:33:45 -0800615
Simon Hunt5989ddf2017-08-02 20:38:12 -0700616 function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_,
617 _fs_, mast, _ks_, _zs_,
618 _gs_, _ms_, _sus_, _flash_,
619 _wss_, _ps_, _th_,
Thomas Vachuska0af26912016-03-21 21:37:30 -0700620 _tds_, _t3s_, _tes_,
Simon Hunt5989ddf2017-08-02 20:38:12 -0700621 _tfs_, _tps_, _tis_,
622 _tss_, _tls_, _tts_,
623 _tos_, _fltr_, _ttbs_,
624 _tms_, _tspr_, _ttip_,
625 _tov_, lion) {
Simon Huntfc5c5842017-02-01 23:32:18 -0800626
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700627 var params = _$loc_.search(),
Simon Huntfc5c5842017-02-01 23:32:18 -0800628 selOverlay = params.overlayId,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700629 projection,
Simon Hunt3a6eec02015-02-09 21:16:43 -0800630 dim,
Simon Hunt1894d792015-02-04 17:09:20 -0800631 uplink = {
632 // provides function calls back into this space
633 showNoDevs: showNoDevs,
634 projection: function () { return projection; },
Simon Huntc3c5b672015-02-20 11:32:13 -0800635 zoomLayer: function () { return zoomLayer; },
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800636 zoomer: function () { return zoomer; },
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700637 opacifyMap: opacifyMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100638 topoStartDone: topoStartDone,
Simon Huntac4c6f72015-02-03 19:50:53 -0800639 };
640
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700641 $scope = _$scope_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800642 $log = _$log_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700643 $loc = _$loc_;
Simon Hunt7faabd52016-08-18 16:16:19 -0700644 $timeout = _$timeout_;
Simon Hunta11b4eb2015-01-28 16:20:50 -0800645 fs = _fs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800646 ks = _ks_;
Simon Huntcacce342015-01-07 16:13:05 -0800647 zs = _zs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800648 gs = _gs_;
Simon Hunt1e8eff42015-01-08 17:19:02 -0800649 ms = _ms_;
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800650 sus = _sus_;
Simon Hunt0e48c292015-02-19 16:11:37 -0800651 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700652 wss = _wss_;
Simon Huntc7ae7952015-04-08 18:59:27 -0700653 ps = _ps_;
Simon Hunta34fcb52016-02-25 16:27:32 -0800654 th = _th_;
Simon Hunta211f7f2015-11-09 12:48:23 -0800655 tds = _tds_;
Thomas Vachuska0af26912016-03-21 21:37:30 -0700656 t3s = _t3s_;
Simon Huntc252aa62015-02-10 16:45:39 -0800657 tes = _tes_;
Simon Hunt737c89f2015-01-28 12:23:19 -0800658 tfs = _tfs_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800659 // TODO: consider funnelling actions through TopoForceService...
660 // rather than injecting references to these 'sub-modules',
661 // just so we can invoke functions on them.
Simon Huntc252aa62015-02-10 16:45:39 -0800662 tps = _tps_;
Simon Huntac4c6f72015-02-03 19:50:53 -0800663 tis = _tis_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700664 tms = _tms_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700665 tls = _tls_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800666 tos = _tos_;
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -0700667 fltr = _fltr_;
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700668 ttbs = _ttbs_;
Simon Hunta4281242016-02-26 20:18:45 -0800669 tspr = _tspr_;
Simon Hunt72e44bf2015-07-21 21:34:20 -0700670 tov = _tov_;
Steven Burrows1c2a9682017-07-14 16:52:46 +0100671 tss = _tss_;
Simon Huntef31fb22014-12-19 13:16:44 -0800672
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700673 tms.start({
674 toggleMap: toggleMap,
675 currentMap: currentMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100676 setMap: setMap,
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700677 });
678
Simon Hunt441c9ae2017-02-03 18:22:31 -0800679 // pull intent data from the query string...
Viswanath KSP0f297702016-08-13 18:02:43 +0530680 if (params.key && params.appId && params.appName) {
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700681 $scope.intentData = {
Viswanath KSP0f297702016-08-13 18:02:43 +0530682 key: params.key,
683 appId: params.appId,
Simon Hunt441c9ae2017-02-03 18:22:31 -0800684 appName: params.appName,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100685 intentType: params.intentType,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700686 };
687 }
688
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700689 $scope.notifyResize = function () {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800690 svgResized(fs.windowSize(mast.mastHeight()));
Simon Hunt426bd862015-01-14 16:48:41 -0800691 };
Simon Huntef31fb22014-12-19 13:16:44 -0800692
Simon Hunt54442fa2015-01-26 14:17:38 -0800693 // Cleanup on destroyed scope..
Simon Hunt584122a2015-01-21 15:32:40 -0800694 $scope.$on('$destroy', function () {
695 $log.log('OvTopoCtrl is saying Buh-Bye!');
Thomas Vachuska329af532015-03-10 02:08:33 -0700696 tes.stop();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700697 tms.stop();
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700698 ks.unbindKeys();
Simon Hunt626d2102015-01-29 11:54:50 -0800699 tps.destroyPanels();
Simon Hunta211f7f2015-11-09 12:48:23 -0800700 tds.closeDialog();
Simon Hunt4b668592015-01-29 17:33:53 -0800701 tis.destroyInst();
Simon Hunt3a6eec02015-02-09 21:16:43 -0800702 tfs.destroyForce();
Bri Prebilic Coled6219052015-03-19 14:34:02 -0700703 ttbs.destroyToolbar();
Simon Hunta34fcb52016-02-25 16:27:32 -0800704 mapShader(false);
Simon Hunt584122a2015-01-21 15:32:40 -0800705 });
706
Simon Huntcacce342015-01-07 16:13:05 -0800707 // svg layer and initialization of components
Simon Hunt426bd862015-01-14 16:48:41 -0800708 ovtopo = d3.select('#ov-topo');
709 svg = ovtopo.select('svg');
Simon Hunta11b4eb2015-01-28 16:20:50 -0800710 // set the svg size to match that of the window, less the masthead
711 svg.attr(fs.windowSize(mast.mastHeight()));
Simon Hunt3a6eec02015-02-09 21:16:43 -0800712 dim = [svg.attr('width'), svg.attr('height')];
Simon Hunt426bd862015-01-14 16:48:41 -0800713
Thomas Vachuskac616e172018-04-17 16:57:12 -0700714 ps.addListener(applyPreferences);
715
Simon Hunt6cc53692015-01-07 11:33:45 -0800716 setUpKeys();
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700717 setUpToolbar();
Simon Hunt6cc53692015-01-07 11:33:45 -0800718 setUpDefs();
Simon Huntcacce342015-01-07 16:13:05 -0800719 setUpZoom();
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800720 setUpNoDevs();
Simon Hunt90053ed2016-04-06 12:49:02 -0700721 setUpMap().then(
Simon Hunt1894d792015-02-04 17:09:20 -0800722 function (proj) {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100723 var z = ps.getPrefs('topo_zoom', { tx: 0, ty: 0, sc: 1 });
Simon Huntbb5e0d82015-04-16 14:25:46 -0700724 zoomer.panZoom([z.tx, z.ty], z.sc);
725 $log.debug('** Zoom restored:', z);
726
Simon Hunt1894d792015-02-04 17:09:20 -0800727 projection = proj;
Simon Huntbb5e0d82015-04-16 14:25:46 -0700728 $log.debug('** We installed the projection:', proj);
Simon Huntf41f3092015-04-16 10:33:26 -0700729 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700730 toggleMap(prefsState.bg);
Simon Huntf41f3092015-04-16 10:33:26 -0700731 flash.enable(true);
Simon Hunta34fcb52016-02-25 16:27:32 -0800732 mapShader(true);
Simon Hunte1ce4292015-06-12 13:07:02 -0700733
Simon Hunt5989ddf2017-08-02 20:38:12 -0700734 // piggyback off the deferred map loading to load the
735 // localization bundle after the uber bundle has arrived...
736 $scope.lion = lion.bundle('core.view.Topo');
737 topoLion = $scope.lion;
738 $log.debug('Loaded Topo LION Bundle:', topoLion);
739
Simon Hunt3f89cb42017-08-10 13:32:00 -0700740 // insert localized text into already established
741 // DOM elements...
742 lionNoDevs();
743
Simon Hunte2d9dc72017-08-10 15:21:04 -0700744 // pass lion bundle function ref to other topo modules
745 tfs.setLionBundle(topoLion);
746 tis.setLionBundle(topoLion);
Simon Hunt1603c692017-08-10 19:53:35 -0700747 tms.setLionBundle(topoLion);
Simon Hunt879ce452017-08-10 23:32:00 -0700748 tps.setLionBundle(topoLion);
Simon Huntcaed0412017-08-12 13:49:17 -0700749 ttbs.setLionBundle(topoLion);
Simon Hunte2d9dc72017-08-10 15:21:04 -0700750
Simon Hunte1ce4292015-06-12 13:07:02 -0700751 // now we have the map projection, we are ready for
752 // the server to send us device/host data...
753 tes.start();
754 // need to do the following so we immediately get
755 // the summary panel data back from the server
756 restoreSummaryFromPrefs();
Simon Hunt1894d792015-02-04 17:09:20 -0800757 }
758 );
Simon Hunta4281242016-02-26 20:18:45 -0800759 tes.bindHandlers();
Simon Hunt90053ed2016-04-06 12:49:02 -0700760 setUpSprites();
Simon Huntfd1231a2015-01-26 22:14:51 -0800761
Simon Hunt1894d792015-02-04 17:09:20 -0800762 forceG = zoomLayer.append('g').attr('id', 'topo-force');
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800763 tfs.initForce(svg, forceG, uplink, dim);
Simon Hunta142dd22015-02-12 22:07:51 -0800764 tis.initInst({ showMastership: tfs.showMastership });
Simon Hunt237676b52015-03-10 19:04:26 -0700765 tps.initPanels();
Simon Hunt6cc53692015-01-07 11:33:45 -0800766
Simon Huntc7ae7952015-04-08 18:59:27 -0700767 restoreConfigFromPrefs();
Simon Huntfc5c5842017-02-01 23:32:18 -0800768
769 ttbs.selectOverlay(selOverlay || prefsState.ovid);
Simon Hunt36a58c62015-04-08 11:00:07 -0700770
Simon Hunt72e44bf2015-07-21 21:34:20 -0700771 $log.debug('registered overlays...', tov.list());
Simon Hunt6cc53692015-01-07 11:33:45 -0800772 $log.log('OvTopoCtrl has been created');
Simon Huntef31fb22014-12-19 13:16:44 -0800773 }]);
774}());