modules/admin-full: rework wifi CBI maps

This commit is contained in:
Jo-Philipp Wich 2011-01-20 23:26:49 +00:00
parent b8c1487f6d
commit 5d426cf4ac
2 changed files with 15 additions and 17 deletions

View file

@ -17,7 +17,6 @@ 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", "", m = Map("wireless", "",
translate("The <em>Device Configuration</em> section covers physical settings of the radio " .. translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
@ -30,24 +29,25 @@ m:chain("network")
local ifsection local ifsection
function m.on_commit(map) function m.on_commit(map)
local wnet = nw:get_wifinet(arg[2]) local wnet = nw:get_wifinet(arg[1])
if ifsection and wnet then if ifsection and wnet then
ifsection.section = wnet.sid ifsection.section = wnet.sid
m.title = wnet:get_i18n() m.title = luci.util.pcdata(wnet:get_i18n())
end end
end end
nw.init(m.uci) nw.init(m.uci)
local wnet = nw:get_wifinet(arg[2]) local wnet = nw:get_wifinet(arg[1])
local wdev = wnet and wnet:get_device()
-- redirect to overview page if network does not exist anymore (e.g. after a revert) -- redirect to overview page if network does not exist anymore (e.g. after a revert)
if not wnet then if not wnet or not wdev then
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless")) luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return return
end end
m.title = wnet:get_i18n() m.title = luci.util.pcdata(wnet:get_i18n())
local iw = luci.sys.wifi.getiwinfo(arg[1]) local iw = luci.sys.wifi.getiwinfo(arg[1])
@ -55,7 +55,7 @@ local tx_powers = iw.txpwrlist or { }
local hw_modes = iw.hwmodelist or { } local hw_modes = iw.hwmodelist or { }
s = m:section(NamedSection, arg[1], "wifi-device", translate("Device Configuration")) s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration"))
s.addremove = false s.addremove = false
s:tab("general", translate("General Setup")) s:tab("general", translate("General Setup"))
@ -70,7 +70,7 @@ back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
st = s:taboption("general", DummyValue, "__status", translate("Status")) st = s:taboption("general", DummyValue, "__status", translate("Status"))
st.template = "admin_network/wifi_status" st.template = "admin_network/wifi_status"
st.ifname = arg[2] st.ifname = arg[1]
en = s:taboption("general", Flag, "disabled", translate("Enable device")) en = s:taboption("general", Flag, "disabled", translate("Enable device"))
en.enabled = "0" en.enabled = "0"
@ -82,11 +82,11 @@ function en.cfgvalue(self, section)
end end
local hwtype = m:get(arg[1], "type") local hwtype = wdev:get("type")
local htcaps = m:get(arg[1], "ht_capab") and true or false local htcaps = wdev:get("ht_capab") and true or false
-- NanoFoo -- NanoFoo
local nsantenna = m:get(arg[1], "antenna") local nsantenna = wdev:get("antenna")
ch = s:taboption("general", Value, "channel", translate("Channel")) ch = s:taboption("general", Value, "channel", translate("Channel"))
ch:value("auto", translate("auto")) ch:value("auto", translate("auto"))
@ -276,7 +276,7 @@ s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configu
ifsection = s ifsection = s
s.addremove = false s.addremove = false
s.anonymous = true s.anonymous = true
s.defaults.device = arg[1] s.defaults.device = wdev:name()
s:tab("general", translate("General Setup")) s:tab("general", translate("General Setup"))
s:tab("encryption", translate("Wireless Security")) s:tab("encryption", translate("Wireless Security"))
@ -633,7 +633,7 @@ wepslot.cfgvalue = function(self, section)
if not slot or slot < 1 or slot > 4 then if not slot or slot < 1 or slot > 4 then
return 1 return 1
end end
return slot return slot
end end
wepslot.write = function(self, section, value) wepslot.write = function(self, section, value)
@ -648,7 +648,7 @@ for slot=1,4 do
wepkey.datatype = "wepkey" wepkey.datatype = "wepkey"
wepkey.rmempty = true wepkey.rmempty = true
wepkey.password = true wepkey.password = true
function wepkey.write(self, section, value) function wepkey.write(self, section, value)
if value and (#value == 5 or #value == 13) then if value and (#value == 5 or #value == 13) then
value = "s:" .. value value = "s:" .. value

View file

@ -166,9 +166,7 @@ function newnet.parse(self, section)
uci:save("network") uci:save("network")
uci:save("firewall") uci:save("firewall")
luci.http.redirect(luci.dispatcher.build_url( luci.http.redirect(wnet:adminlink())
"admin/network/wireless", wdev:name(), wnet:ifname()
))
end end
end end
end end