lease_status.htm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <script type="text/javascript">//<![CDATA[
  2. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "dhcplease_status")%>', null,
  3. function(x, st)
  4. {
  5. var tb = document.getElementById('lease_status_table');
  6. if (st && st[0] && tb)
  7. {
  8. /* clear all rows */
  9. while( tb.rows.length > 1 )
  10. tb.deleteRow(1);
  11. for( var i = 0; i < st[0].length; i++ )
  12. {
  13. var timestr;
  14. if (st[0][i].expires <= 0)
  15. {
  16. timestr = '<em><%:expired%></em>';
  17. }
  18. else
  19. {
  20. timestr = String.format('%t', st[0][i].expires);
  21. }
  22. var tr = tb.insertRow(-1);
  23. tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
  24. tr.insertCell(-1).innerHTML = st[0][i].hostname ? st[0][i].hostname : '?';
  25. tr.insertCell(-1).innerHTML = st[0][i].ipaddr;
  26. tr.insertCell(-1).innerHTML = st[0][i].macaddr;
  27. tr.insertCell(-1).innerHTML = timestr;
  28. }
  29. if( tb.rows.length == 1 )
  30. {
  31. var tr = tb.insertRow(-1);
  32. tr.className = 'cbi-section-table-row';
  33. var td = tr.insertCell(-1);
  34. td.colSpan = 4;
  35. td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
  36. }
  37. }
  38. var tb6 = document.getElementById('lease6_status_table');
  39. if (st && st[1] && tb6)
  40. {
  41. tb6.parentNode.style.display = 'block';
  42. /* clear all rows */
  43. while( tb6.rows.length > 1 )
  44. tb6.deleteRow(1);
  45. for( var i = 0; i < st[1].length; i++ )
  46. {
  47. var timestr;
  48. if (st[1][i].expires <= 0)
  49. {
  50. timestr = '<em><%:expired%></em>';
  51. }
  52. else
  53. {
  54. timestr = String.format('%t', st[1][i].expires);
  55. }
  56. var tr = tb6.insertRow(-1);
  57. tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
  58. tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?';
  59. tr.insertCell(-1).innerHTML = st[1][i].ip6addr;
  60. tr.insertCell(-1).innerHTML = st[1][i].duid;
  61. tr.insertCell(-1).innerHTML = timestr;
  62. }
  63. if( tb6.rows.length == 1 )
  64. {
  65. var tr = tb6.insertRow(-1);
  66. tr.className = 'cbi-section-table-row';
  67. var td = tr.insertCell(-1);
  68. td.colSpan = 4;
  69. td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
  70. }
  71. }
  72. }
  73. );
  74. //]]></script>
  75. <fieldset class="cbi-section">
  76. <legend><%:Active DHCP Leases%></legend>
  77. <table class="cbi-section-table" id="lease_status_table">
  78. <tr class="cbi-section-table-titles">
  79. <th class="cbi-section-table-cell"><%:Hostname%></th>
  80. <th class="cbi-section-table-cell"><%:IPv4-Address%></th>
  81. <th class="cbi-section-table-cell"><%:MAC-Address%></th>
  82. <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
  83. </tr>
  84. <tr class="cbi-section-table-row">
  85. <td colspan="4"><em><br /><%:Collecting data...%></em></td>
  86. </tr>
  87. </table>
  88. </fieldset>
  89. <fieldset class="cbi-section" style="display:none">
  90. <legend><%:Active DHCPv6 Leases%></legend>
  91. <table class="cbi-section-table" id="lease6_status_table">
  92. <tr class="cbi-section-table-titles">
  93. <th class="cbi-section-table-cell"><%:Hostname%></th>
  94. <th class="cbi-section-table-cell"><%:IPv6-Address%></th>
  95. <th class="cbi-section-table-cell"><%:DUID%></th>
  96. <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
  97. </tr>
  98. <tr class="cbi-section-table-row">
  99. <td colspan="4"><em><br /><%:Collecting data...%></em></td>
  100. </tr>
  101. </table>
  102. </fieldset>