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
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

View File

@ -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 }});