Thomas Vachuska
Committed by Gerrit Code Review

Deferring force layout until quiet period.

Change-Id: I24c66eb695ece45df2b0291f42ccf7d980cad535
...@@ -55,7 +55,7 @@ public class TopologyResource extends BaseResource { ...@@ -55,7 +55,7 @@ public class TopologyResource extends BaseResource {
55 Map<String, ObjectNode> metaUi = TopologyViewMessageHandler.getMetaUi(); 55 Map<String, ObjectNode> metaUi = TopologyViewMessageHandler.getMetaUi();
56 for (String id : metaUi.keySet()) { 56 for (String id : metaUi.keySet()) {
57 ObjectNode memento = metaUi.get(id); 57 ObjectNode memento = metaUi.get(id);
58 - if (id.charAt(17) == '/') { 58 + if (id.length() > 17 && id.charAt(17) == '/') {
59 addGeoData(hosts, "id", id, memento); 59 addGeoData(hosts, "id", id, memento);
60 } else { 60 } else {
61 addGeoData(devices, "uri", id, memento); 61 addGeoData(devices, "uri", id, memento);
......
...@@ -42,7 +42,7 @@ public class UiWebSocket ...@@ -42,7 +42,7 @@ public class UiWebSocket
42 42
43 private static final Logger log = LoggerFactory.getLogger(UiWebSocket.class); 43 private static final Logger log = LoggerFactory.getLogger(UiWebSocket.class);
44 44
45 - private static final long MAX_AGE_MS = 15_000; 45 + private static final long MAX_AGE_MS = 30_000;
46 46
47 private static final byte PING = 0x9; 47 private static final byte PING = 0x9;
48 private static final byte PONG = 0xA; 48 private static final byte PONG = 0xA;
......
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
58 showHosts = false, // whether hosts are displayed 58 showHosts = false, // whether hosts are displayed
59 showOffline = true, // whether offline devices are displayed 59 showOffline = true, // whether offline devices are displayed
60 nodeLock = false, // whether nodes can be dragged or not (locked) 60 nodeLock = false, // whether nodes can be dragged or not (locked)
61 + fTimer, // timer for delayed force layout
62 + fNodesTimer, // timer for delayed nodes update
63 + fLinksTimer, // timer for delayed links update
61 dim; // the dimensions of the force layout [w,h] 64 dim; // the dimensions of the force layout [w,h]
62 65
63 // SVG elements; 66 // SVG elements;
...@@ -479,6 +482,13 @@ ...@@ -479,6 +482,13 @@
479 // ========================================== 482 // ==========================================
480 483
481 function updateNodes() { 484 function updateNodes() {
485 + if (fNodesTimer) {
486 + $timeout.cancel(fNodesTimer);
487 + }
488 + fNodesTimer = $timeout(_updateNodes, 150);
489 + }
490 +
491 + function _updateNodes() {
482 // select all the nodes in the layout: 492 // select all the nodes in the layout:
483 node = nodeG.selectAll('.node') 493 node = nodeG.selectAll('.node')
484 .data(network.nodes, function (d) { return d.id; }); 494 .data(network.nodes, function (d) { return d.id; });
...@@ -526,6 +536,13 @@ ...@@ -526,6 +536,13 @@
526 // ========================== 536 // ==========================
527 537
528 function updateLinks() { 538 function updateLinks() {
539 + if (fLinksTimer) {
540 + $timeout.cancel(fLinksTimer);
541 + }
542 + fLinksTimer = $timeout(_updateLinks, 150);
543 + }
544 +
545 + function _updateLinks() {
529 var th = ts.theme(); 546 var th = ts.theme();
530 547
531 link = linkG.selectAll('.link') 548 link = linkG.selectAll('.link')
...@@ -589,7 +606,13 @@ ...@@ -589,7 +606,13 @@
589 606
590 function fStart() { 607 function fStart() {
591 if (!tos.isOblique()) { 608 if (!tos.isOblique()) {
592 - force.start(); 609 + if (fTimer) {
610 + $timeout.cancel(fTimer);
611 + }
612 + fTimer = $timeout(function () {
613 + $log.debug("Starting force-layout");
614 + force.start();
615 + }, 200);
593 } 616 }
594 } 617 }
595 618
......