luci-app-dawn: rewrite dawn hearing map in table form

Signed-off-by: Jonny Tischbein <jonny_tischbein@systemli.org>
This commit is contained in:
Jonny Tischbein 2020-04-18 10:18:29 +02:00
parent f32978674b
commit f25910a644

View file

@ -6,58 +6,79 @@ s = m:section(NamedSection, "__hearingmap__")
function s.render(self, sid) function s.render(self, sid)
local tpl = require "luci.template" local tpl = require "luci.template"
tpl.render_string([[ tpl.render_string([[
<ul> <style>.hearing_table tr{ border-bottom: 1px solid grey;} tr:nth-child(even){background-color: lightgrey;}</style>
<% <%
local utl = require "luci.util" local utl = require "luci.util"
local status = require "luci.tools.ieee80211" local status = require "luci.tools.ieee80211"
local stat = utl.ubus("dawn", "get_hearing_map", { }) local stat = utl.ubus("dawn", "get_hearing_map", { })
local name, macs local name, macs
for name, macs in pairs(stat) do for name, macs in pairs(stat) do
local count = 0
for a,b in pairs(macs) do for _ in pairs(b) do count = count + 1 end end
%> %>
<li> <table class="table" style="border: 1px solid grey;">
<strong>SSID is: </strong><%= name %><br /> <thead style="background-color: grey; color: white;">
</li> <tr>
<ul> <th>SSID</th>
<th>Client MAC</th>
<th>AP MAC</th>
<th>Frequency</th>
<th>HT Sup</th>
<th>VHT Sup</th>
<th>Signal</th>
<th>RCPI</th>
<th>RSNI</th>
<th>Channel<br />Utilization</th>
<th>Station connect<br />to AP</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<tr class="center" style="border: 1px solid grey;">
<td rowspan="<%= count + 1 %>" style="background-color: white; border-right: 1px solid grey;"><%= name %></td>
<% <%
local mac, data local mac, data
for mac, data in pairs(macs) do for mac, data in pairs(macs) do
%>
<li>
<strong>Client MAC is: </strong><%= mac %><br />
</li>
<ul>
<%
local mac2, data2 local mac2, data2
local count_macs = 0
local count_loop = 0
for _ in pairs(data) do count_macs = count_macs + 1 end
for mac2, data2 in pairs(data) do for mac2, data2 in pairs(data) do
%> %>
<li> <tr class="center" style="border: 1px solid grey;">
<strong>AP is: </strong><%= mac2 %><br /> <% if (count_macs > 1) then %>
<strong>Frequency is: </strong><%= "%.3f" %( data2.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %>)<br /> <% if (count_loop == 0 ) then %>
<strong>HT support is: </strong><%= (data2.ht_capabilities == true and data2.ht_support == true) and "available" or "not available" %><br /> <td rowspan="<%= count_macs %>" style="background-color: white; border-right: 1px solid grey;"><%= mac %></td>
<strong>VHT support is: </strong><%= (data2.vht_capabilities == true and data2.vht_support == true) and "available" or "not available" %><br /> <% end %>
<!-- <% else %>
<strong>AP HT support is: </strong><%= (data2.ht_support == true) and "available" or "not available" %><br /> <td><%= mac %></td>
<strong>AP VHT support is: </strong><%= (data2.vht_support == true) and "available" or "not available" %><br /> <% end %>
<strong>Client HT support is: </strong><%= (data2.ht_capabilities == true) and "available" or "not available" %><br /> <td><%= mac2 %></td>
<strong>Client VHT support is: </strong><%= (data2.vht_capabilities == true) and "available" or "not available" %><br /> <td><%= "%.3f" %( data2.freq / 1000 ) %> GHz<br />(Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %>)</td>
--!> <td><%= (data2.ht_capabilities == true and data2.ht_support == true) and "True" or "False" %></td>
<strong>Signal is: </strong><%= "%d" %data2.signal %><br /> <td><%= (data2.vht_capabilities == true and data2.vht_support == true) and "True" or "False" %></td>
<strong>Channel Utilization is: </strong><%= "%d" %data2.channel_utilization %><br /> <td><%= "%d" %data2.signal %></td>
<strong>Station connected to AP is: </strong><%= "%d" %data2.num_sta %><br /> <td><%= "%d" %data2.rcpi %></td>
<strong>Score is: </strong><%= "%d" %data2.score %><br /> <td><%= "%d" %data2.rsni %></td>
</li> <td><%= "%.2f" %(data2.channel_utilization / 2.55) %> %</td>
<td><%= "%d" %data2.num_sta %></td>
<td><%= "%d" %data2.score %></td>
</tr>
<%
count_loop = count_loop + 1
end
%>
<% <%
end end
%> %>
</ul> </tr>
</tbody>
</table>
<% <%
end end
%> %>
</ul>
<%
end
%>
</ul>
]]) ]])
end end