iface_status.htm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", self.network)%>', null,
  4. function(x, ifc)
  5. {
  6. if (ifc && (ifc = ifc[0]))
  7. {
  8. var html = '';
  9. var s = document.getElementById('<%=self.option%>-ifc-signal');
  10. if (s)
  11. s.innerHTML = String.format(
  12. '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px" />' +
  13. '<br /><small>%s</small>',
  14. ifc.type, ifc.is_up ? '' : '_disabled',
  15. ifc.name
  16. );
  17. var d = document.getElementById('<%=self.option%>-ifc-description');
  18. if (d && ifc.ifname)
  19. {
  20. if (ifc.is_up)
  21. {
  22. html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
  23. }
  24. if (ifc.type != 'tunnel')
  25. {
  26. html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
  27. }
  28. html += String.format(
  29. '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
  30. '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
  31. ifc.rx_bytes, ifc.rx_packets,
  32. ifc.tx_bytes, ifc.tx_packets
  33. );
  34. if (ifc.ipaddrs && ifc.ipaddrs.length)
  35. {
  36. html += '<strong><%:IPv4%>: </strong>';
  37. for (var i = 0; i < ifc.ipaddrs.length; i++)
  38. html += String.format(
  39. '%s%s/%d',
  40. i ? ', ' : '',
  41. ifc.ipaddrs[i].addr,
  42. ifc.ipaddrs[i].prefix
  43. );
  44. html += '<br />';
  45. }
  46. if (ifc.ip6addrs && ifc.ip6addrs.length)
  47. {
  48. html += '<strong><%:IPv6%>: </strong>';
  49. for (var i = 0; i < ifc.ip6addrs.length; i++)
  50. html += String.format(
  51. '%s%s/%d',
  52. i ? ', ' : '',
  53. ifc.ip6addrs[i].addr.toUpperCase(),
  54. ifc.ip6addrs[i].prefix
  55. );
  56. html += '<br />';
  57. }
  58. d.innerHTML = html;
  59. }
  60. else if (d)
  61. {
  62. d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
  63. }
  64. }
  65. }
  66. );
  67. //]]></script>
  68. <table>
  69. <tr class="cbi-section-table">
  70. <td></td>
  71. <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
  72. <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
  73. <small>?</small>
  74. </td>
  75. <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
  76. <em><%:Collecting data...%></em>
  77. </td>
  78. </tr>
  79. </table>
  80. <%+cbi/valuefooter%>