[pve-devel] [PATCH 1/2] expose hd resize button to gui

Alexandre Derumier aderumier at odiso.com
Thu Dec 13 15:41:25 CET 2012


This add a resize button in hardwaretab view. (only enabled if element selected is a disk)

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/Makefile             |    1 +
 www/manager/qemu/HardwareView.js |   39 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/www/manager/Makefile b/www/manager/Makefile
index d14ee66..a4feb40 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -94,6 +94,7 @@ JSSRC= 				                 	\
 	qemu/NetworkEdit.js				\
 	qemu/CDEdit.js					\
 	qemu/HDEdit.js					\
+	qemu/HDResize.js				\
 	qemu/DisplayEdit.js				\
 	qemu/KeyboardEdit.js				\
 	qemu/HardwareView.js				\
diff --git a/www/manager/qemu/HardwareView.js b/www/manager/qemu/HardwareView.js
index 7bb4a88..0f29f51 100644
--- a/www/manager/qemu/HardwareView.js
+++ b/www/manager/qemu/HardwareView.js
@@ -203,6 +203,28 @@ Ext.define('PVE.qemu.HardwareView', {
 	    win.on('destroy', reload);
 	};
 
+	var run_resize = function() {
+	    var rec = sm.getSelection()[0];
+	    if (!rec) {
+		return;
+	    }
+
+	    var rowdef = rows[rec.data.key];
+	    if (!rowdef.editor) {
+		return;
+	    }
+
+	    var win = Ext.create('PVE.window.HDResize', {
+		disk: rec.data.key,
+		nodename: nodename,
+		vmid: vmid
+	    });
+
+	    win.show();
+
+	    win.on('destroy', reload);
+	};
+
 	var edit_btn = new PVE.button.Button({
 	    text: gettext('Edit'),
 	    selModel: sm,
@@ -217,6 +239,20 @@ Ext.define('PVE.qemu.HardwareView', {
 	    handler: run_editor
 	});
 
+	var resize_btn = new PVE.button.Button({
+	    text: gettext('Resize disk'),
+	    selModel: sm,
+	    disabled: true,
+	    enableFn: function(rec) {
+		if (!rec) {
+		    return false;
+		}
+	    	var rowdef = rows[rec.data.key];
+		return rowdef.tdCls == 'pve-itype-icon-storage' && !rec.data.value.match(/media=cdrom/)
+	    },
+	    handler: run_resize
+	});
+
 	var remove_btn = new PVE.button.Button({
 	    text: gettext('Remove'),
 	    selModel: sm,
@@ -309,7 +345,8 @@ Ext.define('PVE.qemu.HardwareView', {
 		    })
 		}, 
 		remove_btn,
-		edit_btn
+		edit_btn,
+		resize_btn
 	    ],
 	    rows: rows,
 	    sorterFn: sorterFn,
-- 
1.7.10.4




More information about the pve-devel mailing list