diff --git a/bat2nodes.py b/bat2nodes.py index 5d0b2ff..6627f2d 100644 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -29,7 +29,7 @@ nodes = [] class Node(): def __init__(self): - self.name = None + self.name = "" self.macs = set() self.group = 0 # groups: @@ -39,9 +39,6 @@ class Node(): # 3 TT def add_mac(self, mac): - if len(self.macs) == 0 and not self.name: - self.name = mac - self.macs.add(mac) def __repr__(self): @@ -103,13 +100,6 @@ for line in lines: for line in lines: x = json.loads(line) - if 'primary' in x: - try: - node = maybe_node_by_mac(nodes, (x['primary'], )) - node.name = x['primary'] - except: - pass - if 'router' in x: try: if 'gateway' in x: @@ -163,7 +153,9 @@ links = map(lambda x: map_link(nodes, x), links) output = dict() -output['nodes'] = map(lambda x: {'group': x.group, 'name': x.name}, nodes) +output['nodes'] = map(lambda x: {'group': x.group, 'name': x.name, + 'macs': ', '.join(x.macs) + }, nodes) output['links'] = map(lambda x: {'source': x.pair[0], 'target': x.pair[1], 'distance': x.distance, 'strength': x.strength diff --git a/html/force.js b/html/force.js index 3556c5b..149d1fc 100644 --- a/html/force.js +++ b/html/force.js @@ -36,7 +36,7 @@ d3.json("nodes.json", function(json) { .call(force.drag); node.append("ellipse") - .attr("rx", function(d) { if (d.group == 3) return 4; else return d.name.length * 5; }) + .attr("rx", function(d) { if (d.group == 3) return 4; else return Math.max(14, d.name.length * 5); }) .attr("ry", function(d) { if (d.group == 3) return 4; else return 14; }) .style("fill", function(d) { if (d.group == 3) return fill(d.group); else return ""; }) .style("stroke", function(d) { return fill(d.group); }); @@ -48,7 +48,7 @@ d3.json("nodes.json", function(json) { .text(function(d) { if (d.group == 3) return ""; else return d.name; }); node.append("title") - .text(function(d) { return d.name; }); + .text(function(d) { return d.macs; }); force.on("tick", function() { link.attr("x1", function(d) { return d.source.x; }) diff --git a/mkmap.sh b/mkmap.sh index 667c29d..a43518c 100644 --- a/mkmap.sh +++ b/mkmap.sh @@ -8,4 +8,4 @@ mkdir $DEST cp html/* $DEST/ -batctl vd json|python ./bat2nodes.py -a aliases.json $GWS - > $DEST/nodes.json +ssh 188.138.99.158 batctl vd json|python ./bat2nodes.py -a aliases.json $GWS - > $DEST/nodes.json