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 v3 6/7] ui: add qemu/MultiHDEdit and use it in the wizard
Date: Tue,  5 Oct 2021 13:29:02 +0200	[thread overview]
Message-ID: <20211005112903.3649291-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211005112903.3649291-1-d.csapak@proxmox.com>

uses the MultiDiskPanel as base and implements the necessary
functions/variables

this allows now to create a vm also without any disk

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/Makefile             |  1 +
 www/manager6/qemu/CreateWizard.js |  7 +---
 www/manager6/qemu/HDEdit.js       |  9 ++++-
 www/manager6/qemu/MultiHDEdit.js  | 62 +++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 6 deletions(-)
 create mode 100644 www/manager6/qemu/MultiHDEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 3b9b057a..04c634f0 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -215,6 +215,7 @@ JSSRC= 							\
 	qemu/MachineEdit.js				\
 	qemu/MemoryEdit.js				\
 	qemu/Monitor.js					\
+	qemu/MultiHDEdit.js				\
 	qemu/NetworkEdit.js				\
 	qemu/OSDefaults.js				\
 	qemu/OSTypeEdit.js				\
diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 015a099d..a785a882 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -154,14 +154,11 @@ Ext.define('PVE.qemu.CreateWizard', {
 	    insideWizard: true,
 	},
 	{
-	    xtype: 'pveQemuHDInputPanel',
-	    padding: 0,
+	    xtype: 'pveMultiHDPanel',
 	    bind: {
 		nodename: '{nodename}',
 	    },
-	    title: gettext('Hard Disk'),
-	    isCreate: true,
-	    insideWizard: true,
+	    title: gettext('Disks'),
 	},
 	{
 	    xtype: 'pveQemuProcessorPanel',
diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js
index 2142c746..9c453b2a 100644
--- a/www/manager6/qemu/HDEdit.js
+++ b/www/manager6/qemu/HDEdit.js
@@ -107,6 +107,12 @@ Ext.define('PVE.qemu.HDInputPanel', {
 	return params;
     },
 
+    updateVMConfig: function(vmconfig) {
+	var me = this;
+	me.vmconfig = vmconfig;
+	me.bussel?.updateVMConfig(vmconfig);
+    },
+
     setVMConfig: function(vmconfig) {
 	var me = this;
 
@@ -183,7 +189,8 @@ Ext.define('PVE.qemu.HDInputPanel', {
 
 	if (!me.confid || me.unused) {
 	    me.bussel = Ext.create('PVE.form.ControllerSelector', {
-		vmconfig: me.insideWizard ? { ide2: 'cdrom' } : {},
+		vmconfig: me.vmconfig,
+		selectFree: true,
 	    });
 	    column1.push(me.bussel);
 
diff --git a/www/manager6/qemu/MultiHDEdit.js b/www/manager6/qemu/MultiHDEdit.js
new file mode 100644
index 00000000..caf74fad
--- /dev/null
+++ b/www/manager6/qemu/MultiHDEdit.js
@@ -0,0 +1,62 @@
+Ext.define('PVE.qemu.MultiHDPanel', {
+    extend: 'PVE.panel.MultiDiskPanel',
+    alias: 'widget.pveMultiHDPanel',
+
+    onlineHelp: 'qm_hard_disk',
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	// maxCount is the sum of all controller ids - 1 (ide2 is fixed in the wizard)
+	maxCount: Object.values(PVE.Utils.diskControllerMaxIDs)
+		.reduce((previous, current) => previous+current, 0) - 1,
+
+	getNextFreeDisk: function(vmconfig) {
+	    let clist = PVE.Utils.sortByPreviousUsage(vmconfig);
+	    return PVE.Utils.nextFreeDisk(clist, vmconfig);
+	},
+
+	addPanel: function(itemId, vmconfig, nextFreeDisk) {
+	    let me = this;
+	    return me.getView().add({
+		vmconfig,
+		border: false,
+		showAdvanced: Ext.state.Manager.getProvider().get('proxmox-advanced-cb'),
+		xtype: 'pveQemuHDInputPanel',
+		bind: {
+		    nodename: '{nodename}',
+		},
+		padding: '0 0 0 5',
+		itemId,
+		isCreate: true,
+		insideWizard: true,
+	    });
+	},
+
+	getBaseVMConfig: function() {
+	    let me = this;
+	    let vm = me.getViewModel();
+
+	    return {
+		ide2: 'media=cdrom',
+		scsihw: vm.get('current.scsihw'),
+		ostype: vm.get('current.ostype'),
+	    };
+	},
+
+	diskSorter: {
+	    sorterFn: function(rec1, rec2) {
+		let [, name1, id1] = PVE.Utils.bus_match.exec(rec1.data.name);
+		let [, name2, id2] = PVE.Utils.bus_match.exec(rec2.data.name);
+
+		if (name1 === name2) {
+		    return parseInt(id1, 10) - parseInt(id2, 10);
+		}
+
+		return name1 < name2 ? -1 : 1;
+	    },
+	},
+
+	deleteDisabled: () => false,
+    },
+});
-- 
2.30.2





  parent reply	other threads:[~2021-10-05 11:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 11:28 [pve-devel] [PATCH manager v3 0/7] multi disk/mp in wizard Dominik Csapak
2021-10-05 11:28 ` [pve-devel] [PATCH manager v3 1/7] ui: lxc/MPEdit: add updateVMConfig Dominik Csapak
2021-10-05 11:28 ` [pve-devel] [PATCH manager v3 2/7] ui: lxc/MPEdit: fire diskidchange event Dominik Csapak
2021-10-05 11:28 ` [pve-devel] [PATCH manager v3 3/7] ui: lxc/MPEdit: add selectFree toggle Dominik Csapak
2021-10-05 11:29 ` [pve-devel] [PATCH manager v3 4/7] ui: add MultiDiskPanel Dominik Csapak
2021-10-05 11:29 ` [pve-devel] [PATCH manager v3 5/7] ui: add lxc/MultiMPEdit and use in lxc/CreateWizard Dominik Csapak
2021-10-05 11:29 ` Dominik Csapak [this message]
2021-10-05 11:29 ` [pve-devel] [PATCH manager v3 7/7] ui: window/Wizard: make it a little wider Dominik Csapak
2021-10-19 13:53 ` [pve-devel] [PATCH manager v3 0/7] multi disk/mp in wizard Lorenz Stechauner
2021-10-20 10:10 ` Aaron Lauterer
2021-11-05 13:13 ` [pve-devel] applied-series: " 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=20211005112903.3649291-7-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