2015-04-07 17:41:17 +02:00
|
|
|
|
define(["sorttable", "virtual-dom"], function (SortTable, V) {
|
|
|
|
|
function linkName(d) {
|
2016-02-27 14:43:27 +01:00
|
|
|
|
return (d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + " – " + d.target.node.nodeinfo.hostname
|
2015-04-07 17:41:17 +02:00
|
|
|
|
}
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
var headings = [{ name: "Knoten",
|
|
|
|
|
sort: function (a, b) {
|
|
|
|
|
return linkName(a).localeCompare(linkName(b))
|
|
|
|
|
},
|
|
|
|
|
reverse: false
|
|
|
|
|
},
|
|
|
|
|
{ name: "TQ",
|
|
|
|
|
sort: function (a, b) { return a.tq - b.tq},
|
|
|
|
|
reverse: true
|
|
|
|
|
},
|
2016-02-18 20:26:05 +01:00
|
|
|
|
{ name: "Typ",
|
|
|
|
|
sort: function (a, b) {
|
|
|
|
|
return a.type.localeCompare(b.type)
|
|
|
|
|
},
|
|
|
|
|
reverse: false
|
|
|
|
|
},
|
2015-04-07 17:41:17 +02:00
|
|
|
|
{ name: "Entfernung",
|
|
|
|
|
sort: function (a, b) {
|
|
|
|
|
return (a.distance === undefined ? -1 : a.distance) -
|
|
|
|
|
(b.distance === undefined ? -1 : b.distance)
|
|
|
|
|
},
|
|
|
|
|
reverse: true
|
|
|
|
|
}]
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
return function(linkScale, router) {
|
|
|
|
|
var table = new SortTable(headings, 2, renderRow)
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
function renderRow(d) {
|
|
|
|
|
var td1Content = [V.h("a", {href: "#", onclick: router.link(d)}, linkName(d))]
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
var td1 = V.h("td", td1Content)
|
|
|
|
|
var td2 = V.h("td", {style: {color: linkScale(d.tq).hex()}}, showTq(d))
|
2016-02-18 20:26:05 +01:00
|
|
|
|
var td3 = V.h("td", d.type)
|
|
|
|
|
var td4 = V.h("td", showDistance(d))
|
2015-04-03 02:32:32 +02:00
|
|
|
|
|
2016-02-18 20:26:05 +01:00
|
|
|
|
return V.h("tr", [td1, td2, td3, td4])
|
2015-04-07 17:41:17 +02:00
|
|
|
|
}
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
this.render = function (d) {
|
|
|
|
|
var el = document.createElement("div")
|
|
|
|
|
el.last = V.h("div")
|
|
|
|
|
d.appendChild(el)
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
var h2 = document.createElement("h2")
|
|
|
|
|
h2.textContent = "Verbindungen"
|
|
|
|
|
el.appendChild(h2)
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
el.appendChild(table.el)
|
|
|
|
|
}
|
2015-03-25 16:04:23 +01:00
|
|
|
|
|
2015-04-07 17:41:17 +02:00
|
|
|
|
this.setData = function (d) {
|
|
|
|
|
table.setData(d.graph.links)
|
2015-03-25 16:04:23 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|