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 1B7A96A268 for ; Thu, 4 Mar 2021 13:52:19 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 147FA1A619 for ; Thu, 4 Mar 2021 13:52:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 A17631A5F6 for ; Thu, 4 Mar 2021 13:52:17 +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 6B30F462B5 for ; Thu, 4 Mar 2021 13:52:17 +0100 (CET) From: Stefan Reiter To: pve-devel@lists.proxmox.com Date: Thu, 4 Mar 2021 13:52:09 +0100 Message-Id: <20210304125209.24078-8-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210304125209.24078-1-s.reiter@proxmox.com> References: <20210304125209.24078-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.024 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager 7/7] ui: MachineEdit: add option for machine version pinning 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, 04 Mar 2021 12:52:19 -0000 Hidden behind "Advanced" options, as to not confuse inexperienced users. Signed-off-by: Stefan Reiter --- www/manager6/qemu/MachineEdit.js | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js index 8a3a6f7a..4eab6b8f 100644 --- a/www/manager6/qemu/MachineEdit.js +++ b/www/manager6/qemu/MachineEdit.js @@ -2,8 +2,51 @@ Ext.define('PVE.qemu.MachineInputPanel', { extend: 'Proxmox.panel.InputPanel', xtype: 'pveMachineInputPanel', + controller: { + xclass: 'Ext.app.ViewController', + control: { + 'combobox[name=machine]': { + change: 'onMachineChange', + }, + }, + onMachineChange: function(field, value) { + let me = this; + let version = me.lookup('version'); + let store = version.getStore(); + let type = value === 'q35' ? 'q35' : 'i440fx'; + store.clearFilter(); + store.addFilter(val => + (val.data.name === 'latest' || val.data.name.indexOf(type) !== -1)); + version.setValue('latest'); + }, + }, + + onGetValues: function(values) { + if (values.version && values.version !== 'latest') { + values.machine = values.version; + delete values.delete; + } + delete values.version; + return values; + }, + + setValues: function(values) { + let me = this; + + if (values.machine !== '__default__' && values.machine !== 'q35') { + values.version = values.machine; + values.machine = values.version.match(/q35/) ? 'q35' : '__default__'; + + // avoid hiding a pinned version + Ext.ComponentQuery.query("#advancedcb")[0].setValue(true); + } + + this.callParent(arguments); + }, + items: [{ name: 'machine', + reference: 'machine', xtype: 'proxmoxKVComboBox', fieldLabel: gettext('Machine'), comboItems: [ @@ -11,6 +54,32 @@ Ext.define('PVE.qemu.MachineInputPanel', { ['q35', 'q35'], ], }], + + advancedItems: [{ + name: 'version', + reference: 'version', + xtype: 'combobox', + fieldLabel: gettext('Version'), + value: 'latest', + allowBlank: false, + editable: false, + valueField: 'name', + displayField: 'name', + queryParam: false, + store: { + autoLoad: true, + fields: ['name'], + proxy: { + type: 'proxmox', + url: "/api2/json/nodes/localhost/machine-types", + }, + listeners: { + load: function(records) { + this.insert(0, { name: 'latest' }); + }, + }, + }, + }], }); Ext.define('PVE.qemu.MachineEdit', { -- 2.20.1