]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
add RRDStore class
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 29 Aug 2017 05:03:32 +0000 (07:03 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 29 Aug 2017 05:27:40 +0000 (07:27 +0200)
Copied from pve-manager:

- removed field specification
- changed statid to proxmoxRRDTypeSelection

Makefile
data/RRDStore.js [new file with mode: 0644]

index 0b3ad30f8caeae241c85f24336075653bc83fad6..46aea79822a0045949edbe87824733d2b814e16a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ JSSRC=                                        \
        data/UpdateStore.js             \
        data/DiffStore.js               \
        data/ObjectStore.js             \
+       data/RRDStore.js                \
        data/TimezoneStore.js           \
        form/IntegerField.js            \
        form/TextField.js               \
diff --git a/data/RRDStore.js b/data/RRDStore.js
new file mode 100644 (file)
index 0000000..8c0a9ff
--- /dev/null
@@ -0,0 +1,77 @@
+/* Extends the Proxmox.data.UpdateStore type
+ *
+ *
+ */
+Ext.define('Proxmox.data.RRDStore', {
+    extend: 'Proxmox.data.UpdateStore',
+    alias: 'store.proxmoxRRDStore',
+
+    setRRDUrl: function(timeframe, cf) {
+       var me = this;
+       if (!timeframe) {
+           timeframe = me.timeframe;
+       }
+
+       if (!cf) {
+           cf = me.cf;
+       }
+
+       me.proxy.url = me.rrdurl + "?timeframe=" + timeframe + "&cf=" + cf;
+    },
+
+    proxy: {
+       type: 'proxmox'
+    },
+
+    timeframe: 'hour',
+
+    cf: 'AVERAGE',
+
+    constructor: function(config) {
+       var me = this;
+
+       config = config || {};
+
+       // set default interval to 30seconds
+       if (!config.interval) {
+           config.interval = 30000;
+       }
+
+       // set a new storeid
+       if (!config.storeid) {
+           config.storeid = 'rrdstore-' + (++Ext.idSeed);
+       }
+
+       // rrdurl is required
+       if (!config.rrdurl) {
+           throw "no rrdurl specified";
+       }
+
+       var stateid = 'proxmoxRRDTypeSelection';
+       var sp = Ext.state.Manager.getProvider();
+       var stateinit = sp.get(stateid);
+
+        if (stateinit) {
+           if(stateinit.timeframe !== me.timeframe || stateinit.cf !== me.rrdcffn){
+               me.timeframe = stateinit.timeframe;
+               me.rrdcffn = stateinit.cf;
+           }
+       }
+
+       me.callParent([config]);
+
+       me.setRRDUrl();
+       me.mon(sp, 'statechange', function(prov, key, state){
+           if (key === stateid) {
+               if (state && state.id) {
+                   if (state.timeframe !== me.timeframe || state.cf !== me.cf) {
+                       me.timeframe = state.timeframe;
+                       me.cf = state.cf;
+                       me.setRRDUrl();
+                       me.reload();
+                   }
+               }
+           }
+       });
+    }
+});