Bugfix for switch node labels getting wrong after some time.
Change-Id: Ibbab82aa09a5ff5650b7435464943fad3b9e20e2
diff --git a/web/js/topo.js b/web/js/topo.js
index b518bd2..2648fc4 100644
--- a/web/js/topo.js
+++ b/web/js/topo.js
@@ -49,6 +49,11 @@
.attr("width", width)
.attr("height", height);
+ var status_header = svg.append("svg:text")
+ .attr("id", "status_header")
+ .attr("x", 50)
+ .attr("y", 20);
+
var force = d3.layout.force()
.charge(-500)
.linkDistance(100)
@@ -71,7 +76,7 @@
init(topodata, nodes, links);
path = svg.append("svg:g").selectAll("path").data(links);
circle = svg.append("svg:g").selectAll("circle").data(nodes);
- text = svg.append("svg:g").selectAll("text").data(nodes);
+ text = svg.append("svg:g").selectAll("text.node-label").data(nodes);
draw();
});
});
@@ -85,7 +90,7 @@
var changed = update(topodata, nodes, links);
path = svg.selectAll("path").data(links)
circle = svg.selectAll("circle").data(nodes);
- text = svg.selectAll("text").data(nodes);
+ text = svg.selectAll("text.node-label").data(nodes);
if ( changed ){
draw();
}
@@ -96,11 +101,9 @@
function draw(){
force.stop();
- svg.append("svg:text")
- .attr("x", 50)
- .attr("y", 20)
+ svg.select("#status_header")
.text(function(){return "Switch: " + force.nodes().length + " (Active: " + nr_active_sw() + ")/ Link: " + force.links().length});
-
+
path.enter().append("svg:path")
.attr("class", function(d) { return "link"; })
.attr("marker-end", function(d) {
@@ -122,6 +125,7 @@
.call(node_drag);
text.enter().append("svg:text")
+ .classed("node-label", true)
.attr("x", radius)
.attr("y", ".31em")
.text(function(d) {
@@ -154,12 +158,6 @@
}
});
- circle.on('mouseover', function(d){
- var nodeSelection = d3.select(this).style({opacity:'0.8'});
- nodeSelection.select("text").style({opacity:'1.0'});
- });
-
-
path.attr("stroke", function(d) {
if(d.type == 1){
return "red"
diff --git a/web/simple_web_server.py b/web/simple_web_server.py
index 14fa05d..3abd0b0 100755
--- a/web/simple_web_server.py
+++ b/web/simple_web_server.py
@@ -17,7 +17,7 @@
@app.route('/', methods=['GET'])
@app.route('/<filename>', methods=['GET'])
@app.route('/js/<filename>', methods=['GET'])
-def return_file(filename):
+def return_file(filename="/"):
if request.path == "/":
fullpath = "./simple-topo.html"
else:
@@ -50,8 +50,7 @@
@app.route('/wm/', defaults={'path':''})
@app.route('/wm/<path:path>')
def rest(path):
- url="http://localhost:8080/wm/" + path
- print url
+ url="http://%s:%s/wm/%s" % (RestIP, RestPort, path)
try:
response = urlopen(url)
except URLError, e:
@@ -61,11 +60,9 @@
print "ONOS REST IF %s has issue. Code %s" % (url, e.code)
result = ""
- print response
result = response.read()
return result
if __name__ == "__main__":
app.debug = True
app.run(threaded=True, host="0.0.0.0", port=9000)
-# app.run(threaded=False, host="0.0.0.0", port=9000)