dawn_network.lua 2.7 KB

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