]> git.proxmox.com Git - pmg-gui.git/blame - js/StatStore.js
add store to read statistics using timeframe from StatTimeSelector
[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,
8
9 reload: function() {
10 var me = this;
11
12 var ts = PMG.StatTimeSelector.getTimeSpan();
13
14 var last = me.proxy.extraParams;
15
16 if (last.starttime === ts.starttime && last.endtime === ts.endtime)
17 return; // avoid repeated loads
18
19 me.proxy.url = me.staturl;
20 me.proxy.extraParams = { starttime: ts.starttime, endtime: ts.endtime };
21
22 console.log("LOAD" + me.proxy.url);
23
24 me.load();
25 },
26
27 proxy: {
28 type: 'proxmox'
29 },
30
31 constructor: function(config) {
32 var me = this;
33
34 config = config || {};
35
36 // staturl is required
37 if (!config.staturl) {
38 throw "no staturl specified";
39 }
40
41 me.mon(Ext.GlobalEvents, 'pmgStatTimeSelectorUpdate', me.reload, me);
42
43 me.callParent([config]);
44
45 me.reload();
46 }
47});