mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-08 04:26:52 +03:00
luci: Fix detect daemons status (empty instances dict)
This commit is contained in:
@@ -94,7 +94,7 @@ return view.extend({
|
|||||||
} else {
|
} else {
|
||||||
btn.enable.disabled = (svc_autorun) ? true : false;
|
btn.enable.disabled = (svc_autorun) ? true : false;
|
||||||
btn.disable.disabled = (svc_autorun) ? false : true;
|
btn.disable.disabled = (svc_autorun) ? false : true;
|
||||||
if (svcinfo.dmn.total == 0) {
|
if (!svcinfo.dmn.inited) {
|
||||||
btn.start.disabled = false;
|
btn.start.disabled = false;
|
||||||
btn.restart.disabled = true;
|
btn.restart.disabled = true;
|
||||||
btn.stop.disabled = true;
|
btn.stop.disabled = true;
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ return baseclass.extend({
|
|||||||
let result = {
|
let result = {
|
||||||
"autorun": svc_autorun,
|
"autorun": svc_autorun,
|
||||||
"dmn": {
|
"dmn": {
|
||||||
|
inited: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
running: 0,
|
running: 0,
|
||||||
working: 0,
|
working: 0,
|
||||||
@@ -162,10 +163,9 @@ return baseclass.extend({
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (typeof(jdata.zapret) == 'object') {
|
if (typeof(jdata.zapret) == 'object') {
|
||||||
|
result.dmn.inited = true;
|
||||||
let dmn_list = jdata.zapret.instances;
|
let dmn_list = jdata.zapret.instances;
|
||||||
if (typeof(dmn_list) !== 'object') {
|
if (typeof(dmn_list) == 'object') {
|
||||||
return -4;
|
|
||||||
}
|
|
||||||
for (const [dmn_name, daemon] of Object.entries(dmn_list)) {
|
for (const [dmn_name, daemon] of Object.entries(dmn_list)) {
|
||||||
result.dmn.total += 1;
|
result.dmn.total += 1;
|
||||||
if (daemon.running) {
|
if (daemon.running) {
|
||||||
@@ -178,11 +178,12 @@ return baseclass.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//console.log('SVC_DAEMONS: ' + result.dmn.working + ' / ' + result.dmn.total);
|
//console.log('SVC_DAEMONS: ' + result.dmn.working + ' / ' + result.dmn.total);
|
||||||
if (result.dmn.total == 0) {
|
if (result.dmn.total == 0) {
|
||||||
result.status = (!svc_autorun) ? this.statusDict.disabled : this.statusDict.stopped;
|
result.status = (!svc_autorun) ? this.statusDict.disabled : this.statusDict.stopped;
|
||||||
} else {
|
} else {
|
||||||
result.status = (!result.dmn.working) ? this.statusDict.started : this.statusDict.running;
|
result.status = (result.dmn.inited) ? this.statusDict.started : this.statusDict.running;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@@ -193,7 +194,7 @@ return baseclass.extend({
|
|||||||
|
|
||||||
if (typeof(svcinfo) == 'object') {
|
if (typeof(svcinfo) == 'object') {
|
||||||
svc_autorun = (svcinfo.autorun) ? _('Enabled') : _('Disabled');
|
svc_autorun = (svcinfo.autorun) ? _('Enabled') : _('Disabled');
|
||||||
if (svcinfo.dmn.total == 0) {
|
if (!svcinfo.dmn.inited) {
|
||||||
svc_daemons = _('Stopped');
|
svc_daemons = _('Stopped');
|
||||||
} else {
|
} else {
|
||||||
svc_daemons = (!svcinfo.dmn.working) ? _('Starting') : _('Running');
|
svc_daemons = (!svcinfo.dmn.working) ? _('Starting') : _('Running');
|
||||||
|
|||||||
Reference in New Issue
Block a user