modules/admin-full: rework wifi CBI maps
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 20 Jan 2011 23:26:49 +0000 (23:26 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 20 Jan 2011 23:26:49 +0000 (23:26 +0000)
modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua

index 0cfc021..fdeea99 100644 (file)
@@ -17,7 +17,6 @@ local nw = require "luci.model.network"
 local fs = require "nixio.fs"
 
 arg[1] = arg[1] or ""
 local fs = require "nixio.fs"
 
 arg[1] = arg[1] or ""
-arg[2] = arg[2] or ""
 
 m = Map("wireless", "",
        translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
 
 m = Map("wireless", "",
        translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
@@ -30,24 +29,25 @@ m:chain("network")
 local ifsection
 
 function m.on_commit(map)
 local ifsection
 
 function m.on_commit(map)
-       local wnet = nw:get_wifinet(arg[2])
+       local wnet = nw:get_wifinet(arg[1])
        if ifsection and wnet then
                ifsection.section = wnet.sid
        if ifsection and wnet then
                ifsection.section = wnet.sid
-               m.title = wnet:get_i18n()
+               m.title = luci.util.pcdata(wnet:get_i18n())
        end
 end
 
 nw.init(m.uci)
 
        end
 end
 
 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"))
        return
 end
 
        luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
        return
 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:tab("general", translate("General Setup"))
 s.addremove = false
 
 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.template = "admin_network/wifi_status"
 
 st = s:taboption("general", DummyValue, "__status", translate("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.enabled = "0"
 
 en = s:taboption("general", Flag, "disabled", translate("Enable device"))
 en.enabled = "0"
@@ -82,11 +82,11 @@ function en.cfgvalue(self, section)
 end
 
 
 end
 
 
-local hwtype = m:get(arg[1], "type")
-local htcaps = m:get(arg[1], "ht_capab") and true or false
+local hwtype = wdev:get("type")
+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:value("auto", translate("auto"))
 
 ch = s:taboption("general", Value, "channel", translate("Channel"))
 ch:value("auto", translate("auto"))
@@ -276,7 +276,7 @@ s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configu
 ifsection = s
 s.addremove = false
 s.anonymous = true
 ifsection = s
 s.addremove = false
 s.anonymous = true
-s.defaults.device = arg[1]
+s.defaults.device = wdev:name()
 
 s:tab("general", translate("General Setup"))
 s:tab("encryption", translate("Wireless Security"))
 
 s:tab("general", translate("General Setup"))
 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
                return 1
        end
        if not slot or slot < 1 or slot > 4 then
                return 1
        end
-       return slot             
+       return slot
 end
 
 wepslot.write = function(self, section, value)
 end
 
 wepslot.write = function(self, section, value)
@@ -648,7 +648,7 @@ for slot=1,4 do
        wepkey.datatype = "wepkey"
        wepkey.rmempty = true
        wepkey.password = true
        wepkey.datatype = "wepkey"
        wepkey.rmempty = true
        wepkey.password = true
-       
+
        function wepkey.write(self, section, value)
                if value and (#value == 5 or #value == 13) then
                        value = "s:" .. value
        function wepkey.write(self, section, value)
                if value and (#value == 5 or #value == 13) then
                        value = "s:" .. value
index 3d0d755..5dd6393 100644 (file)
@@ -166,9 +166,7 @@ function newnet.parse(self, section)
                        uci:save("network")
                        uci:save("firewall")
 
                        uci:save("network")
                        uci:save("firewall")
 
-                       luci.http.redirect(luci.dispatcher.build_url(
-                               "admin/network/wireless", wdev:name(), wnet:ifname()
-                       ))
+                       luci.http.redirect(wnet:adminlink())
                end
        end
 end
                end
        end
 end