modules/admin-full: use network picker widget in wifi config pages
This commit is contained in:
parent
09fa7f18c9
commit
2e8d0a9b6b
1 changed files with 25 additions and 18 deletions
|
@ -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,25 +223,30 @@ 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 ----------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue