mirror of
https://github.com/openwrt/luci.git
synced 2025-12-26 11:16:38 +04:00
luci-mod-status: reorganize include load function for status page
Reorganize include load function for status page an move it inside view extend index page. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
committed by
Paul Donald
parent
b92c7f696e
commit
874752bcc4
@@ -5,30 +5,30 @@
|
||||
'require fs';
|
||||
'require network';
|
||||
|
||||
function invokeIncludesLoad(includes) {
|
||||
var tasks = [], has_load = false;
|
||||
|
||||
for (var i = 0; i < includes.length; i++) {
|
||||
if (typeof(includes[i].load) == 'function') {
|
||||
tasks.push(includes[i].load().catch(L.bind(function() {
|
||||
this.failed = true;
|
||||
}, includes[i])));
|
||||
|
||||
has_load = true;
|
||||
}
|
||||
else {
|
||||
tasks.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
return has_load ? Promise.all(tasks) : Promise.resolve(null);
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
invokeIncludesLoad: function(includes) {
|
||||
var tasks = [], has_load = false;
|
||||
|
||||
for (var i = 0; i < includes.length; i++) {
|
||||
if (typeof(includes[i].load) == 'function') {
|
||||
tasks.push(includes[i].load().catch(L.bind(function() {
|
||||
this.failed = true;
|
||||
}, includes[i])));
|
||||
|
||||
has_load = true;
|
||||
}
|
||||
else {
|
||||
tasks.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
return has_load ? Promise.all(tasks) : Promise.resolve(null);
|
||||
},
|
||||
|
||||
poll_status: function(includes, containers) {
|
||||
return network.flushCache().then(function() {
|
||||
return invokeIncludesLoad(includes);
|
||||
}).then(function(results) {
|
||||
return network.flushCache().then(L.bind(
|
||||
this.invokeIncludesLoad, this, includes
|
||||
)).then(function(results) {
|
||||
for (var i = 0; i < includes.length; i++) {
|
||||
var content = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user