diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-06-27 10:12:20 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-06-27 10:12:20 +0000 |
commit | d30109e350b9804bb2e1d33b987250ea10a05f6b (patch) | |
tree | 3876e4efc12a4187ec60fd784fd04df05b903323 /modules/admin-full | |
parent | 9fab594101f3f80325ab63c3947f264cf267d017 (diff) |
modules/admin-full: sort networks by zone and name in overview
Diffstat (limited to 'modules/admin-full')
-rw-r--r-- | modules/admin-full/luasrc/view/admin_network/iface_overview.htm | 36 |
1 files changed, 25 insertions, 11 deletions
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 9577ed0fd..545d1386d 100644 --- a/modules/admin-full/luasrc/view/admin_network/iface_overview.htm +++ b/modules/admin-full/luasrc/view/admin_network/iface_overview.htm @@ -15,12 +15,26 @@ You may obtain a copy of the License at local fwm = require "luci.model.firewall".init() local net + local ifaces = { } local netlist = { } for _, net in ipairs(ntm:get_networks()) do if net:name() ~= "loopback" then - netlist[#netlist+1] = net:name() + local z = fwm:get_zone_by_network(net:name()) + ifaces[#ifaces+1] = net:name() + netlist[#netlist+1] = { + net:name(), z and z:name() or "-", z + } end end + + table.sort(netlist, + function(a, b) + if a[2] ~= b[2] then + return a[2] < b[2] + else + return a[1] < b[1] + end + end) -%> <script type="text/javascript" src="<%=resource%>/cbi.js"></script> @@ -64,7 +78,7 @@ You may obtain a copy of the License at var wifidevs = <%=luci.http.write_json(netdevs)%>; var arptable = <%=luci.http.write_json(arpcache)%>; - XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(netlist, ","))%>', null, + XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(ifaces, ","))%>', null, function(x, ifcs) { if (ifcs) @@ -162,7 +176,7 @@ You may obtain a copy of the License at d.innerHTML = html; } - else if (d && !ifc.ifname) + else if (d && !ifc.ifname) { d.innerHTML = String.format( '<em><%:Network without interfaces.%></em><br />' + @@ -210,7 +224,7 @@ You may obtain a copy of the License at </tr> <% for i, net in ipairs(netlist) do - local z = fwm:get_zone_by_network(net) + local z = net[3] local c = z and z:get_color() or "#EEEEEE" local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned") %> @@ -218,22 +232,22 @@ You may obtain a copy of the License at <td class="cbi-value-field" style="padding:3px"> <div class="ifacebox"> <div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>"> - <strong><%=net:upper()%></strong> + <strong><%=net[1]:upper()%></strong> </div> - <div class="ifacebox-body" id="<%=net%>-ifc-devices"> + <div class="ifacebox-body" id="<%=net[1]%>-ifc-devices"> <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br /> <small>?</small> </div> </div> </td> - <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net%>-ifc-description"> + <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net[1]%>-ifc-description"> <em><%:Collecting data...%></em> </td> <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%>" /> + <input type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" /> + <input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', 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[1])%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-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[1])%>'" title="<%:Delete this interface%>" value="<%:Delete%>" /> </td> </tr> <% end %> |