]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - src/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
;
37 let load_task
= new Ext
.util
.DelayedTask();
39 let run_load_task = function() {
40 if (me
.getIsStopped()) {
44 if (Proxmox
.Utils
.authOK()) {
45 let start
= new Date();
47 let runtime
= new Date() - start
;
48 let interval
= me
.getInterval() + runtime
*2;
49 load_task
.delay(interval
, run_load_task
);
52 load_task
.delay(200, run_load_task
);
57 startUpdate: function() {
58 me
.setIsStopped(false);
59 // run_load_task(); this makes problems with chrome
60 load_task
.delay(1, run_load_task
);
62 stopUpdate: function() {
63 me
.setIsStopped(true);
68 me
.callParent([config
]);
70 me
.load_task
= load_task
;
72 if (me
.getAutoStart()) {