]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: add lxc/MultiMPEdit and use in lxc/CreateWizard
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 5 Oct 2021 11:29:01 +0000 (13:29 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Nov 2021 08:50:36 +0000 (09:50 +0100)
uses the MultiDiskPanel as a base and implements the necessary
functions/values

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Lorenz Stechauner <l.stechauner@proxmox.com>
Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
www/manager6/Makefile
www/manager6/lxc/CreateWizard.js
www/manager6/lxc/MultiMPEdit.js [new file with mode: 0644]

index 8e64badbdc6e723f14cab0b166f527c6b05360f3..8445944f28180350bd30ac0df318c1ee4b5162f7 100644 (file)
@@ -167,6 +167,7 @@ JSSRC=                                                      \
        lxc/Options.js                                  \
        lxc/ResourceEdit.js                             \
        lxc/Resources.js                                \
+       lxc/MultiMPEdit.js                              \
        menu/MenuItem.js                                \
        menu/TemplateMenu.js                            \
        ceph/CephInstallWizard.js                       \
index aead515f5a56d3ec1cd036141c2cd226d7361869..1f902c2c98d601d8628224ea75e9c6c5069ad7bd 100644 (file)
@@ -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 (file)
index 0000000..709dacb
--- /dev/null
@@ -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',
+    },
+});