From 6beba22a4d96eb0d40132298885e0b7da6741210 Mon Sep 17 00:00:00 2001 From: Pau Escrich Date: Tue, 25 Feb 2014 18:13:05 +0100 Subject: [PATCH] luci-app-bmx6: Fix topology graph with backwards compatibility Signed-off-by: Pau Escrich --- .../files/usr/lib/lua/luci/controller/bmx6.lua | 12 ++++++------ .../files/usr/lib/lua/luci/view/bmx6/graph.htm | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua b/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua index 26e1cb3..9529cf8 100644 --- a/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua +++ b/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua @@ -240,10 +240,10 @@ function action_topology() if first then first = false else - topology = topology .. ', ' + topology = topology .. ', ' end - topology = topology .. '{ "globalId": "%s", "links": [' %o.globalId:match("^[^%.]+") + topology = topology .. '{ "name": "%s", "links": [' %o.name local first2 = true @@ -252,10 +252,10 @@ function action_topology() first2 = false else topology = topology .. ', ' - end - - topology = topology .. '{ "globalId": "%s", "rxRate": %s, "txRate": %s }' - %{ l.globalId:match("^[^%.]+"), l.rxRate, l.txRate } + end + name = l.name or l.llocalIp or "unknown" + topology = topology .. '{ "name": "%s", "rxRate": %s, "txRate": %s }' + %{ name, l.rxRate, l.txRate } end diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm index a4dabb7..401e932 100644 --- a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm +++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm @@ -57,20 +57,20 @@ the file called "COPYING". for (var i = 0; i < (data.length); i++) { // node->node - if (data[i].globalId) + if (data[i].name) { for (var j = 0; j < (data[i].links.length); j++) { - var key = (data[i].globalId < data[i].links[j].globalId) - ? data[i].globalId + '|' + data[i].links[j].globalId - : data[i].links[j].globalId + '|' + data[i].globalId; + var key = (data[i].name < data[i].links[j].name) + ? data[i].name + '|' + data[i].links[j].name + : data[i].links[j].name + '|' + data[i].name; var rxRate = data[i].links[j].rxRate; var txRate = data[i].links[j].txRate; if (!seen[key] && rxRate>0 && txRate>0) { - g.addEdge(data[i].globalId, data[i].links[j].globalId, + g.addEdge(data[i].name, data[i].links[j].name, { label: rxRate + '/' + txRate, directed: false, stroke: '#aaaaaa', fill: '#ffffff', 'label-style': { 'font-size': 8 }}); -- 2.30.2