[pve-devel] [PATCH] rrd display : avoid 2 refresh

Alexandre Derumier aderumier at odiso.com
Tue Jun 11 11:12:58 CEST 2013


Currently when we open a new summary panel

- we display the rrd with default hour timeframe
- then we refresh it
- then we update from timeframe selector

With this patch:
- We display the rrd with timeframe from selector, or if not defined default hour
- We update from timeframe selector value if timeframe && cf are differents from current value

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/panel/RRDView.js |   41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/www/manager/panel/RRDView.js b/www/manager/panel/RRDView.js
index 486a195..84d2450 100644
--- a/www/manager/panel/RRDView.js
+++ b/www/manager/panel/RRDView.js
@@ -5,14 +5,6 @@ Ext.define('PVE.panel.RRDView', {
     initComponent : function() {
 	var me = this;
 
-	if (!me.timeframe) {
-	    me.timeframe = 'hour';
-	}
-
-	if (!me.rrdcffn) {
-	    me.rrdcffn = 'AVERAGE';
-	}
-
 	if (!me.datasource) {
 	    throw "no datasource specified";
 	}
@@ -21,6 +13,27 @@ Ext.define('PVE.panel.RRDView', {
 	    throw "no rrdurl specified";
 	}
 
+	var stateid = 'pveRRDTypeSelection';
+	var sp = Ext.state.Manager.getProvider();
+	var stateinit = sp.get(stateid);
+
+	if (!me.timeframe) {
+	    if(stateinit.timeframe){
+		me.timeframe = stateinit.timeframe;
+	    }else{
+		me.timeframe = 'hour';
+	    }
+	}
+
+	if (!me.rrdcffn) {
+	    if(stateinit.rrdcffn){
+		me.rrdcffn = stateinit.cf;
+	    }else{
+		me.rrdcffn = 'AVERAGE';
+	    }
+	}
+
+
 	var datasource = me.datasource;
 
 	// fixme: dcindex??
@@ -33,7 +46,6 @@ Ext.define('PVE.panel.RRDView', {
 	    return url;
 	};
 
-	var stateid = 'pveRRDTypeSelection';
 
 	Ext.apply(me, {
 	    layout: 'fit',
@@ -45,9 +57,11 @@ Ext.define('PVE.panel.RRDView', {
 	    },
 	    applyState : function(state) {
 		if (state && state.id) {
-		    me.timeframe = state.timeframe;
-		    me.rrdcffn = state.cf;
-		    me.reload_task.delay(10);
+		    if(state.timeframe !== me.timeframe || state.cf !== me.rrdcffn){
+		        me.timeframe = state.timeframe;
+		        me.rrdcffn = state.cf;
+		        me.reload_task.delay(10);
+		    }
 		}
 	    }
 	});
@@ -80,9 +94,6 @@ Ext.define('PVE.panel.RRDView', {
 	    me.reload_task.cancel();
 	});
 
-	var sp = Ext.state.Manager.getProvider();
-	me.applyState(sp.get(stateid));
-
 	var state_change_fn = function(prov, key, value) {
 	    if (key == stateid) {
 		me.applyState(value);
-- 
1.7.10.4




More information about the pve-devel mailing list