mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-06 01:13:19 +00:00
UpdateQueue: add callback
So that we can queue new things after loading is done.
This commit is contained in:
parent
4920fa3a87
commit
7fc1bf3017
@ -15,30 +15,40 @@ Ext.define('PVE.data.UpdateQueue', {
|
||||
return;
|
||||
}
|
||||
|
||||
var store = queue.shift();
|
||||
if (!store) {
|
||||
var storeid = queue.shift();
|
||||
if (!storeid) {
|
||||
return;
|
||||
}
|
||||
var info = queue_idx[storeid];
|
||||
queue_idx[storeid] = null;
|
||||
|
||||
queue_idx[store.storeid] = null;
|
||||
info.updatestart = new Date();
|
||||
|
||||
idle = false;
|
||||
store.load({
|
||||
info.store.load({
|
||||
callback: function(records, operation, success) {
|
||||
idle = true;
|
||||
if (info.callback) {
|
||||
var runtime = (new Date()).getTime() - info.updatestart.getTime();
|
||||
info.callback(runtime, success);
|
||||
}
|
||||
start_update();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Ext.apply(me, {
|
||||
queue: function(store) {
|
||||
if (!store.storeid) {
|
||||
queue: function(store, cb) {
|
||||
var storeid = store.storeid;
|
||||
if (!storeid) {
|
||||
throw "unable to queue store without storeid";
|
||||
}
|
||||
if (!queue_idx[store.storeid]) {
|
||||
queue_idx[store.storeid] = store;
|
||||
queue.push(store);
|
||||
if (!queue_idx[storeid]) {
|
||||
queue_idx[storeid] = {
|
||||
store: store,
|
||||
callback: cb
|
||||
};
|
||||
queue.push(storeid);
|
||||
}
|
||||
start_update();
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ Ext.define('PVE.data.UpdateStore', {
|
||||
|
||||
var run_load_task = function() {
|
||||
if (PVE.Utils.authOK()) {
|
||||
PVE.data.UpdateQueue.queue(me);
|
||||
load_task.delay(config.interval, run_load_task);
|
||||
PVE.data.UpdateQueue.queue(me, function(runtime, success) {
|
||||
load_task.delay(config.interval, run_load_task);
|
||||
});
|
||||
} else {
|
||||
load_task.delay(200, run_load_task);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user