libs/web: convert cbi widgets to new network model
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 30 Oct 2010 00:42:58 +0000 (00:42 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 30 Oct 2010 00:42:58 +0000 (00:42 +0000)
libs/web/luasrc/view/cbi/network_ifacelist.htm
libs/web/luasrc/view/cbi/network_netlist.htm

index 2f98218..53a50e9 100644 (file)
@@ -14,7 +14,6 @@ $Id$
 <%+cbi/valueheader%>
 
 <%-
 <%+cbi/valueheader%>
 
 <%-
-       local utl = require "luci.util"
        local net = require "luci.model.network"
 
        local iface
        local net = require "luci.model.network"
 
        local iface
@@ -26,7 +25,7 @@ $Id$
                if type(value) == "table" then value = table.concat(value, " ") end
                for value in value:gmatch("%S+") do
                        checked[value] = true
                if type(value) == "table" then value = table.concat(value, " ") end
                for value in value:gmatch("%S+") do
                        checked[value] = true
-               end             
+               end
        else
                local n = self.network and net:get_network(self.network)
                if n then
        else
                local n = self.network and net:get_network(self.network)
                if n then
@@ -39,13 +38,16 @@ $Id$
 -%>
 
 <ul style="margin:0; list-style-type:none">
 -%>
 
 <ul style="margin:0; list-style-type:none">
-       <% for _, iface in utl.spairs(ifaces, function(a,b) return (ifaces[a]:type() < ifaces[b]:type()) end) do
+       <% for _, iface in ipairs(ifaces) do
+            local link = iface:adminlink()
          if not self.nobridges or not iface:is_bridge() then %>
        <li>
                <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked")%> /> &nbsp;
                <label<%=attr("for", cbid .. "." .. iface:name())%>>
          if not self.nobridges or not iface:is_bridge() then %>
        <li>
                <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked")%> /> &nbsp;
                <label<%=attr("for", cbid .. "." .. iface:name())%>>
+                       <% if link then -%><a href="<%=link%>"><% end -%>
                        <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
                        <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
-                       <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<%=n:name()%>)<% end %>
+                       <% if link then -%></a><% end -%>
+                       <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<a href="<%=n:adminlink()%>"><%=n:name()%></a>)<% end %>
                </label>
        </li>
        <% end end %>
                </label>
        </li>
        <% end end %>
index c47b3a7..f5a6ce4 100644 (file)
@@ -14,7 +14,6 @@ $Id$
 <%+cbi/valueheader%>
 
 <%-
 <%+cbi/valueheader%>
 
 <%-
-       local utl = require "luci.util"
        local nwm = require "luci.model.network"
 
        local net, iface
        local nwm = require "luci.model.network"
 
        local net, iface
@@ -27,7 +26,7 @@ $Id$
 -%>
 
 <ul style="margin:0; list-style-type:none; text-align:left">
 -%>
 
 <ul style="margin:0; list-style-type:none; text-align:left">
-       <% for _, net in utl.spairs(networks, function(a,b) return (networks[a]:name() < networks[b]:name()) end) do
+       <% for _, net in ipairs(networks) do
               if net:name() ~= "loopback" then %>
        <li style="padding:0.25em 0">
                <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. net:name()) .. attr("name", cbid) .. attr("value", net:name()) .. ifattr(value == net:name(), "checked", "checked")%> /> &nbsp;
               if net:name() ~= "loopback" then %>
        <li style="padding:0.25em 0">
                <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. net:name()) .. attr("name", cbid) .. attr("value", net:name()) .. ifattr(value == net:name(), "checked", "checked")%> /> &nbsp;