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

uses the MultiDiskPanel as a base and implements the necessary
functions/values

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/Makefile            |  1 +
 www/manager6/lxc/CreateWizard.js |  8 +---
 www/manager6/lxc/MultiMPEdit.js  | 79 ++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 6 deletions(-)
 create mode 100644 www/manager6/lxc/MultiMPEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index dc045e73..3b9b057a 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -166,6 +166,7 @@ JSSRC= 							\
 	lxc/Options.js					\
 	lxc/ResourceEdit.js				\
 	lxc/Resources.js				\
+	lxc/MultiMPEdit.js				\
 	menu/MenuItem.js				\
 	menu/TemplateMenu.js				\
 	ceph/CephInstallWizard.js			\
diff --git a/www/manager6/lxc/CreateWizard.js b/www/manager6/lxc/CreateWizard.js
index aead515f..1f902c2c 100644
--- a/www/manager6/lxc/CreateWizard.js
+++ b/www/manager6/lxc/CreateWizard.js
@@ -197,15 +197,11 @@ Ext.define('PVE.lxc.CreateWizard', {
 	    ],
 	},
 	{
-	    xtype: 'pveLxcMountPointInputPanel',
-	    title: gettext('Root Disk'),
+	    xtype: 'pveMultiMPPanel',
+	    title: gettext('Disks'),
 	    insideWizard: true,
 	    isCreate: true,
 	    unused: false,
-	    bind: {
-		nodename: '{nodename}',
-		unprivileged: '{unprivileged}',
-	    },
 	    confid: 'rootfs',
 	},
 	{
diff --git a/www/manager6/lxc/MultiMPEdit.js b/www/manager6/lxc/MultiMPEdit.js
new file mode 100644
index 00000000..709dacb1
--- /dev/null
+++ b/www/manager6/lxc/MultiMPEdit.js
@@ -0,0 +1,79 @@
+Ext.define('PVE.lxc.MultiMPPanel', {
+    extend: 'PVE.panel.MultiDiskPanel',
+    alias: 'widget.pveMultiMPPanel',
+
+    onlineHelp: 'pct_container_storage',
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	// count of mps + rootfs
+	maxCount: PVE.Utils.mp_counts.mps + 1,
+
+	getNextFreeDisk: function(vmconfig) {
+	    let nextFreeDisk;
+	    if (!vmconfig.rootfs) {
+		return {
+		    confid: 'rootfs',
+		};
+	    } else {
+		for (let i = 0; i < PVE.Utils.mp_counts.mps; i++) {
+		    let confid = `mp${i}`;
+		    if (!vmconfig[confid]) {
+			nextFreeDisk = {
+			    confid,
+			};
+			break;
+		    }
+		}
+	    }
+	    return nextFreeDisk;
+	},
+
+	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: 'pveLxcMountPointInputPanel',
+		confid: nextFreeDisk.confid === 'rootfs' ? 'rootfs' : null,
+		bind: {
+		    nodename: '{nodename}',
+		    unprivileged: '{unprivileged}',
+		},
+		padding: '0 5 0 10',
+		itemId,
+		selectFree: true,
+		isCreate: true,
+		insideWizard: true,
+	    });
+	},
+
+	getBaseVMConfig: function() {
+	    let me = this;
+
+	    return {
+		unprivileged: me.getViewModel().get('unprivileged'),
+	    };
+	},
+
+	diskSorter: {
+	    sorterFn: function(rec1, rec2) {
+		if (rec1.data.name === 'rootfs') {
+		    return -1;
+		} else if (rec2.data.name === 'rootfs') {
+		    return 1;
+		}
+
+		let mp_match = /^mp(\d+)$/;
+		let [, id1] = mp_match.exec(rec1.data.name);
+		let [, id2] = mp_match.exec(rec2.data.name);
+
+		return parseInt(id1, 10) - parseInt(id2, 10);
+	    },
+	},
+
+	deleteDisabled: (view, rI, cI, item, rec) => rec.data.name === 'rootfs',
+    },
+});
-- 
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 ` Dominik Csapak [this message]
2021-10-05 11:29 ` [pve-devel] [PATCH manager v3 6/7] ui: add qemu/MultiHDEdit and use it in the wizard Dominik Csapak
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-6-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