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

This commit is contained in:
Jo-Philipp Wich 2009-10-27 21:40:12 +00:00
parent 09fa7f18c9
commit 2e8d0a9b6b

View file

@ -13,12 +13,15 @@ $Id$
]]-- ]]--
local wa = require "luci.tools.webadmin" local wa = require "luci.tools.webadmin"
local nw = require "luci.model.network"
local fs = require "nixio.fs" local fs = require "nixio.fs"
arg[1] = arg[1] or "" arg[1] = arg[1] or ""
arg[2] = arg[2] or ""
m = Map("wireless", translate("networks"), translate("a_w_networks1")) m = Map("wireless", translate("networks"), translate("a_w_networks1"))
m:chain("network")
nw.init(m.uci)
local iw = nil local iw = nil
local tx_powers = nil local tx_powers = nil
@ -198,10 +201,9 @@ end
----------------------- Interface ----------------------- ----------------------- Interface -----------------------
s = m:section(TypedSection, "wifi-iface", translate("interfaces")) s = m:section(NamedSection, arg[2], "wifi-iface", translate("interfaces"))
s.addremove = (iw and iw.mbssid_support) and true or false s.addremove = false
s.anonymous = true s.anonymous = true
s:depends("device", arg[1])
s.defaults.device = arg[1] s.defaults.device = arg[1]
s:tab("general", translate("a_w_general", "General Setup")) s:tab("general", translate("a_w_general", "General Setup"))
@ -221,26 +223,31 @@ bssid = s:taboption("general", Value, "bssid", translate("wifi_bssid"))
network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1")) network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1"))
network.rmempty = true network.rmempty = true
network:value("") network.template = "cbi/network_netlist"
network.combobox_manual = translate("a_w_netmanual") network.widget = "radio"
wa.cbi_add_networks(network)
function network.write(self, section, value) function network.write(self, section, value)
if not m.uci:get("network", value) then local i = nw:get_interface(section)
-- avoid "value not defined in enum" because network is not known yet if i then
s.override_scheme = true if value == '-' then
value = m:formvalue(self:cbid(section) .. ".newnet")
m:chain("network") if value and #value > 0 then
m.uci:set("network", value, "interface") local n = nw:add_network(value, {type="bridge", proto="none"})
Value.write(self, section, value) if n then n:add_interface(i) end
else else
if m.uci:get("network", value) == "interface" then local n = i:get_network()
Value.write(self, section, value) if n then n:del_interface(i) end
end
else
local n = nw:get_network(value)
if n then
n:type("bridge")
n:add_interface(i)
end
end end
end end
end end
-------------------- MAC80211 Interface ---------------------- -------------------- MAC80211 Interface ----------------------
if hwtype == "mac80211" then if hwtype == "mac80211" then