Properly handle link types (#47)

* Properly handle link types

* fixup! Properly handle link types
This commit is contained in:
Marvin W 2016-07-04 11:29:16 +02:00 committed by PetaByteBoy // Milan Pässler
parent 2844a203d5
commit 760cca6806
2 changed files with 25 additions and 14 deletions

View file

@ -214,7 +214,7 @@ define(["d3"], function (d3) {
function drawLabel(d) {
var neighbours = d.neighbours.filter(function (d) {
return d.link.o.type !== "fastd" && d.link.o.type !== "L2TP"
return !d.link.o.isVPN
})
var sum = neighbours.reduce(function (a, b) {
@ -332,8 +332,8 @@ define(["d3"], function (d3) {
ctx.moveTo(d.source.x + dx * nodeRadius, d.source.y + dy * nodeRadius)
ctx.lineTo(d.target.x - dx * nodeRadius, d.target.y - dy * nodeRadius)
ctx.strokeStyle = d.o.type === "Kabel" ? cableColor : d.color
ctx.globalAlpha = d.o.type === "fastd" || d.o.type === "L2TP" ? 0.1 : 0.8
ctx.lineWidth = d.o.type === "fastd" || d.o.type === "L2TP" ? 1.5 : 2.5
ctx.globalAlpha = d.o.isVPN ? 0.1 : 0.8
ctx.lineWidth = d.o.isVPN ? 1.5 : 2.5
ctx.stroke()
})
@ -523,7 +523,7 @@ define(["d3"], function (d3) {
}
var links = intLinks.filter(function (d) {
return d.o.type !== "fastd" && d.o.type !== "L2TP"
return !d.o.isVPN
}).filter(function (d) {
return distanceLink(e, d.source, d.target) < LINE_RADIUS
})
@ -584,13 +584,13 @@ define(["d3"], function (d3) {
.charge(-250)
.gravity(0.1)
.linkDistance(function (d) {
if (d.o.type === "fastd" || d.o.type === "L2TP")
if (d.o.isVPN)
return 0
else
return LINK_DISTANCE
})
.linkStrength(function (d) {
if (d.o.type === "fastd" || d.o.type === "L2TP")
if (d.o.isVPN)
return 0
else
return Math.max(0.5, 1 / d.o.tq)
@ -644,7 +644,7 @@ define(["d3"], function (d3) {
e.source = newNodesDict[d.source.id]
e.target = newNodesDict[d.target.id]
if (d.type === "fastd" || d.type === "L2TP")
if (d.isVPN)
e.color = "rgba(255, 255, 255, " + (0.6 / d.tq) + ")"
else
e.color = linkScale(d.tq).hex()

View file

@ -126,17 +126,28 @@ function (moment, Router, L, GUI, numeral) {
})
links.forEach( function (d) {
if (d.type === "tunnel" || d.type === "fastd")
if (d.type === "tunnel") {
d.type = "VPN"
d.isVPN = true
} else if (d.type === "fastd") {
d.type = "fastd"
else if (d.type === "l2tp") {
d.isVPN = true
} else if (d.type === "l2tp") {
d.type = "L2TP"
d.target.node.flags.uplink = true
} else if (d.type === "wireless")
d.isVPN = true
} else if (d.type === "gre") {
d.type = "GRE"
d.isVPN = true
} else if (d.type === "wireless") {
d.type = "Wifi"
else if (d.type === "other")
d.isVPN = false
} else if (d.type === "other") {
d.type = "Kabel"
else
d.isVPN = false
} else {
d.type = "N/A"
d.isVPN = false
}
var unknown = (d.source.node === undefined)
if (unknown) {
d.target.node.neighbours.push({ id: d.source.id, link: d, incoming: true })
@ -144,7 +155,7 @@ function (moment, Router, L, GUI, numeral) {
}
d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false })
d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true })
if (d.type !== "fastd" && d.type !== "L2TP")
if (!d.isVPN)
d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1
})