mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-31 06:40:42 +03:00
luci: Fix error on call L.hasSystemFeature('apk')
This commit is contained in:
@@ -31,24 +31,39 @@ return baseclass.extend({
|
|||||||
autoHostListFN : '/opt/zapret2/ipset/zapret-hosts-auto.txt',
|
autoHostListFN : '/opt/zapret2/ipset/zapret-hosts-auto.txt',
|
||||||
autoHostListDbgFN : '/opt/zapret2/ipset/zapret-hosts-auto-debug.log',
|
autoHostListDbgFN : '/opt/zapret2/ipset/zapret-hosts-auto-debug.log',
|
||||||
|
|
||||||
load_env: function(dst_obj) {
|
load_env: function(ctx)
|
||||||
|
{
|
||||||
let env_proto = Object.getPrototypeOf(this);
|
let env_proto = Object.getPrototypeOf(this);
|
||||||
Object.getOwnPropertyNames(env_proto).forEach(function(key) {
|
Object.getOwnPropertyNames(env_proto).forEach(function(key) {
|
||||||
if (key === 'constructor' || key === 'load_env' || key.startsWith('__'))
|
if (key === 'constructor' || key.startsWith('__')) {
|
||||||
return;
|
return;
|
||||||
dst_obj[key] = env_proto[key];
|
}
|
||||||
|
if (key === 'load_env' || key === 'load_feat_env') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx[key] = env_proto[key];
|
||||||
});
|
});
|
||||||
dst_obj.packager = { };
|
ctx.skey_pkg_dict = this.appName + '-pkg-dict';
|
||||||
if (L.hasSystemFeature('apk')) {
|
ctx.skey_deffered_action = this.appName + '-deffered-action';
|
||||||
dst_obj.packager.name = 'apk';
|
try {
|
||||||
dst_obj.packager.path = '/usr/bin/apk';
|
L.hasSystemFeature('opkg');
|
||||||
dst_obj.packager.args = [ 'list', '-I', '*'+this.appName+'*' ];
|
this.load_feat_env(ctx);
|
||||||
} else {
|
} catch(e) {
|
||||||
dst_obj.packager.name = 'opkg';
|
// nothing
|
||||||
dst_obj.packager.path = '/bin/opkg';
|
|
||||||
dst_obj.packager.args = [ 'list-installed', '*'+this.appName+'*' ];
|
|
||||||
}
|
}
|
||||||
dst_obj.skey_pkg_dict = this.appName + '-pkg-dict';
|
},
|
||||||
dst_obj.skey_deffered_action = this.appName + '-deffered-action';
|
|
||||||
}
|
load_feat_env: function(ctx)
|
||||||
|
{
|
||||||
|
ctx.packager = { };
|
||||||
|
if (L.hasSystemFeature('apk')) {
|
||||||
|
ctx.packager.name = 'apk';
|
||||||
|
ctx.packager.path = '/usr/bin/apk';
|
||||||
|
ctx.packager.args = [ 'list', '-I', '*'+this.appName+'*' ];
|
||||||
|
} else {
|
||||||
|
ctx.packager.name = 'opkg';
|
||||||
|
ctx.packager.path = '/bin/opkg';
|
||||||
|
ctx.packager.args = [ 'list-installed', '*'+this.appName+'*' ];
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ return view.extend({
|
|||||||
btn.update.disabled = (error_code == 0) ? flag : false;
|
btn.update.disabled = (error_code == 0) ? flag : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAppStatus: function() {
|
getAppStatus: function()
|
||||||
|
{
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
tools.getInitState(tools.appName), // svc_boot
|
tools.getInitState(tools.appName), // svc_boot
|
||||||
fs.exec(tools.execPath, [ 'enabled' ]), // svc_en
|
fs.exec(tools.execPath, [ 'enabled' ]), // svc_en
|
||||||
@@ -294,9 +295,9 @@ return view.extend({
|
|||||||
|
|
||||||
load: function()
|
load: function()
|
||||||
{
|
{
|
||||||
return Promise.all([
|
return tools.baseLoad(this, (data) => {
|
||||||
L.resolveDefault(fs.stat('/bin/cat'), null),
|
//console.log('SYS FEATURES: '+JSON.stringify(data.sys_feat));
|
||||||
]).then( (data) => {
|
tools.load_feat_env();
|
||||||
return this.getAppStatus();
|
return this.getAppStatus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,11 +15,17 @@ document.head.appendChild(E('link', {
|
|||||||
return view.extend({
|
return view.extend({
|
||||||
svc_info: null,
|
svc_info: null,
|
||||||
|
|
||||||
load: function() {
|
load: function()
|
||||||
return tools.baseLoad();
|
{
|
||||||
|
return tools.baseLoad(this, (data) => {
|
||||||
|
//console.log('SYS FEATURES: '+JSON.stringify(data.sys_feat));
|
||||||
|
tools.load_feat_env();
|
||||||
|
return data;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(data) {
|
render: function(data)
|
||||||
|
{
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ return baseclass.extend({
|
|||||||
//console.log('PACKAGER: ' + this.packager.name);
|
//console.log('PACKAGER: ' + this.packager.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
load_feat_env: function()
|
||||||
|
{
|
||||||
|
env_tools.load_feat_env(this);
|
||||||
|
},
|
||||||
|
|
||||||
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
|
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
|
||||||
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
|
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
|
||||||
infoLabelStopped : '<span class="label-status stopped">' + _('Stopped') + '</span>',
|
infoLabelStopped : '<span class="label-status stopped">' + _('Stopped') + '</span>',
|
||||||
@@ -189,19 +194,20 @@ return baseclass.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
baseLoad: function(callback, cbarg)
|
baseLoad: function(ctx, callback)
|
||||||
{
|
{
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
L.probeSystemFeatures(),
|
||||||
this.getSvcInfo(), // svc_info
|
this.getSvcInfo(), // svc_info
|
||||||
uci.load(this.appName),
|
uci.load(this.appName),
|
||||||
])
|
])
|
||||||
.then( ([svcInfo, uci_data]) => {
|
.then( ([ sys_feat, svcInfo, uci_data ]) => {
|
||||||
let svc_info = this.decodeSvcInfo(svcInfo);
|
let svc_info = this.decodeSvcInfo(svcInfo);
|
||||||
let ret = { svc_info, uci_data };
|
let ret = { sys_feat, svc_info, uci_data };
|
||||||
if (typeof callback === 'function') {
|
if (typeof(callback) === 'function') {
|
||||||
const res = callback(cbarg, ret);
|
const res = callback.call(ctx, ret);
|
||||||
if (res && typeof res.then === 'function') {
|
if (res && typeof(res.then) === 'function') {
|
||||||
return res.then(() => ret);
|
return res.then(() => res);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user