]> git.proxmox.com Git - pmg-gui.git/blame - js/StatStore.js
add virusfilter
[pmg-gui.git] / js / StatStore.js
CommitLineData
42a0470d
DM
1Ext.define('PMG.data.StatStore', {
2 extend: 'Ext.data.Store',
3 alias: 'store.pmgStatStore',
4
5 autoDestroy: true,
6
7 staturl: undefined,
3b560b74
DM
8
9 includeTimeSpan: false,
44230744
DM
10
11 setUrl: function(url) {
12 var me = this;
13
89399b2f
DM
14 me.proxy.abort(); // abort pending requests
15
44230744
DM
16 me.staturl = url;
17 me.proxy.extraParams = {};
89399b2f 18 me.setData([]);
44230744
DM
19 },
20
42a0470d
DM
21 reload: function() {
22 var me = this;
23
d6d1af0e 24 me.proxy.abort(); // abort pending requests
44230744
DM
25
26 if (me.staturl === undefined) {
27 me.proxy.extraParams = {};
28 me.setData([]);
29 return;
30 }
31
42a0470d
DM
32 var ts = PMG.StatTimeSelector.getTimeSpan();
33
34 var last = me.proxy.extraParams;
44230744 35
42a0470d
DM
36 if (last.starttime === ts.starttime && last.endtime === ts.endtime)
37 return; // avoid repeated loads
38
39 me.proxy.url = me.staturl;
40 me.proxy.extraParams = { starttime: ts.starttime, endtime: ts.endtime };
41
3b560b74
DM
42 var timespan = 3600;
43 if (me.includeTimeSpan) {
44 var period = ts.endtime - ts.starttime;
45 if (period <= 86400*7) {
46 timespan = 3600;
47 } else {
48 timespan = 3600*24;
49 }
50 me.proxy.extraParams.timespan = timespan;
51 }
44230744 52
42a0470d
DM
53 me.load();
54 },
55
56 proxy: {
57 type: 'proxmox'
58 },
59
c1a5d150
DM
60 autoReload: true,
61
42a0470d
DM
62 constructor: function(config) {
63 var me = this;
64
65 config = config || {};
66
c1a5d150
DM
67 me.mon(Ext.GlobalEvents, 'pmgStatTimeSelectorUpdate', function() {
68 if (me.autoReload) {
69 me.reload();
70 }
71 }, me);
44230744 72
42a0470d
DM
73 me.callParent([config]);
74
75 me.reload();
76 }
77});