fix switch color update logic bug
diff --git a/web/ons-demo/js/debug.js b/web/ons-demo/js/debug.js
index 7b66912..3d3b302 100644
--- a/web/ons-demo/js/debug.js
+++ b/web/ons-demo/js/debug.js
@@ -9,4 +9,23 @@
}
});
return links;
+}
+
+function debug_findswitch(model, dpid) {
+ var sw;
+
+ model.edgeSwitches.forEach(function (s) {
+ if (s.dpid == dpid)
+ sw = s;
+ });
+ model.aggregationSwitches.forEach(function (s) {
+ if (s.dpid == dpid)
+ sw = s;
+ });
+ model.coreSwitches.forEach(function (s) {
+ if (s.dpid == dpid)
+ sw = s;
+ });
+
+ return sw;
}
\ No newline at end of file
diff --git a/web/ons-demo/js/map.js b/web/ons-demo/js/map.js
index 3849b8d..ad590cb 100644
--- a/web/ons-demo/js/map.js
+++ b/web/ons-demo/js/map.js
@@ -344,7 +344,7 @@
}
function switchesEnter(switches) {
- return switchLayer.selectAll('g').data(switches, function (d) {
+ switchLayer.selectAll('g').data(switches, function (d) {
return d.dpid;
})
.enter()
@@ -363,7 +363,9 @@
function switchesUpdate(switches) {
- switches.each(function (d) {
+ switchLayer.selectAll('g').data(switches, function (d) {
+ return d.dpid;
+ }).each(function (d) {
// if there's a pending state changed and then the state changes, clear the pending class
var circle = d3.select(this);
if (d.state === 'ACTIVE' && circle.classed('inactive') ||
@@ -392,7 +394,8 @@
var switches = coreSwitches.concat(aggregationSwitches).concat(edgeSwitches);
- switchesUpdate(switchesEnter(switches));
+ switchesEnter(switches)
+ switchesUpdate(switches);
drawLinkLines();