clients.htm 4.6 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. <div class="table cbi-section-table">
  35. <div class="tr cbi-section-table-titles">
  36. <div class="th cbi-section-table-cell"><%:Hostname%></div>
  37. <div class="th cbi-section-table-cell"><%:IPv4%></div>
  38. <div class="th cbi-section-table-cell"><%:MAC%></div>
  39. <div class="th cbi-section-table-cell"><%:Manufacturer%></div>
  40. <div class="th cbi-section-table-cell"><%:Model%></div>
  41. <div class="th cbi-section-table-cell"><%:Class%></div>
  42. </div>
  43. <%
  44. for i,v in ipairs(devdump) do
  45. if v.DeviceProfileUuid ~= "" then
  46. %>
  47. <div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
  48. <div class="td cbi-value-field"><%=v.Hostname%></div>
  49. <div class="td cbi-value-field"><%=v.Ipv4Address%></div>
  50. <div class="td cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></div>
  51. <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Manufacturer%></div>
  52. <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Model%></div>
  53. <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].ThingClass%></div>
  54. </div>
  55. <%
  56. style=false
  57. end
  58. end
  59. %>
  60. </div>
  61. </div>
  62. </fieldset>
  63. <br />
  64. <fieldset class="cbi-section">
  65. <legend><%:Unrecognized Clients%></legend>
  66. <div class="cbi-section-node">
  67. <div class="table cbi-section-table">
  68. <div class="tr cbi-section-table-titles">
  69. <div class="th cbi-section-table-cell"><%:Hostname%></div>
  70. <div class="th cbi-section-table-cell"><%:IPv4%></div>
  71. <div class="th cbi-section-table-cell"><%:MAC%></div>
  72. <div class="th cbi-section-table-cell"><%:Manufacturer%></div>
  73. <div class="th cbi-section-table-cell"><%:Model%></div>
  74. <div class="th cbi-section-table-cell"><%:DhcpVendor%></div>
  75. <div class="th cbi-section-table-cell"><%:DhcpHostname%></div>
  76. </div>
  77. <%
  78. for i,v in ipairs(devdump) do
  79. if v.DeviceProfileUuid == "" then
  80. %>
  81. <div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
  82. <div class="td cbi-value-field"><%=v.Hostname%></div>
  83. <div class="td cbi-value-field"><%=v.Ipv4Address%></div>
  84. <div class="td cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></div>
  85. <div class="td cbi-value-field"><%=v.SsdpManufacturer%></div>
  86. <div class="td cbi-value-field"><%=v.SsdpModelName%></div>
  87. <div class="td cbi-value-field"><%=v.DhcpVendor1%></div>
  88. <div class="td cbi-value-field"><%=v.DhcpHostname%></div>
  89. </div>
  90. <%
  91. style=false
  92. end
  93. end
  94. %>
  95. </div>
  96. </div>
  97. </fieldset>
  98. </div>
  99. <%+footer%>