luci-mod-admin-full: fix wifi add and scan actions
authorJo-Philipp Wich <jo@mein.io>
Sun, 15 Jul 2018 11:14:24 +0000 (13:14 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sun, 15 Jul 2018 11:14:24 +0000 (13:14 +0200)
Due to conversion to CBI, the inline forms are now nested and thus do not
work anymore.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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 dda31fb1ed9732afc1c9562751a6a0725497556e..dcd03cb0fe30bb4b9495eaf8522fd61b166d6039 100644 (file)
@@ -78,18 +78,9 @@ local tpl_radio = tpl.Template(nil, [[
                                </div>
                                <div class="td middle cbi-section-actions">
                                        <div>
-                                               <input type="button" class="cbi-button cbi-button-neutral" title="<%:Restart radio interface%>" value="<%:Restart%>" onclick="wifi_restart(event)" data-radio="<%=dev:name()%>" />
-
-                                               <form action="<%=url('admin/network/wireless_join')%>" method="post" class="inline">
-                                                       <input type="hidden" name="device" value="<%=dev:name()%>" />
-                                                       <input type="hidden" name="token" value="<%=token%>" />
-                                                       <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" />
-                                               </form>
-                                               <form action="<%=url('admin/network/wireless_add')%>" method="post" class="inline">
-                                                       <input type="hidden" name="device" value="<%=dev:name()%>" />
-                                                       <input type="hidden" name="token" value="<%=token%>" />
-                                                       <input type="submit" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" />
-                                               </form>
+                                               <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')" />
                                        </div>
                                </div>
                        </div>
index 9730bc2c92ba8481341cb3203947afae6a61ecab..cc6db1721fa9e485c9f6bc6bfdac05e7aa5d24c8 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) {