mirror of https://github.com/aredn/aredn.git
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:
parent
270b205a8b
commit
e76c21de2d
|
@ -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 .. " <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 .. " <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,7 +819,6 @@ do
|
|||
if track.type == "RF" then
|
||||
type = "rf,"
|
||||
end
|
||||
if track.blocked then
|
||||
if track.blocks.user then
|
||||
c1 = c1 .. " <small>(" .. type .. "blocked user)</small>"
|
||||
elseif track.blocks.dtd then
|
||||
|
@ -849,9 +847,6 @@ do
|
|||
if track.quality then
|
||||
c4c = track.quality .. "%"
|
||||
end
|
||||
elseif track.hidden then
|
||||
c1 = c1 .. " <small>(" .. type .. "hidden)</small>"
|
||||
end
|
||||
if track.distance then
|
||||
if true then
|
||||
local v = track.distance * 0.000621371
|
||||
|
@ -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"
|
||||
waniface = "wan"
|
||||
end
|
||||
local track = trackers[ip]
|
||||
if track and track.hidden then
|
||||
hidden = "hidden"
|
||||
end
|
||||
if nodeiface then
|
||||
c1 = c1 .. " <small>(" .. nodeiface .. ")</small>"
|
||||
if nodeiface or waniface then
|
||||
c1 = c1 .. " <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>")
|
||||
|
||||
|
|
Loading…
Reference in New Issue