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)
local tpl = require "luci.template"
tpl.render_string([[
<ul>
<%
local utl = require "luci.util"
local status = require "luci.tools.ieee80211"
local stat = utl.ubus("dawn", "get_hearing_map", { })
local name, macs
for name, macs in pairs(stat) do
%>
<li>
<strong>SSID is: </strong><%= name %><br />
</li>
<ul>
<%
local mac, data
for mac, data in pairs(macs) do
%>
<li>
<strong>Client MAC is: </strong><%= mac %><br />
</li>
<ul>
<%
local mac2, data2
for mac2, data2 in pairs(data) do
%>
<li>
<strong>AP is: </strong><%= mac2 %><br />
<strong>Frequency is: </strong><%= "%.3f" %( data2.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %>)<br />
<strong>HT support is: </strong><%= (data2.ht_capabilities == true and data2.ht_support == true) and "available" or "not available" %><br />
<strong>VHT support is: </strong><%= (data2.vht_capabilities == true and data2.vht_support == true) and "available" or "not available" %><br />
<!--
<strong>AP HT support is: </strong><%= (data2.ht_support == true) and "available" or "not available" %><br />
<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 />
<strong>Client VHT support is: </strong><%= (data2.vht_capabilities == true) and "available" or "not available" %><br />
--!>
<strong>Signal is: </strong><%= "%d" %data2.signal %><br />
<strong>Channel Utilization is: </strong><%= "%d" %data2.channel_utilization %><br />
<strong>Station connected to AP is: </strong><%= "%d" %data2.num_sta %><br />
<strong>Score is: </strong><%= "%d" %data2.score %><br />
</li>
<%
end
%>
</ul>
<%
end
%>
</ul>
<style>.hearing_table tr{ border-bottom: 1px solid grey;} tr:nth-child(even){background-color: lightgrey;}</style>
<%
local utl = require "luci.util"
local status = require "luci.tools.ieee80211"
local stat = utl.ubus("dawn", "get_hearing_map", { })
local name, macs
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
%>
<table class="table" style="border: 1px solid grey;">
<thead style="background-color: grey; color: white;">
<tr>
<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
for mac, data in pairs(macs) do
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
%>
<tr class="center" style="border: 1px solid grey;">
<% if (count_macs > 1) then %>
<% if (count_loop == 0 ) then %>
<td rowspan="<%= count_macs %>" style="background-color: white; border-right: 1px solid grey;"><%= mac %></td>
<% end %>
<% else %>
<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
%>
</ul>
]])
]])
end
return m