public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 7/7] ui: MachineEdit: add option for machine version pinning
Date: Thu,  4 Mar 2021 13:52:09 +0100	[thread overview]
Message-ID: <20210304125209.24078-8-s.reiter@proxmox.com> (raw)
In-Reply-To: <20210304125209.24078-1-s.reiter@proxmox.com>

Hidden behind "Advanced" options, as to not confuse inexperienced users.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 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





  parent reply	other threads:[~2021-03-04 12:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 12:52 [pve-devel] [PATCH 0/7] Work around QEMU 5.2 windows incompatibility Stefan Reiter
2021-03-04 12:52 ` [pve-devel] [PATCH pve-qemu 1/7] add static supported machines file Stefan Reiter
2021-03-05 21:27   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-04 12:52 ` [pve-devel] [PATCH pve-qemu 2/7] add ACPI compat patch for 5.1 and older machine types Stefan Reiter
2021-03-05 21:27   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-04 12:52 ` [pve-devel] [PATCH qemu-server 3/7] api: add Machine module to query " Stefan Reiter
2021-03-05 21:28   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-04 12:52 ` [pve-devel] [PATCH qemu-server 4/7] add postinst with Windows device incompatibility workaround Stefan Reiter
2021-03-04 13:31   ` Stefan Reiter
2021-03-05  8:03   ` Fabian Ebner
2021-03-05 21:32   ` [pve-devel] NAK: " Thomas Lamprecht
2021-03-04 12:52 ` [pve-devel] [PATCH manager 5/7] api: register Qemu::Machine call Stefan Reiter
2021-03-05 21:33   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-04 12:52 ` [pve-devel] [PATCH manager 6/7] ui: create MachineEdit window Stefan Reiter
2021-03-05 21:33   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-04 12:52 ` Stefan Reiter [this message]
2021-03-05 21:36   ` [pve-devel] applied: [PATCH manager 7/7] ui: MachineEdit: add option for machine version pinning Thomas Lamprecht
2021-03-05  7:24 ` [pve-devel] [PATCH 0/7] Work around QEMU 5.2 windows incompatibility Fabian Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210304125209.24078-8-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal