]> git.proxmox.com Git - proxmox-widget-toolkit.git/blob - data/RRDStore.js
eslint fixes all over the place
[proxmox-widget-toolkit.git] / data / RRDStore.js
1 /* Extends the Proxmox.data.UpdateStore type
2 *
3 *
4 */
5 Ext.define('Proxmox.data.RRDStore', {
6 extend: 'Proxmox.data.UpdateStore',
7 alias: 'store.proxmoxRRDStore',
8
9 setRRDUrl: function(timeframe, cf) {
10 var me = this;
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: {
23 type: 'proxmox',
24 },
25
26 timeframe: 'hour',
27
28 cf: 'AVERAGE',
29
30 constructor: function(config) {
31 var me = this;
32
33 config = config || {};
34
35 // set default interval to 30seconds
36 if (!config.interval) {
37 config.interval = 30000;
38 }
39
40 // set a new storeid
41 if (!config.storeid) {
42 config.storeid = 'rrdstore-' + ++Ext.idSeed;
43 }
44
45 // rrdurl is required
46 if (!config.rrdurl) {
47 throw "no rrdurl specified";
48 }
49
50 var stateid = 'proxmoxRRDTypeSelection';
51 var sp = Ext.state.Manager.getProvider();
52 var stateinit = sp.get(stateid);
53
54 if (stateinit) {
55 if (stateinit.timeframe !== me.timeframe || stateinit.cf !== me.rrdcffn) {
56 me.timeframe = stateinit.timeframe;
57 me.rrdcffn = stateinit.cf;
58 }
59 }
60
61 me.callParent([config]);
62
63 me.setRRDUrl();
64 me.mon(sp, 'statechange', function(prov, key, state) {
65 if (key === stateid) {
66 if (state && state.id) {
67 if (state.timeframe !== me.timeframe || state.cf !== me.cf) {
68 me.timeframe = state.timeframe;
69 me.cf = state.cf;
70 me.setRRDUrl();
71 me.reload();
72 }
73 }
74 }
75 });
76 },
77 });