iface_status.htm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. XHR.poll(5, '<%=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.macaddr)
  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. for (var i = 0; i < ifc.ipaddrs.length; i++)
  37. html += String.format(
  38. '<strong><%:IPv4%>:</strong> %s<br />',
  39. ifc.ipaddrs[i]
  40. );
  41. }
  42. if (ifc.ip6addrs && ifc.ip6addrs.length)
  43. {
  44. for (var i = 0; i < ifc.ip6addrs.length; i++)
  45. html += String.format(
  46. '<strong><%:IPv6%>:</strong> %s<br />',
  47. ifc.ip6addrs[i]
  48. );
  49. }
  50. d.innerHTML = html;
  51. }
  52. else if (d)
  53. {
  54. d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
  55. }
  56. }
  57. }
  58. );
  59. //]]></script>
  60. <table>
  61. <tr class="cbi-section-table">
  62. <td></td>
  63. <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
  64. <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
  65. <small>?</small>
  66. </td>
  67. <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
  68. <em><%:Collecting data...%></em>
  69. </td>
  70. </tr>
  71. </table>
  72. <%+cbi/valuefooter%>