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)
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 idx = 0; idx < ifcs.length; idx++)
+ var ifc = ifcs[idx];
+ var html = '';
+
+ var s = document.getElementById(ifc.id + '-ifc-devices');
+ if (s)
{
- var ifc = ifcs[idx];
- var html = '';
+ var stat = String.format(
+ '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" />',
+ 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(
- '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" />',
- ifc.type,
- ifc.is_up ? '' : '_disabled'
- );
+ stat += ' <strong>(';
- if (ifc.subdevices && ifc.subdevices.length)
+ for (var j = 0; j < ifc.subdevices.length; j++)
{
- stat += ' <strong>(';
-
- for (var j = 0; j < ifc.subdevices.length; j++)
- {
- var sif = ifc.subdevices[j];
+ var sif = ifc.subdevices[j];
+
+ stat += String.format(
+ '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" title="%h" />',
+ sif.type,
+ sif.is_up ? '' : '_disabled',
+ sif.name
+ );
+ }
- stat += String.format(
- '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" title="%q" />',
- sif.type,
- sif.is_up ? '' : '_disabled',
- sif.name
- );
- }
+ stat += ')</strong>';
+ }
- stat += ')</strong>';
- }
+ stat += String.format(
+ '<br /><small>%h</small>',
+ ifc.name
+ );
- stat += String.format(
- '<br /><small>%s</small>',
- 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('<strong><%:Uptime%>:</strong> %t<br />', 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('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
- }
-
- if (ifc.type != 'tunnel')
- {
- html += String.format('<strong><%:MAC Address%>:</strong> %s<br />', ifc.macaddr);
- }
-
- html += String.format(
- '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
- '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
- ifc.rx_bytes, ifc.rx_packets,
- ifc.tx_bytes, ifc.tx_packets
- );
+ html += String.format('<strong><%:MAC Address%>:</strong> %s<br />', ifc.macaddr);
+ }
- if (ifc.ipaddrs && ifc.ipaddrs.length)
- {
- html += '<strong><%:IPv4%>: </strong>';
+ html += String.format(
+ '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
+ '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
+ 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 += '<strong><%:IPv4%>: </strong>';
- html += '<br />';
- }
+ 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 += '<strong><%:IPv6%>: </strong>';
+ html += '<br />';
+ }
- 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 += '<strong><%:IPv6%>: </strong>';
- html += '<br />';
- }
+ 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 = '<em><%:Interface not present or not connected yet.%></em>';
+ html += '<br />';
}
+
+ 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(
+ '<em><%:Unsupported protocol type.%></em><br />' +
+ '<a href="%h"><%:Install protocol extensions...%></a>',
+ '<%=luci.dispatcher.build_url("admin/system/packages")%>?query=luci-proto&display=available'
+ );
+ }
+ else if (d)
+ {
+ d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
}
}
-
- window.setTimeout(func, 5000);
}
- )
- })();
+ }
+ );
//]]></script>
<fieldset class="cbi-section" style="display:none">
%>
<tr class="cbi-section-table-row cbi-rowstyle-<%=i % 2 + 1%>">
<td class="cbi-value-field" style="padding:3px">
- <div style="background-color:#FFFFFF; border:1px solid #CCCCCC; margin:0 10px">
+ <div style="background-color:#FFFFFF; border:1px solid #CCCCCC; margin:0 10px; text-align:center; white-space:nowrap">
<div style="border-bottom:1px solid #CCCCCC; padding:2px; background-color:<%=c%>" title="<%=pcdata(t)%>">
<strong><%=net:upper()%></strong>
</div>
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net%>-ifc-description">
<em><%:Collecting data...%></em>
</td>
- <td style="width:340px">
- <input type="button" class="cbi-button cbi-button-add" style="width:80px; background-image:url(<%=resource%>/cbi/reload.gif)" onclick="iface_shutdown('<%=net%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" />
- <input type="button" class="cbi-button cbi-button-add" style="width:80px; background-image:url(<%=resource%>/cbi/reset.gif)" onclick="iface_shutdown('<%=net%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" />
- <input type="button" class="cbi-button cbi-button-add" style="width:80px; background-image:url(<%=resource%>/cbi/edit.gif)" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/network", net)%>'" title="<%:Edit this interface%>" value="<%:Edit%>" />
- <input type="button" class="cbi-button cbi-button-add" style="width:80px; background-image:url(<%=resource%>/cbi/remove.gif)" onclick="if (confirm('<%:Really delete this interface? The deletion cannot be undone!\nYou might lose access to this router if you are connected via this interface.%>')) location.href='<%=luci.dispatcher.build_url("admin/network/iface_delete", net)%>'" title="<%:Delete this interface%>" value="<%:Delete%>" />
+ <td style="width:420px">
+ <input type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="iface_shutdown('<%=net%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" />
+ <input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_shutdown('<%=net%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" />
+ <input type="button" class="cbi-button cbi-button-edit" style="width:100px" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/network", net)%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net%>-ifc-edit" />
+ <input type="button" class="cbi-button cbi-button-remove" style="width:100px" onclick="if (confirm('<%:Really delete this interface? The deletion cannot be undone!\nYou might lose access to this router if you are connected via this interface.%>')) location.href='<%=luci.dispatcher.build_url("admin/network/iface_delete", net)%>'" title="<%:Delete this interface%>" value="<%:Delete%>" />
</td>
</tr>
<% end %>