luci-app-bmx6: Fix topology graph with backwards compatibility

Signed-off-by: Pau Escrich <p4u@dabax.net>
This commit is contained in:
Pau Escrich 2014-02-25 18:13:05 +01:00
parent 5366e549dd
commit 6beba22a4d
2 changed files with 11 additions and 11 deletions

View file

@ -240,10 +240,10 @@ function action_topology()
if first then if first then
first = false first = false
else else
topology = topology .. ', ' topology = topology .. ', '
end end
topology = topology .. '{ "globalId": "%s", "links": [' %o.globalId:match("^[^%.]+") topology = topology .. '{ "name": "%s", "links": [' %o.name
local first2 = true local first2 = true
@ -252,10 +252,10 @@ function action_topology()
first2 = false first2 = false
else else
topology = topology .. ', ' topology = topology .. ', '
end end
name = l.name or l.llocalIp or "unknown"
topology = topology .. '{ "globalId": "%s", "rxRate": %s, "txRate": %s }' topology = topology .. '{ "name": "%s", "rxRate": %s, "txRate": %s }'
%{ l.globalId:match("^[^%.]+"), l.rxRate, l.txRate } %{ name, l.rxRate, l.txRate }
end end

View file

@ -57,20 +57,20 @@ the file called "COPYING".
for (var i = 0; i < (data.length); i++) for (var i = 0; i < (data.length); i++)
{ {
// node->node // node->node
if (data[i].globalId) if (data[i].name)
{ {
for (var j = 0; j < (data[i].links.length); j++) for (var j = 0; j < (data[i].links.length); j++)
{ {
var key = (data[i].globalId < data[i].links[j].globalId) var key = (data[i].name < data[i].links[j].name)
? data[i].globalId + '|' + data[i].links[j].globalId ? data[i].name + '|' + data[i].links[j].name
: data[i].links[j].globalId + '|' + data[i].globalId; : data[i].links[j].name + '|' + data[i].name;
var rxRate = data[i].links[j].rxRate; var rxRate = data[i].links[j].rxRate;
var txRate = data[i].links[j].txRate; var txRate = data[i].links[j].txRate;
if (!seen[key] && rxRate>0 && txRate>0) 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, { label: rxRate + '/' + txRate,
directed: false, stroke: '#aaaaaa', fill: '#ffffff', directed: false, stroke: '#aaaaaa', fill: '#ffffff',
'label-style': { 'font-size': 8 }}); 'label-style': { 'font-size': 8 }});