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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id F309D9AA0B for ; Fri, 17 Nov 2023 16:03:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D5A0D35B3D for ; Fri, 17 Nov 2023 16:03:44 +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 for ; Fri, 17 Nov 2023 16:03:44 +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 1098B43EA4 for ; Fri, 17 Nov 2023 16:03:44 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 17 Nov 2023 16:03:42 +0100 Message-Id: <20231117150343.2099607-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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. [me.drive] Subject: [pve-devel] [PATCH manager 1/2] ui: refactor iso selector out of the cd input panel 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: Fri, 17 Nov 2023 15:03:45 -0000 and make it into a proper field it's intended to be used like a single field and exactly as before Signed-off-by: Dominik Csapak --- www/manager6/Makefile | 1 + www/manager6/form/IsoSelector.js | 107 +++++++++++++++++++++++++++++++ www/manager6/qemu/CDEdit.js | 38 ++--------- 3 files changed, 115 insertions(+), 31 deletions(-) create mode 100644 www/manager6/form/IsoSelector.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index dccd2ba1..56dce790 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -88,6 +88,7 @@ JSSRC= \ form/TagEdit.js \ form/MultiFileButton.js \ form/TagFieldSet.js \ + form/IsoSelector.js \ grid/BackupView.js \ grid/FirewallAliases.js \ grid/FirewallOptions.js \ diff --git a/www/manager6/form/IsoSelector.js b/www/manager6/form/IsoSelector.js new file mode 100644 index 00000000..632ee7f0 --- /dev/null +++ b/www/manager6/form/IsoSelector.js @@ -0,0 +1,107 @@ +Ext.define('PVE.form.IsoSelector', { + extend: 'Ext.container.Container', + alias: 'widget.pveIsoSelector', + mixins: [ + 'Ext.form.field.Field', + 'Proxmox.Mixin.CBind', + ], + + nodename: undefined, + insideWizard: false, + + cbindData: function() { + let me = this; + return { + nodename: me.nodename, + insideWizard: me.insideWizard, + }; + }, + + getValue: function() { + return this.lookup('file').getValue(); + }, + + setValue: function(value) { + let me = this; + if (!value) { + me.lookup('file').reset(); + return; + } + var match = value.match(/^([^:]+):/); + if (match) { + me.lookup('storage').setValue(match[1]); + me.lookup('file').setValue(value); + } + }, + + getErrors: function() { + let me = this; + me.lookup('storage').validate(); + let file = me.lookup('file'); + file.validate(); + let value = file.getValue(); + if (!value || !value.length) { + return [""]; // for validation + } + return []; + }, + + setNodename: function(nodename) { + let me = this; + me.lookup('storage').setNodename(nodename); + me.lookup('file').setStorage(undefined, nodename); + }, + + setDisabled: function(disabled) { + let me = this; + me.lookup('storage').setDisabled(disabled); + me.lookup('file').setDisabled(disabled); + me.callParent(); + }, + + referenceHolder: true, + + items: [ + { + xtype: 'pveStorageSelector', + reference: 'storage', + isFormField: false, + fieldLabel: gettext('Storage'), + labelAlign: 'right', + storageContent: 'iso', + allowBlank: false, + cbind: { + nodename: '{nodename}', + autoSelect: '{insideWizard}', + insideWizard: '{insideWizard}', + disabled: '{disabled}', + }, + listeners: { + change: function(f, value) { + let me = this; + let selector = me.up('pveIsoSelector'); + selector.lookup('file').setStorage(value); + selector.checkChange(); + }, + }, + }, + { + xtype: 'pveFileSelector', + reference: 'file', + isFormField: false, + storageContent: 'iso', + fieldLabel: gettext('ISO image'), + labelAlign: 'right', + cbind: { + nodename: '{nodename}', + disabled: '{disabled}', + }, + allowBlank: false, + listeners: { + change: function() { + this.up('pveIsoSelector').checkChange(); + }, + }, + }, + ], +}); diff --git a/www/manager6/qemu/CDEdit.js b/www/manager6/qemu/CDEdit.js index fc7a59cc..3cc16205 100644 --- a/www/manager6/qemu/CDEdit.js +++ b/www/manager6/qemu/CDEdit.js @@ -43,11 +43,7 @@ Ext.define('PVE.qemu.CDInputPanel', { values.mediaType = 'none'; } else { values.mediaType = 'iso'; - var match = drive.file.match(/^([^:]+):/); - if (match) { - values.cdstorage = match[1]; - values.cdimage = drive.file; - } + values.cdimage = drive.file; } me.drive = drive; @@ -58,8 +54,7 @@ Ext.define('PVE.qemu.CDInputPanel', { setNodename: function(nodename) { var me = this; - me.cdstoragesel.setNodename(nodename); - me.cdfilesel.setStorage(undefined, nodename); + me.isosel.setNodename(nodename); }, initComponent: function() { @@ -87,8 +82,7 @@ Ext.define('PVE.qemu.CDInputPanel', { if (!me.rendered) { return; } - me.down('field[name=cdstorage]').setDisabled(!value); - var cdImageField = me.down('field[name=cdimage]'); + var cdImageField = me.down('pveIsoSelector'); cdImageField.setDisabled(!value); if (value) { cdImageField.validate(); @@ -99,32 +93,14 @@ Ext.define('PVE.qemu.CDInputPanel', { }, }); - me.cdfilesel = Ext.create('PVE.form.FileSelector', { - name: 'cdimage', - nodename: me.nodename, - storageContent: 'iso', - fieldLabel: gettext('ISO image'), - labelAlign: 'right', - allowBlank: false, - }); - me.cdstoragesel = Ext.create('PVE.form.StorageSelector', { - name: 'cdstorage', + me.isosel = Ext.create('PVE.form.IsoSelector', { nodename: me.nodename, - fieldLabel: gettext('Storage'), - labelAlign: 'right', - storageContent: 'iso', - allowBlank: false, - autoSelect: me.insideWizard, - listeners: { - change: function(f, value) { - me.cdfilesel.setStorage(value); - }, - }, + insideWizard: me.insideWizard, + name: 'cdimage', }); - items.push(me.cdstoragesel); - items.push(me.cdfilesel); + items.push(me.isosel); items.push({ xtype: 'radiofield', -- 2.30.2