X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fview%2Fadmin_network%2Fiface_overview.htm;h=21990bb7ddba48c87cb7173007f3f0263d2649f6;hp=edfed7d7d2384a530254166fc7fbd00a37d59856;hb=9c97cdb7b6edcc62d29a72ca64cd682503e693f6;hpb=1d40f7fbea14cfbce23519d41b98b182c47a0271 diff --git a/modules/admin-full/luasrc/view/admin_network/iface_overview.htm b/modules/admin-full/luasrc/view/admin_network/iface_overview.htm index edfed7d7d..21990bb7d 100644 --- a/modules/admin-full/luasrc/view/admin_network/iface_overview.htm +++ b/modules/admin-full/luasrc/view/admin_network/iface_overview.htm @@ -44,8 +44,7 @@ $Id$ s.innerHTML = '<%:Waiting for router...%>'; } - var rcxhr = new XHR(); - rcxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/iface_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, null, + XHR.get('<%=luci.dispatcher.build_url("admin", "network")%>/iface_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, null, function(x) { if (s) @@ -67,117 +66,124 @@ $Id$ var wifidevs = <%=luci.http.write_json(netdevs)%>; var arptable = <%=luci.http.write_json(arpcache)%>; - (function() { - var func = arguments.callee; - iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(netlist, ","))%>', null, - function(x, ifcs) + XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(netlist, ","))%>', null, + function(x, ifcs) + { + if (ifcs) { - if (ifcs) + for (var idx = 0; idx < ifcs.length; idx++) { - for (var i = 0; i < ifcs.length; i++) + var ifc = ifcs[idx]; + var html = ''; + + var s = document.getElementById(ifc.id + '-ifc-devices'); + if (s) { - var ifc = ifcs[i]; - var html = ''; + var stat = String.format( + '', + ifc.type, + ifc.is_up ? '' : '_disabled' + ); - var s = document.getElementById(ifc.id + '-ifc-devices'); - if (s) + if (ifc.subdevices && ifc.subdevices.length) { - var stat = String.format( - '', - ifc.type, - ifc.is_up ? '' : '_disabled' - ); + stat += ' ('; - if (ifc.subdevices && ifc.subdevices.length) + for (var j = 0; j < ifc.subdevices.length; j++) { - stat += ' ('; - - for (var j = 0; j < ifc.subdevices.length; j++) - { - var sif = ifc.subdevices[j]; + var sif = ifc.subdevices[j]; + + stat += String.format( + '', + sif.type, + sif.is_up ? '' : '_disabled', + sif.name + ); + } - stat += String.format( - '', - sif.type, - sif.is_up ? '' : '_disabled', - sif.name - ); - } + stat += ')'; + } - stat += ')'; - } + stat += String.format( + '
%s', + ifc.name + ); - stat += String.format( - '
%s', - ifc.name - ); + s.innerHTML = stat; + } - s.innerHTML = stat; + var d = document.getElementById(ifc.id + '-ifc-description'); + if (d && ifc.proto && ifc.ifname) + { + if (ifc.is_up) + { + html += String.format('<%:Uptime%>: %t
', ifc.uptime); } - var d = document.getElementById(ifc.id + '-ifc-description'); - if (d && ifc.ifname) + if (ifc.type != 'tunnel') { - if (ifc.is_up) - { - html += String.format('<%:Uptime%>: %t
', ifc.uptime); - } - - if (ifc.type != 'tunnel') - { - html += String.format('<%:MAC Address%>: %s
', ifc.macaddr); - } - - html += String.format( - '<%:RX%>: %.2mB (%d <%:Pkts.%>)
' + - '<%:TX%>: %.2mB (%d <%:Pkts.%>)
', - ifc.rx_bytes, ifc.rx_packets, - ifc.tx_bytes, ifc.tx_packets - ); + html += String.format('<%:MAC Address%>: %s
', ifc.macaddr); + } - if (ifc.ipaddrs && ifc.ipaddrs.length) - { - html += '<%:IPv4%>: '; + html += String.format( + '<%:RX%>: %.2mB (%d <%:Pkts.%>)
' + + '<%:TX%>: %.2mB (%d <%:Pkts.%>)
', + ifc.rx_bytes, ifc.rx_packets, + ifc.tx_bytes, ifc.tx_packets + ); - for (var i = 0; i < ifc.ipaddrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ipaddrs[i].addr, - ifc.ipaddrs[i].prefix - ); + if (ifc.ipaddrs && ifc.ipaddrs.length) + { + html += '<%:IPv4%>: '; - html += '
'; - } + for (var i = 0; i < ifc.ipaddrs.length; i++) + html += String.format( + '%s%s/%d', + i ? ', ' : '', + ifc.ipaddrs[i].addr, + ifc.ipaddrs[i].prefix + ); - if (ifc.ip6addrs && ifc.ip6addrs.length) - { - html += '<%:IPv6%>: '; + html += '
'; + } - for (var i = 0; i < ifc.ip6addrs.length; i++) - html += String.format( - '%s%s/%d', - i ? ', ' : '', - ifc.ip6addrs[i].addr.toUpperCase(), - ifc.ip6addrs[i].prefix - ); + if (ifc.ip6addrs && ifc.ip6addrs.length) + { + html += '<%:IPv6%>: '; - html += '
'; - } + for (var i = 0; i < ifc.ip6addrs.length; i++) + html += String.format( + '%s%s/%d', + i ? ', ' : '', + ifc.ip6addrs[i].addr.toUpperCase(), + ifc.ip6addrs[i].prefix + ); - d.innerHTML = html; - } - else if (d) - { - d.innerHTML = '<%:Interface not present or not connected yet.%>'; + html += '
'; } + + d.innerHTML = html; + } + else if (d && !ifc.proto) + { + var e = document.getElementById(ifc.id + '-ifc-edit'); + if (e) + e.disabled = true; + + d.innerHTML = String.format( + '<%:Unsupported protocol type.%>
' + + '<%:Install protocol extensions...%>', + '<%=luci.dispatcher.build_url("admin/system/packages")%>?query=luci-proto&display=available' + ); + } + else if (d) + { + d.innerHTML = '<%:Interface not present or not connected yet.%>'; } } - - window.setTimeout(func, 5000); } - ) - })(); + } + ); //]]>