]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - data/UpdateStore.js
2 * Extends the Ext.data.Store type with startUpdate() and stopUpdate() methods
3 * to refresh the store data in the background.
4 * Components using this store directly will flicker due to the redisplay of
5 * the element ater 'config.interval' ms.
7 * Note that you have to set 'autoStart' or call startUpdate() once yourself
8 * for the background load to begin.
10 Ext
.define('Proxmox.data.UpdateStore', {
11 extend
: 'Ext.data.Store',
12 alias
: 'store.update',
28 constructor: function(config
) {
31 config
= config
|| {};
32 if (config
.interval
=== undefined) {
33 delete config
.interval
;
36 if (!config
.storeid
) {
37 throw "no storeid specified";
40 let load_task
= new Ext
.util
.DelayedTask();
42 let run_load_task = function() {
43 if (me
.getIsStopped()) {
47 if (Proxmox
.Utils
.authOK()) {
48 let start
= new Date();
50 let runtime
= (new Date()) - start
;
51 let interval
= me
.getInterval() + runtime
*2;
52 load_task
.delay(interval
, run_load_task
);
55 load_task
.delay(200, run_load_task
);
60 startUpdate: function() {
61 me
.setIsStopped(false);
62 // run_load_task(); this makes problems with chrome
63 load_task
.delay(1, run_load_task
);
65 stopUpdate: function() {
66 me
.setIsStopped(true);
71 me
.callParent([config
]);
73 me
.load_task
= load_task
;
75 if (me
.getAutoStart()) {