clients.htm 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <%#
  2. Copyright (C) 2017 Steven Hessing <steven.hessing@gmail.com>
  3. This is free software, licensed under the GNU General Public License v3.
  4. /usr/lib/lua/luci/view/clients.htm
  5. -%>
  6. <%-
  7. require "nixio.fs"
  8. require "os"
  9. local last_modified = "<boottime>"
  10. local style = true
  11. local v
  12. local devdump
  13. if nixio.fs.access("/var/lib/noddos/DeviceDump.json") then
  14. last_modified = os.date("%c", nixio.fs.stat("/var/lib/noddos/DeviceDump.json")['mtime'])
  15. io.input("/var/lib/noddos/DeviceDump.json")
  16. t = io.read("*all")
  17. devdump = luci.jsonc.parse(t)
  18. io.input("/var/lib/noddos/DeviceProfiles.json")
  19. t = io.read("*all")
  20. temp = luci.jsonc.parse(t)
  21. devicevalues = {}
  22. for i, v in ipairs(temp) do
  23. devicevalues[v.DeviceProfileUuid] = v
  24. end
  25. end
  26. -%>
  27. <%+header%>
  28. <div class="cbi-map" id="cbi-network">
  29. <h2 name="content"><%:Clients%></h2>
  30. <div class="cbi-map-descr"><%:The following clients have been discovered on the network. The last discovery was completed at %><%=last_modified%></div>
  31. <fieldset class="cbi-section">
  32. <legend><%:Recognized Clients%></legend>
  33. <div class="cbi-section-node">
  34. <table class="cbi-section-table">
  35. <tr class="cbi-section-table-titles">
  36. <th class="cbi-section-table-cell"><%:Hostname%></th>
  37. <th class="cbi-section-table-cell"><%:IPv4%></th>
  38. <th class="cbi-section-table-cell"><%:MAC%></th>
  39. <th class="cbi-section-table-cell"><%:Manufacturer%></th>
  40. <th class="cbi-section-table-cell"><%:Model%></th>
  41. <th class="cbi-section-table-cell"><%:Class%></th>
  42. </tr>
  43. <%
  44. for i,v in ipairs(devdump) do
  45. if v.DeviceProfileUuid ~= "" then
  46. %>
  47. <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
  48. <td class="cbi-value-field"><%=v.Hostname%></td>
  49. <td class="cbi-value-field"><%=v.Ipv4Address%></td>
  50. <td class="cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></td>
  51. <td class="cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Manufacturer%></td>
  52. <td class="cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Model%></td>
  53. <td class="cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].ThingClass%></td>
  54. </tr>
  55. <%
  56. style=false
  57. end
  58. end
  59. %>
  60. </table>
  61. </div>
  62. </fieldset>
  63. <br />
  64. <fieldset class="cbi-section">
  65. <legend><%:Unrecognized Clients%></legend>
  66. <div class="cbi-section-node">
  67. <table class="cbi-section-table">
  68. <tr class="cbi-section-table-titles">
  69. <th class="cbi-section-table-cell"><%:Hostname%></th>
  70. <th class="cbi-section-table-cell"><%:IPv4%></th>
  71. <th class="cbi-section-table-cell"><%:MAC%></th>
  72. <th class="cbi-section-table-cell"><%:Manufacturer%></th>
  73. <th class="cbi-section-table-cell"><%:Model%></th>
  74. <th class="cbi-section-table-cell"><%:DhcpVendor%></th>
  75. <th class="cbi-section-table-cell"><%:DhcpHostname%></th>
  76. </tr>
  77. <%
  78. for i,v in ipairs(devdump) do
  79. if v.DeviceProfileUuid == "" then
  80. %>
  81. <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
  82. <td class="cbi-value-field"><%=v.Hostname%></td>
  83. <td class="cbi-value-field"><%=v.Ipv4Address%></td>
  84. <td class="cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></td>
  85. <td class="cbi-value-field"><%=v.SsdpManufacturer%></td>
  86. <td class="cbi-value-field"><%=v.SsdpModelName%></td>
  87. <td class="cbi-value-field"><%=v.DhcpVendor1%></td>
  88. <td class="cbi-value-field"><%=v.DhcpHostname%></td>
  89. </tr>
  90. <%
  91. style=false
  92. end
  93. end
  94. %>
  95. </table>
  96. </div>
  97. </fieldset>
  98. </div>
  99. <%+footer%>