3225e90dac15bb1c8e2b90b0213778f286035f2b
[oweals/luci.git] / applications / luci-app-dawn / luasrc / model / cbi / dawn / dawn_network.lua
1 m = Map("Network Overview", translate("Network Overview"))
2 m.pageaction = false
3
4 s = m:section(NamedSection, "__networkoverview__")
5
6 function s.render(self, sid)
7         local tpl = require "luci.template"
8         local json = require "luci.json"
9         local utl = require "luci.util"
10         tpl.render_string([[
11                 <table class="table" style="border: 1px solid grey;">
12                         <thead style="background-color: grey; color: white;">
13                                 <tr>
14                                                 <th>SSID</th>
15                                                 <th>MAC</th>
16                                                 <th>Channel Utilization</th>
17                                                 <th>Frequency</th>
18                                                 <th>Stations</th>
19                                                 <th>HT Sup</th>
20                                                 <th>VHT Sup</th>
21                                 </tr>
22                         </thead>
23                         <tbody>
24                         <%
25                         local status = require "luci.tools.ieee80211"
26                         local utl = require "luci.util"
27                         local sys = require "luci.sys"
28                         local hosts = sys.net.host_hints()
29                         local stat = utl.ubus("dawn", "get_network", { })
30                         local name, macs
31                         for name, macs in pairs(stat) do
32                                 local mac, data
33                                 for mac, data in pairs(macs) do
34                         %>
35                                 <tr class="center">
36                                         <td><%= name %></td>
37                                         <td><%= mac %></td>
38                                         <td><%= "%.2f" %(data.channel_utilization / 2.55) %> %</td>
39                                         <td><%= "%.3f" %( data.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data.freq) ) %>)</td>
40                                         <td><%= "%d" %data.num_sta %></td>
41                                         <td><%= (data.ht_support == true) and "available" or "not available" %></td>
42                                         <td><%= (data.vht_support == true) and "available" or "not available" %></td>
43                                 </tr>
44                                 <tr>
45                                         <td colspan="7"><hr></td>
46                                 </tr>
47                                 <tr>
48                                         <td colspan="2" class="center"><strong>Clients</strong></td>
49                                         <td colspan="4">
50                                         <table class="table" style="border: 1px solid grey;">
51                                         <thead style="background-color: grey; color: white;">
52                                                 <tr>
53                                                         <th>MAC</th>
54                                                         <th>HT</th>
55                                                         <th>VHT</th>
56                                                         <th>Signal</th>
57                                                 </tr>
58                                         </thead>
59                                         <tbody>
60                                         <%
61                                         local mac2, data2
62                                         for clientmac, clientvals in pairs(data) do
63                                                 if (type(clientvals) == "table") then 
64                                         %>
65                                                 <tr class="center">
66                                                         <td><%= clientmac %></td>
67                                                         <td><%= (clientvals.ht == true) and "available" or "not available" %></td>
68                                                         <td><%= (clientvals.vht == true) and "available" or "not available" %></td>
69                                                         <td><%= "%d" %clientvals.signal %></td>
70                                                 </tr>
71                                         <%
72                                                 end
73                                         end
74                                         %>
75                                         </tbody>
76                                         </table>
77                                 </tr>
78                                 <tr>
79                                         <td colspan="7"><hr></td>
80                                 </tr>
81                                 <%
82                                 end
83                                 %>
84                         <%
85                         end
86                         %>
87                         </tbody>
88                 </table>
89         ]])
90 end
91
92 return m