fix counting of vpn links

This commit is contained in:
Nils Schneider 2012-06-12 16:16:37 +02:00
parent 8e9a08d9e1
commit a35a28cafe

View file

@ -277,29 +277,17 @@ function reload() {
if (typeof d.target == "number") d.target = json.nodes[d.target]; if (typeof d.target == "number") d.target = json.nodes[d.target];
}) })
// count uplinks // count vpn links
json.nodes.forEach(function(d) { json.nodes.forEach(function(d) {
d.uplinks = undefined d.vpns = 0
}) })
json.links.forEach(function(d) { json.links.forEach(function(d) {
var node, other var node, other
if (d.source.flags.vpn) { if (d.type == "vpn") {
node = d.target d.source.vpns++
other = d.source d.target.vpns++
}
if (d.target.flags.vpn) {
node = d.source
other = d.target
}
if (node) {
if (node.uplinks === undefined)
node.uplinks = 0
node.uplinks++
} }
}) })
@ -376,9 +364,6 @@ function update() {
if (!visible.vpn && d.flags.vpn) if (!visible.vpn && d.flags.vpn)
return false return false
if (!visible.vpn && d.flags.client && d.uplinks)
return false
if (!visible.clients && d.flags.client) if (!visible.clients && d.flags.client)
return false return false
@ -446,10 +431,7 @@ function update() {
if (!visible.vpn) { if (!visible.vpn) {
var uplink_info = node.filter(function (d) { var uplink_info = node.filter(function (d) {
if (d.uplinks !== undefined) return d.vpns > 0
return d.uplinks > 0
else
return false
}) })
.append("g") .append("g")
.attr("class", "uplinks") .attr("class", "uplinks")
@ -463,7 +445,7 @@ function update() {
uplink_info.append("text") uplink_info.append("text")
.attr("text-anchor", "middle") .attr("text-anchor", "middle")
.attr("y", 3 - 20) .attr("y", 3 - 20)
.text(function (d) {return d.uplinks}) .text(function (d) {return d.vpns})
} }
node.exit().remove() node.exit().remove()