libs/web: convert cbi widgets to new network model

This commit is contained in:
Jo-Philipp Wich 2010-10-30 00:42:58 +00:00
parent df01f3e431
commit 595020f919
2 changed files with 7 additions and 6 deletions

View file

@ -14,7 +14,6 @@ $Id$
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
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
end
end
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">
<% 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 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" />
<%=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 %>

View file

@ -14,7 +14,6 @@ $Id$
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
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">
<% 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;