lease_status.htm 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <script type="text/javascript">//<![CDATA[
  2. XHR.poll(-1, '<%=url('admin/dhcplease_status')%>', null,
  3. function(x, st)
  4. {
  5. var tb = document.getElementById('lease_status_table');
  6. if (st && st[0] && tb)
  7. {
  8. var rows = [];
  9. for (var i = 0; i < st[0].length; i++)
  10. {
  11. var timestr;
  12. if (st[0][i].expires === false)
  13. timestr = '<em><%:unlimited%></em>';
  14. else if (st[0][i].expires <= 0)
  15. timestr = '<em><%:expired%></em>';
  16. else
  17. timestr = String.format('%t', st[0][i].expires);
  18. rows.push([
  19. st[0][i].hostname || '?',
  20. st[0][i].ipaddr,
  21. st[0][i].macaddr,
  22. timestr
  23. ]);
  24. }
  25. cbi_update_table(tb, rows, '<em><%:There are no active leases.%></em>');
  26. }
  27. var tb6 = document.getElementById('lease6_status_table');
  28. if (st && st[1] && tb6)
  29. {
  30. tb6.parentNode.style.display = 'block';
  31. var rows = [];
  32. for (var i = 0; i < st[1].length; i++)
  33. {
  34. var timestr;
  35. if (st[1][i].expires === false)
  36. timestr = '<em><%:unlimited%></em>';
  37. else if (st[1][i].expires <= 0)
  38. timestr = '<em><%:expired%></em>';
  39. else
  40. timestr = String.format('%t', st[1][i].expires);
  41. var name = st[1][i].hostname,
  42. hint = st[1][i].host_hint;
  43. rows.push([
  44. hint ? '%h (%h)'.format(name || '?', hint) : (name || '?'),
  45. st[1][i].ip6addr,
  46. st[1][i].duid,
  47. timestr
  48. ]);
  49. }
  50. cbi_update_table(tb6, rows, '<em><%:There are no active leases.%></em>');
  51. }
  52. }
  53. );
  54. //]]></script>
  55. <div class="cbi-section">
  56. <h3><%:Active DHCP Leases%></h3>
  57. <div class="table" id="lease_status_table">
  58. <div class="tr table-titles">
  59. <div class="th"><%:Hostname%></div>
  60. <div class="th"><%:IPv4-Address%></div>
  61. <div class="th"><%:MAC-Address%></div>
  62. <div class="th"><%:Leasetime remaining%></div>
  63. </div>
  64. <div class="tr placeholder">
  65. <div class="td"><em><%:Collecting data...%></em></div>
  66. </div>
  67. </div>
  68. </div>
  69. <%
  70. local fs = require "nixio.fs"
  71. local has_ipv6 = fs.access("/proc/net/ipv6_route")
  72. if has_ipv6 then
  73. -%>
  74. <div class="cbi-section" style="display:none">
  75. <h3><%:Active DHCPv6 Leases%></h3>
  76. <div class="table" id="lease6_status_table">
  77. <div class="tr table-titles">
  78. <div class="th"><%:Host%></div>
  79. <div class="th"><%:IPv6-Address%></div>
  80. <div class="th"><%:DUID%></div>
  81. <div class="th"><%:Leasetime remaining%></div>
  82. </div>
  83. <div class="tr placeholder">
  84. <div class="td"><em><%:Collecting data...%></em></div>
  85. </div>
  86. </div>
  87. </div>
  88. <% end -%>