Topo2: Improved the force layout implementation
topo2Collection: Models can be added to a collection aswell as js objects
topo2Layout: New nodes/links are added to the force layout and
the simulation starts again (this was causing a bug
where new nodes wouldn't have drag functionality)
Change-Id: I800b76e09989a07277184f5d14cbfa00ee675967
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js b/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
index 473bd3a..156d67a 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Layout.js
@@ -208,6 +208,7 @@
_update: function () {
this.updateNodes();
this.updateLinks();
+ this.force.start();
},
updateNodes: function () {
var regionNodes = t2rs.regionNodes();
@@ -235,6 +236,8 @@
entering.filter('.sub-region').each(t2d3.nodeEnter);
entering.filter('.host').each(t2d3.nodeEnter);
entering.filter('.peer-region').each(t2d3.nodeEnter);
+
+ this.force.nodes(regionNodes);
},
updateLinks: function () {
@@ -269,6 +272,8 @@
})
.style('opacity', 0.0)
.remove();
+
+ this.force.links(regionLinks);
},
calcPosition: function () {
var lines = this;