diff options
author | Daniel Vijge <danielvijge@gmail.com> | 2023-10-26 22:58:03 +0200 |
---|---|---|
committer | Nick Hainke <vincent@systemli.org> | 2023-10-31 00:28:03 +0100 |
commit | ea8c0aa2a1a1ff9f29ffd452049a7b749298ed17 (patch) | |
tree | a2d46eb95166b157c2edb5670ba8ce632e718447 /applications/luci-app-dawn/luasrc/model/cbi | |
parent | eabf1d020fad5f866ea6742c02fc808d0c43b349 (diff) |
luci-app-dawn: Implement in JavaScript
This commit re-implements luci-app-dawn in JavaScript, removing the older
lua implementation. Besides a 1-to-1 port, there are some
changes/improvements:
* In both the network overview and the hearing map, replace MAC addresses
by host name if known.
* In the hearing map, the table is sortable. If the same client is
connected to multiple access points/frequencies the MAC/host name is
listed twice, whereas in the lua implementation the second MAC address
was empty to show it was referring to the same client. This means the
table can be sorted on any column, and the information remains correct.
* The view in the network overview is a bit different. This table is not
sortable, because LuCi doesn't seem to like a table inside a table for
sorting.
* Align the column names between the network overview and the hearing
table.
* Add tooltips for abbreviations in column names.
Signed-off-by: Daniel Vijge <danielvijge@gmail.com>
Diffstat (limited to 'applications/luci-app-dawn/luasrc/model/cbi')
-rw-r--r-- | applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_hearing_map.lua | 70 | ||||
-rw-r--r-- | applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_network.lua | 94 |
2 files changed, 0 insertions, 164 deletions
diff --git a/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_hearing_map.lua b/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_hearing_map.lua deleted file mode 100644 index 3ba5329855..0000000000 --- a/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_hearing_map.lua +++ /dev/null @@ -1,70 +0,0 @@ -m = Map("dawn", "Hearing Map", translate("Hearing Map")) -m.pageaction = false - -s = m:section(NamedSection, "__hearingmap__") - -function s.render(self, sid) - local tpl = require "luci.template" - tpl.render_string([[ - <% - local utl = require "luci.util" - local xml = require "luci.xml" - local status = require "luci.tools.ieee80211" - local stat = utl.ubus("dawn", "get_hearing_map", { }) - local name, macs - - for name, macs in pairs(stat) do - %> - <div class="cbi-section-node"> - <h3>SSID: <%= xml.pcdata(name) %></h3> - <table class="table" id="dawn_hearing_map"> - <tr class="tr table-titles"> - <th class="th">Client MAC</th> - <th class="th">AP MAC</th> - <th class="th">Frequency</th> - <th class="th">HT Sup</th> - <th class="th">VHT Sup</th> - <th class="th">Signal</th> - <th class="th">RCPI</th> - <th class="th">RSNI</th> - <th class="th">Channel Utilization</th> - <th class="th">Station connect to AP</th> - <th class="th">Score</th> - </tr> - <% - local mac, data - for mac, data in pairs(macs) do - - local mac2, data2 - local count_loop = 0 - for mac2, data2 in pairs(data) do - if data2.freq ~= 0 then --prevent empty entry crashes - %> - <tr class="tr"> - <td class="td"><%= (count_loop == 0) and mac or "" %></td> - <td class="td"><%= mac2 %></td> - <td class="td"><%= "%.3f" %( data2.freq / 1000 ) %> GHz Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %></td> - <td class="td"><%= (data2.ht_capabilities == true and data2.ht_support == true) and "True" or "False" %></td> - <td class="td"><%= (data2.vht_capabilities == true and data2.vht_support == true) and "True" or "False" %></td> - <td class="td"><%= "%d" % data2.signal %></td> - <td class="td"><%= "%d" % data2.rcpi %></td> - <td class="td"><%= "%d" % data2.rsni %></td> - <td class="td"><%= "%.2f" % (data2.channel_utilization / 2.55) %> %</td> - <td class="td"><%= "%d" % data2.num_sta %></td> - <td class="td"><%= "%d" % data2.score %></td> - </tr> - <% - count_loop = count_loop + 1 - end - end - end - %> - </table> - </div> - <% - end - %> - ]]) -end - -return m diff --git a/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_network.lua b/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_network.lua deleted file mode 100644 index f9e04b90cb..0000000000 --- a/applications/luci-app-dawn/luasrc/model/cbi/dawn/dawn_network.lua +++ /dev/null @@ -1,94 +0,0 @@ -m = Map("dawn", "Network Overview", translate("Network Overview")) -m.pageaction = false - -s = m:section(NamedSection, "__networkoverview__") - -function s.render(self, sid) - local tpl = require "luci.template" - local json = require "luci.json" - local utl = require "luci.util" - tpl.render_string([[ - <% - local status = require "luci.tools.ieee80211" - local utl = require "luci.util" - local sys = require "luci.sys" - local xml = require "luci.xml" - local hosts = sys.net.host_hints() - local stat = utl.ubus("dawn", "get_network", { }) - local name, macs - for name, macs in pairs(stat) do - %> - <div class="cbi-section-node"> - <h3>SSID: <%= xml.pcdata(name) %></h3> - <table class="table" id="network_overview_main"> - <tr class="tr table-titles"> - <th class="th">AP</th> - <th class="th">Clients</th> - </tr> - <% - local mac, data - for mac, data in pairs(macs) do - %> - <tr class="tr"> - <td class="td" style="vertical-align: top;"> - <table class="table" id="ap-<%= mac %>"> - <tr class="tr table-titles"> - <th class="th">Hostname</th> - <th class="th">Interface</th> - <th class="th">MAC</th> - <th class="th">Utilization</th> - <th class="th">Frequency</th> - <th class="th">Stations</th> - <th class="th">HT Sup</th> - <th class="th">VHT Sup</th> - </tr> - <tr class="tr"> - <td class="td"><%= xml.pcdata(data.hostname) %></td> - <td class="td"><%= xml.pcdata(data.iface) %></td> - <td class="td"><%= mac %></td> - <td class="td"><%= "%.2f" %(data.channel_utilization / 2.55) %> %</td> - <td class="td"><%= "%.3f" %( data.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data.freq) ) %>)</td> - <td class="td"><%= "%d" % data.num_sta %></td> - <td class="td"><%= (data.ht_support == true) and "available" or "not available" %></td> - <td class="td"><%= (data.vht_support == true) and "available" or "not available" %></td> - </tr> - </table> - </td> - <td class="td" style="vertical-align: top;"> - <table class="table" id="clients-<%= mac %>"> - <tr class="tr table-titles"> - <th class="th">MAC</th> - <th class="th">HT</th> - <th class="th">VHT</th> - <th class="th">Signal</th> - </tr> - <% - local mac2, data2 - for clientmac, clientvals in pairs(data) do - if (type(clientvals) == "table") then - %> - <tr class="tr"> - <td class="td"><%= clientmac %></td> - <td class="td"><%= (clientvals.ht == true) and "available" or "not available" %></td> - <td class="td"><%= (clientvals.vht == true) and "available" or "not available" %></td> - <td class="td"><%= "%d" % clientvals.signal %></td> - </tr> - <% - end - end - %> - </table> - </td> - </tr> - <% - end - %> - </table> - </div> - <% - end - %> - ]]) -end - -return m |