summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-sqm/htdocs
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2021-06-13 07:45:43 +0200
committerGitHub <noreply@github.com>2021-06-13 07:45:43 +0200
commit3ad3affc1b41e9fbb79e9b743c8180a8c49d1c4d (patch)
tree445b13f053445324467681f2dc9d99b6041b0bc7 /applications/luci-app-sqm/htdocs
parent4798354e01c8f2dab53e3dcec337e733df4d936c (diff)
parente76d9cc7673ffbebd8887bcfc14542c1269288e0 (diff)
Merge pull request #5101 from dibdot/sqm-fix
luci-app-sqm: fix JS error if service is disabled
Diffstat (limited to 'applications/luci-app-sqm/htdocs')
-rw-r--r--applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js22
1 files changed, 19 insertions, 3 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);