luci-mod-admin-full: properly reset internal device form field
authorJo-Philipp Wich <jo@mein.io>
Wed, 18 Jul 2018 08:02:07 +0000 (10:02 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 20 Jul 2018 05:56:46 +0000 (07:56 +0200)
In some cases the hidden internal device field was not reset, e.g. after
aborting a wifi scan and using the browser back buttons to navigate to the
overview page again.

In such a case, the previous device hidden field was still present and a new
one getting created, causing further wireless scan attempts to get invoked
with multiple radio names as parameter which fails.

Fix this issue by using the new generic cbi_submit() helper any by dropping
the faulty wifi_action() function.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 90f9c59a2d392837bbef39b5acf402531ab2d9be)

modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua
modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm

index dcd03cb0fe30bb4b9495eaf8522fd61b166d6039..32bf1965f3bc355cace89fb3eaf0fe8526a38244 100644 (file)
@@ -79,8 +79,8 @@ local tpl_radio = tpl.Template(nil, [[
                                <div class="td middle cbi-section-actions">
                                        <div>
                                                <input type="button" class="cbi-button cbi-button-neutral" title="<%:Restart radio interface%>" value="<%:Restart%>" data-radio="<%=dev:name()%>" onclick="wifi_restart(event)" />
-                                               <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" data-radio="<%=dev:name()%>" onclick="wifi_action(event, 'join')" />
-                                               <input type="submit" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" data-radio="<%=dev:name()%>" onclick="wifi_action(event, 'add')" />
+                                               <input type="button" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_join')%>')" />
+                                               <input type="button" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_add')%>')" />
                                        </div>
                                </div>
                        </div>
index cc6db1721fa9e485c9f6bc6bfdac05e7aa5d24c8..9730bc2c92ba8481341cb3203947afae6a61ecab 100644 (file)
                        { token: '<%=token%>' }, XHR.run);
        }
 
-       function wifi_action(ev, action) {
-               var i = ev.target,
-                   e = i.getAttribute('data-radio');
-
-               i.parentNode.appendChild(E('input', { type: 'hidden', name: 'device', value: e }));
-               i.form.action = '<%=url('admin/network/wireless_')%>' + action;
-       }
-
        var networks = [ ];
 
        document.querySelectorAll('[data-network]').forEach(function(n) {