From b4861da8860576f2ceda20384b896288b989b52a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 1 Nov 2019 12:32:17 +0100 Subject: [PATCH] luci-mod-network: fix disabled state in wifi settings modal Also auto-enable the radio upon network join. Signed-off-by: Jo-Philipp Wich --- .../resources/view/network/wireless.js | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js index 847a712c3..1909f3c24 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js @@ -743,7 +743,8 @@ return L.view.extend({ ss.tab('general', _('General Setup')); ss.tab('advanced', _('Advanced Settings')); - var isDisabled = (radioNet.get('disabled') == '1'); + var isDisabled = (radioNet.get('disabled') == '1' || + uci.get('wireless', radioNet.getWifiDeviceName(), 'disabled') == 1); o = ss.taboption('general', form.DummyValue, '_wifistat_modal', _('Status')); o.cfgvalue = L.bind(function(radioNet) { @@ -1734,15 +1735,23 @@ return L.view.extend({ var section_id = null; return this.map.save(function() { + var wifi_sections = uci.sections('wireless', 'wifi-iface'); + if (replopt.formvalue('_new_') == '1') { - var sections = uci.sections('wireless', 'wifi-iface'); + for (var i = 0; i < wifi_sections.length; i++) + if (wifi_sections[i].device == radioDev.getName()) + uci.remove('wireless', wifi_sections[i]['.name']); + } + + if (uci.get('wireless', radioDev.getName(), 'disabled') == '1') { + for (var i = 0; i < wifi_sections.length; i++) + if (wifi_sections[i].device == radioDev.getName()) + uci.set('wireless', wifi_sections[i]['.name'], 'disabled', '1'); - for (var i = 0; i < sections.length; i++) - if (sections[i].device == radioDev.getName()) - uci.remove('wireless', sections[i]['.name']); + uci.unset('wireless', radioDev.getName(), 'disabled'); } - section_id = next_free_sid(uci.sections('wifi-iface').length); + section_id = next_free_sid(wifi_sections.length); uci.add('wireless', 'wifi-iface', section_id); uci.set('wireless', section_id, 'device', radioDev.getName()); -- 2.25.1