From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 1A22471CC4
 for <pve-devel@lists.proxmox.com>; Tue,  5 Oct 2021 13:29:37 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0E704274B0
 for <pve-devel@lists.proxmox.com>; Tue,  5 Oct 2021 13:29:07 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (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 9863227494
 for <pve-devel@lists.proxmox.com>; Tue,  5 Oct 2021 13:29:05 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6EEF7456AA
 for <pve-devel@lists.proxmox.com>; Tue,  5 Oct 2021 13:29:05 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue,  5 Oct 2021 13:29:01 +0200
Message-Id: <20211005112903.3649291-6-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20211005112903.3649291-1-d.csapak@proxmox.com>
References: <20211005112903.3649291-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.312 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [data.name]
Subject: [pve-devel] [PATCH manager v3 5/7] ui: add lxc/MultiMPEdit and use
 in lxc/CreateWizard
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 05 Oct 2021 11:29:37 -0000

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