luci-app-olsr: change menu order and improve etx display for neighbours status view.

Signed-off-by: Ayushman Tripathi <ayushmantripathi7724@gmail.com>
This commit is contained in:
Ayushman Tripathi 2023-10-29 17:14:05 +05:30
parent ebd09332b4
commit df70c0d328
2 changed files with 49 additions and 49 deletions

View file

@ -161,26 +161,26 @@ return view.extend({
}); });
await Promise.all(networkPromises); await Promise.all(networkPromises);
var res = ''; var res = '';
var self = this; var self = this;
await (async function() { await (async function () {
try { try {
res = await self.callGetHosts(); res = await self.callGetHosts();
} }
catch (e) { catch (e) {
console.error(e); console.error(e);
} }
})(); })();
function matchHostnames(ip) { function matchHostnames(ip) {
var lines = res.hosts.split('\n'); var lines = res.hosts.split('\n');
for (var i = 0; i < lines.length; i++) { for (var i = 0; i < lines.length; i++) {
var ipandhostname = lines[i].trim().split(/\s+/); var ipandhostname = lines[i].trim().split(/\s+/);
if (ipandhostname[0] === ip) { if (ipandhostname[0] === ip) {
return ipandhostname[1]; return ipandhostname[1];
} }
} }
return null; return null;
} }
var modifiedData = await Promise.all( var modifiedData = await Promise.all(
data.map(async function (v) { data.map(async function (v) {
@ -197,7 +197,7 @@ return view.extend({
v.hostname = hostname; v.hostname = hostname;
} }
} }
var hosthints = await network.getHostHints(); var hosthints = await network.getHostHints();
var interfac = await network.getStatusByAddress(v.localIP); var interfac = await network.getStatusByAddress(v.localIP);
var lmac = await hosthints.getMACAddrByIPAddr(v.localIP); var lmac = await hosthints.getMACAddrByIPAddr(v.localIP);
var rmac = await hosthints.getMACAddrByIPAddr(v.remoteIP); var rmac = await hosthints.getMACAddrByIPAddr(v.remoteIP);
@ -281,7 +281,7 @@ return view.extend({
var rv = []; var rv = [];
for (var k = 0; k < neigh_res.length; k++) { for (var k = 0; k < neigh_res.length; k++) {
var link = neigh_res[k]; var link = neigh_res[k];
link.linkCost = parseInt(link.linkCost) || 0; link.linkCost = (link.linkCost).toFixed(3) || 0;
if (link.linkCost === 4194304) { if (link.linkCost === 4194304) {
link.linkCost = 0; link.linkCost = 0;
} }
@ -299,7 +299,7 @@ return view.extend({
ifn: link.interface, ifn: link.interface,
lq: link.linkQuality.toFixed(3), lq: link.linkQuality.toFixed(3),
nlq: link.neighborLinkQuality.toFixed(3), nlq: link.neighborLinkQuality.toFixed(3),
cost: link.linkCost.toFixed(3), cost: link.linkCost,
snr: link.snr, snr: link.snr,
signal: link.signal, signal: link.signal,
noise: link.noise, noise: link.noise,
@ -365,7 +365,7 @@ return view.extend({
'<div class="td cbi-section-table-cell left" style="background-color:' + '<div class="td cbi-section-table-cell left" style="background-color:' +
neigh.dfgcolor + neigh.dfgcolor +
'">' + '">' +
(neigh?.ifn?.interface ?? '?') + (neigh?.ifn?.interface ?? '?') +
'</div>' + '</div>' +
'<div class="td cbi-section-table-cell left" style="background-color:' + '<div class="td cbi-section-table-cell left" style="background-color:' +
neigh.dfgcolor + neigh.dfgcolor +
@ -406,7 +406,7 @@ return view.extend({
for (var k = 0; k < neigh_res.length; k++) { for (var k = 0; k < neigh_res.length; k++) {
var link = neigh_res[k]; var link = neigh_res[k];
link.linkCost = parseInt(link.linkCost) || 0; link.linkCost = Number(link.linkCost).toFixed(3) || 0;
if (link.linkCost === 4194304) { if (link.linkCost === 4194304) {
link.linkCost = 0; link.linkCost = 0;
} }
@ -431,37 +431,37 @@ return view.extend({
[ [
link.proto === '6' link.proto === '6'
? E( ? E(
'div', 'div',
{ {
'class': 'td cbi-section-table-cell left', 'class': 'td cbi-section-table-cell left',
'style': 'background-color:' + defaultgw_color, 'style': 'background-color:' + defaultgw_color,
}, },
[ [
E( E(
'a', 'a',
{ {
'href': 'http://[' + link.remoteIP + ']/cgi-bin-status.html', 'href': 'http://[' + link.remoteIP + ']/cgi-bin-status.html',
}, },
link.remoteIP link.remoteIP
), ),
] ]
) )
: E( : E(
'div', 'div',
{ {
'class': 'td cbi-section-table-cell left', 'class': 'td cbi-section-table-cell left',
'style': 'background-color:' + defaultgw_color, 'style': 'background-color:' + defaultgw_color,
}, },
[ [
E( E(
'a', 'a',
{ {
'href': 'http://' + link.remoteIP + '/cgi-bin-status.html', 'href': 'http://' + link.remoteIP + '/cgi-bin-status.html',
}, },
link.remoteIP link.remoteIP
), ),
] ]
), ),
E( E(
'div', 'div',
{ {
@ -508,7 +508,7 @@ return view.extend({
'class': 'td cbi-section-table-cell left', 'class': 'td cbi-section-table-cell left',
'style': 'background-color:' + color, 'style': 'background-color:' + color,
}, },
[E('div', {}, link.linkCost.toFixed(3))] [E('div', {}, link.linkCost)]
), ),
E( E(
'div', 'div',

View file

@ -1,7 +1,7 @@
{ {
"olsr": { "olsr": {
"title": "OLSR", "title": "OLSR",
"order": 5, "order": 9,
"action": { "action": {
"type": "firstchild" "type": "firstchild"
} }