From ae47a5104d515bff83077f33e96fe6355504da1d Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sun, 1 Nov 2020 01:45:41 +0100 Subject: [PATCH 1/2] luci-mod-network: use createHanleFn for handleJoin function handleJoin can be slow to parse all the data and show the new modal, this can result in the disappear of the scan modal and the showing of the wifi config page while the data are generating. This is wrong since a user can think that he did something wrong. Fix this by using the createHandleFn and by removing the scan pool function instead of calling ScanAbort function that with the other thing wrongly removes the Scan modal. (the modal is replaced with the add one when all the data are ready) Signed-off-by: Ansuel Smith --- .../htdocs/luci-static/resources/view/network/wireless.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 dc75c9509f..26ddbaa19b 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 @@ -1742,7 +1742,7 @@ return view.extend({ E('span', { 'style': s }, '%h'.format(network.formatWifiEncryption(res.encryption))), E('div', { 'class': 'right' }, E('button', { 'class': 'cbi-button cbi-button-action important', - 'click': L.bind(this.handleJoin, this, radioDev, res) + 'click': ui.createHandlerFn(this, 'handleJoin', radioDev, res) }, _('Join Network'))) ]); @@ -1886,7 +1886,7 @@ return view.extend({ }; s.handleJoin = function(radioDev, bss, ev) { - this.handleScanAbort(ev); + poll.remove(this.pollFn); var m2 = new form.Map('wireless'), s2 = m2.section(form.NamedSection, '_new_'), From ba98a2fd0500a4f94680240255ae8c8034fea850 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sun, 1 Nov 2020 01:51:02 +0100 Subject: [PATCH 2/2] luci-mod-network: fix logic bug in parse enc for network join In handleJoinConfirm while is_wep is a boolean, is_psk and is_sae are an array. In the following if check, all 3 are used as boolean but Js treat empty array as positive values and this cause the ui to wrongly set the encryption to sae. fix this by checking if the array actually contains data. Fixes: #4524 Signed-off-by: Ansuel Smith --- .../htdocs/luci-static/resources/view/network/wireless.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 26ddbaa19b..d53f973588 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 @@ -1841,11 +1841,11 @@ return view.extend({ uci.set('wireless', section_id, 'bssid', bss.bssid); } - if (is_sae) { + if (is_sae.length > 0) { uci.set('wireless', section_id, 'encryption', 'sae'); uci.set('wireless', section_id, 'key', passval); } - else if (is_psk) { + else if (is_psk.length > 0) { for (var i = enc.wpa.length - 1; i >= 0; i--) { if (enc.wpa[i] == 2) { uci.set('wireless', section_id, 'encryption', 'psk2');