[pve-devel] r6245 - in pve-manager/pve2: . www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jul 6 10:19:07 CEST 2011


Author: dietmar
Date: 2011-07-06 10:19:07 +0200 (Wed, 06 Jul 2011)
New Revision: 6245

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
* www/manager/qemu/HardwareView.js: add 'Deletion Confirmation',
  ability to re-add unused disks.



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-06 06:30:26 UTC (rev 6244)
+++ pve-manager/pve2/ChangeLog	2011-07-06 08:19:07 UTC (rev 6245)
@@ -1,3 +1,8 @@
+2011-07-06  Proxmox Support Team  <support at proxmox.com>
+
+	* www/manager/qemu/HardwareView.js: add 'Deletion Confirmation',
+	ability to re-add unused disks.
+
 2011-07-05  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/qemu/HardwareView.js: impl. PVE.qemu.CDEdit

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-06 06:30:26 UTC (rev 6244)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-06 08:19:07 UTC (rev 6245)
@@ -216,6 +216,8 @@
 
     cdrom: false,
 
+    unused: false,
+
     getParams: function(values) {
 	var me = this;
 
@@ -233,9 +235,13 @@
 		drive.file = 'none';
 	    }
 	} else {
-	    drive.file = values.storage + ":" + values.disksize;
-	    drive.format = values.diskformat;
-	
+	    if (me.unused) {
+		drive.file = me.vmconfig[values.unusedId];
+	    } else {
+		drive.file = values.storage + ":" + values.disksize;
+		drive.format = values.diskformat;
+	    }
+
 	    if (values.cache)
 		drive.cache = values.cache;
 	    
@@ -257,15 +263,21 @@
 	if (!nodename) 
 	    throw "no node name specified";	    
 
+	if (!me.cdrom && me.confid && me.confid.match(/^unused\d+$/))
+	    me.unused = true;
+
 	var maxIds = {
 	    ide: 3,
 	    virtio: 15,
 	    scsi: 15
 	};
 
+	var unused_disks;
+
 	var bussel = Ext.createWidget('fieldcontainer', {
 	    fieldLabel: 'Bus/Device',
 	    layout: 'hbox',
+	    height: 22, // hack: set to same height as other fields
 	    defaults: {
                 flex: 1,
                 hideLabel: true
@@ -367,36 +379,45 @@
 	    ];
 
 	} else {
-	    me.column1 = [
-		{
-		    xtype: 'PVE.form.StorageSelector',
-		    name: 'storage',
-		    nodename: nodename,
-		    fieldLabel: 'Storage',
-		    storageContent: 'images',
+	    if (me.unused) {
+
+		unused_disks = Ext.create('PVE.form.KVComboBox', {
+		    name: 'unusedId',	
+		    fieldLabel: 'Disk image',
+		    matchFieldWidth: false,
+		    listConfig: {
+			width: 350
+		    },
+		    data: [],
 		    allowBlank: false
-		},
-		{
-		    xtype: 'numberfield',
-		    name: 'disksize',
-		    minValue: 1,
-		    maxValue: 128*1024,
-		    value: 32,
-		    fieldLabel: 'Disk size (GB)',
-		    allowBlank: false
-		},
-		bussel
-	    ];
+		});
 
+		me.column1 = [ bussel, unused_disks ];
+	    } else {
+		me.column1 = [
+		    bussel,
+		    {
+			xtype: 'PVE.form.StorageSelector',
+			name: 'storage',
+			nodename: nodename,
+			fieldLabel: 'Storage',
+			storageContent: 'images',
+			allowBlank: false
+		    },
+		    {
+			xtype: 'numberfield',
+			name: 'disksize',
+			minValue: 1,
+			maxValue: 128*1024,
+			value: 32,
+			fieldLabel: 'Disk size (GB)',
+			allowBlank: false
+		    }
+		];
+	    }
+
 	    me.column2 = [
 		{
-		    xtype: 'PVE.form.DiskFormatSelector',
-		    name: 'diskformat',
-		    fieldLabel: 'Image format',
-		    value: 'raw',
-		    allowBlank: false
-		},
-		{
 		    xtype: 'CacheTypeSelector',
 		    name: 'cache',
 		    value: '',
@@ -408,11 +429,26 @@
                     name: 'nobackup'
  		}
 	    ];
+
+	    if (!me.unused) {
+		me.column2.unshift({
+		    xtype: 'PVE.form.DiskFormatSelector',
+		    name: 'diskformat',
+		    fieldLabel: 'Image format',
+		    value: 'raw',
+		    allowBlank: false
+		});
+	    };
+
 	}
 
-	Ext.applyIf(me, {
-	    title: me.cdrom ? 'Add CD/DVD Drive' : 'Add Harddisk',
-	});
+	if (me.cdrom) {
+	    me.title = 'Add CD/DVD Drive';
+	} else if (me.unused) {
+	    me.title = 'Add (previously unused) Harddisk';	    
+	} else {
+	    me.title = 'Add Harddisk';
+	}
 
 	me.callParent();
 
@@ -428,6 +464,16 @@
 		    return;
 		}
 
+		if (unused_disks) {
+		    var disklist = [];
+		    
+		    Ext.Object.each(me.vmconfig, function(key, value) {
+			if (key.match(/^unused\d+$/))
+			    disklist.push([key, value]);
+		    });
+		    unused_disks.store.loadData(disklist);
+		    unused_disks.setValue(me.confid);
+		}
 		var controller = 'ide';
 		if (me.vmconfig.ostype === 'l26') {
 		    controller = 'virtio';
@@ -705,6 +751,7 @@
 	for (i = 0; i < 8; i++) {
 	    rows["unused" + i] = {
 		tdCls: 'pve-itype-icon-storage',
+		editor: 'PVE.qemu.HDCreate',
 		header: 'Unused Disk'
 	    };
 	}
@@ -758,22 +805,33 @@
 		if (!rec)
 		    return;
 
-		me.setLoading(true, true);
-		PVE.Utils.API2Request({
-		    url: '/api2/extjs/' + baseurl,
-		    method: 'PUT',
-		    params: {
-			delete: rec.data.key
-		    },
-		    callback: function() {
-			me.setLoading(false);
-			reload();
-		    },
-		    failure: function (response, opts) {
-			Ext.Msg.alert('Error',response.htmlStatus);
-		    }
+		var msg = 'Are you sure you want to remove: ' + 
+		    me.renderKey(rec.data.key, {}, rec);
+		if (rec.data.key.match(/^unused\d+$/)) {
+		    msg = 'Are you sure you want to remove image "' +
+			rec.data.value + '"? This will permanently erase ' +
+			'all image data.';
+		}
+
+		Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
+		    if (btn !== 'yes')
+			return;
+		    me.setLoading(true, true);
+		    PVE.Utils.API2Request({
+			url: '/api2/extjs/' + baseurl,
+			method: 'PUT',
+			params: {
+			    delete: rec.data.key
+			},
+			callback: function() {
+			    me.setLoading(false);
+			    reload();
+			},
+			failure: function (response, opts) {
+			    Ext.Msg.alert('Error',response.htmlStatus);
+			}
+		    });
 		});
-
 	    }
 	});
 




More information about the pve-devel mailing list