[pve-devel] [PATCH 7/7] implement revert button

Alexandre Derumier aderumier at odiso.com
Fri Jan 2 15:18:10 CET 2015


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/qemu/HardwareView.js |   36 +++++++++++++++++++++++++++++++++++-
 www/manager/qemu/Options.js      |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/www/manager/qemu/HardwareView.js b/www/manager/qemu/HardwareView.js
index 60f462b..50bf6aa 100644
--- a/www/manager/qemu/HardwareView.js
+++ b/www/manager/qemu/HardwareView.js
@@ -370,6 +370,39 @@ Ext.define('PVE.qemu.HardwareView', {
 	    }
 	});
 
+	var revert_btn = new PVE.button.Button({
+	    text: gettext('Revert'),
+	    selModel: sm,
+	    disabled: true,
+	    enableFn: function(rec) {
+		if (!rec) {
+		    return false;
+		}
+		if(!rec.data['pending'] && !rec.data['delete']){
+		    return false;
+		}
+		var rowdef = rows[rec.data.key];
+
+		return true;    
+	    },
+	    handler: function(b, e, rec) {
+		PVE.Utils.API2Request({
+		    url: '/api2/extjs/' + baseurl,
+		    waitMsgTarget: me,
+		    method: 'PUT',
+		    params: {
+			'revert': rec.data.key
+		    },
+		    callback: function() {
+			reload();
+		    },
+		    failure: function (response, opts) {
+			Ext.Msg.alert('Error',response.htmlStatus);
+		    }
+		});
+	    }
+	});
+
 	Ext.applyIf(me, {
 	    url: '/api2/json/' + 'nodes/' + nodename + '/qemu/' + vmid + '/pending',
 	    selModel: sm,
@@ -425,7 +458,8 @@ Ext.define('PVE.qemu.HardwareView', {
 		edit_btn,
 		resize_btn,
 		move_btn,
-		diskthrottle_btn
+		diskthrottle_btn,
+		revert_btn
 	    ],
 	    rows: rows,
 	    sorterFn: sorterFn,
diff --git a/www/manager/qemu/Options.js b/www/manager/qemu/Options.js
index 49e8641..8ad7bb8 100644
--- a/www/manager/qemu/Options.js
+++ b/www/manager/qemu/Options.js
@@ -302,6 +302,33 @@ Ext.define('PVE.qemu.Options', {
 	    handler: run_editor
 	});
 
+        var revert_btn = new PVE.button.Button({
+            text: gettext('Revert'),
+            disabled: true,
+            handler: function() {
+		var sm = me.getSelectionModel();
+		var rec = sm.getSelection()[0];
+		if (!rec) {
+		    return;
+		}
+
+                PVE.Utils.API2Request({
+                    url: '/api2/extjs/' + baseurl,
+                    waitMsgTarget: me,
+                    method: 'PUT',
+                    params: {
+                        'revert': rec.data.key
+                    },
+                    callback: function() {
+                        reload();
+                    },
+                    failure: function (response, opts) {
+                        Ext.Msg.alert('Error',response.htmlStatus);
+                    }
+                });
+            }
+        });
+
 	var set_button_status = function() {
 	    var sm = me.getSelectionModel();
 	    var rec = sm.getSelection()[0];
@@ -310,6 +337,13 @@ Ext.define('PVE.qemu.Options', {
 		edit_btn.disable();
 		return;
 	    }
+
+            if(rec.data['pending'] || rec.data['delete']){
+                revert_btn.setDisabled(false);
+            }else {
+                revert_btn.setDisabled(true);
+	    }
+
 	    var rowdef = rows[rec.data.key];
 	    edit_btn.setDisabled(!rowdef.editor);
 	};
@@ -317,7 +351,7 @@ Ext.define('PVE.qemu.Options', {
 	Ext.applyIf(me, {
 	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/pending",
 	    cwidth1: 170,
-	    tbar: [ edit_btn ],
+	    tbar: [ edit_btn, revert_btn ],
 	    rows: rows,
 	    listeners: {
 		itemdblclick: run_editor,
-- 
1.7.10.4



More information about the pve-devel mailing list