diff --git a/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua b/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua index df92c965..31aeb902 100644 --- a/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua +++ b/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua @@ -9,13 +9,12 @@ http://www.apache.org/licenses/LICENSE-2.0 ]]-- local uci = require("simple-uci").cursor() -local sysconfig = require 'gluon.sysconfig' -local util = require 'gluon.util' local wan = uci:get_all("network", "wan") local wan6 = uci:get_all("network", "wan6") local dns_static = uci:get_first("gluon-wan-dnsmasq", "static") + local f = Form(translate("WAN connection")) local s = f:section(Section) @@ -76,36 +75,22 @@ end s = f:section(Section) -local wired_mesh_help = { - single = translate('Enable meshing on the Ethernet interface'), - wan = translate('Enable meshing on the WAN interface'), - lan = translate('Enable meshing on the LAN interface'), -} +uci:foreach('gluon', 'interface', function(config) + local section_name = config['.name'] + local ifaces = s:option(MultiListValue, section_name, config.name) -local function wired_mesh(iface) - if not sysconfig[iface .. '_ifname'] then return end - local iface_roles = uci:get_list('gluon', 'iface_' .. iface, 'role') + ifaces.orientation = 'horizontal' + ifaces:value('uplink', 'Uplink') -- TODO: Uplink and Client should be mutually exclusive. + ifaces:value('mesh', 'Mesh') + ifaces:value('client', 'Client') - local option = s:option(Flag, 'mesh_' .. iface, wired_mesh_help[iface]) - option.default = util.contains(iface_roles, 'mesh') ~= false + ifaces.default = config.role - function option:write(data) - local roles = uci:get_list('gluon', 'iface_' .. iface, 'role') - if data then - util.add_to_set(roles, 'mesh') - else - util.remove_from_set(roles, 'mesh') - end - uci:set_list('gluon', 'iface_' .. iface, 'role', roles) - - -- Reconfigure on next reboot - uci:set('gluon', 'core', 'reconfigure', true) + function ifaces:write(data) + uci:set_list("gluon", section_name, "role", data) end -end +end) -wired_mesh('single') -wired_mesh('wan') -wired_mesh('lan') local section uci:foreach("system", "gpio_switch", function(si) @@ -166,4 +151,5 @@ function f:write() uci:commit('system') end + return f