]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - src/data/RRDStore.js
data/*Store: drop storeid requirement
[proxmox-widget-toolkit.git] / src / data / RRDStore.js
CommitLineData
1748088d
DM
1/* Extends the Proxmox.data.UpdateStore type
2 *
3 *
4 */
5Ext.define('Proxmox.data.RRDStore', {
6 extend: 'Proxmox.data.UpdateStore',
7 alias: 'store.proxmoxRRDStore',
8
9 setRRDUrl: function(timeframe, cf) {
05a977a2 10 let me = this;
1748088d
DM
11 if (!timeframe) {
12 timeframe = me.timeframe;
13 }
14
15 if (!cf) {
16 cf = me.cf;
17 }
18
19 me.proxy.url = me.rrdurl + "?timeframe=" + timeframe + "&cf=" + cf;
20 },
21
22 proxy: {
01031528 23 type: 'proxmox',
1748088d
DM
24 },
25
26 timeframe: 'hour',
27
28 cf: 'AVERAGE',
29
30 constructor: function(config) {
05a977a2 31 let me = this;
1748088d
DM
32
33 config = config || {};
34
35 // set default interval to 30seconds
36 if (!config.interval) {
37 config.interval = 30000;
38 }
39
1748088d
DM
40 // rrdurl is required
41 if (!config.rrdurl) {
42 throw "no rrdurl specified";
43 }
44
05a977a2
TL
45 let stateid = 'proxmoxRRDTypeSelection';
46 let sp = Ext.state.Manager.getProvider();
47 let stateinit = sp.get(stateid);
1748088d
DM
48
49 if (stateinit) {
01031528 50 if (stateinit.timeframe !== me.timeframe || stateinit.cf !== me.rrdcffn) {
1748088d
DM
51 me.timeframe = stateinit.timeframe;
52 me.rrdcffn = stateinit.cf;
53 }
54 }
55
56 me.callParent([config]);
57
58 me.setRRDUrl();
01031528 59 me.mon(sp, 'statechange', function(prov, key, state) {
1748088d
DM
60 if (key === stateid) {
61 if (state && state.id) {
62 if (state.timeframe !== me.timeframe || state.cf !== me.cf) {
63 me.timeframe = state.timeframe;
64 me.cf = state.cf;
65 me.setRRDUrl();
66 me.reload();
67 }
68 }
69 }
70 });
01031528 71 },
1748088d 72});