modules/admin-full: change workflow of wifi config page; display only one network (choosen in wifi overview) and add a hook for section remapping
on uci commit
This commit is contained in:
parent
66fe827403
commit
2a1f1a1d7b
1 changed files with 305 additions and 285 deletions
|
@ -14,6 +14,7 @@ $Id$
|
||||||
|
|
||||||
local wa = require "luci.tools.webadmin"
|
local wa = require "luci.tools.webadmin"
|
||||||
local nw = require "luci.model.network"
|
local nw = require "luci.model.network"
|
||||||
|
local ww = require "luci.model.wireless"
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
arg[1] = arg[1] or ""
|
arg[1] = arg[1] or ""
|
||||||
|
@ -21,7 +22,22 @@ 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")
|
m:chain("network")
|
||||||
|
|
||||||
|
local ifsection
|
||||||
|
|
||||||
|
function m.on_commit(map)
|
||||||
|
nw.init(map.uci)
|
||||||
|
ww.init(map.uci)
|
||||||
|
|
||||||
|
local wnet = ww:get_network(arg[2])
|
||||||
|
if ifsection and wnet then
|
||||||
|
ifsection.section = wnet.sid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
nw.init(m.uci)
|
nw.init(m.uci)
|
||||||
|
ww.init(m.uci)
|
||||||
|
|
||||||
|
|
||||||
local iw = nil
|
local iw = nil
|
||||||
local tx_powers = nil
|
local tx_powers = nil
|
||||||
|
@ -201,32 +217,36 @@ end
|
||||||
|
|
||||||
----------------------- Interface -----------------------
|
----------------------- Interface -----------------------
|
||||||
|
|
||||||
s = m:section(NamedSection, arg[2], "wifi-iface", translate("interfaces"))
|
local wnet = ww:get_network(arg[2])
|
||||||
s.addremove = false
|
|
||||||
s.anonymous = true
|
|
||||||
s.defaults.device = arg[1]
|
|
||||||
|
|
||||||
s:tab("general", translate("a_w_general", "General Setup"))
|
if wnet then
|
||||||
s:tab("encryption", translate("a_w_security", "Wireless Security"))
|
s = m:section(NamedSection, wnet.sid, "wifi-iface", ww:get_i18n(wnet))
|
||||||
s:tab("macfilter", translate("a_w_macfilter", "MAC-Filter"))
|
ifsection = s
|
||||||
s:tab("advanced", translate("a_w_advanced", "Advanced Settings"))
|
s.addremove = false
|
||||||
|
s.anonymous = true
|
||||||
|
s.defaults.device = arg[1]
|
||||||
|
|
||||||
s:taboption("general", Value, "ssid", translate("wifi_essid"))
|
s:tab("general", translate("a_w_general", "General Setup"))
|
||||||
|
s:tab("encryption", translate("a_w_security", "Wireless Security"))
|
||||||
|
s:tab("macfilter", translate("a_w_macfilter", "MAC-Filter"))
|
||||||
|
s:tab("advanced", translate("a_w_advanced", "Advanced Settings"))
|
||||||
|
|
||||||
mode = s:taboption("general", ListValue, "mode", translate("mode"))
|
s:taboption("general", Value, "ssid", translate("wifi_essid"))
|
||||||
mode.override_values = true
|
|
||||||
mode:value("ap", translate("a_w_ap"))
|
|
||||||
mode:value("sta", translate("a_w_client"))
|
|
||||||
mode:value("adhoc", translate("a_w_adhoc"))
|
|
||||||
|
|
||||||
bssid = s:taboption("general", Value, "bssid", translate("wifi_bssid"))
|
mode = s:taboption("general", ListValue, "mode", translate("mode"))
|
||||||
|
mode.override_values = true
|
||||||
|
mode:value("ap", translate("a_w_ap"))
|
||||||
|
mode:value("sta", translate("a_w_client"))
|
||||||
|
mode:value("adhoc", translate("a_w_adhoc"))
|
||||||
|
|
||||||
network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1"))
|
bssid = s:taboption("general", Value, "bssid", translate("wifi_bssid"))
|
||||||
network.rmempty = true
|
|
||||||
network.template = "cbi/network_netlist"
|
|
||||||
network.widget = "radio"
|
|
||||||
|
|
||||||
function network.write(self, section, value)
|
network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1"))
|
||||||
|
network.rmempty = true
|
||||||
|
network.template = "cbi/network_netlist"
|
||||||
|
network.widget = "radio"
|
||||||
|
|
||||||
|
function network.write(self, section, value)
|
||||||
local i = nw:get_interface(section)
|
local i = nw:get_interface(section)
|
||||||
if i then
|
if i then
|
||||||
if value == '-' then
|
if value == '-' then
|
||||||
|
@ -246,11 +266,11 @@ function network.write(self, section, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------- MAC80211 Interface ----------------------
|
-------------------- MAC80211 Interface ----------------------
|
||||||
|
|
||||||
if hwtype == "mac80211" then
|
if hwtype == "mac80211" then
|
||||||
if fs.access("/usr/sbin/iw") then
|
if fs.access("/usr/sbin/iw") then
|
||||||
mode:value("mesh", "802.11s")
|
mode:value("mesh", "802.11s")
|
||||||
end
|
end
|
||||||
|
@ -261,13 +281,13 @@ if hwtype == "mac80211" then
|
||||||
|
|
||||||
s:taboption("advanced", Value, "frag", translate("wifi_frag"))
|
s:taboption("advanced", Value, "frag", translate("wifi_frag"))
|
||||||
s:taboption("advanced", Value, "rts", translate("wifi_rts"))
|
s:taboption("advanced", Value, "rts", translate("wifi_rts"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------------------- Madwifi Interface ----------------------
|
-------------------- Madwifi Interface ----------------------
|
||||||
|
|
||||||
if hwtype == "atheros" then
|
if hwtype == "atheros" then
|
||||||
mode:value("ahdemo", translate("a_w_ahdemo"))
|
mode:value("ahdemo", translate("a_w_ahdemo"))
|
||||||
mode:value("monitor", translate("a_w_monitor"))
|
mode:value("monitor", translate("a_w_monitor"))
|
||||||
mode:value("ap-wds", "%s (%s)" % {translate("a_w_ap"), translate("a_w_wds")})
|
mode:value("ap-wds", "%s (%s)" % {translate("a_w_ap"), translate("a_w_wds")})
|
||||||
|
@ -350,12 +370,12 @@ if hwtype == "atheros" then
|
||||||
local probereq = s:taboption("advanced", Flag, "probereq", translate("wifi_noprobereq"))
|
local probereq = s:taboption("advanced", Flag, "probereq", translate("wifi_noprobereq"))
|
||||||
probereq.enabled = "0"
|
probereq.enabled = "0"
|
||||||
probereq.disabled = "1"
|
probereq.disabled = "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------- Broadcom Interface ----------------------
|
-------------------- Broadcom Interface ----------------------
|
||||||
|
|
||||||
if hwtype == "broadcom" then
|
if hwtype == "broadcom" then
|
||||||
mode:value("wds", translate("a_w_wds"))
|
mode:value("wds", translate("a_w_wds"))
|
||||||
mode:value("monitor", translate("a_w_monitor"))
|
mode:value("monitor", translate("a_w_monitor"))
|
||||||
|
|
||||||
|
@ -373,12 +393,12 @@ if hwtype == "broadcom" then
|
||||||
|
|
||||||
bssid:depends({mode="wds"})
|
bssid:depends({mode="wds"})
|
||||||
bssid:depends({mode="adhoc"})
|
bssid:depends({mode="adhoc"})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
----------------------- HostAP Interface ---------------------
|
----------------------- HostAP Interface ---------------------
|
||||||
|
|
||||||
if hwtype == "prism2" then
|
if hwtype == "prism2" then
|
||||||
mode:value("wds", translate("a_w_wds"))
|
mode:value("wds", translate("a_w_wds"))
|
||||||
mode:value("monitor", translate("a_w_monitor"))
|
mode:value("monitor", translate("a_w_monitor"))
|
||||||
|
|
||||||
|
@ -400,25 +420,25 @@ if hwtype == "prism2" then
|
||||||
s:taboption("advanced", Value, "rate", translate("wifi_rate"))
|
s:taboption("advanced", Value, "rate", translate("wifi_rate"))
|
||||||
s:taboption("advanced", Value, "frag", translate("wifi_frag"))
|
s:taboption("advanced", Value, "frag", translate("wifi_frag"))
|
||||||
s:taboption("advanced", Value, "rts", translate("wifi_rts"))
|
s:taboption("advanced", Value, "rts", translate("wifi_rts"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
------------------- WiFI-Encryption -------------------
|
------------------- WiFI-Encryption -------------------
|
||||||
|
|
||||||
encr = s:taboption("encryption", ListValue, "encryption", translate("encryption"))
|
encr = s:taboption("encryption", ListValue, "encryption", translate("encryption"))
|
||||||
encr.override_values = true
|
encr.override_values = true
|
||||||
encr:depends({mode="ap"})
|
encr:depends({mode="ap"})
|
||||||
encr:depends({mode="sta"})
|
encr:depends({mode="sta"})
|
||||||
encr:depends({mode="adhoc"})
|
encr:depends({mode="adhoc"})
|
||||||
encr:depends({mode="ahdemo"})
|
encr:depends({mode="ahdemo"})
|
||||||
encr:depends({mode="ap-wds"})
|
encr:depends({mode="ap-wds"})
|
||||||
encr:depends({mode="sta-wds"})
|
encr:depends({mode="sta-wds"})
|
||||||
encr:depends({mode="mesh"})
|
encr:depends({mode="mesh"})
|
||||||
|
|
||||||
encr:value("none", "No Encryption")
|
encr:value("none", "No Encryption")
|
||||||
encr:value("wep", "WEP")
|
encr:value("wep", "WEP")
|
||||||
|
|
||||||
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
||||||
local supplicant = fs.access("/usr/sbin/wpa_supplicant")
|
local supplicant = fs.access("/usr/sbin/wpa_supplicant")
|
||||||
local hostapd = fs.access("/usr/sbin/hostapd")
|
local hostapd = fs.access("/usr/sbin/hostapd")
|
||||||
|
|
||||||
|
@ -445,40 +465,40 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
||||||
else
|
else
|
||||||
encr.description = translate("wifi_wpareq")
|
encr.description = translate("wifi_wpareq")
|
||||||
end
|
end
|
||||||
elseif hwtype == "broadcom" then
|
elseif hwtype == "broadcom" then
|
||||||
encr:value("psk", "WPA-PSK")
|
encr:value("psk", "WPA-PSK")
|
||||||
encr:value("psk2", "WPA2-PSK")
|
encr:value("psk2", "WPA2-PSK")
|
||||||
encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
|
encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
|
||||||
end
|
end
|
||||||
|
|
||||||
encr:depends("mode", "ap")
|
encr:depends("mode", "ap")
|
||||||
encr:depends("mode", "sta")
|
encr:depends("mode", "sta")
|
||||||
encr:depends("mode", "ap-wds")
|
encr:depends("mode", "ap-wds")
|
||||||
encr:depends("mode", "sta-wds")
|
encr:depends("mode", "sta-wds")
|
||||||
encr:depends("mode", "wds")
|
encr:depends("mode", "wds")
|
||||||
|
|
||||||
server = s:taboption("encryption", Value, "server", translate("a_w_radiussrv"))
|
server = s:taboption("encryption", Value, "server", translate("a_w_radiussrv"))
|
||||||
server:depends({mode="ap", encryption="wpa"})
|
server:depends({mode="ap", encryption="wpa"})
|
||||||
server:depends({mode="ap", encryption="wpa2"})
|
server:depends({mode="ap", encryption="wpa2"})
|
||||||
server.rmempty = true
|
server.rmempty = true
|
||||||
|
|
||||||
port = s:taboption("encryption", Value, "port", translate("a_w_radiusport"))
|
port = s:taboption("encryption", Value, "port", translate("a_w_radiusport"))
|
||||||
port:depends({mode="ap", encryption="wpa"})
|
port:depends({mode="ap", encryption="wpa"})
|
||||||
port:depends({mode="ap", encryption="wpa2"})
|
port:depends({mode="ap", encryption="wpa2"})
|
||||||
port.rmempty = true
|
port.rmempty = true
|
||||||
|
|
||||||
key = s:taboption("encryption", Value, "key", translate("key"))
|
key = s:taboption("encryption", Value, "key", translate("key"))
|
||||||
key:depends("encryption", "wep")
|
key:depends("encryption", "wep")
|
||||||
key:depends("encryption", "psk")
|
key:depends("encryption", "psk")
|
||||||
key:depends("encryption", "psk2")
|
key:depends("encryption", "psk2")
|
||||||
key:depends("encryption", "psk+psk2")
|
key:depends("encryption", "psk+psk2")
|
||||||
key:depends("encryption", "psk-mixed")
|
key:depends("encryption", "psk-mixed")
|
||||||
key:depends({mode="ap", encryption="wpa"})
|
key:depends({mode="ap", encryption="wpa"})
|
||||||
key:depends({mode="ap", encryption="wpa2"})
|
key:depends({mode="ap", encryption="wpa2"})
|
||||||
key.rmempty = true
|
key.rmempty = true
|
||||||
key.password = true
|
key.password = true
|
||||||
|
|
||||||
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
||||||
nasid = s:taboption("encryption", Value, "nasid", translate("a_w_nasid"))
|
nasid = s:taboption("encryption", Value, "nasid", translate("a_w_nasid"))
|
||||||
nasid:depends({mode="ap", encryption="wpa"})
|
nasid:depends({mode="ap", encryption="wpa"})
|
||||||
nasid:depends({mode="ap", encryption="wpa2"})
|
nasid:depends({mode="ap", encryption="wpa2"})
|
||||||
|
@ -526,7 +546,7 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
||||||
password:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
|
password:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
|
||||||
password:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
|
password:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
|
||||||
password:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
|
password:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
Loading…
Reference in a new issue