Changeset 8791

Show
Ignore:
Timestamp:
06/27/12 12:12:20 (11 months ago)
Author:
jow
Message:

modules/admin-full: sort networks by zone and name in overview

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/modules/admin-full/luasrc/view/admin_network/iface_overview.htm

    r8604 r8791  
    1616 
    1717    local net 
     18    local ifaces = { } 
    1819    local netlist = { } 
    1920    for _, net in ipairs(ntm:get_networks()) do 
    2021        if net:name() ~= "loopback" then 
    21             netlist[#netlist+1] = net:name() 
     22            local z = fwm:get_zone_by_network(net:name()) 
     23            ifaces[#ifaces+1] = net:name() 
     24            netlist[#netlist+1] = { 
     25                net:name(), z and z:name() or "-", z 
     26            } 
    2227        end 
    2328    end 
     29 
     30    table.sort(netlist, 
     31        function(a, b) 
     32            if a[2] ~= b[2] then 
     33                return a[2] < b[2] 
     34            else 
     35                return a[1] < b[1] 
     36            end 
     37        end) 
    2438-%> 
    2539 
     
    6579    var arptable = <%=luci.http.write_json(arpcache)%>; 
    6680 
    67     XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(netlist, ","))%>', null, 
     81    XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(ifaces, ","))%>', null, 
    6882        function(x, ifcs) 
    6983        { 
     
    163177                        d.innerHTML = html; 
    164178                    } 
    165                     else if (d && !ifc.ifname)                                      
     179                    else if (d && !ifc.ifname) 
    166180                    { 
    167181                        d.innerHTML = String.format( 
     
    211225            <% 
    212226                for i, net in ipairs(netlist) do 
    213                     local z = fwm:get_zone_by_network(net) 
     227                    local z = net[3] 
    214228                    local c = z and z:get_color() or "#EEEEEE" 
    215229                    local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned") 
     
    219233                        <div class="ifacebox"> 
    220234                            <div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>"> 
    221                                 <strong><%=net:upper()%></strong> 
     235                                <strong><%=net[1]:upper()%></strong> 
    222236                            </div> 
    223                             <div class="ifacebox-body" id="<%=net%>-ifc-devices"> 
     237                            <div class="ifacebox-body" id="<%=net[1]%>-ifc-devices"> 
    224238                                <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br /> 
    225239                                <small>?</small> 
     
    227241                        </div> 
    228242                    </td> 
    229                     <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net%>-ifc-description"> 
     243                    <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=net[1]%>-ifc-description"> 
    230244                        <em><%:Collecting data...%></em> 
    231245                    </td> 
    232246                    <td style="width:420px"> 
    233                         <input type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="iface_shutdown('<%=net%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" /> 
    234                         <input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_shutdown('<%=net%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" /> 
    235                         <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" /> 
    236                         <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%>" /> 
     247                        <input type="button" class="cbi-button cbi-button-reload" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" /> 
     248                        <input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_shutdown('<%=net[1]%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" /> 
     249                        <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" /> 
     250                        <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%>" /> 
    237251                    </td> 
    238252                </tr>