]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - data/RRDStore.js
use eslint and execute as check target
[proxmox-widget-toolkit.git] / 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
40 // set a new storeid
41 if (!config.storeid) {
01031528 42 config.storeid = 'rrdstore-' + ++Ext.idSeed;
1748088d
DM
43 }
44
45 // rrdurl is required
46 if (!config.rrdurl) {
47 throw "no rrdurl specified";
48 }
49
05a977a2
TL
50 let stateid = 'proxmoxRRDTypeSelection';
51 let sp = Ext.state.Manager.getProvider();
52 let stateinit = sp.get(stateid);
1748088d
DM
53
54 if (stateinit) {
01031528 55 if (stateinit.timeframe !== me.timeframe || stateinit.cf !== me.rrdcffn) {
1748088d
DM
56 me.timeframe = stateinit.timeframe;
57 me.rrdcffn = stateinit.cf;
58 }
59 }
60
61 me.callParent([config]);
62
63 me.setRRDUrl();
01031528 64 me.mon(sp, 'statechange', function(prov, key, state) {
1748088d
DM
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 });
01031528 76 },
1748088d 77});