[pve-devel] [PATCH v3 manager] close #584: ui qemu: changed remove unused disk to asynchron call

Tim Marx t.marx at proxmox.com
Thu Oct 18 11:59:11 CEST 2018


check for isUnusedDisk is now reusable as suggested by Thomas
the new isUnusedDisk is now used to determine the proper RESTMethod

Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
changes since v2:
* new var isUnusedDisk
* new Button attribute RESTMethod
* deleted trailing comma
 www/manager6/qemu/HardwareView.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index a1bccc3c..f049a239 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -356,6 +356,7 @@ Ext.define('PVE.qemu.HardwareView', {
 	    selModel: sm,
 	    disabled: true,
 	    dangerous: true,
+	    RESTMethod: 'PUT',
 	    confirmMsg: function(rec) {
 		var warn = gettext('Are you sure you want to remove entry {0}');
 		if (this.text === this.alremovetText) {
@@ -376,7 +377,7 @@ Ext.define('PVE.qemu.HardwareView', {
 		Proxmox.Utils.API2Request({
 		    url: '/api2/extjs/' + baseurl,
 		    waitMsgTarget: me,
-		    method: 'PUT',
+		    method: b.RESTMethod,
 		    params: {
 			'delete': rec.data.key
 		    },
@@ -385,6 +386,20 @@ Ext.define('PVE.qemu.HardwareView', {
 		    },
 		    failure: function (response, opts) {
 			Ext.Msg.alert('Error', response.htmlStatus);
+		    },
+		    success: function(response, options) {
+			if (b.RESTMethod === 'POST') {
+			    var upid = response.result.data;
+			    var win = Ext.create('Proxmox.window.TaskProgress', {
+				upid: upid,
+				listeners: {
+				    destroy: function () {
+					me.reload();
+				    }
+				}
+			    });
+			    win.show();
+			}
 		    }
 		});
 	    },
@@ -491,6 +506,7 @@ Ext.define('PVE.qemu.HardwareView', {
 	    var isUsedDisk = !key.match(/^unused\d+/) &&
 		rowdef.tdCls == 'pve-itype-icon-storage' &&
 		(value && !value.match(/media=cdrom/));
+	    var isUnusedDisk = key.match(/^unused\d+/);
 
 	    var isCloudInit = (value && value.toString().match(/vm-.*-cloudinit/));
 
@@ -498,6 +514,7 @@ Ext.define('PVE.qemu.HardwareView', {
 
 	    remove_btn.setDisabled(rec.data['delete'] || (rowdef.never_delete === true));
 	    remove_btn.setText((isUsedDisk && !isCloudInit) ? remove_btn.altText : remove_btn.defaultText);
+	    remove_btn.RESTMethod = isUnusedDisk ? 'POST':'PUT';
 
 	    edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor || isCloudInit);
 
-- 
2.11.0




More information about the pve-devel mailing list