public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v2 2/2] ui: vm wizard: allow second iso for windows vms
Date: Mon, 20 Nov 2023 16:45:43 +0100	[thread overview]
Message-ID: <20231120154543.2067217-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231120154543.2067217-1-d.csapak@proxmox.com>

This is useful for adding the virtio-win iso for new installs, and thus
we change the default disk type to scsi and network type to virtio.

we add special logic to the OSTypeInputPanel when 'insideWizard' is
true to add an additional checkbox + iso selector

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* update the vm config for the MultiHDEdit so that it correctly can set
  the value back to ide0
* fix the OSTypeInputPanel in the non insideWizard case
* use onGetValues to construct the drive properly in the wizard

 www/manager6/qemu/CreateWizard.js |  3 ++
 www/manager6/qemu/MultiHDEdit.js  |  8 ++-
 www/manager6/qemu/OSTypeEdit.js   | 84 ++++++++++++++++++++++++++++++-
 3 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 74b1feb6..443e42c6 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -161,6 +161,9 @@ Ext.define('PVE.qemu.CreateWizard', {
 		{
 		    xtype: 'pveQemuOSTypePanel',
 		    insideWizard: true,
+		    bind: {
+			nodename: '{nodename}',
+		    },
 		},
 	    ],
 	},
diff --git a/www/manager6/qemu/MultiHDEdit.js b/www/manager6/qemu/MultiHDEdit.js
index caf74fad..27884f3f 100644
--- a/www/manager6/qemu/MultiHDEdit.js
+++ b/www/manager6/qemu/MultiHDEdit.js
@@ -37,11 +37,17 @@ Ext.define('PVE.qemu.MultiHDPanel', {
 	    let me = this;
 	    let vm = me.getViewModel();
 
-	    return {
+	    let res = {
 		ide2: 'media=cdrom',
 		scsihw: vm.get('current.scsihw'),
 		ostype: vm.get('current.ostype'),
 	    };
+
+	    if (vm.get('current.ide0') === "some") {
+		res.ide0 = "media=cdrom";
+	    }
+
+	    return res;
 	},
 
 	diskSorter: {
diff --git a/www/manager6/qemu/OSTypeEdit.js b/www/manager6/qemu/OSTypeEdit.js
index 3332a0bc..109f645d 100644
--- a/www/manager6/qemu/OSTypeEdit.js
+++ b/www/manager6/qemu/OSTypeEdit.js
@@ -14,9 +14,21 @@ Ext.define('PVE.qemu.OSTypeInputPanel', {
 		afterrender: 'onOSTypeChange',
 		change: 'onOSTypeChange',
 	    },
+	    'checkbox[reference=enableSecondCD]': {
+		change: 'onSecondCDChange',
+	    },
 	},
 	onOSBaseChange: function(field, value) {
-	    this.lookup('ostype').getStore().setData(PVE.Utils.kvm_ostypes[value]);
+	    let me = this;
+	    me.lookup('ostype').getStore().setData(PVE.Utils.kvm_ostypes[value]);
+	    if (me.getView().insideWizard) {
+		let isWindows = value === 'Microsoft Windows';
+		let enableSecondCD = me.lookup('enableSecondCD');
+		enableSecondCD.setVisible(isWindows);
+		if (!isWindows) {
+		    enableSecondCD.setValue(false);
+		}
+	    }
 	},
 	onOSTypeChange: function(field) {
 	    var me = this, ostype = field.getValue();
@@ -42,6 +54,48 @@ Ext.define('PVE.qemu.OSTypeInputPanel', {
 		// ignore multiple disks, we only want to set the type if there is a single disk
 	    }
 	},
+	onSecondCDChange: function(widget, value, lastValue) {
+	    let me = this;
+	    let vm = me.getViewModel();
+	    let updateVMConfig = function () {
+		let widgets = Ext.ComponentQuery.query('pveMultiHDPanel');
+		if (widgets.length === 1) {
+		    widgets[0].getController().updateVMConfig();
+		}
+	    };
+	    if (value) {
+		// only for windows
+		vm.set('current.ide0', "some");
+		vm.notify();
+		updateVMConfig();
+		me.setWidget('pveBusSelector', 'scsi');
+		me.setWidget('pveNetworkCardSelector', 'virtio');
+	    } else {
+		vm.set('current.ide0', "");
+		vm.notify();
+		updateVMConfig();
+		me.setWidget('pveBusSelector', 'scsi');
+		let ostype = me.lookup('ostype').getValue();
+		var targetValues = PVE.qemu.OSDefaults.getDefaults(ostype);
+		me.setWidget('pveBusSelector', targetValues.busType);
+	    }
+	},
+    },
+
+    setNodename: function(nodename) {
+	var me = this;
+	me.lookup('isoSelector').setNodename(nodename);
+    },
+
+    onGetValues: function(values) {
+	if (values.ide0) {
+	    let drive = {
+		media: 'cdrom',
+		file: values.ide0,
+	    };
+	    values.ide0 = PVE.Parser.printQemuDrive(drive);
+	}
+	return values;
     },
 
     initComponent: function() {
@@ -92,6 +146,34 @@ Ext.define('PVE.qemu.OSTypeInputPanel', {
 	    },
 	];
 
+	if (me.insideWizard) {
+	    me.items.push(
+		{
+		    xtype: 'proxmoxcheckbox',
+		    reference: 'enableSecondCD',
+		    isFormField: false,
+		    hidden: true,
+		    checked: false,
+		    boxLabel: gettext('Add Second CD/DVD Image file (iso)'),
+		    listeners: {
+			change: function(cb, value) {
+			    me.lookup('isoSelector').setDisabled(!value);
+			    me.lookup('isoSelector').setHidden(!value);
+			},
+		    },
+		},
+		{
+		    xtype: 'pveIsoSelector',
+		    reference: 'isoSelector',
+		    name: 'ide0',
+		    nodename: me.nodename,
+		    insideWizard: true,
+		    hidden: true,
+		    disabled: true,
+		},
+	    );
+	}
+
 	me.callParent();
     },
 });
-- 
2.30.2





  reply	other threads:[~2023-11-20 15:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 15:45 [pve-devel] [PATCH manager v2 1/2] ui: refactor iso selector out of the cd input panel Dominik Csapak
2023-11-20 15:45 ` Dominik Csapak [this message]
2023-11-21 13:25 ` [pve-devel] applied: " Thomas Lamprecht

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=20231120154543.2067217-2-d.csapak@proxmox.com \
    --to=d.csapak@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