]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/MultiMPEdit.js
ui: lxc resources: support font awesome icons directly
[pve-manager.git] / www / manager6 / lxc / MultiMPEdit.js
1 Ext.define('PVE.lxc.MultiMPPanel', {
2 extend: 'PVE.panel.MultiDiskPanel',
3 alias: 'widget.pveMultiMPPanel',
4
5 onlineHelp: 'pct_container_storage',
6
7 controller: {
8 xclass: 'Ext.app.ViewController',
9
10 // count of mps + rootfs
11 maxCount: PVE.Utils.mp_counts.mps + 1,
12
13 getNextFreeDisk: function(vmconfig) {
14 let nextFreeDisk;
15 if (!vmconfig.rootfs) {
16 return {
17 confid: 'rootfs',
18 };
19 } else {
20 for (let i = 0; i < PVE.Utils.mp_counts.mps; i++) {
21 let confid = `mp${i}`;
22 if (!vmconfig[confid]) {
23 nextFreeDisk = {
24 confid,
25 };
26 break;
27 }
28 }
29 }
30 return nextFreeDisk;
31 },
32
33 addPanel: function(itemId, vmconfig, nextFreeDisk) {
34 let me = this;
35 return me.getView().add({
36 vmconfig,
37 border: false,
38 showAdvanced: Ext.state.Manager.getProvider().get('proxmox-advanced-cb'),
39 xtype: 'pveLxcMountPointInputPanel',
40 confid: nextFreeDisk.confid === 'rootfs' ? 'rootfs' : null,
41 bind: {
42 nodename: '{nodename}',
43 unprivileged: '{unprivileged}',
44 },
45 padding: '0 5 0 10',
46 itemId,
47 selectFree: true,
48 isCreate: true,
49 insideWizard: true,
50 });
51 },
52
53 getBaseVMConfig: function() {
54 let me = this;
55
56 return {
57 unprivileged: me.getViewModel().get('unprivileged'),
58 };
59 },
60
61 diskSorter: {
62 sorterFn: function(rec1, rec2) {
63 if (rec1.data.name === 'rootfs') {
64 return -1;
65 } else if (rec2.data.name === 'rootfs') {
66 return 1;
67 }
68
69 let mp_match = /^mp(\d+)$/;
70 let [, id1] = mp_match.exec(rec1.data.name);
71 let [, id2] = mp_match.exec(rec2.data.name);
72
73 return parseInt(id1, 10) - parseInt(id2, 10);
74 },
75 },
76
77 deleteDisabled: (view, rI, cI, item, rec) => rec.data.name === 'rootfs',
78 },
79 });