blob: ab803f6ff5840d90df26c0c3b64d4ebbd6ba0fd5 [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'); }
Simon Hunt5989ddf2017-08-02 20:38:12 -070086
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -070087 actionMap = {
Simon Hunt5989ddf2017-08-02 20:38:12 -070088 I: [toggleInstances, togInst],
89 O: [toggleSummary, togSumm],
90 D: [toggleUseDetailsFlag, togUseDet],
Simon Huntac4c6f72015-02-03 19:50:53 -080091
Simon Hunt5989ddf2017-08-02 20:38:12 -070092 H: [toggleHosts, togHost],
93 M: [toggleOffline, togOff],
94 P: [togglePorts, togPortHi],
Simon Huntac4c6f72015-02-03 19:50:53 -080095
Simon Hunt5989ddf2017-08-02 20:38:12 -070096 dash: [tfs.showBadLinks, showBad],
97 B: [toggleMap, togMap],
98 G: [openMapSelection, selMap],
99 S: [toggleSprites, togSpr],
Simon Huntac4c6f72015-02-03 19:50:53 -0800100
Simon Hunt5989ddf2017-08-02 20:38:12 -0700101 X: [tfs.resetAllLocations, rstLoc],
102 Z: [tos.toggleOblique, togOb],
103 N: [fltr.clickAction, cycLayer],
104 L: [tfs.cycleDeviceLabels, cycDev],
105 'shift-L': [tfs.cycleHostLabels, cycHost],
106
107 U: [tfs.unpin, unpin],
108 R: [resetZoom, rzoom],
109 dot: [ttbs.toggleToolbar, togtb],
110 E: [equalizeMasters, eqmaster],
Simon Huntac4c6f72015-02-03 19:50:53 -0800111
Steven Burrows1c2a9682017-07-14 16:52:46 +0100112 // -- instance color palette debug
Simon Hunta9761342016-06-10 18:02:53 -0700113 // 9: function () { sus.cat7().testCard(svg); },
114
Simon Hunt5b024d72016-01-29 11:02:43 -0800115 // topology overlay selections
116 F1: function () { ttbs.fnkey(0); },
117 F2: function () { ttbs.fnkey(1); },
118 F3: function () { ttbs.fnkey(2); },
119 F4: function () { ttbs.fnkey(3); },
120 F5: function () { ttbs.fnkey(4); },
121
Simon Hunt08f841d02015-02-10 14:39:20 -0800122 esc: handleEscape,
Simon Huntac4c6f72015-02-03 19:50:53 -0800123
Simon Hunt09060142015-03-18 20:23:32 -0700124 _keyListener: ttbs.keyListener,
125
Simon Hunt5724fb42015-02-05 16:59:40 -0800126 _helpFormat: [
Steven Burrows1c2a9682017-07-14 16:52:46 +0100127 ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B', 'G', 'S'],
Simon Hunt10618f62017-06-15 19:30:52 -0700128 ['X', 'Z', 'N', 'L', 'shift-L', 'U', 'R', '-', 'E', '-', 'dot'],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100129 [], // this column reserved for overlay actions
130 ],
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700131 };
132
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700133 if (fs.isO(overlayKeys)) {
134 mergeKeys(overlayKeys);
135 }
136
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700137 ks.keyBindings(actionMap);
Simon Huntac4c6f72015-02-03 19:50:53 -0800138
Simon Hunt639dc662015-02-18 14:19:20 -0800139 ks.gestureNotes([
Simon Hunt5989ddf2017-08-02 20:38:12 -0700140 [uiClick, uiClickTxt],
141 [uiShClick, uiShClickTxt],
142 [uiDrag, uiDragTxt],
143 [uiCmdScr, uiCmdScrTxt],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100144 [uiCmdDrag, uiCmdDragTxt],
Simon Hunt639dc662015-02-18 14:19:20 -0800145 ]);
Simon Hunt5724fb42015-02-05 16:59:40 -0800146 }
Simon Hunt6cc53692015-01-07 11:33:45 -0800147
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700148 // when a topology overlay is activated, we need to bind their keystrokes
149 // and include them in the quick-help panel
150 function mergeKeys(extra) {
151 var _hf = actionMap._helpFormat[2];
Simon Hunt71892222015-09-29 13:39:40 -0700152
153 ks.checkNotGlobal(extra);
154
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700155 extra._keyOrder.forEach(function (k) {
156 var d = extra[k],
157 cb = d && d.cb,
158 tt = d && d.tt;
159 // NOTE: ignore keys that are already defined
160 if (d && !actionMap[k]) {
161 actionMap[k] = [cb, tt];
162 _hf.push(k);
163 }
164 });
165 }
166
Simon Hunt08f841d02015-02-10 14:39:20 -0800167 // --- Keystroke functions -------------------------------------------
Simon Huntac4c6f72015-02-03 19:50:53 -0800168
Simon Hunt36a58c62015-04-08 11:00:07 -0700169 function toggleInstances(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700170 updatePrefsState('insts', tis.toggle(x));
Simon Huntac4c6f72015-02-03 19:50:53 -0800171 tfs.updateDeviceColors();
Simon Hunt6cc53692015-01-07 11:33:45 -0800172 }
Simon Huntac4c6f72015-02-03 19:50:53 -0800173
Simon Huntee7a3ce2015-04-09 13:28:37 -0700174 function toggleSummary(x) {
175 updatePrefsState('summary', tps.toggleSummary(x));
Simon Hunt18bf9822015-02-12 17:35:45 -0800176 }
177
Simon Hunt239e5882015-04-23 15:07:04 -0700178 function toggleUseDetailsFlag(x) {
179 updatePrefsState('detail', tps.toggleUseDetailsFlag(x));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700180 }
181
Simon Huntfcbde892015-04-16 12:05:28 -0700182 function toggleHosts(x) {
183 updatePrefsState('hosts', tfs.toggleHosts(x));
184 }
185
186 function toggleOffline(x) {
187 updatePrefsState('offdev', tfs.toggleOffline(x));
188 }
189
190 function togglePorts(x) {
191 updatePrefsState('porthl', tfs.togglePorts(x));
192 }
193
194 function _togSvgLayer(x, G, tag, what) {
195 var on = (x === 'keyev') ? !sus.visible(G) : !!x,
Simon Hunt3f89cb42017-08-10 13:32:00 -0700196 verb = on ? topoLion('show') : topoLion('hide');
Simon Huntfcbde892015-04-16 12:05:28 -0700197 sus.visible(G, on);
198 updatePrefsState(tag, on);
199 flash.flash(verb + ' ' + what);
200 }
201
202 function toggleMap(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700203 _togSvgLayer(x, mapG, 'bg', topoLion('fl_background_map'));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700204 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700205
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700206 function openMapSelection() {
207 tms.openMapSelection();
208 }
209
Simon Hunt2052e5d2015-04-13 17:40:44 -0700210 function toggleSprites(x) {
Simon Hunt3f89cb42017-08-10 13:32:00 -0700211 _togSvgLayer(x, spriteG, 'spr', topoLion('fl_sprite_layer'));
Simon Hunt2052e5d2015-04-13 17:40:44 -0700212 }
213
Simon Hunt08f841d02015-02-10 14:39:20 -0800214 function resetZoom() {
215 zoomer.reset();
Simon Hunt3f89cb42017-08-10 13:32:00 -0700216 flash.flash(topoLion('fl_pan_zoom_reset'));
Simon Hunt08f841d02015-02-10 14:39:20 -0800217 }
218
Simon Hunt0e48c292015-02-19 16:11:37 -0800219 function equalizeMasters() {
Simon Hunt237676b52015-03-10 19:04:26 -0700220 wss.sendEvent('equalizeMasters');
Simon Hunt3f89cb42017-08-10 13:32:00 -0700221 flash.flash(topoLion('fl_eq_masters'));
Simon Hunt0e48c292015-02-19 16:11:37 -0800222 }
223
Simon Hunt08f841d02015-02-10 14:39:20 -0800224 function handleEscape() {
Simon Hunta142dd22015-02-12 22:07:51 -0800225 if (tis.showMaster()) {
226 // if an instance is selected, cancel the affinity mapping
Steven Burrows1c2a9682017-07-14 16:52:46 +0100227 tis.cancelAffinity();
Simon Hunt08f841d02015-02-10 14:39:20 -0800228
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700229 } else if (tov.hooks.escape()) {
230 // else if the overlay consumed the ESC event...
231 // (work already done)
232
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700233 } else if (tss.deselectAll()) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800234 // else if we have node selections, deselect them all
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700235 // (work already done)
236
Prince Pereira46c82d42016-09-19 13:30:50 +0530237 } else if (tls.deselectAllLinks()) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700238 // else if we have a link selected, deselect it
239 // (work already done)
Simon Hunt08f841d02015-02-10 14:39:20 -0800240
Simon Hunta0eb0a82015-02-11 12:30:06 -0800241 } else if (tis.isVisible()) {
242 // else if the Instance Panel is visible, hide it
243 tis.hide();
244 tfs.updateDeviceColors();
Simon Hunt08f841d02015-02-10 14:39:20 -0800245
Simon Hunta0eb0a82015-02-11 12:30:06 -0800246 } else if (tps.summaryVisible()) {
247 // else if the Summary Panel is visible, hide it
Simon Hunt356da762016-05-27 11:54:02 -0700248 tps.hideSummary();
Simon Hunta0eb0a82015-02-11 12:30:06 -0800249 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800250 }
Simon Huntcacce342015-01-07 16:13:05 -0800251
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700252 // --- Toolbar Functions ---------------------------------------------
253
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700254 function notValid(what) {
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700255 $log.warn('topo.js getActionEntry(): Not a valid ' + what);
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700256 }
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700257
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700258 function getActionEntry(key) {
Bri Prebilic Cole2efc7152015-04-29 15:47:06 -0700259 var entry;
260
261 if (!key) {
262 notValid('key');
263 return null;
264 }
265
266 entry = actionMap[key];
267
268 if (!entry) {
269 notValid('actionMap entry');
270 return null;
271 }
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700272 return fs.isA(entry) || [entry, ''];
273 }
274
275 function setUpToolbar() {
276 ttbs.init({
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700277 getActionEntry: getActionEntry,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100278 setUpKeys: setUpKeys,
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700279 });
280 ttbs.createToolbar();
281 }
282
Simon Huntcacce342015-01-07 16:13:05 -0800283 // --- Glyphs, Icons, and the like -----------------------------------
284
Simon Hunt6cc53692015-01-07 11:33:45 -0800285 function setUpDefs() {
Simon Huntcacce342015-01-07 16:13:05 -0800286 defs = svg.append('defs');
Simon Hunt6cc53692015-01-07 11:33:45 -0800287 gs.loadDefs(defs);
Simon Hunt0ee28682015-02-12 20:48:11 -0800288 sus.loadGlowDefs(defs);
Simon Hunt6cc53692015-01-07 11:33:45 -0800289 }
290
291
Simon Huntcacce342015-01-07 16:13:05 -0800292 // --- Pan and Zoom --------------------------------------------------
293
294 // zoom enabled predicate. ev is a D3 source event.
295 function zoomEnabled(ev) {
Simon Huntd552ee92015-04-02 17:06:35 -0700296 return fs.isMobile() || (ev.metaKey || ev.altKey);
Simon Huntcacce342015-01-07 16:13:05 -0800297 }
298
299 function zoomCallback() {
Simon Huntbb5e0d82015-04-16 14:25:46 -0700300 var sc = zoomer.scale(),
301 tr = zoomer.translate();
302
Steven Burrows1c2a9682017-07-14 16:52:46 +0100303 ps.setPrefs('topo_zoom', { tx: tr[0], ty: tr[1], sc: sc });
Simon Huntcacce342015-01-07 16:13:05 -0800304
Simon Hunt0541fb82015-01-14 18:59:57 -0800305 // keep the map lines constant width while zooming
Simon Hunt737c89f2015-01-28 12:23:19 -0800306 mapG.style('stroke-width', (2.0 / sc) + 'px');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700307
308 tfs.setNodeScale(sc);
Simon Huntcacce342015-01-07 16:13:05 -0800309 }
310
311 function setUpZoom() {
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800312 zoomLayer = svg.append('g').attr('id', 'topo-zoomlayer');
Simon Huntcacce342015-01-07 16:13:05 -0800313 zoomer = zs.createZoomer({
314 svg: svg,
315 zoomLayer: zoomLayer,
316 zoomEnabled: zoomEnabled,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100317 zoomCallback: zoomCallback,
Simon Huntcacce342015-01-07 16:13:05 -0800318 });
319 }
320
321
Simon Hunt0541fb82015-01-14 18:59:57 -0800322 // callback invoked when the SVG view has been resized..
Simon Hunt3a6eec02015-02-09 21:16:43 -0800323 function svgResized(s) {
324 tfs.newDim([s.width, s.height]);
Simon Hunt0541fb82015-01-14 18:59:57 -0800325 }
326
Simon Hunta7b6a6b2015-01-13 19:53:09 -0800327 // --- Background Map ------------------------------------------------
328
Simon Hunte2d9dc72017-08-10 15:21:04 -0700329 function recenterLabel(g) {
330 var box = g.node().getBBox();
331
332 box.x -= box.width/2;
333 box.y -= box.height/2;
334 g.attr('transform', sus.translate(box.x, box.y));
Simon Hunte2d9dc72017-08-10 15:21:04 -0700335 }
336
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800337 function setUpNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700338 var g;
339
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800340 noDevsLayer = svg.append('g').attr({
341 id: 'topo-noDevsLayer',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100342 transform: sus.translate(500, 500),
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800343 });
344 // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html.
345 // We are translating this layer to have its origin at the center
346
347 g = noDevsLayer.append('g');
348 gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird');
Simon Huntcaed0412017-08-12 13:49:17 -0700349 g.append('text').text('').attr({ x: 120, y: 80 });
Simon Hunte2d9dc72017-08-10 15:21:04 -0700350 recenterLabel(g);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800351 showNoDevs(true);
352 }
353
Simon Hunt3f89cb42017-08-10 13:32:00 -0700354 function lionNoDevs() {
Simon Hunte2d9dc72017-08-10 15:21:04 -0700355 var g = d3.select('#topo-noDevsLayer g');
356
357 g.select('text').text(topoLion('no_devices_are_connected'));
358 recenterLabel(g);
Simon Hunt3f89cb42017-08-10 13:32:00 -0700359 }
360
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800361 function showNoDevs(b) {
Simon Hunt18bf9822015-02-12 17:35:45 -0800362 sus.visible(noDevsLayer, b);
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800363 }
364
Simon Hunt2362b072015-06-11 20:08:22 -0700365
366 var countryFilters = {
Simon Hunt2362b072015-06-11 20:08:22 -0700367 s_america: function (c) {
368 return c.properties.continent === 'South America';
369 },
370
Simon Huntac099e82015-12-03 09:17:47 -0800371 ns_america: function (c) {
372 return c.properties.custom === 'US-cont' ||
373 c.properties.subregion === 'Central America' ||
Simon Huntd4712622015-12-02 11:19:50 -0800374 c.properties.continent === 'South America';
375 },
376
Simon Hunt2362b072015-06-11 20:08:22 -0700377 japan: function (c) {
378 return c.properties.geounit === 'Japan';
379 },
380
381 europe: function (c) {
382 return c.properties.continent === 'Europe';
383 },
384
385 italy: function (c) {
386 return c.properties.geounit === 'Italy';
387 },
388
389 uk: function (c) {
390 // technically, Ireland is not part of the United Kingdom,
391 // but the map looks weird without it showing.
392 return c.properties.adm0_a3 === 'GBR' ||
393 c.properties.adm0_a3 === 'IRL';
Simon Hunt1178d5b2015-09-02 17:02:37 -0700394 },
395
396 s_korea: function (c) {
397 return c.properties.adm0_a3 === 'KOR';
398 },
399
400 australia: function (c) {
401 return c.properties.adm0_a3 === 'AUS';
Steven Burrows1c2a9682017-07-14 16:52:46 +0100402 },
Simon Hunt2362b072015-06-11 20:08:22 -0700403 };
404
Simon Hunta34fcb52016-02-25 16:27:32 -0800405 var tintOn = 0,
406 shadeFlip = 0,
407 shadePalette = {
408 light: {
409 sea: 'aliceblue',
410 land: 'white',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100411 outline: '#ddd',
Simon Hunta34fcb52016-02-25 16:27:32 -0800412 },
413 dark: {
414 sea: '#001830',
415 land: '#232331',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100416 outline: '#3a3a3a',
417 },
Simon Hunta34fcb52016-02-25 16:27:32 -0800418 };
419
420 function shading() {
421 return tintOn ? {
422 palette: shadePalette[th.theme()],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100423 flip: shadeFlip,
Simon Hunta34fcb52016-02-25 16:27:32 -0800424 } : '';
425 }
Simon Hunt2362b072015-06-11 20:08:22 -0700426
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700427 function setMap(map) {
428 ps.setPrefs('topo_mapid', map);
Simon Hunt90053ed2016-04-06 12:49:02 -0700429 setUpMap();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700430 opacifyMap(true);
431 }
432
433 function currentMap() {
434 return ps.getPrefs(
435 'topo_mapid',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100436 {
437 mapid: 'usa',
438 mapscale: 1,
439 mapfilepath: '*continental_us',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100440 tint: 'off',
Steven Burrows3a9a6442016-05-05 15:31:16 +0100441 },
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700442 $loc.search()
443 );
444 }
445
Simon Hunt90053ed2016-04-06 12:49:02 -0700446 function setUpMap() {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700447 var prefs = currentMap(),
Simon Hunt8a119b02016-03-29 16:00:32 -0700448 mapId = prefs.mapid,
Steven Burrows3a9a6442016-05-05 15:31:16 +0100449 mapFilePath = prefs.mapfilepath,
Simon Hunt8a119b02016-03-29 16:00:32 -0700450 mapScale = prefs.mapscale,
451 tint = prefs.tint,
Simon Hunt2362b072015-06-11 20:08:22 -0700452 promise,
Simon Huntfacad992016-02-25 09:58:33 -0800453 cfilter;
Simon Hunt2362b072015-06-11 20:08:22 -0700454
Simon Hunta34fcb52016-02-25 16:27:32 -0800455 tintOn = tint === 'on' ? 1 : 0;
456
Simon Hunt18491362016-03-04 11:09:42 -0800457 $log.debug('setUpMap() mapId:', mapId, ', mapScale:', mapScale,
458 ', tint:', tint);
459
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700460 mapG = d3.select('#topo-map');
461 if (mapG.empty()) {
462 mapG = zoomLayer.append('g').attr('id', 'topo-map');
463 } else {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100464 mapG.each(function (d, i) {
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700465 d3.selectAll(this.childNodes).remove();
466 });
467 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100468
469 if (mapFilePath === '*countries') {
470
Simon Hunt90053ed2016-04-06 12:49:02 -0700471 cfilter = countryFilters[mapId] || countryFilters.uk;
Steven Burrows3a9a6442016-05-05 15:31:16 +0100472
Simon Hunta34fcb52016-02-25 16:27:32 -0800473 promise = ms.loadMapRegionInto(mapG, {
474 countryFilter: cfilter,
475 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100476 shading: shading(),
Simon Hunta34fcb52016-02-25 16:27:32 -0800477 });
Steven Burrows3a9a6442016-05-05 15:31:16 +0100478 } else {
479
480 promise = ms.loadMapInto(mapG, mapFilePath, mapId, {
481 adjustScale: mapScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100482 shading: shading(),
Steven Burrows3a9a6442016-05-05 15:31:16 +0100483 });
Simon Hunt2362b072015-06-11 20:08:22 -0700484 }
Steven Burrows3a9a6442016-05-05 15:31:16 +0100485
Simon Hunt8a119b02016-03-29 16:00:32 -0700486 ps.setPrefs('topo_mapid', prefs);
Simon Hunt2362b072015-06-11 20:08:22 -0700487 return promise;
Simon Hunt0541fb82015-01-14 18:59:57 -0800488 }
489
Simon Huntf51bf462016-06-29 16:22:57 -0700490 function mapReshader() {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100491 $log.debug('... Re-shading map ...');
Simon Huntf51bf462016-06-29 16:22:57 -0700492 ms.reshade(shading());
493 }
494
Simon Hunta34fcb52016-02-25 16:27:32 -0800495 // set up theme listener to re-shade the map when required.
496 function mapShader(on) {
497 if (on) {
Simon Huntf51bf462016-06-29 16:22:57 -0700498 th.addListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800499 } else {
Simon Huntf51bf462016-06-29 16:22:57 -0700500 th.removeListener(mapReshader);
Simon Hunta34fcb52016-02-25 16:27:32 -0800501 }
502 }
503
Simon Huntc3c5b672015-02-20 11:32:13 -0800504 function opacifyMap(b) {
505 mapG.transition()
506 .duration(1000)
507 .attr('opacity', b ? 1 : 0);
508 }
Simon Hunt737c89f2015-01-28 12:23:19 -0800509
Simon Hunt90053ed2016-04-06 12:49:02 -0700510 function setUpSprites() {
Simon Hunt8a119b02016-03-29 16:00:32 -0700511 var prefs = ps.getPrefs('topo_sprites', { sprites: '' }, $loc.search()),
512 sprId = prefs.sprites;
Simon Huntf9fc0e72015-04-16 15:10:57 -0700513
Steven Burrows1c2a9682017-07-14 16:52:46 +0100514 spriteG = zoomLayer.append('g').attr('id', 'topo-sprites');
Simon Huntf9fc0e72015-04-16 15:10:57 -0700515 if (sprId) {
Simon Hunt8a119b02016-03-29 16:00:32 -0700516 ps.setPrefs('topo_sprites', prefs);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700517 tspr.loadSprites(spriteG, defs, sprId);
518 }
519 }
Simon Hunt9c1c45e2015-04-10 13:38:27 -0700520
Simon Huntc7ae7952015-04-08 18:59:27 -0700521 // --- User Preferemces ----------------------------------------------
Simon Hunt36a58c62015-04-08 11:00:07 -0700522
Simon Huntc7ae7952015-04-08 18:59:27 -0700523 var prefsState = {};
Simon Hunt36a58c62015-04-08 11:00:07 -0700524
Simon Huntc7ae7952015-04-08 18:59:27 -0700525 function updatePrefsState(what, b) {
526 prefsState[what] = b ? 1 : 0;
527 ps.setPrefs('topo_prefs', prefsState);
Simon Hunt36a58c62015-04-08 11:00:07 -0700528 }
529
Thomas Vachuskac616e172018-04-17 16:57:12 -0700530 function applyPreferences(evt) {
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700531// var zoomPrefs = ps.getPrefs('topo_zoom', null);
Thomas Vachuskabf5d1fe2018-04-25 15:49:00 -0400532// if (ps.getPrefs('topo_prefs', null)) {
533// restoreConfigFromPrefs();
534// }
Thomas Vachuskae4a75a12018-04-20 15:44:17 -0700535// if (zoomPrefs) {
536// $log.debug('TOPO- Zoom State:', zoomPrefs);
537// zoomer.panZoom([zoomPrefs.tx, zoomPrefs.ty], zoomPrefs.sc, 100);
538// }
Thomas Vachuskac616e172018-04-17 16:57:12 -0700539 }
Simon Hunt36a58c62015-04-08 11:00:07 -0700540
Simon Huntc7ae7952015-04-08 18:59:27 -0700541 function restoreConfigFromPrefs() {
542 // NOTE: toolbar will have set this for us..
Simon Huntfc5c5842017-02-01 23:32:18 -0800543 prefsState = ps.asNumbers(
544 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
545 );
Simon Hunt36a58c62015-04-08 11:00:07 -0700546
Simon Hunte1ce4292015-06-12 13:07:02 -0700547 $log.debug('TOPO- Prefs State:', prefsState);
Simon Huntc7ae7952015-04-08 18:59:27 -0700548
Simon Huntf41f3092015-04-16 10:33:26 -0700549 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700550 toggleInstances(prefsState.insts);
Simon Huntee7a3ce2015-04-09 13:28:37 -0700551 toggleSummary(prefsState.summary);
Simon Hunt239e5882015-04-23 15:07:04 -0700552 toggleUseDetailsFlag(prefsState.detail);
Bri Prebilic Cole9b80ca02015-08-03 11:26:54 -0700553 toggleHosts(prefsState.hosts);
554 toggleOffline(prefsState.offdev);
555 togglePorts(prefsState.porthl);
556 toggleMap(prefsState.bg);
Simon Huntf9fc0e72015-04-16 15:10:57 -0700557 toggleSprites(prefsState.spr);
Thomas Vachuskac616e172018-04-17 16:57:12 -0700558 ttbs.setToolbar(prefsState.toolbar);
Thomas Vachuska0af26912016-03-21 21:37:30 -0700559 t3s.setDevLabIndex(prefsState.dlbls);
Simon Hunt10618f62017-06-15 19:30:52 -0700560 t3s.setHostLabIndex(prefsState.hlbls);
Simon Huntf41f3092015-04-16 10:33:26 -0700561 flash.enable(true);
Simon Hunt36a58c62015-04-08 11:00:07 -0700562 }
563
564
Simon Hunte1ce4292015-06-12 13:07:02 -0700565 // somewhat hackish, because summary update cannot happen until we
566 // have opened the websocket to the server; hence this extra function
567 // invoked after tes.start()
568 function restoreSummaryFromPrefs() {
Simon Huntfc5c5842017-02-01 23:32:18 -0800569 prefsState = ps.asNumbers(
570 ps.getPrefs('topo_prefs', ttbs.defaultPrefs), ['ovid'], true
571 );
Simon Hunte1ce4292015-06-12 13:07:02 -0700572 $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary);
573
574 flash.enable(false);
575 toggleSummary(prefsState.summary);
576 flash.enable(true);
577 }
578
Simon Hunt8419efd2017-01-12 12:36:28 -0800579 // initial set of topo events received, now do post-processing
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700580 function topoStartDone() {
Simon Hunt8419efd2017-01-12 12:36:28 -0800581 // give a small delay before attempting to reselect node(s) and
582 // highlight elements, since they have to be re-added to the DOM first...
Simon Hunt7faabd52016-08-18 16:16:19 -0700583 $timeout(function () {
Simon Hunt8419efd2017-01-12 12:36:28 -0800584 $log.debug('^^ topo.topoStartDone() ^^');
585
586 // reselect the previous selection...
Simon Hunt7faabd52016-08-18 16:16:19 -0700587 tss.reselect();
Simon Hunt8419efd2017-01-12 12:36:28 -0800588
589 // if an intent should be shown, invoke the appropriate callback
590 if ($scope.intentData) {
Simon Hunt8419efd2017-01-12 12:36:28 -0800591 tov.hooks.showIntent($scope.intentData);
Simon Hunt7faabd52016-08-18 16:16:19 -0700592 }
Simon Hunt8419efd2017-01-12 12:36:28 -0800593
Simon Hunt7faabd52016-08-18 16:16:19 -0700594 }, 200);
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700595 }
Simon Hunte1ce4292015-06-12 13:07:02 -0700596
Simon Huntcacce342015-01-07 16:13:05 -0800597 // --- Controller Definition -----------------------------------------
598
Simon Hunt6cc53692015-01-07 11:33:45 -0800599 angular.module('ovTopo', moduleDependencies)
Simon Hunt5989ddf2017-08-02 20:38:12 -0700600 .controller('OvTopoCtrl',
601 ['$scope', '$log', '$location', '$timeout', '$cookies',
602 'FnService', 'MastService', 'KeyService', 'ZoomService',
Simon Hunt0e48c292015-02-19 16:11:37 -0800603 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService',
Simon Hunta34fcb52016-02-25 16:27:32 -0800604 'WebSocketService', 'PrefsService', 'ThemeService',
Simon Hunt5989ddf2017-08-02 20:38:12 -0700605 'TopoDialogService', 'TopoD3Service', 'TopoEventService',
606 'TopoForceService', 'TopoPanelService', 'TopoInstService',
607 'TopoSelectService', 'TopoLinkService', 'TopoTrafficService',
608 'TopoObliqueService', 'TopoFilterService', 'TopoToolbarService',
609 'TopoMapService', 'TopoSpriteService', 'TooltipService',
610 'TopoOverlayService', 'LionService',
Simon Hunt6cc53692015-01-07 11:33:45 -0800611
Simon Hunt5989ddf2017-08-02 20:38:12 -0700612 function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_,
613 _fs_, mast, _ks_, _zs_,
614 _gs_, _ms_, _sus_, _flash_,
615 _wss_, _ps_, _th_,
Thomas Vachuska0af26912016-03-21 21:37:30 -0700616 _tds_, _t3s_, _tes_,
Simon Hunt5989ddf2017-08-02 20:38:12 -0700617 _tfs_, _tps_, _tis_,
618 _tss_, _tls_, _tts_,
619 _tos_, _fltr_, _ttbs_,
620 _tms_, _tspr_, _ttip_,
621 _tov_, lion) {
Simon Huntfc5c5842017-02-01 23:32:18 -0800622
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700623 var params = _$loc_.search(),
Simon Huntfc5c5842017-02-01 23:32:18 -0800624 selOverlay = params.overlayId,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700625 projection,
Simon Hunt3a6eec02015-02-09 21:16:43 -0800626 dim,
Simon Hunt1894d792015-02-04 17:09:20 -0800627 uplink = {
628 // provides function calls back into this space
629 showNoDevs: showNoDevs,
630 projection: function () { return projection; },
Simon Huntc3c5b672015-02-20 11:32:13 -0800631 zoomLayer: function () { return zoomLayer; },
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800632 zoomer: function () { return zoomer; },
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700633 opacifyMap: opacifyMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100634 topoStartDone: topoStartDone,
Simon Huntac4c6f72015-02-03 19:50:53 -0800635 };
636
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700637 $scope = _$scope_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800638 $log = _$log_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700639 $loc = _$loc_;
Simon Hunt7faabd52016-08-18 16:16:19 -0700640 $timeout = _$timeout_;
Simon Hunta11b4eb2015-01-28 16:20:50 -0800641 fs = _fs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800642 ks = _ks_;
Simon Huntcacce342015-01-07 16:13:05 -0800643 zs = _zs_;
Simon Hunt6cc53692015-01-07 11:33:45 -0800644 gs = _gs_;
Simon Hunt1e8eff42015-01-08 17:19:02 -0800645 ms = _ms_;
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800646 sus = _sus_;
Simon Hunt0e48c292015-02-19 16:11:37 -0800647 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700648 wss = _wss_;
Simon Huntc7ae7952015-04-08 18:59:27 -0700649 ps = _ps_;
Simon Hunta34fcb52016-02-25 16:27:32 -0800650 th = _th_;
Simon Hunta211f7f2015-11-09 12:48:23 -0800651 tds = _tds_;
Thomas Vachuska0af26912016-03-21 21:37:30 -0700652 t3s = _t3s_;
Simon Huntc252aa62015-02-10 16:45:39 -0800653 tes = _tes_;
Simon Hunt737c89f2015-01-28 12:23:19 -0800654 tfs = _tfs_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800655 // TODO: consider funnelling actions through TopoForceService...
656 // rather than injecting references to these 'sub-modules',
657 // just so we can invoke functions on them.
Simon Huntc252aa62015-02-10 16:45:39 -0800658 tps = _tps_;
Simon Huntac4c6f72015-02-03 19:50:53 -0800659 tis = _tis_;
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700660 tms = _tms_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700661 tls = _tls_;
Simon Hunt96f88c62015-02-19 17:57:25 -0800662 tos = _tos_;
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -0700663 fltr = _fltr_;
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700664 ttbs = _ttbs_;
Simon Hunta4281242016-02-26 20:18:45 -0800665 tspr = _tspr_;
Simon Hunt72e44bf2015-07-21 21:34:20 -0700666 tov = _tov_;
Steven Burrows1c2a9682017-07-14 16:52:46 +0100667 tss = _tss_;
Simon Huntef31fb22014-12-19 13:16:44 -0800668
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700669 tms.start({
670 toggleMap: toggleMap,
671 currentMap: currentMap,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100672 setMap: setMap,
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700673 });
674
Simon Hunt441c9ae2017-02-03 18:22:31 -0800675 // pull intent data from the query string...
Viswanath KSP0f297702016-08-13 18:02:43 +0530676 if (params.key && params.appId && params.appName) {
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700677 $scope.intentData = {
Viswanath KSP0f297702016-08-13 18:02:43 +0530678 key: params.key,
679 appId: params.appId,
Simon Hunt441c9ae2017-02-03 18:22:31 -0800680 appName: params.appName,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100681 intentType: params.intentType,
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700682 };
683 }
684
Bri Prebilic Cole068814d2015-05-14 16:06:38 -0700685 $scope.notifyResize = function () {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800686 svgResized(fs.windowSize(mast.mastHeight()));
Simon Hunt426bd862015-01-14 16:48:41 -0800687 };
Simon Huntef31fb22014-12-19 13:16:44 -0800688
Simon Hunt54442fa2015-01-26 14:17:38 -0800689 // Cleanup on destroyed scope..
Simon Hunt584122a2015-01-21 15:32:40 -0800690 $scope.$on('$destroy', function () {
691 $log.log('OvTopoCtrl is saying Buh-Bye!');
Thomas Vachuska329af532015-03-10 02:08:33 -0700692 tes.stop();
Thomas Vachuska26be4f32016-03-31 01:10:27 -0700693 tms.stop();
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700694 ks.unbindKeys();
Simon Hunt626d2102015-01-29 11:54:50 -0800695 tps.destroyPanels();
Simon Hunta211f7f2015-11-09 12:48:23 -0800696 tds.closeDialog();
Simon Hunt4b668592015-01-29 17:33:53 -0800697 tis.destroyInst();
Simon Hunt3a6eec02015-02-09 21:16:43 -0800698 tfs.destroyForce();
Bri Prebilic Coled6219052015-03-19 14:34:02 -0700699 ttbs.destroyToolbar();
Simon Hunta34fcb52016-02-25 16:27:32 -0800700 mapShader(false);
Simon Hunt584122a2015-01-21 15:32:40 -0800701 });
702
Simon Huntcacce342015-01-07 16:13:05 -0800703 // svg layer and initialization of components
Simon Hunt426bd862015-01-14 16:48:41 -0800704 ovtopo = d3.select('#ov-topo');
705 svg = ovtopo.select('svg');
Simon Hunta11b4eb2015-01-28 16:20:50 -0800706 // set the svg size to match that of the window, less the masthead
707 svg.attr(fs.windowSize(mast.mastHeight()));
Simon Hunt3a6eec02015-02-09 21:16:43 -0800708 dim = [svg.attr('width'), svg.attr('height')];
Simon Hunt426bd862015-01-14 16:48:41 -0800709
Thomas Vachuskac616e172018-04-17 16:57:12 -0700710 ps.addListener(applyPreferences);
711
Simon Hunt6cc53692015-01-07 11:33:45 -0800712 setUpKeys();
Bri Prebilic Cole4db8dce2015-03-18 13:57:24 -0700713 setUpToolbar();
Simon Hunt6cc53692015-01-07 11:33:45 -0800714 setUpDefs();
Simon Huntcacce342015-01-07 16:13:05 -0800715 setUpZoom();
Simon Hunt7c8ab8d2015-02-03 15:05:15 -0800716 setUpNoDevs();
Simon Hunt90053ed2016-04-06 12:49:02 -0700717 setUpMap().then(
Simon Hunt1894d792015-02-04 17:09:20 -0800718 function (proj) {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100719 var z = ps.getPrefs('topo_zoom', { tx: 0, ty: 0, sc: 1 });
Simon Huntbb5e0d82015-04-16 14:25:46 -0700720 zoomer.panZoom([z.tx, z.ty], z.sc);
721 $log.debug('** Zoom restored:', z);
722
Simon Hunt1894d792015-02-04 17:09:20 -0800723 projection = proj;
Simon Huntbb5e0d82015-04-16 14:25:46 -0700724 $log.debug('** We installed the projection:', proj);
Simon Huntf41f3092015-04-16 10:33:26 -0700725 flash.enable(false);
Simon Huntc7ae7952015-04-08 18:59:27 -0700726 toggleMap(prefsState.bg);
Simon Huntf41f3092015-04-16 10:33:26 -0700727 flash.enable(true);
Simon Hunta34fcb52016-02-25 16:27:32 -0800728 mapShader(true);
Simon Hunte1ce4292015-06-12 13:07:02 -0700729
Simon Hunt5989ddf2017-08-02 20:38:12 -0700730 // piggyback off the deferred map loading to load the
731 // localization bundle after the uber bundle has arrived...
732 $scope.lion = lion.bundle('core.view.Topo');
733 topoLion = $scope.lion;
734 $log.debug('Loaded Topo LION Bundle:', topoLion);
735
Simon Hunt3f89cb42017-08-10 13:32:00 -0700736 // insert localized text into already established
737 // DOM elements...
738 lionNoDevs();
739
Simon Hunte2d9dc72017-08-10 15:21:04 -0700740 // pass lion bundle function ref to other topo modules
741 tfs.setLionBundle(topoLion);
742 tis.setLionBundle(topoLion);
Simon Hunt1603c692017-08-10 19:53:35 -0700743 tms.setLionBundle(topoLion);
Simon Hunt879ce452017-08-10 23:32:00 -0700744 tps.setLionBundle(topoLion);
Simon Huntcaed0412017-08-12 13:49:17 -0700745 ttbs.setLionBundle(topoLion);
Simon Hunte2d9dc72017-08-10 15:21:04 -0700746
Simon Hunte1ce4292015-06-12 13:07:02 -0700747 // now we have the map projection, we are ready for
748 // the server to send us device/host data...
749 tes.start();
750 // need to do the following so we immediately get
751 // the summary panel data back from the server
752 restoreSummaryFromPrefs();
Simon Hunt1894d792015-02-04 17:09:20 -0800753 }
754 );
Simon Hunta4281242016-02-26 20:18:45 -0800755 tes.bindHandlers();
Simon Hunt90053ed2016-04-06 12:49:02 -0700756 setUpSprites();
Simon Huntfd1231a2015-01-26 22:14:51 -0800757
Simon Hunt1894d792015-02-04 17:09:20 -0800758 forceG = zoomLayer.append('g').attr('id', 'topo-force');
Simon Huntfb8ea1f2015-02-24 21:38:09 -0800759 tfs.initForce(svg, forceG, uplink, dim);
Simon Hunta142dd22015-02-12 22:07:51 -0800760 tis.initInst({ showMastership: tfs.showMastership });
Simon Hunt237676b52015-03-10 19:04:26 -0700761 tps.initPanels();
Simon Hunt6cc53692015-01-07 11:33:45 -0800762
Simon Huntc7ae7952015-04-08 18:59:27 -0700763 restoreConfigFromPrefs();
Simon Huntfc5c5842017-02-01 23:32:18 -0800764
765 ttbs.selectOverlay(selOverlay || prefsState.ovid);
Simon Hunt36a58c62015-04-08 11:00:07 -0700766
Simon Hunt72e44bf2015-07-21 21:34:20 -0700767 $log.debug('registered overlays...', tov.list());
Simon Hunt6cc53692015-01-07 11:33:45 -0800768 $log.log('OvTopoCtrl has been created');
Simon Huntef31fb22014-12-19 13:16:44 -0800769 }]);
770}());