Commit c656f6fb authored by Alexandre Derumier's avatar Alexandre Derumier Committed by Dietmar Maurer

rrd display : avoid 2 refresh

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: 's avatarAlexandre Derumier <aderumier@odiso.com>
parent 7bf2d98f
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment