router.html: Display name for all neighbors (including "historic")

This change the behavior concerning the displayed netif name in
the legend of the neighbor stats plot. Previously, the netif name
of the device was shown, now we show the netif name corresponding
to the neighbor. This is necessary, as we do not log netif names
for neighbors.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-04-13 12:57:45 +02:00
parent 54764f7f43
commit 6a85c59ce6
3 changed files with 25 additions and 13 deletions

View File

@ -244,6 +244,24 @@ def router_info(dbid):
neighdata[ns["mac"]] = []
neighdata[ns["mac"]].append(ns)
neighident = mysql.fetchall("""
SELECT snb.mac, r.hostname, n.netif
FROM router_stats_neighbor AS snb
INNER JOIN router_netif AS n ON snb.mac = n.mac
INNER JOIN router AS r ON n.router = r.id
WHERE snb.router = %s AND n.netif <> 'w2ap' AND n.netif <> 'w5ap'
GROUP BY snb.mac, r.hostname, n.netif
""",(dbid,))
neighlabel = {}
for ni in neighident:
label = ni["hostname"]
# add network interface when there are multiple links to same node
for ni2 in neighident:
if label == ni2["hostname"] and ni["mac"] != ni2["mac"]:
# This shows the NEIGHBOR'S interface name
label += "@" + ni["netif"]
neighlabel[ni["mac"]] = label
gwfetch = mysql.fetchall("""
SELECT quality, mac, time FROM router_stats_gw WHERE router = %s
""",(dbid,))
@ -324,6 +342,7 @@ def router_info(dbid):
mac = mac,
tileurls = tileurls,
neighstats = neighdata,
neighlabel = neighlabel,
gwstats = gwfetch,
authuser = is_authorized(router["user"], session),
authadmin = session.get('admin')

View File

@ -99,7 +99,7 @@ function network_graph(netif) {
setup_plot_zoom(plot, pdata, len);
}
function neighbour_graph(neighbours) {
function neighbour_graph(neigh_label) {
var meshstat = $("#meshstat");
var pdata = [];
var len, i;
@ -109,16 +109,8 @@ function neighbour_graph(neighbours) {
var dataset = neigh_stats[j];
var label = j;
var data = [];
for(n=0; n<neighbours.length; n++) {
if (neighbours[n].mac != j) { continue; }
label = neighbours[n].name;
// add network interface when there are multiple links to same node
var k;
for(k=0; k<neighbours.length; k++) {
if(label == neighbours[k].name && k != n) {
label += "@" + neighbours[n].netif;
}
}
if(j in neigh_label) {
label = neigh_label[j];
}
for (len=dataset.length, i=0; i<len; i++) {
try {

View File

@ -420,6 +420,7 @@
var router_stats = {{ router.stats|statbson2json|safe }};
var netif_stats = null;
var neigh_stats = {{ neighstats|safe }};
var neigh_label = {{ neighlabel|bson2json|safe }};
var gw_stats = {{ gwstats|statbson2json|safe }};
var neighbours = [
{%- for neighbour in router.neighbours %}
@ -433,7 +434,7 @@
];
$(document).ready(function() {
{%- if router.neighbours|length > 0 %}
neighbour_graph(neighbours);
neighbour_graph(neigh_label);
{%- endif %}
{%- if router.gws|length > 0 %}
gw_graph(gws);
@ -459,7 +460,7 @@
var starttimeneigh = performance.now();
ajax_get_request(url_load_neigh_stats, function(neighstats) {
neigh_stats = neighstats;
neighbour_graph(neighbours) && $("#loadneighstats").hide();
neighbour_graph(neigh_label) && $("#loadneighstats").hide();
console.debug("Loaded full neighbor stats in "+((performance.now() - starttimeneigh)/1000).toFixed(3)+" seconds.");
});
}