diff options
author | Dirk Brenken <dev@brenken.org> | 2021-06-13 07:45:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-13 07:45:43 +0200 |
commit | 3ad3affc1b41e9fbb79e9b743c8180a8c49d1c4d (patch) | |
tree | 445b13f053445324467681f2dc9d99b6041b0bc7 | |
parent | 4798354e01c8f2dab53e3dcec337e733df4d936c (diff) | |
parent | e76d9cc7673ffbebd8887bcfc14542c1269288e0 (diff) |
Merge pull request #5101 from dibdot/sqm-fix
luci-app-sqm: fix JS error if service is disabled
-rw-r--r-- | applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js | 22 | ||||
-rw-r--r-- | applications/luci-app-sqm/root/usr/share/rpcd/acl.d/luci-app-sqm.json | 4 |
2 files changed, 22 insertions, 4 deletions
diff --git a/applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js b/applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js index 337911ac5e..d115ca973b 100644 --- a/applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js +++ b/applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js @@ -1,5 +1,6 @@ 'use strict'; 'require fs'; +'require ui'; 'require rpc'; 'require uci'; 'require view'; @@ -23,8 +24,8 @@ return view.extend({ load: function() { return Promise.all([ - fs.list("/var/run/sqm/available_qdiscs"), - fs.list("/usr/lib/sqm").then(L.bind(function(scripts) { + L.resolveDefault(fs.list('/var/run/sqm/available_qdiscs'), []), + L.resolveDefault(fs.list('/usr/lib/sqm'), []).then(L.bind(function(scripts) { var tasks = [], scriptHelpTbl = {}; for (var i = 0; i < scripts.length; i++) @@ -41,6 +42,21 @@ return view.extend({ var qdiscs = data[0], scripts = data[1]; + if (qdiscs.length === 0) { + 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(); + }) + }, _('Enable SQM')) + ])); + } + var m, s, o; m = new form.Map('sqm', _('Smart Queue Management')); @@ -62,7 +78,7 @@ return view.extend({ o.write = L.bind(function(section, value) { if (value == "1") { this.handleEnableSQM(); - L.ui.addNotification(null, E('p', _("The SQM GUI has just enabled the sqm initscript on your behalf. Remember to disable the sqm initscript manually under System Startup menu in case this change was not wished for."))); + ui.addNotification(null, E('p', _("The SQM GUI has just enabled the sqm initscript on your behalf. Remember to disable the sqm initscript manually under System Startup menu in case this change was not wished for."))); } return uci.set("sqm", section, "enabled", value); diff --git a/applications/luci-app-sqm/root/usr/share/rpcd/acl.d/luci-app-sqm.json b/applications/luci-app-sqm/root/usr/share/rpcd/acl.d/luci-app-sqm.json index 2b56b1fc78..13c702449f 100644 --- a/applications/luci-app-sqm/root/usr/share/rpcd/acl.d/luci-app-sqm.json +++ b/applications/luci-app-sqm/root/usr/share/rpcd/acl.d/luci-app-sqm.json @@ -4,7 +4,9 @@ "read": { "file": { "/var/run/sqm/available_qdiscs": [ "list" ], - "/usr/lib/sqm/*.qos.help": [ "read" ] + "/usr/lib/sqm/*.qos.help": [ "read" ], + "/etc/init.d/sqm enable" : [ "exec" ], + "/etc/init.d/sqm start" : [ "exec" ] }, "uci": [ "sqm" ], "ubus": { |