Improve hidden node reporting & fix column alignments (#1098)

* Fix ETX alignment

* Move hidden into Remote Nodes section.
Simplify node status construction
This commit is contained in:
Tim Wilkinson 2024-02-11 21:04:02 -08:00 committed by GitHub
parent 270b205a8b
commit e76c21de2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 61 additions and 66 deletions

View File

@ -360,6 +360,16 @@ if nixio.fs.stat("/tmp/node.history") then
end end
end end
function ac(a, b)
if not a or a == "" then
return b
elseif not b or b == "" then
return a
else
return a .. "," .. b
end
end
------------------ ------------------
-- generate page -- generate page
------------------ ------------------
@ -442,10 +452,15 @@ html.print([[
#cTable th:nth-child(9) { #cTable th:nth-child(9) {
width: 25%; width: 25%;
} }
#rTable th:nth-child(3) { #rTable th:nth-child(3), #rTable td:nth-child(3) {
width: 30%; width: 4%;
padding: 0 2px 0 0;
text-align: right;
} }
#rTable th:nth-child(4) { #rTable th:nth-child(4) {
width: 26%;
}
#rTable th:nth-child(5) {
width: 25%; width: 25%;
} }
tr.s.f.nf { tr.s.f.nf {
@ -747,23 +762,7 @@ do
end end
if nodeiface or waniface or lqmstatus then if nodeiface or waniface or lqmstatus then
c1 = c1 .. "&nbsp;<small>(" c1 = c1 .. "&nbsp;<small>(" .. ac(ac(nodeiface, waniface), lqmstatus) .. ")</small>"
if nodeiface then
c1 = c1 .. nodeiface
end
if waniface then
if nodeiface then
c1 = c1 .. ","
end
c1 = c1 .. waniface
end
if lqmstatus then
if nodeiface or waniface then
c1 = c1 .. ","
end
c1 = c1 .. lqmstatus
end
c1 = c1 .. ")</small>"
end end
-- print node services if any -- print node services if any
@ -807,7 +806,7 @@ do
end end
for _, track in pairs(trackers) for _, track in pairs(trackers)
do do
if track.blocked or track.hidden then if track.blocked then
local name = track.ip local name = track.ip
if track.hostname then if track.hostname then
name = track.hostname name = track.hostname
@ -820,37 +819,33 @@ do
if track.type == "RF" then if track.type == "RF" then
type = "rf," type = "rf,"
end end
if track.blocked then if track.blocks.user then
if track.blocks.user then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked user)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked user)</small>" elseif track.blocks.dtd then
elseif track.blocks.dtd then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked dtd)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked dtd)</small>" elseif track.blocks.distance then
elseif track.blocks.distance then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked distance)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked distance)</small>" elseif track.blocks.signal then
elseif track.blocks.signal then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked signal)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked signal)</small>" elseif track.blocks.dup then
elseif track.blocks.dup then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked dup)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked dup)</small>" elseif track.blocks.quality then
elseif track.blocks.quality then if track.tx_quality < track.ping_quality then
if track.tx_quality < track.ping_quality then c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked retries)</small>"
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked retries)</small>"
else
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked latency)</small>"
end
else else
c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked)</small>" c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked latency)</small>"
end end
if track.snr > 0 then else
c4b = track.snr c1 = c1 .. "&nbsp;<small>(" .. type .. "blocked)</small>"
if track.rev_snr then end
c4b = c4b .. "/" .. track.rev_snr if track.snr > 0 then
end c4b = track.snr
if track.rev_snr then
c4b = c4b .. "/" .. track.rev_snr
end end
if track.quality then end
c4c = track.quality .. "%" if track.quality then
end c4c = track.quality .. "%"
elseif track.hidden then
c1 = c1 .. "&nbsp;<small>(" .. type .. "hidden)</small>"
end end
if track.distance then if track.distance then
if true then if true then
@ -868,6 +863,7 @@ do
rows[#rows + 1] = { key = name:lower(), row = row } rows[#rows + 1] = { key = name:lower(), row = row }
end end
end end
if #rows > 0 then if #rows > 0 then
table.sort(rows, function(a,b) return a.key < b.key end) table.sort(rows, function(a,b) return a.key < b.key end)
for _, row in ipairs(rows) for _, row in ipairs(rows)
@ -938,7 +934,7 @@ html.print("</table>")
html.print("<table id='rTable' class=s><tr class=h>") html.print("<table id='rTable' class=s><tr class=h>")
html.print("<th>Remote Nodes</th>") html.print("<th>Remote Nodes</th>")
html.print("<th>LAN Hostname</th>") html.print("<th>LAN Hostname</th>")
html.print("<th>ETX</th>") html.print("<th>ETX</th><th></th>")
html.print("<th>Service Name</th>") html.print("<th>Service Name</th>")
html.print("</tr>") html.print("</tr>")
@ -956,6 +952,9 @@ do
local etx = string.format("%.2f", host.etx) local etx = string.format("%.2f", host.etx)
c1 = "<a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>" c1 = "<a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>"
local nodeiface local nodeiface
local tuniface
local waniface
local hidden
local mycount = 0 local mycount = 0
if midcount[ip] then if midcount[ip] then
mycount = midcount[ip] mycount = midcount[ip]
@ -971,21 +970,17 @@ do
mycount = mycount - 1 mycount = mycount - 1
end end
if mycount > 0 then if mycount > 0 then
if nodeiface then tuniface = "tun*" .. mycount
nodeiface = nodeiface .. ",tun*" .. mycount
else
nodeiface = "tun*" .. mycount
end
end end
if wangateway[ip] then if wangateway[ip] then
if nodeiface then waniface = "wan"
nodeiface = nodeiface .. ",wan"
else
nodeiface = "wan"
end
end end
if nodeiface then local track = trackers[ip]
c1 = c1 .. " &nbsp; <small>(" .. nodeiface .. ")</small>" if track and track.hidden then
hidden = "hidden"
end
if nodeiface or waniface then
c1 = c1 .. "&nbsp;<small>(" .. ac(ac(ac(nodeiface, tuniface), waniface), hidden) .. ")</small>"
end end
c2 = "<br>" c2 = "<br>"
c3 = string.format("%s", etx) c3 = string.format("%s", etx)
@ -1039,7 +1034,7 @@ do
end end
end end
-- Build this row -- Build this row
local row = "<tr class=s><td class='s f'>" .. c1 .. "</td><td class='s f'>" .. c2 .. "</td><td>" .. c3 .. "</td><td class='s f'>" .. c4 .. "</td></tr>" local row = "<tr class=s><td class='s f'>" .. c1 .. "</td><td class='s f'>" .. c2 .. "</td><td>" .. c3 .. "</td><td></td><td class='s f'>" .. c4 .. "</td></tr>"
rows[#rows + 1] = { key = string.format("%05d/%s", math.floor(100 * host.etx), host.name:lower()), row = row } rows[#rows + 1] = { key = string.format("%05d/%s", math.floor(100 * host.etx), host.name:lower()), row = row }
end end
end end
@ -1051,24 +1046,24 @@ if #rows > 0 then
do do
html.print(row.row) html.print(row.row)
end end
-- discard
rows = nil
else else
html.print("<tr><td class='s f'>none</td></tr>") html.print("<tr><td class='s f'>none</td></tr>")
end end
-- discard -- discard
rows = nil
neighbor = nil neighbor = nil
dtd = nil dtd = nil
midcount = nil midcount = nil
xlinkcount = nil xlinkcount = nil
wangateway = nil wangateway = nil
services = nil services = nil
trackers = nil
-- discard
links = nil links = nil
ipalias = nil ipalias = nil
hosts = nil hosts = nil
history = nil history = nil
-- end remote nodes table -- end remote nodes table
html.print("</table>") html.print("</table>")