]> git.proxmox.com Git - pmg-gui.git/blame - js/StatStore.js
add icons for white/blacklist in QuarantineView
[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
c17f9fe4 36 if (last.starttime === ts.starttime && last.endtime === ts.endtime) {
42a0470d 37 return; // avoid repeated loads
c17f9fe4 38 }
42a0470d
DM
39
40 me.proxy.url = me.staturl;
41 me.proxy.extraParams = { starttime: ts.starttime, endtime: ts.endtime };
42
3b560b74
DM
43 var timespan = 3600;
44 if (me.includeTimeSpan) {
45 var period = ts.endtime - ts.starttime;
46 if (period <= 86400*7) {
47 timespan = 3600;
48 } else {
49 timespan = 3600*24;
50 }
51 me.proxy.extraParams.timespan = timespan;
52 }
44230744 53
42a0470d
DM
54 me.load();
55 },
56
57 proxy: {
58 type: 'proxmox'
59 },
60
c1a5d150
DM
61 autoReload: true,
62
42a0470d
DM
63 constructor: function(config) {
64 var me = this;
65
66 config = config || {};
67
c1a5d150
DM
68 me.mon(Ext.GlobalEvents, 'pmgStatTimeSelectorUpdate', function() {
69 if (me.autoReload) {
70 me.reload();
71 }
72 }, me);
44230744 73
42a0470d
DM
74 me.callParent([config]);
75
76 me.reload();
77 }
78});