From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BA50868B4E for ; Thu, 10 Mar 2022 12:19:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF44D198F4 for ; Thu, 10 Mar 2022 12:19:48 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id F195C198E8 for ; Thu, 10 Mar 2022 12:19:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BCC5646401 for ; Thu, 10 Mar 2022 12:19:47 +0100 (CET) Message-ID: <1aaa5f5b-6ea8-8c0f-ac53-44d6ca67c051@proxmox.com> Date: Thu, 10 Mar 2022 12:19:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Content-Language: en-US To: pve-devel@lists.proxmox.com, Aaron Lauterer References: <20220307100722.257128-1-a.lauterer@proxmox.com> <20220307100722.257128-5-a.lauterer@proxmox.com> From: Fabian Ebner In-Reply-To: <20220307100722.257128-5-a.lauterer@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.122 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [params.storage] Subject: Re: [pve-devel] [PATCH v3 manager 4/4] ui: hdmove: modernize/refactor X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2022 11:19:48 -0000 Am 07.03.22 um 11:07 schrieb Aaron Lauterer: > Signed-off-by: Aaron Lauterer > --- > changes since > > v2: > * switch from generic window to proxmox edit > > v1: much of the feedback to the HDReassign.js from the > first patch has been incorporated here as well. > > * reducing predefined cbind values for more arrow functions > * using more arrow functions in general > * template strings > www/manager6/qemu/HDMove.js | 192 ++++++++++++++---------------- > www/manager6/qemu/HardwareView.js | 1 + > 2 files changed, 88 insertions(+), 105 deletions(-) > > diff --git a/www/manager6/qemu/HDMove.js b/www/manager6/qemu/HDMove.js > index 181b7bdc..3e94479c 100644 > --- a/www/manager6/qemu/HDMove.js > +++ b/www/manager6/qemu/HDMove.js > @@ -1,48 +1,102 @@ > Ext.define('PVE.window.HDMove', { > - extend: 'Ext.window.Window', > + extend: 'Proxmox.window.Edit', > + mixins: ['Proxmox.Mixin.CBind'], > > resizable: false, > + modal: true, > + width: 350, > + border: false, > + layout: 'fit', > + showReset: false, > + showProgress: true, > + method: 'POST', > + > + cbindData: function() { > + let me = this; > + return { > + disk: me.disk, > + isQemu: me.type === 'qemu', > + nodename: me.nodename, > + url: `/nodes/${me.nodename}/${me.type}/${me.vmid}/`, > + }; > + }, > + > + cbind: { > + title: get => get('isQemu') ? gettext("Move disk") : gettext('Move Volume'), > + submitText: get => get('title'), > + qemu: '{isQemu}', > + url: '{url}', > + }, > + > + submitUrl: function(url, values) { > + url += this.qemu ? 'move_disk' : 'move_volume'; Same as in patch #1: url could be constructed above in one go. > + return url; > + }, > > + getValues: function() { > + let me = this; > + let values = me.formPanel.getForm().getValues(); > > - move_disk: function(disk, storage, format, delete_disk) { > - var me = this; > - var qemu = me.type === 'qemu'; > - var params = {}; > - params.storage = storage; > - params[qemu ? 'disk':'volume'] = disk; > + let params = { > + storage: values.hdstorage, > + }; > + params[me.qemu ? 'disk':'volume'] = me.disk; Style nit: missing spaces around the colon > > - if (format && qemu) { > - params.format = format; > + if (values.diskformat && me.qemu) { > + params.format = values.diskformat; > } > > - if (delete_disk) { > + if (values.deleteDisk) { > params.delete = 1; > } > - > - var url = '/nodes/' + me.nodename + '/' + me.type + '/' + me.vmid + '/'; > - url += qemu ? 'move_disk' : 'move_volume'; > - > - Proxmox.Utils.API2Request({ > - params: params, > - url: url, > - waitMsgTarget: me, > - method: 'POST', > - failure: function(response, opts) { > - Ext.Msg.alert('Error', response.htmlStatus); > - }, > - success: function(response, options) { > - var upid = response.result.data; > - var win = Ext.create('Proxmox.window.TaskViewer', { > - upid: upid, > - }); > - win.show(); > - win.on('destroy', function() { me.close(); }); > - }, > - }); > + return params; > }, Style nit: missing blank line > + items: [ > + { > + xtype: 'form', > + reference: 'moveFormPanel', > + bodyPadding: 10, > + border: false, > + fieldDefaults: { > + labelWidth: 100, > + anchor: '100%', > + }, > + items: [ > + { > + xtype: 'displayfield', > + cbind: { > + name: get => get('isQemu') ? 'disk' : 'volume', > + fieldLabel: get => get('isQemu') > + ? gettext('Disk') > + : gettext('Mount Point'), Style nit: (exactly) fits in one line > + value: '{disk}', > + }, > + vtype: 'StorageId', Not a storage ID either, but here it's pre-existing. There is a 'ConfigId' vtype, but that's also not entirely correct, since this is a config key. The field is not editable anyways, so I think we can just drop it. > + allowBlank: false, > + },