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