Changeset 5427

Show
Ignore:
Timestamp:
10/27/09 22:40:12 (4 years ago)
Author:
jow
Message:

modules/admin-full: use network picker widget in wifi config pages

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua

    r5399 r5427  
    1414 
    1515local wa = require "luci.tools.webadmin" 
     16local nw = require "luci.model.network" 
    1617local fs = require "nixio.fs" 
    1718 
    1819arg[1] = arg[1] or "" 
     20arg[2] = arg[2] or "" 
    1921 
    2022m = Map("wireless", translate("networks"), translate("a_w_networks1")) 
    21  
     23m:chain("network") 
     24nw.init(m.uci) 
    2225 
    2326local iw = nil 
     
    199202----------------------- Interface ----------------------- 
    200203 
    201 s = m:section(TypedSection, "wifi-iface", translate("interfaces")) 
    202 s.addremove = (iw and iw.mbssid_support) and true or false 
     204s = m:section(NamedSection, arg[2], "wifi-iface", translate("interfaces")) 
     205s.addremove = false 
    203206s.anonymous = true 
    204 s:depends("device", arg[1]) 
    205207s.defaults.device = arg[1] 
    206208 
     
    222224network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1")) 
    223225network.rmempty = true 
    224 network:value("") 
    225 network.combobox_manual = translate("a_w_netmanual") 
    226 wa.cbi_add_networks(network) 
     226network.template = "cbi/network_netlist" 
     227network.widget = "radio" 
    227228 
    228229function network.write(self, section, value) 
    229     if not m.uci:get("network", value) then 
    230         -- avoid "value not defined in enum" because network is not known yet 
    231         s.override_scheme = true 
    232  
    233         m:chain("network") 
    234         m.uci:set("network", value, "interface") 
    235         Value.write(self, section, value) 
    236     else 
    237         if m.uci:get("network", value) == "interface" then 
    238             Value.write(self, section, value) 
     230    local i = nw:get_interface(section) 
     231    if i then 
     232        if value == '-' then 
     233            value = m:formvalue(self:cbid(section) .. ".newnet") 
     234            if value and #value > 0 then 
     235                local n = nw:add_network(value, {type="bridge", proto="none"}) 
     236                if n then n:add_interface(i) end 
     237            else 
     238                local n = i:get_network() 
     239                if n then n:del_interface(i) end 
     240            end 
     241        else 
     242            local n = nw:get_network(value) 
     243            if n then 
     244                n:type("bridge") 
     245                n:add_interface(i) 
     246            end 
    239247        end 
    240248    end 
    241249end 
    242  
    243250 
    244251-------------------- MAC80211 Interface ----------------------