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