Changeset 5389

Show
Ignore:
Timestamp:
10/10/09 15:47:37 (4 years ago)
Author:
jow
Message:

libs/cbi: various widget fixes

Location:
luci/trunk/libs/cbi/luasrc/view/cbi
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/cbi/luasrc/view/cbi/firewall_zonelist.htm

    r5376 r5389  
    1616<%- 
    1717    local utl = require "luci.util" 
    18     local wba = require "luci.tools.webadmin" 
    19     local wbi = require "luci.tools.webadmin_interfaces" 
    2018    local fwm = require "luci.model.firewall" 
     19    local nwm = require "luci.model.network" 
    2120 
    22     wbi.init(self.map.uci) 
    23  
    24     local zone, iface, ifname 
     21    local zone, net, iface 
    2522    local zones = fwm:get_zones() 
    2623    local value = self:cfgvalue(section) or self.default 
     24    local selected = false 
    2725 
    2826    if value and #value == 0 then value = nil end 
     
    3028 
    3129<ul style="margin:0; list-style-type:none"> 
    32     <% for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do %> 
     30    <% 
     31        for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do 
     32            selected = selected or (value == zone:name()) 
     33    %> 
    3334    <li style="padding:0.5em"> 
    3435        <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(value == zone:name(), "checked", "checked")%> /> &nbsp; 
     
    3738            <% 
    3839                local empty = true 
    39                 for _, iface in ipairs(zone:get_networks()) do 
    40                     local ifname = wbi.network_get_ifname(iface) 
    41                     local dev    = wbi.iface_get_list()[ifname] 
     40                for _, net in ipairs(zone:get_networks()) do 
     41                    net = nwm:get_network(net) 
     42                    for _, iface in ipairs(net and net:get_interfaces() or {}) do 
     43                        if not iface:is_bridgeport() then 
     44                            empty = false 
    4245             %> 
    43                 <% if ifname and dev then empty = false %> 
    44                     <img title="<%=wbi.iface_format_type(dev.type)%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=dev.type or "ethernet"%><%=dev.flags and dev.flags.up and "" or "_disabled"%>.png" /> 
    45                     <% if iface == self.iface then %><strong><%=ifname%></strong><% else %><%=ifname%><% end %> &nbsp; 
    46                 <% end %> 
    47             <% end %> 
     46                <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" /> 
     47                <% if iface:name() == self.iface then %><strong><%=iface:name()%></strong><% else %><%=iface:name()%><% end %> &nbsp; 
     48            <% end end end %> 
    4849            <% if empty then %><em><%:a_s_ipt_zone_empty (no interfaces attached)%></em><% end %> 
    4950        </label> 
     
    5152    <% end %> 
    5253 
     54    <% if not self.nocreate then %> 
    5355    <li style="padding:0.5em"> 
    54         <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value, "checked", "checked")%> /> &nbsp; 
     56        <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &nbsp; 
    5557        <div style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em; display:inline"> 
    5658            <label<%=attr("for", cbid .. "_new")%>><em><%:a_s_ipt_zone_unspec_create unspecified -or- create:%>&nbsp;</em></label> 
    57             <input style="width:6em" type="text"<%=attr("name", cbid .. ".newzone")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" /> 
     59            <input style="width:6em" type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" /> 
    5860        </div> 
    5961    </li> 
     62    <% end %> 
    6063</ul> 
    6164 
  • luci/trunk/libs/cbi/luasrc/view/cbi/fvalue.htm

    r3530 r5389  
    1414-%> 
    1515<%+cbi/valueheader%> 
    16     <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self:cfgvalue(section) == self.enabled, "checked", "checked") %> value="1" /> 
     16    <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") %> value="1" /> 
    1717<%+cbi/valuefooter%> 
  • luci/trunk/libs/cbi/luasrc/view/cbi/network_ifacelist.htm

    r5380 r5389  
    2323    local checked = { } 
    2424 
     25    if type(value) == "table" then value = table.concat(value, " ") end 
    2526    for value in value:gmatch("%S+") do 
    2627        checked[value] = true 
  • luci/trunk/libs/cbi/luasrc/view/cbi/value.htm

    r3530 r5389  
    1414-%> 
    1515<%+cbi/valueheader%> 
    16     <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section)) .. ifattr(self.size, "size")%> /> 
     16    <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) .. ifattr(self.size, "size")%> /> 
    1717    <% if #self.keylist > 0 then -%> 
    1818    <script type="text/javascript">