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,59 +6,80 @@ 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
<li> local count = 0
<strong>SSID is: </strong><%= name %><br /> for a,b in pairs(macs) do for _ in pairs(b) do count = count + 1 end end
</li> %>
<ul> <table class="table" style="border: 1px solid grey;">
<% <thead style="background-color: grey; color: white;">
local mac, data <tr>
for mac, data in pairs(macs) do <th>SSID</th>
%> <th>Client MAC</th>
<li> <th>AP MAC</th>
<strong>Client MAC is: </strong><%= mac %><br /> <th>Frequency</th>
</li> <th>HT Sup</th>
<ul> <th>VHT Sup</th>
<% <th>Signal</th>
local mac2, data2 <th>RCPI</th>
for mac2, data2 in pairs(data) do <th>RSNI</th>
%> <th>Channel<br />Utilization</th>
<li> <th>Station connect<br />to AP</th>
<strong>AP is: </strong><%= mac2 %><br /> <th>Score</th>
<strong>Frequency is: </strong><%= "%.3f" %( data2.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %>)<br /> </tr>
<strong>HT support is: </strong><%= (data2.ht_capabilities == true and data2.ht_support == true) and "available" or "not available" %><br /> </thead>
<strong>VHT support is: </strong><%= (data2.vht_capabilities == true and data2.vht_support == true) and "available" or "not available" %><br /> <tbody>
<!-- <tr class="center" style="border: 1px solid grey;">
<strong>AP HT support is: </strong><%= (data2.ht_support == true) and "available" or "not available" %><br /> <td rowspan="<%= count + 1 %>" style="background-color: white; border-right: 1px solid grey;"><%= name %></td>
<strong>AP VHT support is: </strong><%= (data2.vht_support == true) and "available" or "not available" %><br /> <%
<strong>Client HT support is: </strong><%= (data2.ht_capabilities == true) and "available" or "not available" %><br /> local mac, data
<strong>Client VHT support is: </strong><%= (data2.vht_capabilities == true) and "available" or "not available" %><br /> for mac, data in pairs(macs) do
--!> local mac2, data2
<strong>Signal is: </strong><%= "%d" %data2.signal %><br /> local count_macs = 0
<strong>Channel Utilization is: </strong><%= "%d" %data2.channel_utilization %><br /> local count_loop = 0
<strong>Station connected to AP is: </strong><%= "%d" %data2.num_sta %><br /> for _ in pairs(data) do count_macs = count_macs + 1 end
<strong>Score is: </strong><%= "%d" %data2.score %><br />
</li> for mac2, data2 in pairs(data) do
<% %>
end <tr class="center" style="border: 1px solid grey;">
%> <% if (count_macs > 1) then %>
</ul> <% if (count_loop == 0 ) then %>
<% <td rowspan="<%= count_macs %>" style="background-color: white; border-right: 1px solid grey;"><%= mac %></td>
end <% end %>
%> <% else %>
</ul> <td><%= mac %></td>
<% end %>
<td><%= mac2 %></td>
<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>
<td><%= (data2.vht_capabilities == true and data2.vht_support == true) and "True" or "False" %></td>
<td><%= "%d" %data2.signal %></td>
<td><%= "%d" %data2.rcpi %></td>
<td><%= "%d" %data2.rsni %></td>
<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
%>
</tr>
</tbody>
</table>
<% <%
end end
%> %>
</ul> ]])
]])
end end
return m return m