]>
Commit | Line | Data |
---|---|---|
ab2fac2f DM |
1 | var labelWidth = 120; |
2 | ||
3 | Ext.define('PVE.lxc.MemoryEdit', { | |
9fccc702 | 4 | extend: 'Proxmox.window.Edit', |
ab2fac2f | 5 | |
8058410f | 6 | initComponent: function() { |
ab2fac2f DM |
7 | var me = this; |
8 | ||
9 | Ext.apply(me, { | |
10 | subject: gettext('Memory'), | |
f6710aac | 11 | items: Ext.create('PVE.lxc.MemoryInputPanel'), |
ab2fac2f DM |
12 | }); |
13 | ||
14 | me.callParent(); | |
15 | ||
16 | me.load(); | |
f6710aac | 17 | }, |
ab2fac2f DM |
18 | }); |
19 | ||
20 | ||
21 | Ext.define('PVE.lxc.CPUEdit', { | |
9fccc702 | 22 | extend: 'Proxmox.window.Edit', |
5a2e333c FE |
23 | alias: 'widget.pveLxcCPUEdit', |
24 | ||
25 | viewModel: { | |
26 | data: { | |
27 | cgroupMode: 2, | |
28 | }, | |
29 | }, | |
ab2fac2f | 30 | |
8058410f | 31 | initComponent: function() { |
5a2e333c FE |
32 | let me = this; |
33 | me.getViewModel().set('cgroupMode', me.cgroupMode); | |
ab2fac2f DM |
34 | |
35 | Ext.apply(me, { | |
36 | subject: gettext('CPU'), | |
f6710aac | 37 | items: Ext.create('PVE.lxc.CPUInputPanel'), |
ab2fac2f DM |
38 | }); |
39 | ||
40 | me.callParent(); | |
41 | ||
42 | me.load(); | |
f6710aac | 43 | }, |
ab2fac2f DM |
44 | }); |
45 | ||
5a2e333c | 46 | // The view model of the parent shoul contain a 'cgroupMode' variable (or params for v2 are used). |
ab2fac2f | 47 | Ext.define('PVE.lxc.CPUInputPanel', { |
ef4ef788 | 48 | extend: 'Proxmox.panel.InputPanel', |
ab2fac2f DM |
49 | alias: 'widget.pveLxcCPUInputPanel', |
50 | ||
cb38d277 DC |
51 | onlineHelp: 'pct_cpu', |
52 | ||
ab2fac2f DM |
53 | insideWizard: false, |
54 | ||
5a2e333c FE |
55 | viewModel: { |
56 | formulas: { | |
57 | cpuunitsDefault: (get) => get('cgroupMode') === 1 ? 1024 : 100, | |
58 | cpuunitsMax: (get) => get('cgroupMode') === 1 ? 500000 : 10000, | |
59 | }, | |
60 | }, | |
61 | ||
92b5029f | 62 | onGetValues: function(values) { |
5a2e333c FE |
63 | let me = this; |
64 | let cpuunitsDefault = me.getViewModel().get('cpuunitsDefault'); | |
92b5029f | 65 | |
61c03387 | 66 | PVE.Utils.delete_if_default(values, 'cpulimit', '0', me.insideWizard); |
5a2e333c | 67 | PVE.Utils.delete_if_default(values, 'cpuunits', `${cpuunitsDefault}`, me.insideWizard); |
92b5029f DM |
68 | |
69 | return values; | |
70 | }, | |
71 | ||
53395db1 DC |
72 | advancedColumn1: [ |
73 | { | |
74 | xtype: 'numberfield', | |
75 | name: 'cpulimit', | |
76 | minValue: 0, | |
77 | value: '', | |
78 | step: 1, | |
79 | fieldLabel: gettext('CPU limit'), | |
80 | allowBlank: true, | |
f6710aac TL |
81 | emptyText: gettext('unlimited'), |
82 | }, | |
53395db1 DC |
83 | ], |
84 | ||
85 | advancedColumn2: [ | |
86 | { | |
87 | xtype: 'proxmoxintegerfield', | |
88 | name: 'cpuunits', | |
89 | fieldLabel: gettext('CPU units'), | |
a3b5c220 | 90 | value: '', |
53395db1 | 91 | minValue: 8, |
5a2e333c FE |
92 | maxValue: '10000', |
93 | emptyText: '100', | |
94 | bind: { | |
95 | emptyText: '{cpuunitsDefault}', | |
96 | maxValue: '{cpuunitsMax}', | |
97 | }, | |
53395db1 | 98 | labelWidth: labelWidth, |
a3b5c220 FE |
99 | deleteEmpty: true, |
100 | allowBlank: true, | |
f6710aac | 101 | }, |
53395db1 DC |
102 | ], |
103 | ||
104 | initComponent: function() { | |
ab2fac2f DM |
105 | var me = this; |
106 | ||
53395db1 DC |
107 | me.column1 = [ |
108 | { | |
109 | xtype: 'proxmoxintegerfield', | |
110 | name: 'cores', | |
92b5029f | 111 | minValue: 1, |
641da26d | 112 | maxValue: 8192, |
92b5029f DM |
113 | value: me.insideWizard ? 1 : '', |
114 | fieldLabel: gettext('Cores'), | |
115 | allowBlank: true, | |
bf96f60d | 116 | deleteEmpty: true, |
f6710aac TL |
117 | emptyText: gettext('unlimited'), |
118 | }, | |
ab2fac2f DM |
119 | ]; |
120 | ||
ab2fac2f | 121 | me.callParent(); |
f6710aac | 122 | }, |
ab2fac2f DM |
123 | }); |
124 | ||
125 | Ext.define('PVE.lxc.MemoryInputPanel', { | |
ef4ef788 | 126 | extend: 'Proxmox.panel.InputPanel', |
ab2fac2f DM |
127 | alias: 'widget.pveLxcMemoryInputPanel', |
128 | ||
cb38d277 DC |
129 | onlineHelp: 'pct_memory', |
130 | ||
ab2fac2f DM |
131 | insideWizard: false, |
132 | ||
8058410f | 133 | initComponent: function() { |
ab2fac2f DM |
134 | var me = this; |
135 | ||
136 | var items = [ | |
137 | { | |
bf96f60d | 138 | xtype: 'proxmoxintegerfield', |
ab2fac2f | 139 | name: 'memory', |
18401445 | 140 | minValue: 16, |
ab2fac2f DM |
141 | value: '512', |
142 | step: 32, | |
07de0118 | 143 | fieldLabel: gettext('Memory') + ' (MiB)', |
ab2fac2f | 144 | labelWidth: labelWidth, |
f6710aac | 145 | allowBlank: false, |
ab2fac2f DM |
146 | }, |
147 | { | |
bf96f60d | 148 | xtype: 'proxmoxintegerfield', |
ab2fac2f DM |
149 | name: 'swap', |
150 | minValue: 0, | |
ab2fac2f DM |
151 | value: '512', |
152 | step: 32, | |
07de0118 | 153 | fieldLabel: gettext('Swap') + ' (MiB)', |
ab2fac2f | 154 | labelWidth: labelWidth, |
f6710aac TL |
155 | allowBlank: false, |
156 | }, | |
ab2fac2f DM |
157 | ]; |
158 | ||
159 | if (me.insideWizard) { | |
160 | me.column1 = items; | |
161 | } else { | |
162 | me.items = items; | |
163 | } | |
2a4971d8 | 164 | |
ab2fac2f | 165 | me.callParent(); |
f6710aac | 166 | }, |
ab2fac2f | 167 | }); |