2016-05-26 16:37:24 +00:00
|
|
|
|
define(["sorttable", "virtual-dom", "helper"], function (SortTable, V, helper) {
|
2016-05-27 21:59:01 +00:00
|
|
|
|
"use strict";
|
|
|
|
|
|
2015-04-07 15:41:17 +00:00
|
|
|
|
function linkName(d) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
return (d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + " – " + d.target.node.nodeinfo.hostname;
|
2015-04-07 15:41:17 +00:00
|
|
|
|
}
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2016-05-22 12:51:30 +00: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
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Entfernung",
|
|
|
|
|
sort: function (a, b) {
|
|
|
|
|
return (a.distance === undefined ? -1 : a.distance) -
|
|
|
|
|
(b.distance === undefined ? -1 : b.distance);
|
|
|
|
|
},
|
|
|
|
|
reverse: true
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
return function (linkScale, router) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
var table = new SortTable(headings, 2, renderRow);
|
2016-05-26 23:34:42 +00:00
|
|
|
|
table.el.classList.add("link-list");
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2015-04-07 15:41:17 +00:00
|
|
|
|
function renderRow(d) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
var td1Content = [V.h("a", {href: "#", onclick: router.link(d)}, linkName(d))];
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
|
var td1 = V.h("td", td1Content);
|
2016-05-26 16:37:24 +00:00
|
|
|
|
var td2 = V.h("td", {style: {color: linkScale(d.tq).hex()}}, helper.showTq(d));
|
|
|
|
|
var td3 = V.h("td", helper.showDistance(d));
|
2015-04-03 00:32:32 +00:00
|
|
|
|
|
2016-05-24 21:21:46 +00:00
|
|
|
|
return V.h("tr", [td1, td2, td3]);
|
2015-04-07 15:41:17 +00:00
|
|
|
|
}
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
|
this.render = function (d) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
var h2 = document.createElement("h2");
|
|
|
|
|
h2.textContent = "Verbindungen";
|
2016-05-26 23:34:42 +00:00
|
|
|
|
d.appendChild(h2);
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2016-05-26 23:34:42 +00:00
|
|
|
|
d.appendChild(table.el);
|
2016-05-22 11:23:43 +00:00
|
|
|
|
};
|
2015-03-25 15:04:23 +00:00
|
|
|
|
|
2015-04-07 15:41:17 +00:00
|
|
|
|
this.setData = function (d) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
table.setData(d.graph.links);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|