]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - data/UpdateStore.js
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',
15 constructor: function(config
) {
18 config
= config
|| {};
20 if (!config
.interval
) {
21 config
.interval
= 3000;
24 if (!config
.storeid
) {
25 throw "no storeid specified";
28 var load_task
= new Ext
.util
.DelayedTask();
30 var run_load_task = function() {
35 if (Proxmox
.Utils
.authOK()) {
36 Proxmox
.data
.UpdateQueue
.queue(me
, function(runtime
, success
) {
37 var interval
= config
.interval
+ runtime
*2;
38 load_task
.delay(interval
, run_load_task
);
41 load_task
.delay(200, run_load_task
);
46 startUpdate: function() {
50 stopUpdate: function() {
53 Proxmox
.data
.UpdateQueue
.unqueue(me
);
57 me
.callParent([config
]);
59 me
.on('destroy', function() {
61 Proxmox
.data
.UpdateQueue
.unqueue(me
);