mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-08 05:07:34 +00:00
remove updatequeue
since all modern browsers can properly handle multiple xmlhttprequests, we do not need to serialize them ourselves, but leave it to the browser this fixes an issue wehre a canceled request of an updatestore blocks all other updatestores until refresh Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
03c29495f5
commit
ff5351f775
1
Makefile
1
Makefile
@ -16,7 +16,6 @@ JSSRC= \
|
|||||||
mixin/CBind.js \
|
mixin/CBind.js \
|
||||||
data/reader/JsonObject.js \
|
data/reader/JsonObject.js \
|
||||||
data/ProxmoxProxy.js \
|
data/ProxmoxProxy.js \
|
||||||
data/UpdateQueue.js \
|
|
||||||
data/UpdateStore.js \
|
data/UpdateStore.js \
|
||||||
data/DiffStore.js \
|
data/DiffStore.js \
|
||||||
data/ObjectStore.js \
|
data/ObjectStore.js \
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
// Serialize load (avoid too many parallel connections)
|
|
||||||
Ext.define('Proxmox.data.UpdateQueue', {
|
|
||||||
singleton: true,
|
|
||||||
|
|
||||||
constructor : function(){
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
var queue = [];
|
|
||||||
var queue_idx = {};
|
|
||||||
|
|
||||||
var idle = true;
|
|
||||||
|
|
||||||
var start_update = function() {
|
|
||||||
if (!idle) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var storeid = queue.shift();
|
|
||||||
if (!storeid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var info = queue_idx[storeid];
|
|
||||||
queue_idx[storeid] = null;
|
|
||||||
|
|
||||||
info.updatestart = new Date();
|
|
||||||
|
|
||||||
idle = false;
|
|
||||||
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, cb) {
|
|
||||||
var storeid = store.storeid;
|
|
||||||
if (!storeid) {
|
|
||||||
throw "unable to queue store without storeid";
|
|
||||||
}
|
|
||||||
if (!queue_idx[storeid]) {
|
|
||||||
queue_idx[storeid] = {
|
|
||||||
store: store,
|
|
||||||
callback: cb
|
|
||||||
};
|
|
||||||
queue.push(storeid);
|
|
||||||
}
|
|
||||||
start_update();
|
|
||||||
},
|
|
||||||
unqueue: function(store) {
|
|
||||||
var storeid = store.storeid;
|
|
||||||
if (!storeid) {
|
|
||||||
throw "unabel to unqueue store without storeid";
|
|
||||||
}
|
|
||||||
if (queue_idx[storeid]) {
|
|
||||||
Ext.Array.remove(queue,storeid);
|
|
||||||
queue_idx[storeid] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
@ -17,8 +17,7 @@ Ext.define('Proxmox.data.UpdateStore', {
|
|||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.load_task.cancel();
|
me.stopUpdate();
|
||||||
Proxmox.data.UpdateQueue.unqueue(me);
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -43,7 +42,9 @@ Ext.define('Proxmox.data.UpdateStore', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Proxmox.Utils.authOK()) {
|
if (Proxmox.Utils.authOK()) {
|
||||||
Proxmox.data.UpdateQueue.queue(me, function(runtime, success) {
|
var start = new Date();
|
||||||
|
me.load(function() {
|
||||||
|
var runtime = (new Date()) - start;
|
||||||
var interval = config.interval + runtime*2;
|
var interval = config.interval + runtime*2;
|
||||||
load_task.delay(interval, run_load_task);
|
load_task.delay(interval, run_load_task);
|
||||||
});
|
});
|
||||||
@ -61,7 +62,6 @@ Ext.define('Proxmox.data.UpdateStore', {
|
|||||||
stopUpdate: function() {
|
stopUpdate: function() {
|
||||||
me.isStopped = true;
|
me.isStopped = true;
|
||||||
load_task.cancel();
|
load_task.cancel();
|
||||||
Proxmox.data.UpdateQueue.unqueue(me);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user