[TASK] Add gateway filter

This commit is contained in:
Xaver Maierhofer 2017-04-23 00:03:42 +02:00 committed by Xaver Maierhofer
parent 62c9c1c830
commit ecf73dd7ab
6 changed files with 34 additions and 14 deletions

View File

@ -36,9 +36,9 @@ define(['infobox/link', 'infobox/node', 'infobox/location'], function (link, nod
self.resetView = destroy;
self.gotoNode = function gotoNode(d) {
self.gotoNode = function gotoNode(d, gateways) {
create();
node(config, el, router, d);
node(config, el, router, d, gateways);
};
self.gotoLink = function gotoLink(d) {

View File

@ -178,7 +178,7 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
return helper.showStat(o, subst);
}
return function (config, el, router, d) {
return function (config, el, router, d, gateways) {
var linkScale = d3Interpolate.interpolate('#F02311', '#04C714');
function renderNeighbourRow(n) {
@ -235,7 +235,7 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
helper.attributeEntry(attributes, 'node.ram', showRAM(d));
}
helper.attributeEntry(attributes, 'node.ipAddresses', showIPs(d));
helper.attributeEntry(attributes, 'node.selectedGateway', helper.dictGet(d.statistics, ['gateway']));
helper.attributeEntry(attributes, 'node.selectedGateway', gateways[helper.dictGet(d.statistics, ['gateway'])]);
helper.attributeEntry(attributes, 'node.update', showAutoupdate(d));
helper.attributeEntry(attributes, 'node.clients', showClients(d));

View File

@ -10,6 +10,7 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
dataGraph.batadv = {};
dataGraph.batadv.nodes = [];
dataGraph.batadv.links = [];
var gateways = {};
function rearrangeLinks(d) {
d.source += dataGraph.batadv.nodes.length;
@ -86,6 +87,12 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
nodes.forEach(function (d) {
d.neighbours = [];
if (d.flags.gateway) {
var mesh = d.nodeinfo.network.mesh;
mesh[Object.keys(mesh)[0]].interfaces.tunnel.forEach(function (mac) {
gateways[mac] = d.nodeinfo.hostname;
});
}
});
links.forEach(function (d) {
@ -123,7 +130,8 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
graph: {
links: links,
nodes: graph.nodes
}
},
gateways: gateways
};
}

View File

@ -12,8 +12,10 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
var hwTable;
var geoTable;
var autoTable;
var gatewayTable;
var siteTable;
function showStatGlobal(o) {
return helper.showStat(o);
}
@ -105,16 +107,25 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
return _.t('node.deactivated');
});
var gatewayDict = count(nodes, ['statistics', 'gateway'], function (d) {
for (var mac in data.gateways) {
if (data.gateways.hasOwnProperty(mac) && mac === d) {
d = data.gateways[mac];
return d;
}
}
return null;
});
var siteDict = count(nodes, ['nodeinfo', 'system', 'site_code'], function (d) {
var rt = d;
if (config.siteNames) {
config.siteNames.forEach(function (t) {
if (d === t.site) {
rt = t.name;
d = t.name;
}
});
}
return rt;
return d;
});
statusTable = fillTable('node.status', statusTable, statusDict.sort(function (a, b) {
@ -138,6 +149,9 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
autoTable = fillTable('node.update', autoTable, autoDict.sort(function (a, b) {
return b[1] - a[1];
}));
gatewayTable = fillTable('node.gateway', gatewayTable, gatewayDict.sort(function (a, b) {
return b[1] - a[1];
}));
siteTable = fillTable('node.site', siteTable, siteDict.sort(function (a, b) {
return b[1] - a[1];
}));
@ -150,6 +164,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
self.renderSingle(el, 'node.hardware', hwTable);
self.renderSingle(el, 'node.visible', geoTable);
self.renderSingle(el, 'node.update', autoTable);
self.renderSingle(el, 'node.gateway', gatewayTable);
self.renderSingle(el, 'node.site', siteTable);
if (config.globalInfos) {

View File

@ -48,10 +48,6 @@ define({
return 1;
},
trueDefault: function trueDefault(d) {
return d === undefined ? true : d;
},
dictGet: function dictGet(dict, key) {
var k = key.shift();

View File

@ -3,7 +3,7 @@ define(['Navigo'], function (Navigo) {
return function (language) {
var init = false;
var objects = { nodes: {}, links: {} };
var objects = { nodes: {}, links: {}, gateways: {} };
var targets = [];
var views = {};
var current = {};
@ -18,7 +18,7 @@ define(['Navigo'], function (Navigo) {
function gotoNode(d) {
if (d.nodeId in objects.nodes) {
targets.forEach(function (t) {
t.gotoNode(objects.nodes[d.nodeId]);
t.gotoNode(objects.nodes[d.nodeId], objects.gateways);
});
}
}
@ -141,6 +141,7 @@ define(['Navigo'], function (Navigo) {
router.setData = function setData(data) {
objects.nodes = {};
objects.links = {};
objects.gateways = data.gateways;
data.nodes.all.forEach(function (d) {
objects.nodes[d.nodeinfo.node_id] = d;