]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - data/UpdateStore.js
4368835637e6b5ba545930d237ab76e00de9d143
1 /* Extends the Ext.data.Store type
2 * with startUpdate() and stopUpdate() methods
3 * to refresh the store data in the background
4 * Components using this store directly will flicker
5 * due to the redisplay of the element ater 'config.interval' ms
7 * Note that you have to call yourself startUpdate() for the background load
10 Ext
.define('Proxmox.data.UpdateStore', {
11 extend
: 'Ext.data.Store',
12 alias
: 'store.update',
20 me
.load_task
.cancel();
21 Proxmox
.data
.UpdateQueue
.unqueue(me
);
25 constructor: function(config
) {
28 config
= config
|| {};
30 if (!config
.interval
) {
31 config
.interval
= 3000;
34 if (!config
.storeid
) {
35 throw "no storeid specified";
38 var load_task
= new Ext
.util
.DelayedTask();
40 var run_load_task = function() {
45 if (Proxmox
.Utils
.authOK()) {
46 Proxmox
.data
.UpdateQueue
.queue(me
, function(runtime
, success
) {
47 var interval
= config
.interval
+ runtime
*2;
48 load_task
.delay(interval
, run_load_task
);
51 load_task
.delay(200, run_load_task
);
56 startUpdate: function() {
60 stopUpdate: function() {
63 Proxmox
.data
.UpdateQueue
.unqueue(me
);
67 me
.callParent([config
]);
69 me
.load_task
= load_task
;