Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 18 | ONOS GUI -- Topology Force Module. |
| 19 | Visualization of the topology in an SVG layer, using a D3 Force Layout. |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
| 25 | // injected refs |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 26 | var $log, $timeout, fs, sus, ts, flash, wss, tov, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 27 | tis, tms, td3, tss, tts, tos, fltr, tls, uplink, svg, tpis; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 28 | |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 29 | // function to be replaced by the localization bundle function |
| 30 | var topoLion = function (x) { |
| 31 | return '#tfs#' + x + '#'; |
| 32 | }; |
| 33 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 34 | // configuration |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 35 | var linkConfig = { |
| 36 | light: { |
Simon Hunt | f44d726 | 2016-06-14 14:46:56 -0700 | [diff] [blame] | 37 | baseColor: '#939598', |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 38 | inColor: '#66f', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 39 | outColor: '#f00', |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 40 | }, |
| 41 | dark: { |
Simon Hunt | f44d726 | 2016-06-14 14:46:56 -0700 | [diff] [blame] | 42 | // TODO : theme |
| 43 | baseColor: '#939598', |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 44 | inColor: '#66f', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 45 | outColor: '#f00', |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 46 | }, |
| 47 | inWidth: 12, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 48 | outWidth: 10, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 51 | // internal state |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 52 | var settings, // merged default settings and options |
| 53 | force, // force layout object |
| 54 | drag, // drag behavior handler |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 55 | network = { |
| 56 | nodes: [], |
| 57 | links: [], |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 58 | linksByDevice: {}, |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 59 | lookup: {}, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 60 | revLinkToKey: {}, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 61 | }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 62 | 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 |
| 74 | devIconDimMax = 40, // node maximum dimension when zoomed in |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 75 | portLabelDim = 30; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 76 | |
| 77 | // SVG elements; |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 78 | var linkG, linkLabelG, numLinkLblsG, portLabelG, nodeG; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 79 | |
| 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 Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 91 | _def_: -12000, |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 92 | }, |
| 93 | linkDistance: { |
| 94 | // note: key is link.type |
| 95 | direct: 100, |
| 96 | optical: 120, |
| 97 | hostLink: 3, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 98 | _def_: 50, |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 99 | }, |
| 100 | linkStrength: { |
| 101 | // note: key is link.type |
| 102 | // range: {0.0 ... 1.0} |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 103 | // direct: 1.0, |
| 104 | // optical: 1.0, |
| 105 | // hostLink: 1.0, |
| 106 | _def_: 1.0, |
| 107 | }, |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 111 | // ========================== |
| 112 | // === EVENT HANDLERS |
| 113 | |
| 114 | function addDevice(data) { |
| 115 | var id = data.id, |
| 116 | d; |
| 117 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 118 | uplink.showNoDevs(false); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 119 | |
| 120 | // although this is an add device event, if we already have the |
| 121 | // device, treat it as an update instead.. |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 122 | if (lu[id]) { |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 123 | updateDevice(data); |
| 124 | return; |
| 125 | } |
| 126 | |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 127 | d = tms.createDeviceNode(data); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 128 | network.nodes.push(d); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 129 | lu[id] = d; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 130 | updateNodes(); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 131 | fStart(); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | function updateDevice(data) { |
| 135 | var id = data.id, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 136 | d = lu[id], |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 137 | wasOnline; |
| 138 | |
| 139 | if (d) { |
| 140 | wasOnline = d.online; |
| 141 | angular.extend(d, data); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 142 | if (tms.positionNode(d, true)) { |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 143 | sendUpdateMeta(d); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 144 | } |
| 145 | updateNodes(); |
| 146 | if (wasOnline !== d.online) { |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 147 | tms.findAttachedLinks(d.id).forEach(restyleLinkElement); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 148 | updateOfflineVisibility(d); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 149 | } |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 153 | function removeDevice(data) { |
| 154 | var id = data.id, |
| 155 | d = lu[id]; |
| 156 | if (d) { |
| 157 | removeDeviceElement(d); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
| 161 | function addHost(data) { |
| 162 | var id = data.id, |
| 163 | d, lnk; |
| 164 | |
| 165 | // although this is an add host event, if we already have the |
| 166 | // host, treat it as an update instead.. |
| 167 | if (lu[id]) { |
| 168 | updateHost(data); |
| 169 | return; |
| 170 | } |
| 171 | |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 172 | d = tms.createHostNode(data); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 173 | network.nodes.push(d); |
| 174 | lu[id] = d; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 175 | updateNodes(); |
| 176 | |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 177 | lnk = tms.createHostLink(data); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 178 | if (lnk) { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 179 | d.linkData = lnk; // cache ref on its host |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 180 | network.links.push(lnk); |
| 181 | lu[d.ingress] = lnk; |
| 182 | lu[d.egress] = lnk; |
| 183 | updateLinks(); |
| 184 | } |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 185 | fStart(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | function updateHost(data) { |
| 189 | var id = data.id, |
| 190 | d = lu[id]; |
| 191 | if (d) { |
| 192 | angular.extend(d, data); |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 193 | if (tms.positionNode(d, true)) { |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 194 | sendUpdateMeta(d); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 195 | } |
| 196 | updateNodes(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | |
Simon Hunt | 95d56fd | 2015-11-12 11:06:44 -0800 | [diff] [blame] | 200 | function moveHost(data) { |
| 201 | var id = data.id, |
| 202 | d = lu[id], |
| 203 | lnk; |
| 204 | if (d) { |
| 205 | // first remove the old host link |
| 206 | removeLinkElement(d.linkData); |
| 207 | |
| 208 | // merge new data |
| 209 | angular.extend(d, data); |
| 210 | if (tms.positionNode(d, true)) { |
| 211 | sendUpdateMeta(d); |
| 212 | } |
| 213 | |
| 214 | // now create a new host link |
| 215 | lnk = tms.createHostLink(data); |
| 216 | if (lnk) { |
| 217 | d.linkData = lnk; |
| 218 | network.links.push(lnk); |
| 219 | lu[d.ingress] = lnk; |
| 220 | lu[d.egress] = lnk; |
| 221 | } |
| 222 | |
| 223 | updateNodes(); |
| 224 | updateLinks(); |
| 225 | fResume(); |
| 226 | } |
| 227 | } |
| 228 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 229 | function removeHost(data) { |
| 230 | var id = data.id, |
| 231 | d = lu[id]; |
| 232 | if (d) { |
| 233 | removeHostElement(d, true); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
| 237 | function addLink(data) { |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 238 | var result = tms.findLink(data, 'add'), |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 239 | bad = result.badLogic, |
| 240 | d = result.ldata; |
| 241 | |
| 242 | if (bad) { |
Simon Hunt | eb18f52 | 2016-01-28 19:22:23 -0800 | [diff] [blame] | 243 | $log.debug(bad + ': ' + link.id); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 244 | return; |
| 245 | } |
| 246 | |
| 247 | if (d) { |
| 248 | // we already have a backing store link for src/dst nodes |
| 249 | addLinkUpdate(d, data); |
| 250 | return; |
| 251 | } |
| 252 | |
| 253 | // no backing store link yet |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 254 | d = tms.createLink(data); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 255 | if (d) { |
| 256 | network.links.push(d); |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 257 | aggregateLink(d, data); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 258 | lu[d.key] = d; |
| 259 | updateLinks(); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 260 | fStart(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
| 264 | function updateLink(data) { |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 265 | var result = tms.findLink(data, 'update'), |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 266 | bad = result.badLogic; |
| 267 | if (bad) { |
Simon Hunt | eb18f52 | 2016-01-28 19:22:23 -0800 | [diff] [blame] | 268 | $log.debug(bad + ': ' + link.id); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 269 | return; |
| 270 | } |
Simon Hunt | eb18f52 | 2016-01-28 19:22:23 -0800 | [diff] [blame] | 271 | result.updateWith(data); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | function removeLink(data) { |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 275 | var result = tms.findLink(data, 'remove'); |
| 276 | |
| 277 | if (!result.badLogic) { |
| 278 | result.removeRawLink(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 279 | } |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 282 | function topoStartDone(data) { |
| 283 | // called when the initial barrage of data has been sent from server |
| 284 | uplink.topoStartDone(); |
| 285 | } |
| 286 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 287 | // ======================== |
| 288 | |
Simon Hunt | 94f7dae | 2015-08-26 17:40:59 -0700 | [diff] [blame] | 289 | function nodeById(id) { |
| 290 | return lu[id]; |
| 291 | } |
| 292 | |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 293 | function makeNodeKey(node1, node2) { |
| 294 | return node1 + '-' + node2; |
| 295 | } |
| 296 | |
| 297 | function findNodePair(key, keyRev) { |
| 298 | if (network.linksByDevice[key]) { |
| 299 | return key; |
| 300 | } else if (network.linksByDevice[keyRev]) { |
| 301 | return keyRev; |
| 302 | } else { |
| 303 | return false; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | function aggregateLink(ldata, link) { |
| 308 | var key = makeNodeKey(link.src, link.dst), |
| 309 | keyRev = makeNodeKey(link.dst, link.src), |
| 310 | found = findNodePair(key, keyRev); |
| 311 | |
| 312 | if (found) { |
| 313 | network.linksByDevice[found].push(ldata); |
| 314 | ldata.devicePair = found; |
| 315 | } else { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 316 | network.linksByDevice[key] = [ldata]; |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 317 | ldata.devicePair = key; |
| 318 | } |
| 319 | } |
| 320 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 321 | function addLinkUpdate(ldata, link) { |
| 322 | // add link event, but we already have the reverse link installed |
| 323 | ldata.fromTarget = link; |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 324 | rlk[link.id] = ldata.key; |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 325 | // possible solution to el being undefined in restyleLinkElement: |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 326 | // _updateLinks(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 327 | restyleLinkElement(ldata); |
| 328 | } |
| 329 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 330 | |
| 331 | var widthRatio = 1.4, |
| 332 | linkScale = d3.scale.linear() |
| 333 | .domain([1, 12]) |
| 334 | .range([widthRatio, 12 * widthRatio]) |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 335 | .clamp(true), |
Ray Milkey | b7f0f64 | 2016-01-22 16:08:14 -0800 | [diff] [blame] | 336 | allLinkTypes = 'direct indirect optical tunnel', |
| 337 | allLinkSubTypes = 'inactive not-permitted'; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 338 | |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 339 | function restyleLinkElement(ldata, immediate) { |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 340 | // this fn's job is to look at raw links and decide what svg classes |
| 341 | // need to be applied to the line element in the DOM |
| 342 | var th = ts.theme(), |
| 343 | el = ldata.el, |
| 344 | type = ldata.type(), |
| 345 | lw = ldata.linkWidth(), |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 346 | online = ldata.online(), |
Ray Milkey | b7f0f64 | 2016-01-22 16:08:14 -0800 | [diff] [blame] | 347 | modeCls = ldata.expected() ? 'inactive' : 'not-permitted', |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 348 | delay = immediate ? 0 : 1000; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 349 | |
Simon Hunt | f44d726 | 2016-06-14 14:46:56 -0700 | [diff] [blame] | 350 | // NOTE: understand why el is sometimes undefined on addLink events... |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 351 | // Investigated: |
| 352 | // el is undefined when it's a reverse link that is being added. |
| 353 | // updateLinks (which sets ldata.el) isn't called before this is called. |
| 354 | // Calling _updateLinks in addLinkUpdate fixes it, but there might be |
| 355 | // a more efficient way to fix it. |
| 356 | if (el && !el.empty()) { |
Thomas Vachuska | cb5016f | 2015-05-18 14:11:43 -0700 | [diff] [blame] | 357 | el.classed('link', true); |
Ray Milkey | b7f0f64 | 2016-01-22 16:08:14 -0800 | [diff] [blame] | 358 | el.classed(allLinkSubTypes, false); |
| 359 | el.classed(modeCls, !online); |
Thomas Vachuska | cb5016f | 2015-05-18 14:11:43 -0700 | [diff] [blame] | 360 | el.classed(allLinkTypes, false); |
| 361 | if (type) { |
| 362 | el.classed(type, true); |
| 363 | } |
| 364 | el.transition() |
| 365 | .duration(delay) |
| 366 | .attr('stroke-width', linkScale(lw)) |
| 367 | .attr('stroke', linkConfig[th].baseColor); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 368 | } |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 371 | function removeLinkElement(d) { |
| 372 | var idx = fs.find(d.key, network.links, 'key'), |
| 373 | removed; |
| 374 | if (idx >=0) { |
| 375 | // remove from links array |
| 376 | removed = network.links.splice(idx, 1); |
| 377 | // remove from lookup cache |
| 378 | delete lu[removed[0].key]; |
| 379 | updateLinks(); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 380 | fResume(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
| 384 | function removeHostElement(d, upd) { |
| 385 | // first, remove associated hostLink... |
| 386 | removeLinkElement(d.linkData); |
| 387 | |
| 388 | // remove hostLink bindings |
| 389 | delete lu[d.ingress]; |
| 390 | delete lu[d.egress]; |
| 391 | |
| 392 | // remove from lookup cache |
| 393 | delete lu[d.id]; |
| 394 | // remove from nodes array |
| 395 | var idx = fs.find(d.id, network.nodes); |
| 396 | network.nodes.splice(idx, 1); |
| 397 | |
| 398 | // remove from SVG |
| 399 | // NOTE: upd is false if we were called from removeDeviceElement() |
| 400 | if (upd) { |
| 401 | updateNodes(); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 402 | fResume(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | |
| 406 | function removeDeviceElement(d) { |
Bri Prebilic Cole | 8d00378 | 2015-07-31 15:33:06 -0700 | [diff] [blame] | 407 | var id = d.id, |
| 408 | idx; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 409 | // first, remove associated hosts and links.. |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 410 | tms.findAttachedHosts(id).forEach(removeHostElement); |
| 411 | tms.findAttachedLinks(id).forEach(removeLinkElement); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 412 | |
| 413 | // remove from lookup cache |
| 414 | delete lu[id]; |
| 415 | // remove from nodes array |
Bri Prebilic Cole | 8d00378 | 2015-07-31 15:33:06 -0700 | [diff] [blame] | 416 | idx = fs.find(id, network.nodes); |
| 417 | if (idx > -1) { |
| 418 | network.nodes.splice(idx, 1); |
| 419 | } |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 420 | |
| 421 | if (!network.nodes.length) { |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 422 | uplink.showNoDevs(true); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | // remove from SVG |
| 426 | updateNodes(); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 427 | fResume(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 428 | } |
| 429 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 430 | function updateHostVisibility() { |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 431 | sus.visible(nodeG.selectAll('.host'), showHosts); |
| 432 | sus.visible(linkG.selectAll('.hostLink'), showHosts); |
Simon Hunt | 8eb4d3a | 2015-02-23 18:23:29 -0800 | [diff] [blame] | 433 | sus.visible(linkLabelG.selectAll('.hostLinkLabel'), showHosts); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | function updateOfflineVisibility(dev) { |
| 437 | function updDev(d, show) { |
Simon Hunt | 8eb4d3a | 2015-02-23 18:23:29 -0800 | [diff] [blame] | 438 | var b; |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 439 | sus.visible(d.el, show); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 440 | |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 441 | tms.findAttachedLinks(d.id).forEach(function (link) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 442 | b = show && ((link.type() !== 'hostLink') || showHosts); |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 443 | sus.visible(link.el, b); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 444 | }); |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 445 | tms.findAttachedHosts(d.id).forEach(function (host) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 446 | b = show && showHosts; |
Simon Hunt | 18bf982 | 2015-02-12 17:35:45 -0800 | [diff] [blame] | 447 | sus.visible(host.el, b); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 448 | }); |
| 449 | } |
| 450 | |
| 451 | if (dev) { |
| 452 | // updating a specific device that just toggled off/on-line |
| 453 | updDev(dev, dev.online || showOffline); |
| 454 | } else { |
| 455 | // updating all offline devices |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 456 | tms.findDevices(true).forEach(function (d) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 457 | updDev(d, showOffline); |
| 458 | }); |
| 459 | } |
| 460 | } |
| 461 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 462 | |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 463 | function sendUpdateMeta(d, clearPos) { |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 464 | var metaUi = {}, |
| 465 | ll; |
| 466 | |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 467 | // if we are not clearing the position data (unpinning), |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 468 | // attach the x, y, (and equivalent longitude, latitude)... |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 469 | if (!clearPos) { |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 470 | ll = tms.lngLatFromCoord([d.x, d.y]); |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 471 | metaUi = { |
| 472 | x: d.x, |
| 473 | y: d.y, |
| 474 | equivLoc: { |
| 475 | lng: ll[0], |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 476 | lat: ll[1], |
| 477 | }, |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 478 | }; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 479 | } |
| 480 | d.metaUi = metaUi; |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 481 | wss.sendEvent('updateMeta', { |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 482 | id: d.id, |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 483 | class: d.class, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 484 | memento: metaUi, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 485 | }); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 488 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 489 | function mkSvgClass(d) { |
| 490 | return d.fixed ? d.svgClass + ' fixed' : d.svgClass; |
| 491 | } |
| 492 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 493 | function vis(b) { |
Simon Hunt | 1603c69 | 2017-08-10 19:53:35 -0700 | [diff] [blame] | 494 | return topoLion(b ? 'visible' : 'hidden'); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 495 | } |
| 496 | |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 497 | function toggleHosts(x) { |
| 498 | var kev = (x === 'keyev'), |
| 499 | on = kev ? !showHosts : !!x; |
| 500 | |
| 501 | showHosts = on; |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 502 | updateHostVisibility(); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 503 | flash.flash(topoLion('hosts') + ' ' + vis(on)); |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 504 | return on; |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 505 | } |
| 506 | |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 507 | function toggleOffline(x) { |
| 508 | var kev = (x === 'keyev'), |
| 509 | on = kev ? !showOffline : !!x; |
| 510 | |
| 511 | showOffline = on; |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 512 | updateOfflineVisibility(); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 513 | flash.flash(topoLion('fl_offline_devices') + ' ' + vis(on)); |
Simon Hunt | fcbde89 | 2015-04-16 12:05:28 -0700 | [diff] [blame] | 514 | return on; |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | function cycleDeviceLabels() { |
Bri Prebilic Cole | 9cf1a8d | 2015-04-21 13:15:29 -0700 | [diff] [blame] | 518 | flash.flash(td3.incDevLabIndex()); |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 519 | tms.findDevices().forEach(function (d) { |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 520 | td3.updateDeviceLabel(d); |
Simon Hunt | 1c36711 | 2015-02-05 18:02:46 -0800 | [diff] [blame] | 521 | }); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 522 | } |
| 523 | |
Simon Hunt | 10618f6 | 2017-06-15 19:30:52 -0700 | [diff] [blame] | 524 | function cycleHostLabels() { |
| 525 | flash.flash(td3.incHostLabIndex()); |
| 526 | tms.findHosts().forEach(function (d) { |
| 527 | td3.updateHostLabel(d); |
| 528 | }); |
| 529 | } |
| 530 | |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 531 | function unpin() { |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 532 | var hov = tss.hovered(); |
| 533 | if (hov) { |
| 534 | sendUpdateMeta(hov, true); |
| 535 | hov.fixed = false; |
| 536 | hov.el.classed('fixed', false); |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 537 | fResume(); |
| 538 | } |
| 539 | } |
| 540 | |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 541 | function showMastership(masterId) { |
| 542 | if (!masterId) { |
| 543 | restoreLayerState(); |
| 544 | } else { |
| 545 | showMastershipFor(masterId); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | function restoreLayerState() { |
| 550 | // NOTE: this level of indirection required, for when we have |
| 551 | // the layer filter functionality re-implemented |
| 552 | suppressLayers(false); |
| 553 | } |
| 554 | |
| 555 | function showMastershipFor(id) { |
| 556 | suppressLayers(true); |
| 557 | node.each(function (n) { |
| 558 | if (n.master === id) { |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 559 | n.el.classed('suppressedmax', false); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 560 | } |
| 561 | }); |
| 562 | } |
| 563 | |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 564 | function supAmt(less) { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 565 | return less ? 'suppressed' : 'suppressedmax'; |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | function suppressLayers(b, less) { |
| 569 | var cls = supAmt(less); |
| 570 | node.classed(cls, b); |
| 571 | link.classed(cls, b); |
| 572 | } |
| 573 | |
| 574 | function unsuppressNode(id, less) { |
| 575 | var cls = supAmt(less); |
| 576 | node.each(function (n) { |
| 577 | if (n.id === id) { |
| 578 | n.el.classed(cls, false); |
| 579 | } |
| 580 | }); |
| 581 | } |
| 582 | |
Simon Hunt | 94f7dae | 2015-08-26 17:40:59 -0700 | [diff] [blame] | 583 | function unsuppressLink(key, less) { |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 584 | var cls = supAmt(less); |
| 585 | link.each(function (n) { |
Simon Hunt | 94f7dae | 2015-08-26 17:40:59 -0700 | [diff] [blame] | 586 | if (n.key === key) { |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 587 | n.el.classed(cls, false); |
| 588 | } |
| 589 | }); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 590 | } |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 591 | |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 592 | function showBadLinks() { |
| 593 | var badLinks = tms.findBadLinks(); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 594 | flash.flash(topoLion('fl_bad_links') + ': ' + badLinks.length); |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 595 | $log.debug('Bad Link List (' + badLinks.length + '):'); |
| 596 | badLinks.forEach(function (d) { |
| 597 | $log.debug('bad link: (' + d.bad + ') ' + d.key, d); |
| 598 | if (d.el) { |
| 599 | d.el.attr('stroke-width', linkScale(2.8)) |
| 600 | .attr('stroke', 'red'); |
| 601 | } |
| 602 | }); |
| 603 | // back to normal after 2 seconds... |
| 604 | $timeout(updateLinks, 2000); |
| 605 | } |
| 606 | |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 607 | function deviceScale() { |
| 608 | var scale = uplink.zoomer().scale(), |
| 609 | dim = devIconDim, |
| 610 | multiplier = 1; |
| 611 | |
| 612 | if (dim * scale < devIconDimMin) { |
| 613 | multiplier = devIconDimMin / (dim * scale); |
| 614 | } else if (dim * scale > devIconDimMax) { |
| 615 | multiplier = devIconDimMax / (dim * scale); |
| 616 | } |
| 617 | |
| 618 | return multiplier; |
| 619 | } |
| 620 | |
| 621 | function linkWidthScale(scale) { |
| 622 | var scale = uplink.zoomer().scale(); |
| 623 | return linkScale(widthRatio) / scale; |
| 624 | } |
| 625 | |
| 626 | function portLabelScale(scale) { |
| 627 | var scale = uplink.zoomer().scale(); |
| 628 | return portLabelDim / (portLabelDim * scale); |
| 629 | } |
| 630 | |
| 631 | function setNodeScale(scale) { |
| 632 | // Scale the network nodes |
| 633 | _.each(network.nodes, function (node) { |
| 634 | if (node.class === 'host') { |
| 635 | node.el.selectAll('g').style('transform', 'scale(' + deviceScale(scale) + ')'); |
| 636 | node.el.selectAll('text').style('transform', 'scale(' + deviceScale(scale) + ')'); |
| 637 | return; |
| 638 | } |
| 639 | node.el.selectAll('*') |
| 640 | .style('transform', 'scale(' + deviceScale(scale) + ')'); |
| 641 | }); |
| 642 | |
| 643 | // Scale the network links |
| 644 | _.each(network.links, function (link) { |
| 645 | link.el.style('stroke-width', linkWidthScale(scale) + 'px'); |
| 646 | }); |
| 647 | |
| 648 | d3.select('#topo-portLabels') |
| 649 | .selectAll('.portLabel') |
| 650 | .selectAll('*') |
| 651 | .style('transform', 'scale(' + portLabelScale(scale) + ')'); |
| 652 | } |
| 653 | |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 654 | function resetAllLocations() { |
| 655 | tms.resetAllLocations(); |
| 656 | updateNodes(); |
| 657 | tick(); // force nodes to be redrawn in their new locations |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 658 | flash.flash(topoLion('fl_reset_node_locations')); |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 659 | } |
| 660 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 661 | // ========================================== |
| 662 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 663 | function updateNodes() { |
Thomas Vachuska | 1a989c1 | 2015-06-09 18:29:22 -0700 | [diff] [blame] | 664 | if (fNodesTimer) { |
| 665 | $timeout.cancel(fNodesTimer); |
| 666 | } |
| 667 | fNodesTimer = $timeout(_updateNodes, 150); |
| 668 | } |
| 669 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 670 | // IMPLEMENTATION NOTE: _updateNodes() should NOT stop, start, or resume |
| 671 | // the force layout; that needs to be determined and implemented elsewhere |
Thomas Vachuska | 1a989c1 | 2015-06-09 18:29:22 -0700 | [diff] [blame] | 672 | function _updateNodes() { |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 673 | // select all the nodes in the layout: |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 674 | node = nodeG.selectAll('.node') |
| 675 | .data(network.nodes, function (d) { return d.id; }); |
| 676 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 677 | // operate on existing nodes: |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 678 | node.filter('.device').each(td3.deviceExisting); |
| 679 | node.filter('.host').each(td3.hostExisting); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 680 | |
| 681 | // operate on entering nodes: |
| 682 | var entering = node.enter() |
| 683 | .append('g') |
| 684 | .attr({ |
| 685 | id: function (d) { return sus.safeId(d.id); }, |
| 686 | class: mkSvgClass, |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 687 | transform: function (d) { |
| 688 | // Need to guard against NaN here ?? |
| 689 | return sus.translate(d.x, d.y); |
| 690 | }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 691 | opacity: 0, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 692 | }) |
| 693 | .call(drag) |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 694 | .on('mouseover', tss.nodeMouseOver) |
| 695 | .on('mouseout', tss.nodeMouseOut) |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 696 | .transition() |
| 697 | .attr('opacity', 1); |
| 698 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 699 | // augment entering nodes: |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 700 | entering.filter('.device').each(td3.deviceEnter); |
| 701 | entering.filter('.host').each(td3.hostEnter); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 702 | |
Simon Hunt | 5105659 | 2015-02-03 21:48:07 -0800 | [diff] [blame] | 703 | // operate on both existing and new nodes: |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 704 | td3.updateDeviceColors(); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 705 | |
| 706 | // operate on exiting nodes: |
| 707 | // Note that the node is removed after 2 seconds. |
| 708 | // Sub element animations should be shorter than 2 seconds. |
| 709 | var exiting = node.exit() |
| 710 | .transition() |
| 711 | .duration(2000) |
| 712 | .style('opacity', 0) |
| 713 | .remove(); |
| 714 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 715 | // exiting node specifics: |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 716 | exiting.filter('.host').each(td3.hostExit); |
| 717 | exiting.filter('.device').each(td3.deviceExit); |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 718 | } |
| 719 | |
Simon Hunt | 5105659 | 2015-02-03 21:48:07 -0800 | [diff] [blame] | 720 | // ========================== |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 721 | |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 722 | function getDefaultPos(link) { |
| 723 | return { |
| 724 | x1: link.source.x, |
| 725 | y1: link.source.y, |
| 726 | x2: link.target.x, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 727 | y2: link.target.y, |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 728 | }; |
| 729 | } |
| 730 | |
| 731 | // returns amount of adjustment along the normal for given link |
| 732 | function amt(numLinks, linkIdx) { |
| 733 | var gap = 6; |
| 734 | return (linkIdx - ((numLinks - 1) / 2)) * gap; |
| 735 | } |
| 736 | |
| 737 | function calcMovement(d, amt, flipped) { |
| 738 | var pos = getDefaultPos(d), |
| 739 | mult = flipped ? -amt : amt, |
| 740 | dx = pos.x2 - pos.x1, |
| 741 | dy = pos.y2 - pos.y1, |
| 742 | length = Math.sqrt((dx * dx) + (dy * dy)); |
| 743 | |
| 744 | return { |
| 745 | x1: pos.x1 + (mult * dy / length), |
| 746 | y1: pos.y1 + (mult * -dx / length), |
| 747 | x2: pos.x2 + (mult * dy / length), |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 748 | y2: pos.y2 + (mult * -dx / length), |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 749 | }; |
| 750 | } |
| 751 | |
| 752 | function calcPosition() { |
| 753 | var lines = this, |
| 754 | linkSrcId; |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 755 | linkNums = []; |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 756 | lines.each(function (d) { |
| 757 | if (d.type() === 'hostLink') { |
| 758 | d.position = getDefaultPos(d); |
| 759 | } |
| 760 | }); |
| 761 | |
| 762 | function normalizeLinkSrc(link) { |
| 763 | // ensure source device is consistent across set of links |
| 764 | // temporary measure until link modeling is refactored |
| 765 | if (!linkSrcId) { |
| 766 | linkSrcId = link.source.id; |
| 767 | return false; |
| 768 | } |
| 769 | |
| 770 | return link.source.id !== linkSrcId; |
| 771 | } |
| 772 | |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 773 | angular.forEach(network.linksByDevice, function (linkArr, key) { |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 774 | var numLinks = linkArr.length, |
| 775 | link; |
| 776 | |
| 777 | if (numLinks === 1) { |
| 778 | link = linkArr[0]; |
| 779 | link.position = getDefaultPos(link); |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 780 | link.position.multiLink = false; |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 781 | } else if (numLinks >= 5) { |
| 782 | // this code is inefficient, in the future the way links |
| 783 | // are modeled will be changed |
| 784 | angular.forEach(linkArr, function (link) { |
| 785 | link.position = getDefaultPos(link); |
| 786 | link.position.multiLink = true; |
| 787 | }); |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 788 | linkNums.push({ |
| 789 | id: key, |
| 790 | num: numLinks, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 791 | linkCoords: linkArr[0].position, |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 792 | }); |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 793 | } else { |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 794 | linkSrcId = null; |
| 795 | angular.forEach(linkArr, function (link, index) { |
| 796 | var offsetAmt = amt(numLinks, index), |
| 797 | needToFlip = normalizeLinkSrc(link); |
| 798 | link.position = calcMovement(link, offsetAmt, needToFlip); |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 799 | link.position.multiLink = false; |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 800 | }); |
| 801 | } |
| 802 | }); |
| 803 | } |
| 804 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 805 | function updateLinks() { |
Thomas Vachuska | 1a989c1 | 2015-06-09 18:29:22 -0700 | [diff] [blame] | 806 | if (fLinksTimer) { |
| 807 | $timeout.cancel(fLinksTimer); |
| 808 | } |
| 809 | fLinksTimer = $timeout(_updateLinks, 150); |
| 810 | } |
| 811 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 812 | // IMPLEMENTATION NOTE: _updateLinks() should NOT stop, start, or resume |
| 813 | // the force layout; that needs to be determined and implemented elsewhere |
Thomas Vachuska | 1a989c1 | 2015-06-09 18:29:22 -0700 | [diff] [blame] | 814 | function _updateLinks() { |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 815 | var th = ts.theme(); |
| 816 | |
| 817 | link = linkG.selectAll('.link') |
| 818 | .data(network.links, function (d) { return d.key; }); |
| 819 | |
| 820 | // operate on existing links: |
Simon Hunt | d526412 | 2015-02-25 10:17:43 -0800 | [diff] [blame] | 821 | link.each(function (d) { |
| 822 | // this is supposed to be an existing link, but we have observed |
| 823 | // occasions (where links are deleted and added rapidly?) where |
| 824 | // the DOM element has not been defined. So protect against that... |
| 825 | if (d.el) { |
| 826 | restyleLinkElement(d, true); |
| 827 | } |
| 828 | }); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 829 | |
| 830 | // operate on entering links: |
| 831 | var entering = link.enter() |
| 832 | .append('line') |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 833 | .call(calcPosition) |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 834 | .attr({ |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 835 | x1: function (d) { return d.position.x1; }, |
| 836 | y1: function (d) { return d.position.y1; }, |
| 837 | x2: function (d) { return d.position.x2; }, |
| 838 | y2: function (d) { return d.position.y2; }, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 839 | stroke: linkConfig[th].inColor, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 840 | 'stroke-width': linkConfig.inWidth, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 841 | }); |
| 842 | |
| 843 | // augment links |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 844 | entering.each(td3.linkEntering); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 845 | |
| 846 | // operate on both existing and new links: |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 847 | // link.each(...) |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 848 | |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 849 | // add labels for how many links are in a thick line |
| 850 | td3.applyNumLinkLabels(linkNums, numLinkLblsG); |
| 851 | |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 852 | // apply or remove labels |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 853 | td3.applyLinkLabels(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 854 | |
| 855 | // operate on exiting links: |
| 856 | link.exit() |
| 857 | .attr('stroke-dasharray', '3 3') |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 858 | .attr('stroke', linkConfig[th].outColor) |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 859 | .style('opacity', 0.5) |
| 860 | .transition() |
| 861 | .duration(1500) |
| 862 | .attr({ |
| 863 | 'stroke-dasharray': '3 12', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 864 | 'stroke-width': linkConfig.outWidth, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 865 | }) |
| 866 | .style('opacity', 0.0) |
| 867 | .remove(); |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 868 | } |
| 869 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 870 | |
| 871 | // ========================== |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 872 | // force layout tick function |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 873 | |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 874 | function fResume() { |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 875 | if (!tos.isOblique()) { |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 876 | force.resume(); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | function fStart() { |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 881 | if (!tos.isOblique()) { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 882 | if (fTimer) { |
| 883 | $timeout.cancel(fTimer); |
| 884 | } |
| 885 | fTimer = $timeout(function () { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 886 | $log.debug('Starting force-layout'); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 887 | force.start(); |
| 888 | }, 200); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 889 | } |
| 890 | } |
| 891 | |
| 892 | var tickStuff = { |
| 893 | nodeAttr: { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 894 | transform: function (d) { |
| 895 | var dx = isNaN(d.x) ? 0 : d.x, |
| 896 | dy = isNaN(d.y) ? 0 : d.y; |
| 897 | return sus.translate(dx, dy); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 898 | }, |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 899 | }, |
| 900 | linkAttr: { |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 901 | x1: function (d) { return d.position.x1; }, |
| 902 | y1: function (d) { return d.position.y1; }, |
| 903 | x2: function (d) { return d.position.x2; }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 904 | y2: function (d) { return d.position.y2; }, |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 905 | }, |
| 906 | linkLabelAttr: { |
| 907 | transform: function (d) { |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 908 | var lnk = tms.findLinkById(d.key); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 909 | if (lnk) { |
Carmelo Cascone | d01eda6 | 2016-08-02 10:19:15 -0700 | [diff] [blame] | 910 | return td3.transformLabel(lnk.position, d.key); |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 911 | } |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 912 | }, |
| 913 | }, |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 914 | }; |
| 915 | |
| 916 | function tick() { |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 917 | // guard against null (which can happen when our view pages out)... |
Bri Prebilic Cole | 8d00378 | 2015-07-31 15:33:06 -0700 | [diff] [blame] | 918 | if (node && node.size()) { |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 919 | node.attr(tickStuff.nodeAttr); |
| 920 | } |
Bri Prebilic Cole | 8d00378 | 2015-07-31 15:33:06 -0700 | [diff] [blame] | 921 | if (link && link.size()) { |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 922 | link.call(calcPosition) |
| 923 | .attr(tickStuff.linkAttr); |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 924 | td3.applyNumLinkLabels(linkNums, numLinkLblsG); |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 925 | } |
Bri Prebilic Cole | 8d00378 | 2015-07-31 15:33:06 -0700 | [diff] [blame] | 926 | if (linkLabel && linkLabel.size()) { |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 927 | linkLabel.attr(tickStuff.linkLabelAttr); |
| 928 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 932 | // ========================== |
| 933 | // === MOUSE GESTURE HANDLERS |
| 934 | |
Simon Hunt | 205099e | 2015-02-07 13:12:01 -0800 | [diff] [blame] | 935 | function zoomingOrPanning(ev) { |
| 936 | return ev.metaKey || ev.altKey; |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | function atDragEnd(d) { |
| 940 | // once we've finished moving, pin the node in position |
| 941 | d.fixed = true; |
| 942 | d3.select(this).classed('fixed', true); |
| 943 | sendUpdateMeta(d); |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 944 | tss.clickConsumed(true); |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | // predicate that indicates when dragging is active |
| 948 | function dragEnabled() { |
| 949 | var ev = d3.event.sourceEvent; |
| 950 | // nodeLock means we aren't allowing nodes to be dragged... |
Simon Hunt | 205099e | 2015-02-07 13:12:01 -0800 | [diff] [blame] | 951 | return !nodeLock && !zoomingOrPanning(ev); |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | // predicate that indicates when clicking is active |
| 955 | function clickEnabled() { |
| 956 | return true; |
| 957 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 958 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 959 | // ============================================= |
| 960 | // function entry points for overlay module |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 961 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 962 | // TODO: find an automatic way of tracking via the "showHighlights" events |
Simon Hunt | e50829c | 2015-06-09 08:39:28 -0700 | [diff] [blame] | 963 | var allTrafficClasses = 'primary secondary optical animated ' + |
Simon Hunt | 21281fd | 2017-03-30 22:28:28 -0700 | [diff] [blame] | 964 | 'port-traffic-green port-traffic-yellow port-traffic-orange ' + |
| 965 | 'port-traffic-red'; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 966 | |
| 967 | function clearLinkTrafficStyle() { |
| 968 | link.style('stroke-width', null) |
| 969 | .classed(allTrafficClasses, false); |
| 970 | } |
| 971 | |
| 972 | function removeLinkLabels() { |
| 973 | network.links.forEach(function (d) { |
| 974 | d.label = ''; |
| 975 | }); |
| 976 | } |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 977 | |
Simon Hunt | e9343f3 | 2015-10-21 18:07:46 -0700 | [diff] [blame] | 978 | function clearNodeDeco() { |
| 979 | node.selectAll('g.badge').remove(); |
| 980 | } |
| 981 | |
| 982 | function removeNodeBadges() { |
| 983 | network.nodes.forEach(function (d) { |
| 984 | d.badge = null; |
| 985 | }); |
| 986 | } |
| 987 | |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 988 | function updateLinkLabelModel() { |
| 989 | // create the backing data for showing labels.. |
| 990 | var data = []; |
| 991 | link.each(function (d) { |
| 992 | if (d.label) { |
| 993 | data.push({ |
| 994 | id: 'lab-' + d.key, |
| 995 | key: d.key, |
| 996 | label: d.label, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 997 | ldata: d, |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 998 | }); |
| 999 | } |
| 1000 | }); |
| 1001 | |
| 1002 | linkLabel = linkLabelG.selectAll('.linkLabel') |
| 1003 | .data(data, function (d) { return d.id; }); |
| 1004 | } |
| 1005 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1006 | // ========================== |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1007 | // Module definition |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1008 | |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 1009 | function mkModelApi(uplink) { |
| 1010 | return { |
| 1011 | projection: uplink.projection, |
| 1012 | network: network, |
| 1013 | restyleLinkElement: restyleLinkElement, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1014 | removeLinkElement: removeLinkElement, |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 1015 | }; |
| 1016 | } |
| 1017 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1018 | function mkD3Api() { |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1019 | return { |
| 1020 | node: function () { return node; }, |
| 1021 | link: function () { return link; }, |
| 1022 | linkLabel: function () { return linkLabel; }, |
| 1023 | instVisible: function () { return tis.isVisible(); }, |
| 1024 | posNode: tms.positionNode, |
| 1025 | showHosts: function () { return showHosts; }, |
| 1026 | restyleLinkElement: restyleLinkElement, |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 1027 | updateLinkLabelModel: updateLinkLabelModel, |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 1028 | linkConfig: function () { return linkConfig; }, |
| 1029 | deviceScale: deviceScale, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1030 | linkWidthScale: linkWidthScale, |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1031 | }; |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1032 | } |
| 1033 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1034 | function mkSelectApi() { |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 1035 | return { |
| 1036 | node: function () { return node; }, |
| 1037 | zoomingOrPanning: zoomingOrPanning, |
Simon Hunt | 0c6b2d3 | 2015-03-26 17:46:29 -0700 | [diff] [blame] | 1038 | updateDeviceColors: td3.updateDeviceColors, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1039 | deselectAllLinks: tls.deselectAllLinks, |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 1040 | }; |
| 1041 | } |
| 1042 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1043 | function mkTrafficApi() { |
| 1044 | return { |
| 1045 | hovered: tss.hovered, |
| 1046 | somethingSelected: tss.somethingSelected, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1047 | selectOrder: tss.selectOrder, |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1048 | }; |
| 1049 | } |
| 1050 | |
| 1051 | function mkOverlayApi() { |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1052 | return { |
Simon Hunt | e9343f3 | 2015-10-21 18:07:46 -0700 | [diff] [blame] | 1053 | clearNodeDeco: clearNodeDeco, |
| 1054 | removeNodeBadges: removeNodeBadges, |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1055 | clearLinkTrafficStyle: clearLinkTrafficStyle, |
| 1056 | removeLinkLabels: removeLinkLabels, |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 1057 | findLinkById: tms.findLinkById, |
Simon Hunt | 94f7dae | 2015-08-26 17:40:59 -0700 | [diff] [blame] | 1058 | findNodeById: nodeById, |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1059 | updateLinks: updateLinks, |
Simon Hunt | 743a849 | 2015-08-25 16:18:19 -0700 | [diff] [blame] | 1060 | updateNodes: updateNodes, |
| 1061 | supLayers: suppressLayers, |
| 1062 | unsupNode: unsuppressNode, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1063 | unsupLink: unsuppressLink, |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1064 | }; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1065 | } |
| 1066 | |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 1067 | function mkObliqueApi(uplink, fltr) { |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 1068 | return { |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1069 | force: function () { return force; }, |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 1070 | zoomLayer: uplink.zoomLayer, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1071 | nodeGBBox: function () { return nodeG.node().getBBox(); }, |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 1072 | node: function () { return node; }, |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 1073 | link: function () { return link; }, |
| 1074 | linkLabel: function () { return linkLabel; }, |
| 1075 | nodes: function () { return network.nodes; }, |
| 1076 | tickStuff: tickStuff, |
| 1077 | nodeLock: function (b) { |
| 1078 | var old = nodeLock; |
| 1079 | nodeLock = b; |
| 1080 | return old; |
| 1081 | }, |
| 1082 | opacifyMap: uplink.opacifyMap, |
Bri Prebilic Cole | 038aedd | 2015-07-13 15:25:16 -0700 | [diff] [blame] | 1083 | inLayer: fltr.inLayer, |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 1084 | calcLinkPos: calcPosition, |
| 1085 | applyNumLinkLabels: function () { |
| 1086 | td3.applyNumLinkLabels(linkNums, numLinkLblsG); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1087 | }, |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 1088 | }; |
| 1089 | } |
| 1090 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1091 | function mkFilterApi() { |
Simon Hunt | eb0fa05 | 2015-02-17 19:20:28 -0800 | [diff] [blame] | 1092 | return { |
| 1093 | node: function () { return node; }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1094 | link: function () { return link; }, |
Simon Hunt | eb0fa05 | 2015-02-17 19:20:28 -0800 | [diff] [blame] | 1095 | }; |
| 1096 | } |
| 1097 | |
Simon Hunt | 9e2104c | 2015-02-26 10:48:59 -0800 | [diff] [blame] | 1098 | function mkLinkApi(svg, uplink) { |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1099 | return { |
| 1100 | svg: svg, |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1101 | zoomer: uplink.zoomer(), |
| 1102 | network: network, |
Simon Hunt | 1a5301e | 2015-02-25 15:31:25 -0800 | [diff] [blame] | 1103 | portLabelG: function () { return portLabelG; }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1104 | showHosts: function () { return showHosts; }, |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1105 | }; |
| 1106 | } |
| 1107 | |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 1108 | function updateLinksAndNodes() { |
| 1109 | updateLinks(); |
| 1110 | updateNodes(); |
| 1111 | } |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 1112 | |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 1113 | // invoked after the localization bundle has been received from the server |
| 1114 | function setLionBundle(bundle) { |
| 1115 | topoLion = bundle; |
| 1116 | td3.setLionBundle(bundle); |
| 1117 | fltr.setLionBundle(bundle); |
| 1118 | tls.setLionBundle(bundle); |
Simon Hunt | 1603c69 | 2017-08-10 19:53:35 -0700 | [diff] [blame] | 1119 | tos.setLionBundle(bundle); |
| 1120 | tov.setLionBundle(bundle); |
Simon Hunt | caed041 | 2017-08-12 13:49:17 -0700 | [diff] [blame^] | 1121 | tss.setLionBundle(bundle); |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1124 | angular.module('ovTopo') |
| 1125 | .factory('TopoForceService', |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1126 | ['$log', '$timeout', 'FnService', 'SvgUtilService', |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 1127 | 'ThemeService', 'FlashService', 'WebSocketService', |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1128 | 'TopoOverlayService', 'TopoInstService', 'TopoModelService', |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1129 | 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService', |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1130 | 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService', |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1131 | 'TopoProtectedIntentsService', |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1132 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1133 | function (_$log_, _$timeout_, _fs_, _sus_, _ts_, _flash_, _wss_, _tov_, |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1134 | _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_, _tpis_) { |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1135 | $log = _$log_; |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 1136 | $timeout = _$timeout_; |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 1137 | fs = _fs_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1138 | sus = _sus_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1139 | ts = _ts_; |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 1140 | flash = _flash_; |
Simon Hunt | 237676b5 | 2015-03-10 19:04:26 -0700 | [diff] [blame] | 1141 | wss = _wss_; |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1142 | tov = _tov_; |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1143 | tis = _tis_; |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1144 | tms = _tms_; |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1145 | td3 = _td3_; |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 1146 | tss = _tss_; |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1147 | tts = _tts_; |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 1148 | tos = _tos_; |
Simon Hunt | eb0fa05 | 2015-02-17 19:20:28 -0800 | [diff] [blame] | 1149 | fltr = _fltr_; |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1150 | tls = _tls_; |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1151 | tpis = _tpis_; |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1152 | |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 1153 | ts.addListener(updateLinksAndNodes); |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 1154 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1155 | // forceG is the SVG group to display the force layout in |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 1156 | // uplink is the api from the main topo source file |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1157 | // dim is the initial dimensions of the SVG as [w,h] |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1158 | // opts are, well, optional :) |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1159 | function initForce(_svg_, forceG, _uplink_, _dim_, opts) { |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 1160 | uplink = _uplink_; |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1161 | dim = _dim_; |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1162 | svg = _svg_; |
| 1163 | |
| 1164 | lu = network.lookup; |
| 1165 | rlk = network.revLinkToKey; |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1166 | |
| 1167 | $log.debug('initForce().. dim = ' + dim); |
| 1168 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1169 | tov.setApi(mkOverlayApi(), tss); |
Simon Hunt | dc6adea | 2015-02-09 22:29:36 -0800 | [diff] [blame] | 1170 | tms.initModel(mkModelApi(uplink), dim); |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 1171 | td3.initD3(mkD3Api(), uplink.zoomer()); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1172 | tss.initSelect(mkSelectApi()); |
| 1173 | tts.initTraffic(mkTrafficApi()); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1174 | tpis.initProtectedIntents(mkTrafficApi()); |
Simon Hunt | c3c5b67 | 2015-02-20 11:32:13 -0800 | [diff] [blame] | 1175 | tos.initOblique(mkObliqueApi(uplink, fltr)); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1176 | fltr.initFilter(mkFilterApi()); |
Simon Hunt | 9e2104c | 2015-02-26 10:48:59 -0800 | [diff] [blame] | 1177 | tls.initLink(mkLinkApi(svg, uplink), td3); |
Simon Hunt | a11b4eb | 2015-01-28 16:20:50 -0800 | [diff] [blame] | 1178 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1179 | settings = angular.extend({}, defaultSettings, opts); |
| 1180 | |
| 1181 | linkG = forceG.append('g').attr('id', 'topo-links'); |
| 1182 | linkLabelG = forceG.append('g').attr('id', 'topo-linkLabels'); |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 1183 | numLinkLblsG = forceG.append('g').attr('id', 'topo-numLinkLabels'); |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1184 | nodeG = forceG.append('g').attr('id', 'topo-nodes'); |
Simon Hunt | 1a5301e | 2015-02-25 15:31:25 -0800 | [diff] [blame] | 1185 | portLabelG = forceG.append('g').attr('id', 'topo-portLabels'); |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1186 | |
| 1187 | link = linkG.selectAll('.link'); |
| 1188 | linkLabel = linkLabelG.selectAll('.linkLabel'); |
| 1189 | node = nodeG.selectAll('.node'); |
| 1190 | |
| 1191 | force = d3.layout.force() |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1192 | .size(dim) |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1193 | .nodes(network.nodes) |
| 1194 | .links(network.links) |
| 1195 | .gravity(settings.gravity) |
| 1196 | .friction(settings.friction) |
| 1197 | .charge(settings.charge._def_) |
| 1198 | .linkDistance(settings.linkDistance._def_) |
| 1199 | .linkStrength(settings.linkStrength._def_) |
| 1200 | .on('tick', tick); |
| 1201 | |
| 1202 | drag = sus.createDragBehavior(force, |
Simon Hunt | 08f841d0 | 2015-02-10 14:39:20 -0800 | [diff] [blame] | 1203 | tss.selectObject, atDragEnd, dragEnabled, clickEnabled); |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1204 | } |
| 1205 | |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1206 | function newDim(_dim_) { |
| 1207 | dim = _dim_; |
| 1208 | force.size(dim); |
| 1209 | tms.newDim(dim); |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1210 | } |
| 1211 | |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1212 | function destroyForce() { |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1213 | force.stop(); |
| 1214 | |
Simon Hunt | fb8ea1f | 2015-02-24 21:38:09 -0800 | [diff] [blame] | 1215 | tls.destroyLink(); |
Simon Hunt | 96f88c6 | 2015-02-19 17:57:25 -0800 | [diff] [blame] | 1216 | tos.destroyOblique(); |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1217 | tts.destroyTraffic(); |
Andrea Campanella | 732ea83 | 2017-02-06 09:25:59 -0800 | [diff] [blame] | 1218 | tpis.destroyProtectedIntents(); |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1219 | tss.destroySelect(); |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1220 | td3.destroyD3(); |
Simon Hunt | f542d84 | 2015-02-11 16:20:33 -0800 | [diff] [blame] | 1221 | tms.destroyModel(); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1222 | // note: no need to destroy overlay service |
Simon Hunt | f51bf46 | 2016-06-29 16:22:57 -0700 | [diff] [blame] | 1223 | ts.removeListener(updateLinksAndNodes); |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1224 | |
| 1225 | // clean up the DOM |
| 1226 | svg.selectAll('g').remove(); |
| 1227 | svg.selectAll('defs').remove(); |
| 1228 | |
| 1229 | // clean up internal state |
| 1230 | network.nodes = []; |
| 1231 | network.links = []; |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1232 | network.linksByDevice = {}; |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1233 | network.lookup = {}; |
| 1234 | network.revLinkToKey = {}; |
| 1235 | |
Bri Prebilic Cole | 8040176 | 2015-07-16 11:36:18 -0700 | [diff] [blame] | 1236 | linkNums = []; |
| 1237 | |
| 1238 | linkG = linkLabelG = numLinkLblsG = nodeG = portLabelG = null; |
Simon Hunt | 3ab2028 | 2015-02-26 20:32:19 -0800 | [diff] [blame] | 1239 | link = linkLabel = node = null; |
| 1240 | force = drag = null; |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1241 | |
| 1242 | // clean up $timeout promises |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 1243 | if (fTimer) { |
| 1244 | $timeout.cancel(fTimer); |
| 1245 | } |
Bri Prebilic Cole | aeeb33e | 2015-07-09 15:15:54 -0700 | [diff] [blame] | 1246 | if (fNodesTimer) { |
| 1247 | $timeout.cancel(fNodesTimer); |
| 1248 | } |
| 1249 | if (fLinksTimer) { |
| 1250 | $timeout.cancel(fLinksTimer); |
| 1251 | } |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1252 | } |
| 1253 | |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1254 | return { |
| 1255 | initForce: initForce, |
Simon Hunt | 3a6eec0 | 2015-02-09 21:16:43 -0800 | [diff] [blame] | 1256 | newDim: newDim, |
| 1257 | destroyForce: destroyForce, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1258 | |
Simon Hunt | a4242de | 2015-02-24 17:11:55 -0800 | [diff] [blame] | 1259 | updateDeviceColors: td3.updateDeviceColors, |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 1260 | toggleHosts: toggleHosts, |
Simon Hunt | 9e2104c | 2015-02-26 10:48:59 -0800 | [diff] [blame] | 1261 | togglePorts: tls.togglePorts, |
Simon Hunt | 5724fb4 | 2015-02-05 16:59:40 -0800 | [diff] [blame] | 1262 | toggleOffline: toggleOffline, |
| 1263 | cycleDeviceLabels: cycleDeviceLabels, |
Simon Hunt | 10618f6 | 2017-06-15 19:30:52 -0700 | [diff] [blame] | 1264 | cycleHostLabels: cycleHostLabels, |
Simon Hunt | 445e815 | 2015-02-06 13:00:12 -0800 | [diff] [blame] | 1265 | unpin: unpin, |
Simon Hunt | a142dd2 | 2015-02-12 22:07:51 -0800 | [diff] [blame] | 1266 | showMastership: showMastership, |
Simon Hunt | 86b7c88 | 2015-04-02 23:06:08 -0700 | [diff] [blame] | 1267 | showBadLinks: showBadLinks, |
Steven Burrows | f17f0ab | 2017-04-11 11:03:58 -0700 | [diff] [blame] | 1268 | setNodeScale: setNodeScale, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1269 | |
Simon Hunt | fd7106c | 2016-02-09 15:05:26 -0800 | [diff] [blame] | 1270 | resetAllLocations: resetAllLocations, |
Simon Hunt | ac4c6f7 | 2015-02-03 19:50:53 -0800 | [diff] [blame] | 1271 | addDevice: addDevice, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 1272 | updateDevice: updateDevice, |
| 1273 | removeDevice: removeDevice, |
| 1274 | addHost: addHost, |
| 1275 | updateHost: updateHost, |
Simon Hunt | 95d56fd | 2015-11-12 11:06:44 -0800 | [diff] [blame] | 1276 | moveHost: moveHost, |
Simon Hunt | 1894d79 | 2015-02-04 17:09:20 -0800 | [diff] [blame] | 1277 | removeHost: removeHost, |
| 1278 | addLink: addLink, |
| 1279 | updateLink: updateLink, |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 1280 | removeLink: removeLink, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 1281 | topoStartDone: topoStartDone, |
Simon Hunt | e2d9dc7 | 2017-08-10 15:21:04 -0700 | [diff] [blame] | 1282 | |
| 1283 | setLionBundle: setLionBundle, |
Simon Hunt | 737c89f | 2015-01-28 12:23:19 -0800 | [diff] [blame] | 1284 | }; |
| 1285 | }]); |
| 1286 | }()); |