mirror of https://github.com/aredn/aredn.git
fix mesh search rows (#546)
This commit is contained in:
parent
eb631e4819
commit
cd661106a8
|
@ -512,6 +512,7 @@ if not next(localhosts) and not next(links) then
|
||||||
end
|
end
|
||||||
|
|
||||||
-- show local node table
|
-- show local node table
|
||||||
|
|
||||||
html.print("<table id=nTable>")
|
html.print("<table id=nTable>")
|
||||||
html.print("<tr>")
|
html.print("<tr>")
|
||||||
html.print("<th width=25%><input class=search type=text id='inNN' onkeyup=nSearch('inNN','nTable',0) placeholder='Node Name'></th>")
|
html.print("<th width=25%><input class=search type=text id='inNN' onkeyup=nSearch('inNN','nTable',0) placeholder='Node Name'></th>")
|
||||||
|
@ -523,24 +524,37 @@ if next(localhosts) then
|
||||||
local rows = {}
|
local rows = {}
|
||||||
for ip, host in pairs(localhosts)
|
for ip, host in pairs(localhosts)
|
||||||
do
|
do
|
||||||
|
local c1, c2, c3
|
||||||
local localpart = host.name:match("([^.]*)%.")
|
local localpart = host.name:match("([^.]*)%.")
|
||||||
if localpart then
|
if localpart then
|
||||||
local tactical = ""
|
local tactical = ""
|
||||||
if host.tactical ~= "" then
|
if host.tactical ~= "" then
|
||||||
tactical = " / " .. host.tactical
|
tactical = " / " .. host.tactical
|
||||||
end
|
end
|
||||||
local row = "<tr><td>" .. localpart .. tactical
|
c1 = localpart .. tactical
|
||||||
if wangateway[ip] then
|
if wangateway[ip] then
|
||||||
row = row .. " <small>(wan)</small>"
|
c1 = c1 .. " <small>(wan)</small>"
|
||||||
end
|
end
|
||||||
row = row .. "</td><td></td><td>"
|
c2 = "<br>"
|
||||||
if services[host.name] then
|
if services[host.name] then
|
||||||
for n, v in pairs(services[host.name])
|
local i=1
|
||||||
|
for _, v in pairs(services[host.name])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c3 then
|
||||||
|
c3 = c3 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c3 = v .. "<br>"
|
||||||
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if c3 then
|
||||||
|
c3 = c3 .. "<br>"
|
||||||
|
else
|
||||||
|
c3 = "<br>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
|
||||||
|
|
||||||
-- add locally advertised dmz hosts
|
-- add locally advertised dmz hosts
|
||||||
for i, dmzhost in ipairs(host.hosts)
|
for i, dmzhost in ipairs(host.hosts)
|
||||||
|
@ -564,22 +578,29 @@ if next(localhosts) then
|
||||||
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
||||||
if localpart then
|
if localpart then
|
||||||
if not nopropd and not aliased then
|
if not nopropd and not aliased then
|
||||||
row = row .. "<tr><td></td><td>" .. localpart .. "</td>"
|
c2 = c2 .. localpart .. "<br>"
|
||||||
elseif aliased then
|
elseif aliased then
|
||||||
row = row .. "<tr><td></td><td class=aliased-hosts title='Aliased Host'>" .. localpart .. "</td>"
|
c2 = c2 .. "<span class=aliased-hosts>" .. localpart .. "</span><br>"
|
||||||
else
|
else
|
||||||
row = row .. "<tr><td></td><td class=hidden-hosts title='Non Propagated Host'>" .. localpart .."</td>"
|
c2 = c2 .. "<span class=hidden-hosts>" .. localpart .. "</span><br>"
|
||||||
end
|
end
|
||||||
if services[dmzhost] then
|
if services[dmzhost] then
|
||||||
row = row .. "</td><td>"
|
local i=1
|
||||||
for n, v in pairs(services[dmzhost])
|
for n, v in pairs(services[dmzhost])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c3 then
|
||||||
|
c3 = c3 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c3 = v .. "<br>"
|
||||||
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Build this row
|
||||||
|
local row = "<tr><td>" .. c1 .. "</td><td>" .. c2 .. "</td><td>" .. c3 .. "</td></tr>"
|
||||||
rows[#rows + 1] = { key = host.name, row = row }
|
rows[#rows + 1] = { key = host.name, row = row }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -596,16 +617,15 @@ end
|
||||||
|
|
||||||
-- discard
|
-- discard
|
||||||
localhosts = nil
|
localhosts = nil
|
||||||
|
|
||||||
-- end local node table
|
-- end local node table
|
||||||
html.print("</table>")
|
html.print("</table>")
|
||||||
|
|
||||||
-- show current neighbors table
|
-- show current neighbors table
|
||||||
|
|
||||||
html.print("<br><table id='cTable'><tr>")
|
html.print("<br><table id='cTable'><tr>")
|
||||||
html.print("<th width=25%><input class=search type=text id='inCN' onkeyup=nSearch('inCN','cTable',0) placeholder='Current Neighbor'></th>")
|
html.print("<th width=25%><input class=search type=text id='inCN' onkeyup=nSearch('inCN','cTable',0) placeholder='Current Neighbor'></th>")
|
||||||
html.print("<th><input class=search type=text id='inCH' onkeyup=nSearch('inCH','cTable',1) placeholder='Lan Hostname'></th>")
|
html.print("<th><input class=search type=text id='inCH' onkeyup=nSearch('inCH','cTable',1) placeholder='Lan Hostname'></th>")
|
||||||
html.print("<th>LQ</th><th>NLQ</th><th>TxMbps</th>")
|
html.print("<th>LQ</th><th>NLQ</th><th>TxMbps</th>")
|
||||||
--html.print("<th>Service Name</th>")
|
|
||||||
html.print("<th><input class=search type=text id='inCS' onkeyup=nSearch('inCS','cTable',5) placeholder='Service Name'></th>")
|
html.print("<th><input class=search type=text id='inCS' onkeyup=nSearch('inCS','cTable',5) placeholder='Service Name'></th>")
|
||||||
html.print("</tr>")
|
html.print("</tr>")
|
||||||
|
|
||||||
|
@ -613,6 +633,7 @@ local rows = {}
|
||||||
local neighservices = {}
|
local neighservices = {}
|
||||||
for ip, link in pairs(links)
|
for ip, link in pairs(links)
|
||||||
do
|
do
|
||||||
|
local c1,c2,c3,c4,c5,c6
|
||||||
local ipmain = ipalias[ip]
|
local ipmain = ipalias[ip]
|
||||||
if not ipmain then
|
if not ipmain then
|
||||||
ipmain = ip
|
ipmain = ip
|
||||||
|
@ -637,7 +658,7 @@ do
|
||||||
name = name .. " " -- avoid collision 2 links to same host {rf, dtd}
|
name = name .. " " -- avoid collision 2 links to same host {rf, dtd}
|
||||||
end
|
end
|
||||||
local no_space_host = name:match("(.*%S)%s*$")
|
local no_space_host = name:match("(.*%S)%s*$")
|
||||||
local row = "<tr><td><a href='http://" .. no_space_host .. ":8080/'>" .. localpart .. tactical .. "</a>"
|
c1 = "<a href='http://" .. no_space_host .. ":8080/'>" .. localpart .. tactical .. "</a>"
|
||||||
local nodeiface
|
local nodeiface
|
||||||
if ipmain ~= ip then
|
if ipmain ~= ip then
|
||||||
if links[ip].dtd then
|
if links[ip].dtd then
|
||||||
|
@ -656,20 +677,35 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nodeiface then
|
if nodeiface then
|
||||||
row = row .. " <small>(" .. nodeiface .. ")</small>"
|
c1 = c1 .. " <small>(" .. nodeiface .. ")</small>"
|
||||||
end
|
end
|
||||||
row = row .. string.format("</td><td></td><td>%.0f%%</td><td>%.0f%%</td><td>%s</td>", 100 * link.lq, 100 * link.nlq, link.mbps)
|
c2 = "<br>"
|
||||||
|
c3 = string.format("%.0f%%", 100 * link.lq)
|
||||||
|
c4 = string.format("%.0f%%", 100 * link.nlq)
|
||||||
|
c5 = string.format("%s", link.mbps)
|
||||||
|
|
||||||
|
-- print node services if any
|
||||||
if not neighservices[name] then
|
if not neighservices[name] then
|
||||||
neighservices[name] = true
|
neighservices[name] = true
|
||||||
row = row .. "<td>"
|
|
||||||
if services[name] then
|
if services[name] then
|
||||||
|
local i=1
|
||||||
for _, v in pairs(services[name])
|
for _, v in pairs(services[name])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c6 then
|
||||||
|
c6 = c6 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c6 = v .. "<br>"
|
||||||
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if c6 then
|
||||||
|
c6 = c6 .. "<br>"
|
||||||
|
else
|
||||||
|
c6 = "<br>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
|
||||||
|
|
||||||
-- add advertised dmz hosts
|
-- add advertised dmz hosts
|
||||||
if host then
|
if host then
|
||||||
|
@ -677,20 +713,32 @@ do
|
||||||
do
|
do
|
||||||
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
||||||
if localpart then
|
if localpart then
|
||||||
row = row .. "<tr><td></td><td>" .. localpart .. "</td>"
|
c2 = c2 .. localpart .. "<br>"
|
||||||
row = row .. "<td></td><td></td><td></td><td>"
|
|
||||||
if services[dmzhost] then
|
if services[dmzhost] then
|
||||||
|
local i=1
|
||||||
for _, v in pairs(services[dmzhost])
|
for _, v in pairs(services[dmzhost])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c6 then
|
||||||
|
c6 = c6 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c6 = v .. "<br>"
|
||||||
end
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
else
|
||||||
|
if c6 then
|
||||||
|
c6 = c6 .. "<br>"
|
||||||
|
else
|
||||||
|
c6 = "<br>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Build this row
|
||||||
|
local row = "<tr><td>" .. c1 .. "</td><td>" .. c2 .. "</td><td>" .. c3 .. "</td><td>" .. c4 .. "</td><td>" .. c5 .. "</td><td>" .. c6 .. "</td></tr>"
|
||||||
rows[#rows + 1] = { key = name, row = row }
|
rows[#rows + 1] = { key = name, row = row }
|
||||||
end
|
end
|
||||||
if #rows > 0 then
|
if #rows > 0 then
|
||||||
|
@ -746,7 +794,7 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #rows > 0 then
|
if #rows > 0 then
|
||||||
html.print("<tr><td style='color:sienna;font-weight:bold'>Previous Neighbors</td></tr>")
|
html.print("<tr><td style='color:sienna;font-weight:bold;padding-top:10px;'>Previous Neighbors</td></tr>")
|
||||||
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)
|
||||||
do
|
do
|
||||||
|
@ -755,11 +803,11 @@ if #rows > 0 then
|
||||||
-- discard
|
-- discard
|
||||||
rows = nil
|
rows = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- end current neighbors table
|
-- end current neighbors table
|
||||||
html.print("</table>")
|
html.print("</table>")
|
||||||
|
|
||||||
-- show remote node table
|
-- show remote node table
|
||||||
|
|
||||||
html.print("<br><table id='rTable'><tr>")
|
html.print("<br><table id='rTable'><tr>")
|
||||||
html.print("<th width=25%><input class=search type=text id='inRN' onkeyup=nSearch('inRN','rTable',0) placeholder='Remote Nodes'></th>")
|
html.print("<th width=25%><input class=search type=text id='inRN' onkeyup=nSearch('inRN','rTable',0) placeholder='Remote Nodes'></th>")
|
||||||
html.print("<th><input class=search type=text id='inRH' onkeyup=nSearch('inRH','rTable',1) placeholder='LAN Hostname'</th>")
|
html.print("<th><input class=search type=text id='inRH' onkeyup=nSearch('inRH','rTable',1) placeholder='LAN Hostname'</th>")
|
||||||
|
@ -767,10 +815,10 @@ html.print("<th>ETX</th>")
|
||||||
html.print("<th><input class=search type=text id='inRS' onkeyup=nSearch('inRS','rTable',3) placeholder='Service Name'</th>")
|
html.print("<th><input class=search type=text id='inRS' onkeyup=nSearch('inRS','rTable',3) placeholder='Service Name'</th>")
|
||||||
html.print("</tr>")
|
html.print("</tr>")
|
||||||
|
|
||||||
|
|
||||||
local rows = {}
|
local rows = {}
|
||||||
for ip, host in pairs(hosts)
|
for ip, host in pairs(hosts)
|
||||||
do
|
do
|
||||||
|
local c1,c2,c3,c4
|
||||||
if not neighbor[ip] and host.name then
|
if not neighbor[ip] and host.name then
|
||||||
local localpart = host.name:match("(.*)%.local%.mesh")
|
local localpart = host.name:match("(.*)%.local%.mesh")
|
||||||
if localpart then
|
if localpart then
|
||||||
|
@ -779,7 +827,7 @@ do
|
||||||
tactical = " / " .. host.tactical
|
tactical = " / " .. host.tactical
|
||||||
end
|
end
|
||||||
local etx = string.format("%.2f", host.etx)
|
local etx = string.format("%.2f", host.etx)
|
||||||
local row = "<tr><td><a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>"
|
c1 = "<a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>"
|
||||||
local nodeiface
|
local nodeiface
|
||||||
local mycount = 0
|
local mycount = 0
|
||||||
if midcount[ip] then
|
if midcount[ip] then
|
||||||
|
@ -802,33 +850,61 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nodeiface then
|
if nodeiface then
|
||||||
row = row .. " <small>(" .. nodeiface .. ")</small>"
|
c1 = c1 .. " <small>(" .. nodeiface .. ")</small>"
|
||||||
end
|
end
|
||||||
row = row .. "</td><td></td><td>" .. etx .. "</td><td>"
|
c2 = "<br>"
|
||||||
|
c3 = string.format("%s", etx)
|
||||||
|
|
||||||
|
-- print node services if any
|
||||||
if services[host.name] then
|
if services[host.name] then
|
||||||
|
local i=1
|
||||||
for _, v in pairs(services[host.name])
|
for _, v in pairs(services[host.name])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c4 then
|
||||||
|
c4 = c4 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c4 = v .. "<br>"
|
||||||
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if c4 then
|
||||||
|
c4 = c4 .. "<br>"
|
||||||
|
else
|
||||||
|
c4 = "<br>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
|
||||||
|
|
||||||
-- add locally advertised dmz hosts
|
-- add locally advertised dmz hosts
|
||||||
for _, dmzhost in ipairs(host.hosts)
|
for _, dmzhost in ipairs(host.hosts)
|
||||||
do
|
do
|
||||||
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
local localpart = dmzhost:match("(.*)%.local%.mesh")
|
||||||
if localpart then
|
if localpart then
|
||||||
row = row .. "<tr><td></td><td>" .. localpart .. "</td><td></td><td>"
|
c2 = c2 .. localpart .. "<br>"
|
||||||
if services[dmzhost] then
|
if services[dmzhost] then
|
||||||
|
local i=1
|
||||||
for _, v in pairs(services[dmzhost])
|
for _, v in pairs(services[dmzhost])
|
||||||
do
|
do
|
||||||
row = row .. v .. "<br>"
|
if c4 then
|
||||||
|
c4 = c4 .. v .. "<br>"
|
||||||
|
else
|
||||||
|
c4 = v .. "<br>"
|
||||||
|
end
|
||||||
|
if i > 1 then c2 = c2 .. "<br>" end
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if c4 then
|
||||||
|
c4 = c4 .. "<br>"
|
||||||
|
else
|
||||||
|
c4 = "<br>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
row = row .. "</td></tr>"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Build this row
|
||||||
|
local row = "<tr><td>" .. c1 .. "</td><td>" .. c2 .. "</td><td>" .. c3 .. "</td><td>" .. c4 .. "</td></tr>"
|
||||||
rows[#rows + 1] = { key = host.etx, row = row }
|
rows[#rows + 1] = { key = host.etx, row = row }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -857,7 +933,6 @@ 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>")
|
||||||
|
|
||||||
|
@ -889,4 +964,3 @@ html.print([[
|
||||||
html.footer();
|
html.footer();
|
||||||
html.print("</body>")
|
html.print("</body>")
|
||||||
html.print("</html>")
|
html.print("</html>")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue