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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Oct 18 13:08:23 CEST 2018


On 10/18/18 11:59 AM, Tim Marx wrote:> 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) {
                                       ^^^^^^
You inserted 'remove' in the altText property, possible an editing glitch,
but git complains about non matching context..


> @@ -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+/);

Could you please move this above the isUsedDisk method and switch then
the key.match statement there with this variable? Could be fixed up, but
as you need to send another version anyway...

Looks good otherwise, thanks!

>  
>  	    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);
>  
> 




More information about the pve-devel mailing list