| 1 | <%+cbi/valueheader%> |
|---|
| 2 | |
|---|
| 3 | <script type="text/javascript">//<![CDATA[ |
|---|
| 4 | XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", self.network)%>', null, |
|---|
| 5 | function(x, ifc) |
|---|
| 6 | { |
|---|
| 7 | if (ifc && (ifc = ifc[0])) |
|---|
| 8 | { |
|---|
| 9 | var html = ''; |
|---|
| 10 | |
|---|
| 11 | var s = document.getElementById('<%=self.option%>-ifc-signal'); |
|---|
| 12 | if (s && ifc.proto == '3g' && ifc.wan3g.ctrldev) { |
|---|
| 13 | var qual = ifc.wan3g.quality ? ifc.wan3g.quality : "0" |
|---|
| 14 | var sigqual = parseInt(qual.substring(15)) |
|---|
| 15 | var icon; |
|---|
| 16 | if (sigqual == 99 || !sigqual) |
|---|
| 17 | icon = "/luci-static/resources/icons/signal-none.png"; |
|---|
| 18 | else if (sigqual == 0) |
|---|
| 19 | icon = "/luci-static/resources/icons/signal-0.png"; |
|---|
| 20 | else if (sigqual < 7) |
|---|
| 21 | icon = "/luci-static/resources/icons/signal-0-25.png"; |
|---|
| 22 | else if (sigqual < 15) |
|---|
| 23 | icon = "/luci-static/resources/icons/signal-25-50.png"; |
|---|
| 24 | else if (sigqual < 24) |
|---|
| 25 | icon = "/luci-static/resources/icons/signal-50-75.png"; |
|---|
| 26 | else |
|---|
| 27 | icon = "/luci-static/resources/icons/signal-75-100.png"; |
|---|
| 28 | |
|---|
| 29 | s.innerHTML = String.format( |
|---|
| 30 | '<img src="%s" /><br /><small>%s</small>', |
|---|
| 31 | icon, ifc.ifname |
|---|
| 32 | ); |
|---|
| 33 | } |
|---|
| 34 | else if (s) |
|---|
| 35 | s.innerHTML = String.format( |
|---|
| 36 | '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px" />' + |
|---|
| 37 | '<br /><small>%s</small>', |
|---|
| 38 | ifc.type, ifc.is_up ? '' : '_disabled', |
|---|
| 39 | ifc.name |
|---|
| 40 | ); |
|---|
| 41 | |
|---|
| 42 | var d = document.getElementById('<%=self.option%>-ifc-description'); |
|---|
| 43 | if (d && ifc.ifname) |
|---|
| 44 | { |
|---|
| 45 | if (ifc.proto =='3g' && ifc.wan3g.ctrldev) |
|---|
| 46 | { |
|---|
| 47 | var qual = ifc.wan3g.quality ? ifc.wan3g.quality : "0" |
|---|
| 48 | html += String.format('<strong><%:Operator%>:</strong> %s<br /><strong><%:Signal%>:</strong> %d%%<br /><strong><%:SIM%>:</strong> %s<br />', ifc.wan3g.operator ? ifc.wan3g.operator : "reading...", qual.substring(15)*100/31, ifc.wan3g.sim ? ifc.wan3g.sim : "ERROR"); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | if (ifc.is_up) |
|---|
| 52 | { |
|---|
| 53 | html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if (ifc.type != 'tunnel') |
|---|
| 57 | { |
|---|
| 58 | html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | html += String.format( |
|---|
| 62 | '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' + |
|---|
| 63 | '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />', |
|---|
| 64 | ifc.rx_bytes, ifc.rx_packets, |
|---|
| 65 | ifc.tx_bytes, ifc.tx_packets |
|---|
| 66 | ); |
|---|
| 67 | |
|---|
| 68 | if (ifc.ipaddrs && ifc.ipaddrs.length) |
|---|
| 69 | { |
|---|
| 70 | html += '<strong><%:IPv4%>: </strong>'; |
|---|
| 71 | |
|---|
| 72 | for (var i = 0; i < ifc.ipaddrs.length; i++) |
|---|
| 73 | html += String.format( |
|---|
| 74 | '%s%s/%d', |
|---|
| 75 | i ? ', ' : '', |
|---|
| 76 | ifc.ipaddrs[i].addr, |
|---|
| 77 | ifc.ipaddrs[i].prefix |
|---|
| 78 | ); |
|---|
| 79 | |
|---|
| 80 | html += '<br />'; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | if (ifc.ip6addrs && ifc.ip6addrs.length) |
|---|
| 84 | { |
|---|
| 85 | html += '<strong><%:IPv6%>: </strong>'; |
|---|
| 86 | |
|---|
| 87 | for (var i = 0; i < ifc.ip6addrs.length; i++) |
|---|
| 88 | html += String.format( |
|---|
| 89 | '%s%s/%d', |
|---|
| 90 | i ? ', ' : '', |
|---|
| 91 | ifc.ip6addrs[i].addr.toUpperCase(), |
|---|
| 92 | ifc.ip6addrs[i].prefix |
|---|
| 93 | ); |
|---|
| 94 | |
|---|
| 95 | html += '<br />'; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | d.innerHTML = html; |
|---|
| 99 | } |
|---|
| 100 | else if (d) |
|---|
| 101 | { |
|---|
| 102 | d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>'; |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | } |
|---|
| 106 | ); |
|---|
| 107 | //]]></script> |
|---|
| 108 | |
|---|
| 109 | <table> |
|---|
| 110 | <tr class="cbi-section-table"> |
|---|
| 111 | <td></td> |
|---|
| 112 | <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal"> |
|---|
| 113 | <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br /> |
|---|
| 114 | <small>?</small> |
|---|
| 115 | </td> |
|---|
| 116 | <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description"> |
|---|
| 117 | <em><%:Collecting data...%></em> |
|---|
| 118 | </td> |
|---|
| 119 | </tr> |
|---|
| 120 | </table> |
|---|
| 121 | |
|---|
| 122 | <%+cbi/valuefooter%> |
|---|