gluon-web-wifi-config: make mesh VIF options depend on outdoor=false

Instead of relying on the existence of interface sections only (which is
still used for the case of interface types that are not configured at
all in the site config), add a proper dependency.

This fixes section visiblity with enabled outdoor mode after the following
fix, and gives the user immediate feedback (allowing to disable outdoor
mode and enable meshing in a single step).

(cherry picked from commit d012d7d32f)
This commit is contained in:
Matthias Schiffer 2020-06-06 16:58:00 +02:00
parent 5a17b81999
commit fc4bc6fd53
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -47,13 +47,18 @@ f:section(Section, nil, translate(
))
local mesh_vifs_5ghz = {}
uci:foreach('wireless', 'wifi-device', function(config)
local radio = config['.name']
local is_5ghz = false
local title
if config.hwmode == '11g' or config.hwmode == '11ng' then
title = translate("2.4GHz WLAN")
elseif config.hwmode == '11a' or config.hwmode == '11na' then
is_5ghz = true
title = translate("5GHz WLAN")
else
return
@ -72,10 +77,16 @@ uci:foreach('wireless', 'wifi-device', function(config)
function o:write(data)
uci:set('wireless', t .. '_' .. radio, 'disabled', not data)
end
return o
end
vif_option('client', translate('Enable client network (access point)'))
vif_option('mesh', translate("Enable mesh network (802.11s)"))
local mesh_vif = vif_option('mesh', translate("Enable mesh network (802.11s)"))
if is_5ghz then
table.insert(mesh_vifs_5ghz, mesh_vif)
end
local phy = util.find_phy(config)
if not phy then
@ -119,6 +130,10 @@ if has_5ghz_radio() then
local outdoor = r:option(Flag, 'outdoor', translate("Node will be installed outdoors"))
outdoor.default = uci:get_bool('gluon', 'wireless', 'outdoor')
for _, mesh_vif in ipairs(mesh_vifs_5ghz) do
mesh_vif:depends(outdoor, false)
end
function outdoor:write(data)
uci:set('gluon', 'wireless', 'outdoor', data)
end