luci-app-sqm: only reload view once sqm enable/start completed
authorJo-Philipp Wich <jo@mein.io>
Sun, 13 Jun 2021 06:57:27 +0000 (08:57 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 7 Jul 2021 15:20:09 +0000 (17:20 +0200)
Chain the exec calls to enable and start the SQM service and only reload
the view once these operations are complete and return the entire promise
chain from the handler function to ensure that the busy indicator remains
active throughout the entire duration of the operation.

Also replace exec_direct() with exec() as there is no need to bypass ubus
for the init script calls.

Fixes: e76d9cc767 ("luci-app-sqm: fix JS error if service is disabled")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 005c09a293d1d0f4a5a76e210e0fa23842f13cb3)

applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js

index d115ca973b61dacdcd15107af1fabc22cec39d02..28004215b829dbbf3a1f2adc22af31723046bbcb 100644 (file)
@@ -43,15 +43,17 @@ return view.extend({
                    scripts = data[1];
 
                if (qdiscs.length === 0) {
-                       ui.addNotification(null, 
+                       ui.addNotification(null,
                                E('div', { 'class': 'left' }, [
                                E('p', _("The SQM service seems to be disabled. Please use the button below to activate this service.")),
                                E('button', {
                                        'class': 'btn cbi-button-active',
                                        'click': ui.createHandlerFn(this, function() {
-                                               fs.exec_direct('/etc/init.d/sqm', ['enable']);
-                                               fs.exec_direct('/etc/init.d/sqm', ['start']);
-                                               location.reload();
+                                               return fs.exec('/etc/init.d/sqm', ['enable']).then(function() {
+                                                       return fs.exec('/etc/init.d/sqm', ['start']);
+                                               }).then(function() {
+                                                       location.reload();
+                                               });
                                        })
                                }, _('Enable SQM'))
                        ]));
@@ -223,4 +225,4 @@ return view.extend({
 
                return m.render();
        }
-})
\ No newline at end of file
+})