[pve-devel] [PATCH manager v2] add undo Zoom Button

Dominik Csapak d.csapak at proxmox.com
Tue May 3 09:09:23 CEST 2016


this adds a decent undo zoom button, which is only enabled
when the chart is zoomed

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes since v1:
 * rebased on current master
 www/manager6/panel/RRDChart.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/www/manager6/panel/RRDChart.js b/www/manager6/panel/RRDChart.js
index 2b3db50..b36ea61 100644
--- a/www/manager6/panel/RRDChart.js
+++ b/www/manager6/panel/RRDChart.js
@@ -24,7 +24,8 @@ Ext.define('PVE.widget.RRDChart', {
 	width: 140
     },
     listeners: {
-	afterrender: 'onAfterRender'
+	afterrender: 'onAfterRender',
+	animationend: 'onAfterAnimation',
     },
 
     bytesArr : [
@@ -108,6 +109,18 @@ Ext.define('PVE.widget.RRDChart', {
 	}
 	me.axes[0].setTitle(axisTitle);
 
+
+	me.addTool({
+	    type: 'minus',
+	    disabled: true,
+	    tooltip: gettext('Undo Zoom'),
+	    handler: function(){
+		var undoButton = me.interactions[0].getUndoButton();
+		if (undoButton.handler) {
+		    undoButton.handler();
+		}
+	    }
+	});
 	// add a series for each field we get
 	me.fields.forEach(function(item, index){
 	    var title = item;
@@ -144,6 +157,14 @@ Ext.define('PVE.widget.RRDChart', {
 	});
     },
 
+    onAfterAnimation: function(chart, eopts) {
+	// if the undobuton is disabled,
+	// disable our tool
+	var ourUndoZoomButton = chart.tools[0];
+	var undoButton = chart.interactions[0].getUndoButton();
+	ourUndoZoomButton.setDisabled(undoButton.isDisabled());
+    },
+
     initComponent: function() {
 	var me = this;
 
-- 
2.1.4





More information about the pve-devel mailing list