blob: e648d6d28b45aa948c1bc4e687c45bd294321525 [file] [log] [blame]
Simon Hunt737c89f2015-01-28 12:23:19 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Simon Hunt737c89f2015-01-28 12:23:19 -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/*
Simon Hunt3a6eec02015-02-09 21:16:43 -080018 ONOS GUI -- Topology Force Module.
19 Visualization of the topology in an SVG layer, using a D3 Force Layout.
Simon Hunt737c89f2015-01-28 12:23:19 -080020 */
21
22(function () {
23 'use strict';
24
25 // injected refs
Simon Hunt8d22c4b2015-08-06 16:24:43 -070026 var $log, $timeout, fs, sus, ts, flash, wss, tov,
Andrea Campanella732ea832017-02-06 09:25:59 -080027 tis, tms, td3, tss, tts, tos, fltr, tls, uplink, svg, tpis;
Simon Huntac4c6f72015-02-03 19:50:53 -080028
Simon Hunte2d9dc72017-08-10 15:21:04 -070029 // function to be replaced by the localization bundle function
30 var topoLion = function (x) {
31 return '#tfs#' + x + '#';
32 };
33
Simon Huntac4c6f72015-02-03 19:50:53 -080034 // configuration
Simon Hunt1894d792015-02-04 17:09:20 -080035 var linkConfig = {
36 light: {
Simon Huntf44d7262016-06-14 14:46:56 -070037 baseColor: '#939598',
Simon Hunt1894d792015-02-04 17:09:20 -080038 inColor: '#66f',
Steven Burrows1c2a9682017-07-14 16:52:46 +010039 outColor: '#f00',
Simon Hunt1894d792015-02-04 17:09:20 -080040 },
41 dark: {
Simon Huntf44d7262016-06-14 14:46:56 -070042 // TODO : theme
43 baseColor: '#939598',
Simon Hunt1894d792015-02-04 17:09:20 -080044 inColor: '#66f',
Steven Burrows1c2a9682017-07-14 16:52:46 +010045 outColor: '#f00',
Simon Hunt1894d792015-02-04 17:09:20 -080046 },
47 inWidth: 12,
Steven Burrows1c2a9682017-07-14 16:52:46 +010048 outWidth: 10,
Simon Hunt1894d792015-02-04 17:09:20 -080049 };
50
Simon Hunt737c89f2015-01-28 12:23:19 -080051 // internal state
Steven Burrows1c2a9682017-07-14 16:52:46 +010052 var settings, // merged default settings and options
53 force, // force layout object
54 drag, // drag behavior handler
Simon Hunt737c89f2015-01-28 12:23:19 -080055 network = {
56 nodes: [],
57 links: [],
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -070058 linksByDevice: {},
Simon Hunt737c89f2015-01-28 12:23:19 -080059 lookup: {},
Steven Burrows1c2a9682017-07-14 16:52:46 +010060 revLinkToKey: {},
Simon Huntac4c6f72015-02-03 19:50:53 -080061 },
Steven Burrows1c2a9682017-07-14 16:52:46 +010062 lu, // shorthand for lookup
63 rlk, // shorthand for revLinktoKey
64 showHosts = false, // whether hosts are displayed
65 showOffline = true, // whether offline devices are displayed
66 nodeLock = false, // whether nodes can be dragged or not (locked)
67 fTimer, // timer for delayed force layout
68 fNodesTimer, // timer for delayed nodes update
69 fLinksTimer, // timer for delayed links update
70 dim, // the dimensions of the force layout [w,h]
71 linkNums = [], // array of link number labels
72 devIconDim = 36, // node target dimension
73 devIconDimMin = 20, // node minimum dimension when zoomed out
Thomas Vachuskac8c8f462021-03-01 11:22:56 -080074 devIconDimMax = 70, // node maximum dimension when zoomed in
Steven Burrowsf17f0ab2017-04-11 11:03:58 -070075 portLabelDim = 30;
Simon Hunt737c89f2015-01-28 12:23:19 -080076
77 // SVG elements;
Bri Prebilic Cole80401762015-07-16 11:36:18 -070078 var linkG, linkLabelG, numLinkLblsG, portLabelG, nodeG;
Simon Hunt737c89f2015-01-28 12:23:19 -080079
80 // D3 selections;
81 var link, linkLabel, node;
82
83 // default settings for force layout
84 var defaultSettings = {
85 gravity: 0.4,
86 friction: 0.7,
87 charge: {
88 // note: key is node.class
89 device: -8000,
90 host: -5000,
Steven Burrows1c2a9682017-07-14 16:52:46 +010091 _def_: -12000,
Simon Hunt737c89f2015-01-28 12:23:19 -080092 },
93 linkDistance: {
94 // note: key is link.type
95 direct: 100,
96 optical: 120,
97 hostLink: 3,
Steven Burrows1c2a9682017-07-14 16:52:46 +010098 _def_: 50,
Simon Hunt737c89f2015-01-28 12:23:19 -080099 },
100 linkStrength: {
101 // note: key is link.type
102 // range: {0.0 ... 1.0}
Steven Burrows1c2a9682017-07-14 16:52:46 +0100103 // direct: 1.0,
104 // optical: 1.0,
105 // hostLink: 1.0,
106 _def_: 1.0,
107 },
Simon Hunt737c89f2015-01-28 12:23:19 -0800108 };
109
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800110 var hostScaleFactor = {icon: 1.0, text: 1.0};
Simon Hunt737c89f2015-01-28 12:23:19 -0800111
Simon Huntac4c6f72015-02-03 19:50:53 -0800112 // ==========================
113 // === EVENT HANDLERS
114
Thomas Vachuskac616e172018-04-17 16:57:12 -0700115 function mergeNodeData(o, n) {
116 angular.extend(o, n);
117 if (!n.location) {
118 delete o.location;
119 }
120 }
121
Simon Huntac4c6f72015-02-03 19:50:53 -0800122 function addDevice(data) {
123 var id = data.id,
124 d;
125
Simon Hunt1894d792015-02-04 17:09:20 -0800126 uplink.showNoDevs(false);
Simon Huntac4c6f72015-02-03 19:50:53 -0800127
128 // although this is an add device event, if we already have the
129 // device, treat it as an update instead..
Simon Hunt1894d792015-02-04 17:09:20 -0800130 if (lu[id]) {
Simon Huntac4c6f72015-02-03 19:50:53 -0800131 updateDevice(data);
132 return;
133 }
134
Simon Hunt3a6eec02015-02-09 21:16:43 -0800135 d = tms.createDeviceNode(data);
Simon Huntac4c6f72015-02-03 19:50:53 -0800136 network.nodes.push(d);
Simon Hunt1894d792015-02-04 17:09:20 -0800137 lu[id] = d;
Simon Huntac4c6f72015-02-03 19:50:53 -0800138 updateNodes();
Simon Hunta17fa672015-08-19 18:42:22 -0700139 fStart();
Simon Huntac4c6f72015-02-03 19:50:53 -0800140 }
141
142 function updateDevice(data) {
143 var id = data.id,
Simon Hunt1894d792015-02-04 17:09:20 -0800144 d = lu[id],
Simon Huntac4c6f72015-02-03 19:50:53 -0800145 wasOnline;
146
147 if (d) {
148 wasOnline = d.online;
Thomas Vachuskac616e172018-04-17 16:57:12 -0700149 mergeNodeData(d, data);
Simon Hunt3a6eec02015-02-09 21:16:43 -0800150 if (tms.positionNode(d, true)) {
Simon Hunt445e8152015-02-06 13:00:12 -0800151 sendUpdateMeta(d);
Simon Huntac4c6f72015-02-03 19:50:53 -0800152 }
153 updateNodes();
Thomas Vachuskac616e172018-04-17 16:57:12 -0700154 tick();
Simon Huntac4c6f72015-02-03 19:50:53 -0800155 if (wasOnline !== d.online) {
Simon Huntdc6adea2015-02-09 22:29:36 -0800156 tms.findAttachedLinks(d.id).forEach(restyleLinkElement);
Simon Hunt5724fb42015-02-05 16:59:40 -0800157 updateOfflineVisibility(d);
Simon Huntac4c6f72015-02-03 19:50:53 -0800158 }
Thomas Vachuskac616e172018-04-17 16:57:12 -0700159 fStart();
Simon Huntac4c6f72015-02-03 19:50:53 -0800160 }
161 }
162
Simon Hunt1894d792015-02-04 17:09:20 -0800163 function removeDevice(data) {
164 var id = data.id,
165 d = lu[id];
166 if (d) {
167 removeDeviceElement(d);
Simon Hunt1894d792015-02-04 17:09:20 -0800168 }
169 }
170
171 function addHost(data) {
172 var id = data.id,
Simon Hunt12c79ed2017-09-12 11:58:44 -0700173 d;
Simon Hunt1894d792015-02-04 17:09:20 -0800174
175 // although this is an add host event, if we already have the
176 // host, treat it as an update instead..
177 if (lu[id]) {
178 updateHost(data);
179 return;
180 }
181
Simon Hunt3a6eec02015-02-09 21:16:43 -0800182 d = tms.createHostNode(data);
Simon Hunt1894d792015-02-04 17:09:20 -0800183 network.nodes.push(d);
184 lu[id] = d;
Simon Hunt1894d792015-02-04 17:09:20 -0800185 updateNodes();
186
Simon Hunt12c79ed2017-09-12 11:58:44 -0700187 // need to handle possible multiple links (multi-homed host)
Simon Hunt7df764f2017-09-14 21:26:14 -0700188 createHostLinks(data.allCps, d);
Simon Hunt12c79ed2017-09-12 11:58:44 -0700189
190 if (d.links.length) {
Simon Hunt1894d792015-02-04 17:09:20 -0800191 updateLinks();
192 }
Simon Hunta17fa672015-08-19 18:42:22 -0700193 fStart();
Simon Hunt1894d792015-02-04 17:09:20 -0800194 }
195
196 function updateHost(data) {
197 var id = data.id,
198 d = lu[id];
199 if (d) {
Thomas Vachuskac616e172018-04-17 16:57:12 -0700200 mergeNodeData(d, data);
Simon Hunt3a6eec02015-02-09 21:16:43 -0800201 if (tms.positionNode(d, true)) {
Simon Hunt445e8152015-02-06 13:00:12 -0800202 sendUpdateMeta(d);
Simon Hunt1894d792015-02-04 17:09:20 -0800203 }
204 updateNodes();
Thomas Vachuskac616e172018-04-17 16:57:12 -0700205 tick();
206 fStart();
Simon Hunt1894d792015-02-04 17:09:20 -0800207 }
208 }
209
Simon Hunt7df764f2017-09-14 21:26:14 -0700210 function createHostLinks(cps, model) {
211 model.links = [];
212 cps.forEach(function (cp) {
213 var linkData = {
214 key: model.id + '/0-' + cp.device + '/' + cp.port,
215 dst: cp.device,
216 dstPort: cp.port,
217 };
218 model.links.push(linkData);
219
220 var lnk = tms.createHostLink(model.id, cp.device, cp.port);
221 if (lnk) {
222 network.links.push(lnk);
223 lu[linkData.key] = lnk;
224 }
225 });
226 }
227
Simon Hunt95d56fd2015-11-12 11:06:44 -0800228 function moveHost(data) {
229 var id = data.id,
Simon Hunt7df764f2017-09-14 21:26:14 -0700230 d = lu[id];
Simon Hunt12c79ed2017-09-12 11:58:44 -0700231
Simon Hunt95d56fd2015-11-12 11:06:44 -0800232 if (d) {
Simon Hunt7df764f2017-09-14 21:26:14 -0700233 removeAllLinkElements(d.links);
Simon Hunt95d56fd2015-11-12 11:06:44 -0800234
235 // merge new data
236 angular.extend(d, data);
237 if (tms.positionNode(d, true)) {
238 sendUpdateMeta(d);
239 }
240
Simon Hunt7df764f2017-09-14 21:26:14 -0700241 // now create new host link(s)
242 createHostLinks(data.allCps, d);
Simon Hunt95d56fd2015-11-12 11:06:44 -0800243
244 updateNodes();
245 updateLinks();
246 fResume();
247 }
248 }
249
Simon Hunt1894d792015-02-04 17:09:20 -0800250 function removeHost(data) {
251 var id = data.id,
252 d = lu[id];
253 if (d) {
254 removeHostElement(d, true);
Simon Hunt1894d792015-02-04 17:09:20 -0800255 }
256 }
257
258 function addLink(data) {
Simon Huntdc6adea2015-02-09 22:29:36 -0800259 var result = tms.findLink(data, 'add'),
Simon Hunt1894d792015-02-04 17:09:20 -0800260 bad = result.badLogic,
261 d = result.ldata;
262
263 if (bad) {
Simon Hunteb18f522016-01-28 19:22:23 -0800264 $log.debug(bad + ': ' + link.id);
Simon Hunt1894d792015-02-04 17:09:20 -0800265 return;
266 }
267
268 if (d) {
269 // we already have a backing store link for src/dst nodes
270 addLinkUpdate(d, data);
271 return;
272 }
273
274 // no backing store link yet
Simon Hunt3a6eec02015-02-09 21:16:43 -0800275 d = tms.createLink(data);
Simon Hunt1894d792015-02-04 17:09:20 -0800276 if (d) {
277 network.links.push(d);
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700278 aggregateLink(d, data);
Simon Hunt1894d792015-02-04 17:09:20 -0800279 lu[d.key] = d;
280 updateLinks();
Simon Hunta17fa672015-08-19 18:42:22 -0700281 fStart();
Simon Hunt1894d792015-02-04 17:09:20 -0800282 }
283 }
284
285 function updateLink(data) {
Simon Huntdc6adea2015-02-09 22:29:36 -0800286 var result = tms.findLink(data, 'update'),
Simon Hunt1894d792015-02-04 17:09:20 -0800287 bad = result.badLogic;
288 if (bad) {
Simon Hunteb18f522016-01-28 19:22:23 -0800289 $log.debug(bad + ': ' + link.id);
Simon Hunt1894d792015-02-04 17:09:20 -0800290 return;
291 }
Simon Hunteb18f522016-01-28 19:22:23 -0800292 result.updateWith(data);
Simon Hunt1894d792015-02-04 17:09:20 -0800293 }
294
295 function removeLink(data) {
Simon Hunta4242de2015-02-24 17:11:55 -0800296 var result = tms.findLink(data, 'remove');
297
298 if (!result.badLogic) {
299 result.removeRawLink();
Simon Hunt1894d792015-02-04 17:09:20 -0800300 }
Simon Hunt1894d792015-02-04 17:09:20 -0800301 }
302
Simon Hunt4a6b54b2015-10-27 22:08:25 -0700303 function topoStartDone(data) {
304 // called when the initial barrage of data has been sent from server
305 uplink.topoStartDone();
306 }
307
Simon Hunt1894d792015-02-04 17:09:20 -0800308 // ========================
309
Simon Hunt94f7dae2015-08-26 17:40:59 -0700310 function nodeById(id) {
311 return lu[id];
312 }
313
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700314 function makeNodeKey(node1, node2) {
315 return node1 + '-' + node2;
316 }
317
318 function findNodePair(key, keyRev) {
319 if (network.linksByDevice[key]) {
320 return key;
321 } else if (network.linksByDevice[keyRev]) {
322 return keyRev;
323 } else {
324 return false;
325 }
326 }
327
328 function aggregateLink(ldata, link) {
329 var key = makeNodeKey(link.src, link.dst),
330 keyRev = makeNodeKey(link.dst, link.src),
331 found = findNodePair(key, keyRev);
332
333 if (found) {
334 network.linksByDevice[found].push(ldata);
335 ldata.devicePair = found;
336 } else {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100337 network.linksByDevice[key] = [ldata];
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700338 ldata.devicePair = key;
339 }
340 }
341
Simon Hunt1894d792015-02-04 17:09:20 -0800342 function addLinkUpdate(ldata, link) {
343 // add link event, but we already have the reverse link installed
344 ldata.fromTarget = link;
Simon Huntdc6adea2015-02-09 22:29:36 -0800345 rlk[link.id] = ldata.key;
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700346 // possible solution to el being undefined in restyleLinkElement:
Steven Burrows1c2a9682017-07-14 16:52:46 +0100347 // _updateLinks();
Simon Hunt1894d792015-02-04 17:09:20 -0800348 restyleLinkElement(ldata);
349 }
350
Simon Hunt1894d792015-02-04 17:09:20 -0800351
352 var widthRatio = 1.4,
353 linkScale = d3.scale.linear()
354 .domain([1, 12])
355 .range([widthRatio, 12 * widthRatio])
Simon Hunt5724fb42015-02-05 16:59:40 -0800356 .clamp(true),
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800357 allLinkTypes = 'direct indirect optical tunnel',
358 allLinkSubTypes = 'inactive not-permitted';
Simon Hunt1894d792015-02-04 17:09:20 -0800359
Simon Hunta142dd22015-02-12 22:07:51 -0800360 function restyleLinkElement(ldata, immediate) {
Simon Hunt1894d792015-02-04 17:09:20 -0800361 // this fn's job is to look at raw links and decide what svg classes
362 // need to be applied to the line element in the DOM
363 var th = ts.theme(),
364 el = ldata.el,
365 type = ldata.type(),
366 lw = ldata.linkWidth(),
Simon Hunta142dd22015-02-12 22:07:51 -0800367 online = ldata.online(),
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800368 modeCls = ldata.expected() ? 'inactive' : 'not-permitted',
Simon Hunta142dd22015-02-12 22:07:51 -0800369 delay = immediate ? 0 : 1000;
Simon Hunt1894d792015-02-04 17:09:20 -0800370
Simon Huntf44d7262016-06-14 14:46:56 -0700371 // NOTE: understand why el is sometimes undefined on addLink events...
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700372 // Investigated:
373 // el is undefined when it's a reverse link that is being added.
374 // updateLinks (which sets ldata.el) isn't called before this is called.
375 // Calling _updateLinks in addLinkUpdate fixes it, but there might be
376 // a more efficient way to fix it.
377 if (el && !el.empty()) {
Thomas Vachuskacb5016f2015-05-18 14:11:43 -0700378 el.classed('link', true);
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800379 el.classed(allLinkSubTypes, false);
380 el.classed(modeCls, !online);
Thomas Vachuskacb5016f2015-05-18 14:11:43 -0700381 el.classed(allLinkTypes, false);
382 if (type) {
383 el.classed(type, true);
384 }
385 el.transition()
386 .duration(delay)
387 .attr('stroke-width', linkScale(lw))
388 .attr('stroke', linkConfig[th].baseColor);
Simon Hunt1894d792015-02-04 17:09:20 -0800389 }
Simon Hunt1894d792015-02-04 17:09:20 -0800390 }
391
Simon Hunt7df764f2017-09-14 21:26:14 -0700392 function removeAllLinkElements(links) {
393 links.forEach(function (lnk) {
394 removeLinkElement(lnk);
395 });
396 }
397
Simon Hunt1894d792015-02-04 17:09:20 -0800398 function removeLinkElement(d) {
399 var idx = fs.find(d.key, network.links, 'key'),
400 removed;
401 if (idx >=0) {
402 // remove from links array
403 removed = network.links.splice(idx, 1);
404 // remove from lookup cache
405 delete lu[removed[0].key];
406 updateLinks();
Simon Hunta17fa672015-08-19 18:42:22 -0700407 fResume();
Simon Hunt1894d792015-02-04 17:09:20 -0800408 }
409 }
410
411 function removeHostElement(d, upd) {
Simon Hunt1fb00552017-09-15 09:21:14 -0700412 // first, remove associated hostLink(s)...
413 removeAllLinkElements(d.links);
Simon Hunt1894d792015-02-04 17:09:20 -0800414
415 // remove from lookup cache
416 delete lu[d.id];
417 // remove from nodes array
418 var idx = fs.find(d.id, network.nodes);
419 network.nodes.splice(idx, 1);
420
421 // remove from SVG
422 // NOTE: upd is false if we were called from removeDeviceElement()
423 if (upd) {
424 updateNodes();
Simon Hunta17fa672015-08-19 18:42:22 -0700425 fResume();
Simon Hunt1894d792015-02-04 17:09:20 -0800426 }
427 }
428
429 function removeDeviceElement(d) {
Bri Prebilic Cole8d003782015-07-31 15:33:06 -0700430 var id = d.id,
431 idx;
Simon Hunt1894d792015-02-04 17:09:20 -0800432 // first, remove associated hosts and links..
Simon Huntdc6adea2015-02-09 22:29:36 -0800433 tms.findAttachedHosts(id).forEach(removeHostElement);
434 tms.findAttachedLinks(id).forEach(removeLinkElement);
Simon Hunt1894d792015-02-04 17:09:20 -0800435
436 // remove from lookup cache
437 delete lu[id];
438 // remove from nodes array
Bri Prebilic Cole8d003782015-07-31 15:33:06 -0700439 idx = fs.find(id, network.nodes);
440 if (idx > -1) {
441 network.nodes.splice(idx, 1);
442 }
Simon Hunt1894d792015-02-04 17:09:20 -0800443
444 if (!network.nodes.length) {
Simon Huntdc6adea2015-02-09 22:29:36 -0800445 uplink.showNoDevs(true);
Simon Hunt1894d792015-02-04 17:09:20 -0800446 }
447
448 // remove from SVG
449 updateNodes();
Simon Hunta17fa672015-08-19 18:42:22 -0700450 fResume();
Simon Hunt1894d792015-02-04 17:09:20 -0800451 }
452
Simon Hunt5724fb42015-02-05 16:59:40 -0800453 function updateHostVisibility() {
Simon Hunt18bf9822015-02-12 17:35:45 -0800454 sus.visible(nodeG.selectAll('.host'), showHosts);
455 sus.visible(linkG.selectAll('.hostLink'), showHosts);
Simon Hunt8eb4d3a2015-02-23 18:23:29 -0800456 sus.visible(linkLabelG.selectAll('.hostLinkLabel'), showHosts);
Simon Hunt5724fb42015-02-05 16:59:40 -0800457 }
458
459 function updateOfflineVisibility(dev) {
460 function updDev(d, show) {
Simon Hunt8eb4d3a2015-02-23 18:23:29 -0800461 var b;
Simon Hunt18bf9822015-02-12 17:35:45 -0800462 sus.visible(d.el, show);
Simon Hunt5724fb42015-02-05 16:59:40 -0800463
Simon Huntdc6adea2015-02-09 22:29:36 -0800464 tms.findAttachedLinks(d.id).forEach(function (link) {
Simon Hunt5724fb42015-02-05 16:59:40 -0800465 b = show && ((link.type() !== 'hostLink') || showHosts);
Simon Hunt18bf9822015-02-12 17:35:45 -0800466 sus.visible(link.el, b);
Simon Hunt5724fb42015-02-05 16:59:40 -0800467 });
Simon Huntdc6adea2015-02-09 22:29:36 -0800468 tms.findAttachedHosts(d.id).forEach(function (host) {
Simon Hunt5724fb42015-02-05 16:59:40 -0800469 b = show && showHosts;
Simon Hunt18bf9822015-02-12 17:35:45 -0800470 sus.visible(host.el, b);
Simon Hunt5724fb42015-02-05 16:59:40 -0800471 });
472 }
473
474 if (dev) {
475 // updating a specific device that just toggled off/on-line
476 updDev(dev, dev.online || showOffline);
477 } else {
478 // updating all offline devices
Simon Huntdc6adea2015-02-09 22:29:36 -0800479 tms.findDevices(true).forEach(function (d) {
Simon Hunt5724fb42015-02-05 16:59:40 -0800480 updDev(d, showOffline);
481 });
482 }
483 }
484
Simon Hunt1894d792015-02-04 17:09:20 -0800485
Simon Hunt445e8152015-02-06 13:00:12 -0800486 function sendUpdateMeta(d, clearPos) {
Simon Huntac4c6f72015-02-03 19:50:53 -0800487 var metaUi = {},
488 ll;
489
Simon Hunt445e8152015-02-06 13:00:12 -0800490 // if we are not clearing the position data (unpinning),
Simon Huntfd7106c2016-02-09 15:05:26 -0800491 // attach the x, y, (and equivalent longitude, latitude)...
Simon Hunt445e8152015-02-06 13:00:12 -0800492 if (!clearPos) {
Simon Hunt3a6eec02015-02-09 21:16:43 -0800493 ll = tms.lngLatFromCoord([d.x, d.y]);
Simon Huntfd7106c2016-02-09 15:05:26 -0800494 metaUi = {
495 x: d.x,
496 y: d.y,
497 equivLoc: {
498 lng: ll[0],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100499 lat: ll[1],
500 },
Simon Huntfd7106c2016-02-09 15:05:26 -0800501 };
Simon Hunt1894d792015-02-04 17:09:20 -0800502 }
503 d.metaUi = metaUi;
Simon Hunt237676b52015-03-10 19:04:26 -0700504 wss.sendEvent('updateMeta', {
Simon Hunt1894d792015-02-04 17:09:20 -0800505 id: d.id,
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700506 class: d.class,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100507 memento: metaUi,
Simon Hunt1894d792015-02-04 17:09:20 -0800508 });
Simon Huntac4c6f72015-02-03 19:50:53 -0800509 }
510
Simon Hunt1894d792015-02-04 17:09:20 -0800511
Simon Huntac4c6f72015-02-03 19:50:53 -0800512 function mkSvgClass(d) {
513 return d.fixed ? d.svgClass + ' fixed' : d.svgClass;
514 }
515
Simon Hunt5724fb42015-02-05 16:59:40 -0800516 function vis(b) {
Simon Hunt1603c692017-08-10 19:53:35 -0700517 return topoLion(b ? 'visible' : 'hidden');
Simon Hunt5724fb42015-02-05 16:59:40 -0800518 }
519
Simon Huntfcbde892015-04-16 12:05:28 -0700520 function toggleHosts(x) {
521 var kev = (x === 'keyev'),
522 on = kev ? !showHosts : !!x;
523
524 showHosts = on;
Simon Hunt5724fb42015-02-05 16:59:40 -0800525 updateHostVisibility();
Simon Hunte2d9dc72017-08-10 15:21:04 -0700526 flash.flash(topoLion('hosts') + ' ' + vis(on));
Simon Huntfcbde892015-04-16 12:05:28 -0700527 return on;
Simon Hunt5724fb42015-02-05 16:59:40 -0800528 }
529
Simon Huntfcbde892015-04-16 12:05:28 -0700530 function toggleOffline(x) {
531 var kev = (x === 'keyev'),
532 on = kev ? !showOffline : !!x;
533
534 showOffline = on;
Simon Hunt5724fb42015-02-05 16:59:40 -0800535 updateOfflineVisibility();
Simon Hunte2d9dc72017-08-10 15:21:04 -0700536 flash.flash(topoLion('fl_offline_devices') + ' ' + vis(on));
Simon Huntfcbde892015-04-16 12:05:28 -0700537 return on;
Simon Hunt5724fb42015-02-05 16:59:40 -0800538 }
539
540 function cycleDeviceLabels() {
Bri Prebilic Cole9cf1a8d2015-04-21 13:15:29 -0700541 flash.flash(td3.incDevLabIndex());
Simon Huntdc6adea2015-02-09 22:29:36 -0800542 tms.findDevices().forEach(function (d) {
Simon Hunta4242de2015-02-24 17:11:55 -0800543 td3.updateDeviceLabel(d);
Simon Hunt1c367112015-02-05 18:02:46 -0800544 });
Simon Hunt5724fb42015-02-05 16:59:40 -0800545 }
546
Simon Hunt10618f62017-06-15 19:30:52 -0700547 function cycleHostLabels() {
548 flash.flash(td3.incHostLabIndex());
549 tms.findHosts().forEach(function (d) {
550 td3.updateHostLabel(d);
551 });
552 }
553
Simon Hunt445e8152015-02-06 13:00:12 -0800554 function unpin() {
Simon Hunt08f841d02015-02-10 14:39:20 -0800555 var hov = tss.hovered();
556 if (hov) {
557 sendUpdateMeta(hov, true);
558 hov.fixed = false;
559 hov.el.classed('fixed', false);
Simon Hunt445e8152015-02-06 13:00:12 -0800560 fResume();
561 }
562 }
563
Simon Hunta142dd22015-02-12 22:07:51 -0800564 function showMastership(masterId) {
565 if (!masterId) {
566 restoreLayerState();
567 } else {
568 showMastershipFor(masterId);
569 }
570 }
571
572 function restoreLayerState() {
573 // NOTE: this level of indirection required, for when we have
574 // the layer filter functionality re-implemented
575 suppressLayers(false);
576 }
577
578 function showMastershipFor(id) {
579 suppressLayers(true);
580 node.each(function (n) {
581 if (n.master === id) {
Simon Hunt743a8492015-08-25 16:18:19 -0700582 n.el.classed('suppressedmax', false);
Simon Hunta142dd22015-02-12 22:07:51 -0800583 }
584 });
585 }
586
Simon Hunt743a8492015-08-25 16:18:19 -0700587 function supAmt(less) {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100588 return less ? 'suppressed' : 'suppressedmax';
Simon Hunt743a8492015-08-25 16:18:19 -0700589 }
590
591 function suppressLayers(b, less) {
592 var cls = supAmt(less);
593 node.classed(cls, b);
594 link.classed(cls, b);
595 }
596
597 function unsuppressNode(id, less) {
598 var cls = supAmt(less);
599 node.each(function (n) {
600 if (n.id === id) {
601 n.el.classed(cls, false);
602 }
603 });
604 }
605
Simon Hunt94f7dae2015-08-26 17:40:59 -0700606 function unsuppressLink(key, less) {
Simon Hunt743a8492015-08-25 16:18:19 -0700607 var cls = supAmt(less);
608 link.each(function (n) {
Simon Hunt94f7dae2015-08-26 17:40:59 -0700609 if (n.key === key) {
Simon Hunt743a8492015-08-25 16:18:19 -0700610 n.el.classed(cls, false);
611 }
612 });
Simon Hunta142dd22015-02-12 22:07:51 -0800613 }
Simon Hunt445e8152015-02-06 13:00:12 -0800614
Simon Hunt86b7c882015-04-02 23:06:08 -0700615 function showBadLinks() {
616 var badLinks = tms.findBadLinks();
Simon Hunte2d9dc72017-08-10 15:21:04 -0700617 flash.flash(topoLion('fl_bad_links') + ': ' + badLinks.length);
Simon Hunt86b7c882015-04-02 23:06:08 -0700618 $log.debug('Bad Link List (' + badLinks.length + '):');
619 badLinks.forEach(function (d) {
620 $log.debug('bad link: (' + d.bad + ') ' + d.key, d);
621 if (d.el) {
622 d.el.attr('stroke-width', linkScale(2.8))
623 .attr('stroke', 'red');
624 }
625 });
626 // back to normal after 2 seconds...
627 $timeout(updateLinks, 2000);
628 }
629
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800630 function deviceScale(scaleFactor) {
631 var scale = uplink.zoomer().scale() * scaleFactor,
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700632 dim = devIconDim,
633 multiplier = 1;
634
635 if (dim * scale < devIconDimMin) {
636 multiplier = devIconDimMin / (dim * scale);
637 } else if (dim * scale > devIconDimMax) {
638 multiplier = devIconDimMax / (dim * scale);
639 }
640
641 return multiplier;
642 }
643
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800644 function linkWidthScale() {
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700645 var scale = uplink.zoomer().scale();
646 return linkScale(widthRatio) / scale;
647 }
648
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800649 function portLabelScale() {
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700650 var scale = uplink.zoomer().scale();
651 return portLabelDim / (portLabelDim * scale);
652 }
653
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800654 function adjustNodeScale() {
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700655 // Scale the network nodes
656 _.each(network.nodes, function (node) {
657 if (node.class === 'host') {
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800658 node.el.selectAll('g').style('transform', 'scale(' + deviceScale(hostScaleFactor.icon) + ')');
659 node.el.selectAll('text').style('transform', 'scale(' + deviceScale(hostScaleFactor.text) + ')');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700660 return;
661 }
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800662 node.el.selectAll('*').style('transform', 'scale(' + deviceScale(1.0) + ')');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700663 });
664
665 // Scale the network links
666 _.each(network.links, function (link) {
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800667 link.el.style('stroke-width', linkWidthScale() + 'px');
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700668 });
669
670 d3.select('#topo-portLabels')
671 .selectAll('.portLabel')
672 .selectAll('*')
Thomas Vachuskac8c8f462021-03-01 11:22:56 -0800673 .style('transform', 'scale(' + portLabelScale() + ')');
674 }
675
676
677 function toggleScale(scale) {
678 if (scale < 0.5) {
679 return 1.0
680 }
681 return scale - 0.2;
682 }
683
684 function toggleHostTextSize() {
685 hostScaleFactor.text = toggleScale(hostScaleFactor.text);
686 adjustNodeScale();
687 }
688
689 function toggleHostIconSize() {
690 hostScaleFactor.icon = toggleScale(hostScaleFactor.icon);
691 adjustNodeScale();
Steven Burrowsf17f0ab2017-04-11 11:03:58 -0700692 }
693
Simon Huntfd7106c2016-02-09 15:05:26 -0800694 function resetAllLocations() {
695 tms.resetAllLocations();
696 updateNodes();
697 tick(); // force nodes to be redrawn in their new locations
Simon Hunte2d9dc72017-08-10 15:21:04 -0700698 flash.flash(topoLion('fl_reset_node_locations'));
Simon Huntfd7106c2016-02-09 15:05:26 -0800699 }
700
Simon Hunt5724fb42015-02-05 16:59:40 -0800701 // ==========================================
702
Simon Huntac4c6f72015-02-03 19:50:53 -0800703 function updateNodes() {
Thomas Vachuska1a989c12015-06-09 18:29:22 -0700704 if (fNodesTimer) {
705 $timeout.cancel(fNodesTimer);
706 }
707 fNodesTimer = $timeout(_updateNodes, 150);
708 }
709
Simon Hunta17fa672015-08-19 18:42:22 -0700710 // IMPLEMENTATION NOTE: _updateNodes() should NOT stop, start, or resume
711 // the force layout; that needs to be determined and implemented elsewhere
Thomas Vachuska1a989c12015-06-09 18:29:22 -0700712 function _updateNodes() {
Simon Hunt1894d792015-02-04 17:09:20 -0800713 // select all the nodes in the layout:
Simon Huntac4c6f72015-02-03 19:50:53 -0800714 node = nodeG.selectAll('.node')
715 .data(network.nodes, function (d) { return d.id; });
716
Simon Hunt1894d792015-02-04 17:09:20 -0800717 // operate on existing nodes:
Simon Hunta4242de2015-02-24 17:11:55 -0800718 node.filter('.device').each(td3.deviceExisting);
719 node.filter('.host').each(td3.hostExisting);
Simon Huntac4c6f72015-02-03 19:50:53 -0800720
721 // operate on entering nodes:
722 var entering = node.enter()
723 .append('g')
724 .attr({
725 id: function (d) { return sus.safeId(d.id); },
726 class: mkSvgClass,
Simon Hunta17fa672015-08-19 18:42:22 -0700727 transform: function (d) {
728 // Need to guard against NaN here ??
729 return sus.translate(d.x, d.y);
730 },
Steven Burrows1c2a9682017-07-14 16:52:46 +0100731 opacity: 0,
Simon Huntac4c6f72015-02-03 19:50:53 -0800732 })
733 .call(drag)
Simon Hunt08f841d02015-02-10 14:39:20 -0800734 .on('mouseover', tss.nodeMouseOver)
735 .on('mouseout', tss.nodeMouseOut)
Simon Huntac4c6f72015-02-03 19:50:53 -0800736 .transition()
737 .attr('opacity', 1);
738
Simon Hunt1894d792015-02-04 17:09:20 -0800739 // augment entering nodes:
Simon Hunta4242de2015-02-24 17:11:55 -0800740 entering.filter('.device').each(td3.deviceEnter);
741 entering.filter('.host').each(td3.hostEnter);
Simon Huntac4c6f72015-02-03 19:50:53 -0800742
Simon Hunt51056592015-02-03 21:48:07 -0800743 // operate on both existing and new nodes:
Simon Hunta4242de2015-02-24 17:11:55 -0800744 td3.updateDeviceColors();
Simon Huntac4c6f72015-02-03 19:50:53 -0800745
746 // operate on exiting nodes:
747 // Note that the node is removed after 2 seconds.
748 // Sub element animations should be shorter than 2 seconds.
749 var exiting = node.exit()
750 .transition()
751 .duration(2000)
752 .style('opacity', 0)
753 .remove();
754
Simon Hunt1894d792015-02-04 17:09:20 -0800755 // exiting node specifics:
Simon Hunta4242de2015-02-24 17:11:55 -0800756 exiting.filter('.host').each(td3.hostExit);
757 exiting.filter('.device').each(td3.deviceExit);
Thomas Vachuskac616e172018-04-17 16:57:12 -0700758 tick();
Simon Huntac4c6f72015-02-03 19:50:53 -0800759 }
760
Simon Hunt51056592015-02-03 21:48:07 -0800761 // ==========================
Simon Hunt1894d792015-02-04 17:09:20 -0800762
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700763 function getDefaultPos(link) {
764 return {
765 x1: link.source.x,
766 y1: link.source.y,
767 x2: link.target.x,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100768 y2: link.target.y,
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700769 };
770 }
771
772 // returns amount of adjustment along the normal for given link
773 function amt(numLinks, linkIdx) {
774 var gap = 6;
775 return (linkIdx - ((numLinks - 1) / 2)) * gap;
776 }
777
778 function calcMovement(d, amt, flipped) {
779 var pos = getDefaultPos(d),
780 mult = flipped ? -amt : amt,
781 dx = pos.x2 - pos.x1,
782 dy = pos.y2 - pos.y1,
783 length = Math.sqrt((dx * dx) + (dy * dy));
784
785 return {
786 x1: pos.x1 + (mult * dy / length),
787 y1: pos.y1 + (mult * -dx / length),
788 x2: pos.x2 + (mult * dy / length),
Steven Burrows1c2a9682017-07-14 16:52:46 +0100789 y2: pos.y2 + (mult * -dx / length),
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700790 };
791 }
792
793 function calcPosition() {
794 var lines = this,
795 linkSrcId;
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700796 linkNums = [];
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700797 lines.each(function (d) {
798 if (d.type() === 'hostLink') {
799 d.position = getDefaultPos(d);
800 }
801 });
802
803 function normalizeLinkSrc(link) {
804 // ensure source device is consistent across set of links
805 // temporary measure until link modeling is refactored
806 if (!linkSrcId) {
807 linkSrcId = link.source.id;
808 return false;
809 }
810
811 return link.source.id !== linkSrcId;
812 }
813
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700814 angular.forEach(network.linksByDevice, function (linkArr, key) {
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700815 var numLinks = linkArr.length,
816 link;
817
818 if (numLinks === 1) {
819 link = linkArr[0];
820 link.position = getDefaultPos(link);
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700821 link.position.multiLink = false;
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700822 } else if (numLinks >= 5) {
823 // this code is inefficient, in the future the way links
824 // are modeled will be changed
825 angular.forEach(linkArr, function (link) {
826 link.position = getDefaultPos(link);
827 link.position.multiLink = true;
828 });
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700829 linkNums.push({
830 id: key,
831 num: numLinks,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100832 linkCoords: linkArr[0].position,
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700833 });
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700834 } else {
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700835 linkSrcId = null;
836 angular.forEach(linkArr, function (link, index) {
837 var offsetAmt = amt(numLinks, index),
838 needToFlip = normalizeLinkSrc(link);
839 link.position = calcMovement(link, offsetAmt, needToFlip);
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700840 link.position.multiLink = false;
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700841 });
842 }
843 });
844 }
845
Simon Hunt1894d792015-02-04 17:09:20 -0800846 function updateLinks() {
Thomas Vachuska1a989c12015-06-09 18:29:22 -0700847 if (fLinksTimer) {
848 $timeout.cancel(fLinksTimer);
849 }
850 fLinksTimer = $timeout(_updateLinks, 150);
851 }
852
Simon Hunta17fa672015-08-19 18:42:22 -0700853 // IMPLEMENTATION NOTE: _updateLinks() should NOT stop, start, or resume
854 // the force layout; that needs to be determined and implemented elsewhere
Thomas Vachuska1a989c12015-06-09 18:29:22 -0700855 function _updateLinks() {
Simon Hunt1894d792015-02-04 17:09:20 -0800856 var th = ts.theme();
857
858 link = linkG.selectAll('.link')
859 .data(network.links, function (d) { return d.key; });
860
861 // operate on existing links:
Simon Huntd5264122015-02-25 10:17:43 -0800862 link.each(function (d) {
863 // this is supposed to be an existing link, but we have observed
864 // occasions (where links are deleted and added rapidly?) where
865 // the DOM element has not been defined. So protect against that...
866 if (d.el) {
867 restyleLinkElement(d, true);
868 }
869 });
Simon Hunt1894d792015-02-04 17:09:20 -0800870
871 // operate on entering links:
872 var entering = link.enter()
873 .append('line')
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700874 .call(calcPosition)
Simon Hunt1894d792015-02-04 17:09:20 -0800875 .attr({
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700876 x1: function (d) { return d.position.x1; },
877 y1: function (d) { return d.position.y1; },
878 x2: function (d) { return d.position.x2; },
879 y2: function (d) { return d.position.y2; },
Simon Hunt1894d792015-02-04 17:09:20 -0800880 stroke: linkConfig[th].inColor,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100881 'stroke-width': linkConfig.inWidth,
Simon Hunt1894d792015-02-04 17:09:20 -0800882 });
883
884 // augment links
Simon Hunta4242de2015-02-24 17:11:55 -0800885 entering.each(td3.linkEntering);
Simon Hunt1894d792015-02-04 17:09:20 -0800886
887 // operate on both existing and new links:
Steven Burrows1c2a9682017-07-14 16:52:46 +0100888 // link.each(...)
Simon Hunt1894d792015-02-04 17:09:20 -0800889
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700890 // add labels for how many links are in a thick line
891 td3.applyNumLinkLabels(linkNums, numLinkLblsG);
892
Simon Hunt1894d792015-02-04 17:09:20 -0800893 // apply or remove labels
Simon Hunta4242de2015-02-24 17:11:55 -0800894 td3.applyLinkLabels();
Simon Hunt1894d792015-02-04 17:09:20 -0800895
896 // operate on exiting links:
897 link.exit()
898 .attr('stroke-dasharray', '3 3')
Simon Hunt5724fb42015-02-05 16:59:40 -0800899 .attr('stroke', linkConfig[th].outColor)
Simon Hunt1894d792015-02-04 17:09:20 -0800900 .style('opacity', 0.5)
901 .transition()
902 .duration(1500)
903 .attr({
904 'stroke-dasharray': '3 12',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100905 'stroke-width': linkConfig.outWidth,
Simon Hunt1894d792015-02-04 17:09:20 -0800906 })
907 .style('opacity', 0.0)
908 .remove();
Simon Hunt1894d792015-02-04 17:09:20 -0800909 }
910
Simon Huntac4c6f72015-02-03 19:50:53 -0800911
912 // ==========================
Simon Hunt737c89f2015-01-28 12:23:19 -0800913 // force layout tick function
Simon Hunt737c89f2015-01-28 12:23:19 -0800914
Simon Hunt5724fb42015-02-05 16:59:40 -0800915 function fResume() {
Simon Huntc3c5b672015-02-20 11:32:13 -0800916 if (!tos.isOblique()) {
Simon Hunt5724fb42015-02-05 16:59:40 -0800917 force.resume();
918 }
919 }
920
921 function fStart() {
Simon Huntc3c5b672015-02-20 11:32:13 -0800922 if (!tos.isOblique()) {
Simon Hunta17fa672015-08-19 18:42:22 -0700923 if (fTimer) {
924 $timeout.cancel(fTimer);
925 }
926 fTimer = $timeout(function () {
Steven Burrows1c2a9682017-07-14 16:52:46 +0100927 $log.debug('Starting force-layout');
Simon Hunta17fa672015-08-19 18:42:22 -0700928 force.start();
929 }, 200);
Simon Hunt5724fb42015-02-05 16:59:40 -0800930 }
931 }
932
933 var tickStuff = {
934 nodeAttr: {
Simon Hunta17fa672015-08-19 18:42:22 -0700935 transform: function (d) {
936 var dx = isNaN(d.x) ? 0 : d.x,
937 dy = isNaN(d.y) ? 0 : d.y;
938 return sus.translate(dx, dy);
Steven Burrows1c2a9682017-07-14 16:52:46 +0100939 },
Simon Hunt5724fb42015-02-05 16:59:40 -0800940 },
941 linkAttr: {
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700942 x1: function (d) { return d.position.x1; },
943 y1: function (d) { return d.position.y1; },
944 x2: function (d) { return d.position.x2; },
Steven Burrows1c2a9682017-07-14 16:52:46 +0100945 y2: function (d) { return d.position.y2; },
Simon Hunt5724fb42015-02-05 16:59:40 -0800946 },
947 linkLabelAttr: {
948 transform: function (d) {
Simon Huntdc6adea2015-02-09 22:29:36 -0800949 var lnk = tms.findLinkById(d.key);
Simon Hunt5724fb42015-02-05 16:59:40 -0800950 if (lnk) {
Carmelo Casconed01eda62016-08-02 10:19:15 -0700951 return td3.transformLabel(lnk.position, d.key);
Simon Hunt5724fb42015-02-05 16:59:40 -0800952 }
Steven Burrows1c2a9682017-07-14 16:52:46 +0100953 },
954 },
Simon Hunt5724fb42015-02-05 16:59:40 -0800955 };
956
957 function tick() {
Simon Hunt3ab20282015-02-26 20:32:19 -0800958 // guard against null (which can happen when our view pages out)...
Bri Prebilic Cole8d003782015-07-31 15:33:06 -0700959 if (node && node.size()) {
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700960 node.attr(tickStuff.nodeAttr);
961 }
Bri Prebilic Cole8d003782015-07-31 15:33:06 -0700962 if (link && link.size()) {
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -0700963 link.call(calcPosition)
964 .attr(tickStuff.linkAttr);
Bri Prebilic Cole80401762015-07-16 11:36:18 -0700965 td3.applyNumLinkLabels(linkNums, numLinkLblsG);
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700966 }
Bri Prebilic Cole8d003782015-07-31 15:33:06 -0700967 if (linkLabel && linkLabel.size()) {
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -0700968 linkLabel.attr(tickStuff.linkLabelAttr);
969 }
Simon Hunt737c89f2015-01-28 12:23:19 -0800970 }
971
972
Simon Huntac4c6f72015-02-03 19:50:53 -0800973 // ==========================
974 // === MOUSE GESTURE HANDLERS
975
Simon Hunt205099e2015-02-07 13:12:01 -0800976 function zoomingOrPanning(ev) {
977 return ev.metaKey || ev.altKey;
Simon Hunt445e8152015-02-06 13:00:12 -0800978 }
979
980 function atDragEnd(d) {
981 // once we've finished moving, pin the node in position
982 d.fixed = true;
983 d3.select(this).classed('fixed', true);
984 sendUpdateMeta(d);
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700985 tss.clickConsumed(true);
Simon Hunt445e8152015-02-06 13:00:12 -0800986 }
987
988 // predicate that indicates when dragging is active
989 function dragEnabled() {
990 var ev = d3.event.sourceEvent;
991 // nodeLock means we aren't allowing nodes to be dragged...
Simon Hunt205099e2015-02-07 13:12:01 -0800992 return !nodeLock && !zoomingOrPanning(ev);
Simon Hunt445e8152015-02-06 13:00:12 -0800993 }
994
995 // predicate that indicates when clicking is active
996 function clickEnabled() {
997 return true;
998 }
Simon Hunt737c89f2015-01-28 12:23:19 -0800999
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001000 // =============================================
1001 // function entry points for overlay module
Simon Huntf542d842015-02-11 16:20:33 -08001002
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001003 // TODO: find an automatic way of tracking via the "showHighlights" events
Simon Hunte50829c2015-06-09 08:39:28 -07001004 var allTrafficClasses = 'primary secondary optical animated ' +
Simon Hunt21281fd2017-03-30 22:28:28 -07001005 'port-traffic-green port-traffic-yellow port-traffic-orange ' +
1006 'port-traffic-red';
Simon Huntf542d842015-02-11 16:20:33 -08001007
1008 function clearLinkTrafficStyle() {
1009 link.style('stroke-width', null)
1010 .classed(allTrafficClasses, false);
1011 }
1012
1013 function removeLinkLabels() {
1014 network.links.forEach(function (d) {
1015 d.label = '';
1016 });
1017 }
Simon Hunt737c89f2015-01-28 12:23:19 -08001018
Simon Hunte9343f32015-10-21 18:07:46 -07001019 function clearNodeDeco() {
1020 node.selectAll('g.badge').remove();
1021 }
1022
1023 function removeNodeBadges() {
1024 network.nodes.forEach(function (d) {
1025 d.badge = null;
1026 });
1027 }
1028
Simon Hunta4242de2015-02-24 17:11:55 -08001029 function updateLinkLabelModel() {
1030 // create the backing data for showing labels..
1031 var data = [];
1032 link.each(function (d) {
1033 if (d.label) {
1034 data.push({
1035 id: 'lab-' + d.key,
1036 key: d.key,
1037 label: d.label,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001038 ldata: d,
Simon Hunta4242de2015-02-24 17:11:55 -08001039 });
1040 }
1041 });
1042
1043 linkLabel = linkLabelG.selectAll('.linkLabel')
1044 .data(data, function (d) { return d.id; });
1045 }
1046
Simon Hunt737c89f2015-01-28 12:23:19 -08001047 // ==========================
Simon Huntac4c6f72015-02-03 19:50:53 -08001048 // Module definition
Simon Hunt737c89f2015-01-28 12:23:19 -08001049
Simon Huntdc6adea2015-02-09 22:29:36 -08001050 function mkModelApi(uplink) {
1051 return {
1052 projection: uplink.projection,
1053 network: network,
1054 restyleLinkElement: restyleLinkElement,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001055 removeLinkElement: removeLinkElement,
Simon Huntdc6adea2015-02-09 22:29:36 -08001056 };
1057 }
1058
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001059 function mkD3Api() {
Simon Hunta4242de2015-02-24 17:11:55 -08001060 return {
1061 node: function () { return node; },
1062 link: function () { return link; },
1063 linkLabel: function () { return linkLabel; },
1064 instVisible: function () { return tis.isVisible(); },
1065 posNode: tms.positionNode,
1066 showHosts: function () { return showHosts; },
1067 restyleLinkElement: restyleLinkElement,
Bri Prebilic Cole80401762015-07-16 11:36:18 -07001068 updateLinkLabelModel: updateLinkLabelModel,
Steven Burrowsf17f0ab2017-04-11 11:03:58 -07001069 linkConfig: function () { return linkConfig; },
1070 deviceScale: deviceScale,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001071 linkWidthScale: linkWidthScale,
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001072 };
Simon Hunta4242de2015-02-24 17:11:55 -08001073 }
1074
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001075 function mkSelectApi() {
Simon Hunt08f841d02015-02-10 14:39:20 -08001076 return {
1077 node: function () { return node; },
1078 zoomingOrPanning: zoomingOrPanning,
Simon Hunt0c6b2d32015-03-26 17:46:29 -07001079 updateDeviceColors: td3.updateDeviceColors,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001080 deselectAllLinks: tls.deselectAllLinks,
Simon Hunt08f841d02015-02-10 14:39:20 -08001081 };
1082 }
1083
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001084 function mkTrafficApi() {
1085 return {
1086 hovered: tss.hovered,
1087 somethingSelected: tss.somethingSelected,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001088 selectOrder: tss.selectOrder,
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001089 };
1090 }
1091
1092 function mkOverlayApi() {
Simon Huntf542d842015-02-11 16:20:33 -08001093 return {
Simon Hunte9343f32015-10-21 18:07:46 -07001094 clearNodeDeco: clearNodeDeco,
1095 removeNodeBadges: removeNodeBadges,
Simon Huntf542d842015-02-11 16:20:33 -08001096 clearLinkTrafficStyle: clearLinkTrafficStyle,
1097 removeLinkLabels: removeLinkLabels,
Simon Hunt743a8492015-08-25 16:18:19 -07001098 findLinkById: tms.findLinkById,
Simon Hunt94f7dae2015-08-26 17:40:59 -07001099 findNodeById: nodeById,
Simon Huntf542d842015-02-11 16:20:33 -08001100 updateLinks: updateLinks,
Simon Hunt743a8492015-08-25 16:18:19 -07001101 updateNodes: updateNodes,
1102 supLayers: suppressLayers,
1103 unsupNode: unsuppressNode,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001104 unsupLink: unsuppressLink,
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001105 };
Simon Huntf542d842015-02-11 16:20:33 -08001106 }
1107
Simon Huntc3c5b672015-02-20 11:32:13 -08001108 function mkObliqueApi(uplink, fltr) {
Simon Hunt96f88c62015-02-19 17:57:25 -08001109 return {
Steven Burrows1c2a9682017-07-14 16:52:46 +01001110 force: function () { return force; },
Simon Huntc3c5b672015-02-20 11:32:13 -08001111 zoomLayer: uplink.zoomLayer,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001112 nodeGBBox: function () { return nodeG.node().getBBox(); },
Simon Hunt96f88c62015-02-19 17:57:25 -08001113 node: function () { return node; },
Simon Huntc3c5b672015-02-20 11:32:13 -08001114 link: function () { return link; },
1115 linkLabel: function () { return linkLabel; },
1116 nodes: function () { return network.nodes; },
1117 tickStuff: tickStuff,
1118 nodeLock: function (b) {
1119 var old = nodeLock;
1120 nodeLock = b;
1121 return old;
1122 },
1123 opacifyMap: uplink.opacifyMap,
Bri Prebilic Cole038aedd2015-07-13 15:25:16 -07001124 inLayer: fltr.inLayer,
Bri Prebilic Cole80401762015-07-16 11:36:18 -07001125 calcLinkPos: calcPosition,
1126 applyNumLinkLabels: function () {
1127 td3.applyNumLinkLabels(linkNums, numLinkLblsG);
Steven Burrows1c2a9682017-07-14 16:52:46 +01001128 },
Simon Hunt96f88c62015-02-19 17:57:25 -08001129 };
1130 }
1131
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001132 function mkFilterApi() {
Simon Hunteb0fa052015-02-17 19:20:28 -08001133 return {
1134 node: function () { return node; },
Steven Burrows1c2a9682017-07-14 16:52:46 +01001135 link: function () { return link; },
Simon Hunteb0fa052015-02-17 19:20:28 -08001136 };
1137 }
1138
Simon Hunt9e2104c2015-02-26 10:48:59 -08001139 function mkLinkApi(svg, uplink) {
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001140 return {
1141 svg: svg,
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001142 zoomer: uplink.zoomer(),
1143 network: network,
Simon Hunt1a5301e2015-02-25 15:31:25 -08001144 portLabelG: function () { return portLabelG; },
Steven Burrows1c2a9682017-07-14 16:52:46 +01001145 showHosts: function () { return showHosts; },
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001146 };
1147 }
1148
Simon Huntf51bf462016-06-29 16:22:57 -07001149 function updateLinksAndNodes() {
1150 updateLinks();
1151 updateNodes();
1152 }
Steven Burrowsec1f45c2016-08-08 16:14:41 +01001153
Simon Hunte2d9dc72017-08-10 15:21:04 -07001154 // invoked after the localization bundle has been received from the server
1155 function setLionBundle(bundle) {
1156 topoLion = bundle;
1157 td3.setLionBundle(bundle);
1158 fltr.setLionBundle(bundle);
1159 tls.setLionBundle(bundle);
Simon Hunt1603c692017-08-10 19:53:35 -07001160 tos.setLionBundle(bundle);
1161 tov.setLionBundle(bundle);
Simon Huntcaed0412017-08-12 13:49:17 -07001162 tss.setLionBundle(bundle);
Simon Hunte2d9dc72017-08-10 15:21:04 -07001163 }
1164
Simon Hunt737c89f2015-01-28 12:23:19 -08001165 angular.module('ovTopo')
1166 .factory('TopoForceService',
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001167 ['$log', '$timeout', 'FnService', 'SvgUtilService',
Simon Hunt86b7c882015-04-02 23:06:08 -07001168 'ThemeService', 'FlashService', 'WebSocketService',
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001169 'TopoOverlayService', 'TopoInstService', 'TopoModelService',
Simon Hunta4242de2015-02-24 17:11:55 -08001170 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService',
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001171 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService',
Andrea Campanella732ea832017-02-06 09:25:59 -08001172 'TopoProtectedIntentsService',
Simon Hunt737c89f2015-01-28 12:23:19 -08001173
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001174 function (_$log_, _$timeout_, _fs_, _sus_, _ts_, _flash_, _wss_, _tov_,
Andrea Campanella732ea832017-02-06 09:25:59 -08001175 _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_, _tpis_) {
Simon Hunt737c89f2015-01-28 12:23:19 -08001176 $log = _$log_;
Simon Hunt86b7c882015-04-02 23:06:08 -07001177 $timeout = _$timeout_;
Simon Hunt1894d792015-02-04 17:09:20 -08001178 fs = _fs_;
Simon Hunt737c89f2015-01-28 12:23:19 -08001179 sus = _sus_;
Simon Huntac4c6f72015-02-03 19:50:53 -08001180 ts = _ts_;
Simon Hunt5724fb42015-02-05 16:59:40 -08001181 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -07001182 wss = _wss_;
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001183 tov = _tov_;
Simon Huntac4c6f72015-02-03 19:50:53 -08001184 tis = _tis_;
Simon Hunt3a6eec02015-02-09 21:16:43 -08001185 tms = _tms_;
Simon Hunta4242de2015-02-24 17:11:55 -08001186 td3 = _td3_;
Simon Hunt08f841d02015-02-10 14:39:20 -08001187 tss = _tss_;
Simon Huntf542d842015-02-11 16:20:33 -08001188 tts = _tts_;
Simon Hunt96f88c62015-02-19 17:57:25 -08001189 tos = _tos_;
Simon Hunteb0fa052015-02-17 19:20:28 -08001190 fltr = _fltr_;
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001191 tls = _tls_;
Andrea Campanella732ea832017-02-06 09:25:59 -08001192 tpis = _tpis_;
Simon Hunt737c89f2015-01-28 12:23:19 -08001193
Simon Huntf51bf462016-06-29 16:22:57 -07001194 ts.addListener(updateLinksAndNodes);
Simon Hunta142dd22015-02-12 22:07:51 -08001195
Simon Hunt737c89f2015-01-28 12:23:19 -08001196 // forceG is the SVG group to display the force layout in
Simon Huntdc6adea2015-02-09 22:29:36 -08001197 // uplink is the api from the main topo source file
Simon Hunt3a6eec02015-02-09 21:16:43 -08001198 // dim is the initial dimensions of the SVG as [w,h]
Simon Hunt737c89f2015-01-28 12:23:19 -08001199 // opts are, well, optional :)
Simon Hunt3ab20282015-02-26 20:32:19 -08001200 function initForce(_svg_, forceG, _uplink_, _dim_, opts) {
Simon Hunt1894d792015-02-04 17:09:20 -08001201 uplink = _uplink_;
Simon Hunt3a6eec02015-02-09 21:16:43 -08001202 dim = _dim_;
Simon Hunt3ab20282015-02-26 20:32:19 -08001203 svg = _svg_;
1204
1205 lu = network.lookup;
1206 rlk = network.revLinkToKey;
Simon Hunt3a6eec02015-02-09 21:16:43 -08001207
1208 $log.debug('initForce().. dim = ' + dim);
1209
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001210 tov.setApi(mkOverlayApi(), tss);
Simon Huntdc6adea2015-02-09 22:29:36 -08001211 tms.initModel(mkModelApi(uplink), dim);
Steven Burrowsf17f0ab2017-04-11 11:03:58 -07001212 td3.initD3(mkD3Api(), uplink.zoomer());
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001213 tss.initSelect(mkSelectApi());
1214 tts.initTraffic(mkTrafficApi());
Andrea Campanella732ea832017-02-06 09:25:59 -08001215 tpis.initProtectedIntents(mkTrafficApi());
Simon Huntc3c5b672015-02-20 11:32:13 -08001216 tos.initOblique(mkObliqueApi(uplink, fltr));
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001217 fltr.initFilter(mkFilterApi());
Simon Hunt9e2104c2015-02-26 10:48:59 -08001218 tls.initLink(mkLinkApi(svg, uplink), td3);
Simon Hunta11b4eb2015-01-28 16:20:50 -08001219
Simon Hunt737c89f2015-01-28 12:23:19 -08001220 settings = angular.extend({}, defaultSettings, opts);
1221
1222 linkG = forceG.append('g').attr('id', 'topo-links');
1223 linkLabelG = forceG.append('g').attr('id', 'topo-linkLabels');
Bri Prebilic Cole80401762015-07-16 11:36:18 -07001224 numLinkLblsG = forceG.append('g').attr('id', 'topo-numLinkLabels');
Simon Hunt737c89f2015-01-28 12:23:19 -08001225 nodeG = forceG.append('g').attr('id', 'topo-nodes');
Simon Hunt1a5301e2015-02-25 15:31:25 -08001226 portLabelG = forceG.append('g').attr('id', 'topo-portLabels');
Simon Hunt737c89f2015-01-28 12:23:19 -08001227
1228 link = linkG.selectAll('.link');
1229 linkLabel = linkLabelG.selectAll('.linkLabel');
1230 node = nodeG.selectAll('.node');
1231
1232 force = d3.layout.force()
Simon Hunt3a6eec02015-02-09 21:16:43 -08001233 .size(dim)
Simon Hunt737c89f2015-01-28 12:23:19 -08001234 .nodes(network.nodes)
1235 .links(network.links)
1236 .gravity(settings.gravity)
1237 .friction(settings.friction)
1238 .charge(settings.charge._def_)
1239 .linkDistance(settings.linkDistance._def_)
1240 .linkStrength(settings.linkStrength._def_)
1241 .on('tick', tick);
1242
1243 drag = sus.createDragBehavior(force,
Simon Hunt08f841d02015-02-10 14:39:20 -08001244 tss.selectObject, atDragEnd, dragEnabled, clickEnabled);
Simon Hunt737c89f2015-01-28 12:23:19 -08001245 }
1246
Simon Hunt3a6eec02015-02-09 21:16:43 -08001247 function newDim(_dim_) {
1248 dim = _dim_;
1249 force.size(dim);
1250 tms.newDim(dim);
Simon Hunt737c89f2015-01-28 12:23:19 -08001251 }
1252
Simon Hunt3a6eec02015-02-09 21:16:43 -08001253 function destroyForce() {
Simon Hunt3ab20282015-02-26 20:32:19 -08001254 force.stop();
1255
Simon Huntfb8ea1f2015-02-24 21:38:09 -08001256 tls.destroyLink();
Simon Hunt96f88c62015-02-19 17:57:25 -08001257 tos.destroyOblique();
Simon Huntf542d842015-02-11 16:20:33 -08001258 tts.destroyTraffic();
Andrea Campanella732ea832017-02-06 09:25:59 -08001259 tpis.destroyProtectedIntents();
Simon Huntf542d842015-02-11 16:20:33 -08001260 tss.destroySelect();
Simon Hunta4242de2015-02-24 17:11:55 -08001261 td3.destroyD3();
Simon Huntf542d842015-02-11 16:20:33 -08001262 tms.destroyModel();
Simon Hunt8d22c4b2015-08-06 16:24:43 -07001263 // note: no need to destroy overlay service
Simon Huntf51bf462016-06-29 16:22:57 -07001264 ts.removeListener(updateLinksAndNodes);
Simon Hunt3ab20282015-02-26 20:32:19 -08001265
1266 // clean up the DOM
1267 svg.selectAll('g').remove();
1268 svg.selectAll('defs').remove();
1269
1270 // clean up internal state
1271 network.nodes = [];
1272 network.links = [];
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001273 network.linksByDevice = {};
Simon Hunt3ab20282015-02-26 20:32:19 -08001274 network.lookup = {};
1275 network.revLinkToKey = {};
1276
Bri Prebilic Cole80401762015-07-16 11:36:18 -07001277 linkNums = [];
1278
1279 linkG = linkLabelG = numLinkLblsG = nodeG = portLabelG = null;
Simon Hunt3ab20282015-02-26 20:32:19 -08001280 link = linkLabel = node = null;
1281 force = drag = null;
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001282
1283 // clean up $timeout promises
Simon Hunta17fa672015-08-19 18:42:22 -07001284 if (fTimer) {
1285 $timeout.cancel(fTimer);
1286 }
Bri Prebilic Coleaeeb33e2015-07-09 15:15:54 -07001287 if (fNodesTimer) {
1288 $timeout.cancel(fNodesTimer);
1289 }
1290 if (fLinksTimer) {
1291 $timeout.cancel(fLinksTimer);
1292 }
Simon Hunt3a6eec02015-02-09 21:16:43 -08001293 }
1294
Simon Hunt737c89f2015-01-28 12:23:19 -08001295 return {
1296 initForce: initForce,
Simon Hunt3a6eec02015-02-09 21:16:43 -08001297 newDim: newDim,
1298 destroyForce: destroyForce,
Simon Huntac4c6f72015-02-03 19:50:53 -08001299
Simon Hunta4242de2015-02-24 17:11:55 -08001300 updateDeviceColors: td3.updateDeviceColors,
Simon Hunt5724fb42015-02-05 16:59:40 -08001301 toggleHosts: toggleHosts,
Simon Hunt9e2104c2015-02-26 10:48:59 -08001302 togglePorts: tls.togglePorts,
Simon Hunt5724fb42015-02-05 16:59:40 -08001303 toggleOffline: toggleOffline,
1304 cycleDeviceLabels: cycleDeviceLabels,
Simon Hunt10618f62017-06-15 19:30:52 -07001305 cycleHostLabels: cycleHostLabels,
Simon Hunt445e8152015-02-06 13:00:12 -08001306 unpin: unpin,
Simon Hunta142dd22015-02-12 22:07:51 -08001307 showMastership: showMastership,
Simon Hunt86b7c882015-04-02 23:06:08 -07001308 showBadLinks: showBadLinks,
Thomas Vachuskac8c8f462021-03-01 11:22:56 -08001309 adjustNodeScale: adjustNodeScale,
1310
1311 toggleHostTextSize: toggleHostTextSize,
1312 toggleHostIconSize: toggleHostIconSize,
Simon Huntac4c6f72015-02-03 19:50:53 -08001313
Simon Huntfd7106c2016-02-09 15:05:26 -08001314 resetAllLocations: resetAllLocations,
Simon Huntac4c6f72015-02-03 19:50:53 -08001315 addDevice: addDevice,
Simon Hunt1894d792015-02-04 17:09:20 -08001316 updateDevice: updateDevice,
1317 removeDevice: removeDevice,
1318 addHost: addHost,
1319 updateHost: updateHost,
Simon Hunt95d56fd2015-11-12 11:06:44 -08001320 moveHost: moveHost,
Simon Hunt1894d792015-02-04 17:09:20 -08001321 removeHost: removeHost,
1322 addLink: addLink,
1323 updateLink: updateLink,
Simon Hunt4a6b54b2015-10-27 22:08:25 -07001324 removeLink: removeLink,
Steven Burrows1c2a9682017-07-14 16:52:46 +01001325 topoStartDone: topoStartDone,
Simon Hunte2d9dc72017-08-10 15:21:04 -07001326
1327 setLionBundle: setLionBundle,
Simon Hunt737c89f2015-01-28 12:23:19 -08001328 };
1329 }]);
1330}());