]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/MPEdit.js
1 Ext
.define('PVE.lxc.MountPointInputPanel', {
2 extend
: 'Proxmox.panel.InputPanel',
3 xtype
: 'pveLxcMountPointInputPanel',
5 onlineHelp
: 'pct_container_storage',
9 unused
: false, // add unused disk imaged
12 vmconfig
: {}, // used to select unused disks
14 setUnprivileged: function(unprivileged
) {
16 var vm
= me
.getViewModel();
17 me
.unprivileged
= unprivileged
;
18 vm
.set('unpriv', unprivileged
);
21 onGetValues: function(values
) {
24 var confid
= me
.confid
|| "mp"+values
.mpid
;
25 me
.mp
.file
= me
.down('field[name=file]').getValue();
28 confid
= "mp"+values
.mpid
;
29 } else if (me
.isCreate
) {
30 me
.mp
.file
= values
.hdstorage
+ ':' + values
.disksize
;
33 // delete unnecessary fields
35 delete values
.hdstorage
;
36 delete values
.disksize
;
37 delete values
.diskformat
;
39 let setMPOpt
= (k
, src
, v
) => PVE
.Utils
.propertyStringSet(me
.mp
, src
, k
, v
);
41 setMPOpt('mp', values
.mp
);
42 let mountOpts
= (values
.mountoptions
|| []).join(';');
43 setMPOpt('mountoptions', values
.mountoptions
, mountOpts
);
44 setMPOpt('mp', values
.mp
);
45 setMPOpt('backup', values
.backup
);
46 setMPOpt('quota', values
.quota
);
47 setMPOpt('ro', values
.ro
);
48 setMPOpt('acl', values
.acl
);
49 setMPOpt('replicate', values
.replicate
);
52 res
[confid
] = PVE
.Parser
.printLxcMountPoint(me
.mp
);
56 setMountPoint: function(mp
) {
58 let vm
= me
.getViewModel();
59 vm
.set('mptype', mp
.type
);
60 if (mp
.mountoptions
) {
61 mp
.mountoptions
= mp
.mountoptions
.split(';');
64 me
.filterMountOptions();
68 filterMountOptions: function() {
70 if (me
.confid
=== 'rootfs') {
71 let field
= me
.down('field[name=mountoptions]');
72 let exclude
= ['nodev', 'noexec'];
73 let filtered
= field
.comboItems
.filter(v
=> !exclude
.includes(v
[0]));
74 field
.setComboItems(filtered
);
78 updateVMConfig: function(vmconfig
) {
80 let vm
= me
.getViewModel();
81 me
.vmconfig
= vmconfig
;
82 vm
.set('unpriv', vmconfig
.unprivileged
);
83 me
.down('field[name=mpid]').validate();
86 setVMConfig: function(vmconfig
) {
89 me
.updateVMConfig(vmconfig
);
90 PVE
.Utils
.forEachLxcMP((bus
, i
, name
) => {
91 if (!Ext
.isDefined(vmconfig
[name
])) {
92 me
.down('field[name=mpid]').setValue(i
);
99 setNodename: function(nodename
) {
101 let vm
= me
.getViewModel();
102 vm
.set('node', nodename
);
103 me
.down('#diskstorage').setNodename(nodename
);
107 xclass
: 'Ext.app.ViewController',
110 'field[name=mpid]': {
111 change: function(field
, value
) {
113 let view
= this.getView();
114 if (view
.confid
!== 'rootfs') {
115 view
.fireEvent('diskidchange', view
, `mp${value}`);
121 change: function(field
, newValue
) {
127 let rec
= field
.store
.getById(newValue
);
131 me
.getViewModel().set('type', rec
.data
.type
);
135 init: function(view
) {
137 let vm
= this.getViewModel();
139 vm
.set('confid', view
.confid
);
140 vm
.set('unused', view
.unused
);
141 vm
.set('node', view
.nodename
);
142 vm
.set('unpriv', view
.unprivileged
);
143 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
145 if (view
.isCreate
) { // can be array if created from unused disk
146 vm
.set('isIncludedInBackup', true);
147 if (view
.insideWizard
) {
148 view
.filterMountOptions();
151 if (view
.selectFree
) {
152 view
.setVMConfig(view
.vmconfig
);
161 showStorageSelector
: false,
169 quota: function(get) {
170 return !(get('type') === 'zfs' ||
171 get('type') === 'zfspool' ||
175 hasMP: function(get) {
176 return !!get('confid') && !get('unused');
178 isRoot: function(get) {
179 return get('confid') === 'rootfs';
181 isBind: function(get) {
182 return get('mptype') === 'bind';
184 isBindOrRoot: function(get) {
185 return get('isBind') || get('isRoot');
192 xtype
: 'proxmoxintegerfield',
194 fieldLabel
: gettext('Mount Point ID'),
196 maxValue
: PVE
.Utils
.lxc_mp_counts
.mp
- 1,
204 validator: function(value
) {
205 let view
= this.up('inputpanel');
206 if (!view
.rendered
) {
209 if (Ext
.isDefined(view
.vmconfig
["mp"+value
])) {
210 return "Mount point is already in use.";
216 xtype
: 'pveDiskStorageSelector',
217 itemId
: 'diskstorage',
218 storageContent
: 'rootdir',
224 hidden
: '{hideStorSelector}',
225 disabled
: '{hideStorSelector}',
233 fieldLabel
: gettext('Disk image'),
236 hidden
: '{!hideStorSelector}',
246 emptyText
: gettext('/some/path'),
249 fieldLabel
: gettext('Path'),
252 disabled
: '{isRoot}',
256 xtype
: 'proxmoxcheckbox',
258 fieldLabel
: gettext('Backup'),
261 'data-qtip': gettext('Include volume in backup job'),
265 disabled
: '{isBindOrRoot}',
266 value
: '{isIncludedInBackup}',
273 xtype
: 'proxmoxcheckbox',
277 disabled
: '{!quota}',
279 fieldLabel
: gettext('Enable quota'),
281 disable: function() {
287 xtype
: 'proxmoxcheckbox',
292 disabled
: '{isRoot}',
294 fieldLabel
: gettext('Read-only'),
297 xtype
: 'proxmoxKVComboBox',
298 name
: 'mountoptions',
299 fieldLabel
: gettext('Mount options'),
302 ['lazytime', 'lazytime'],
303 ['noatime', 'noatime'],
305 ['noexec', 'noexec'],
306 ['nosuid', 'nosuid'],
316 xtype
: 'proxmoxKVComboBox',
321 ['__default__', Proxmox
.Utils
.defaultText
],
322 ['1', Proxmox
.Utils
.enabledText
],
323 ['0', Proxmox
.Utils
.disabledText
],
325 value
: '__default__',
327 disabled
: '{isBind}',
332 xtype
: 'proxmoxcheckbox',
333 inputValue
: '0', // reverses the logic
335 fieldLabel
: gettext('Skip replication'),
340 Ext
.define('PVE.lxc.MountPointEdit', {
341 extend
: 'Proxmox.window.Edit',
345 initComponent: function() {
348 let nodename
= me
.pveSelNode
.data
.node
;
350 throw "no node name specified";
353 let unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
355 me
.isCreate
= me
.confid
? unused
: true;
357 let ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
361 unprivileged
: me
.unprivileged
,
362 isCreate
: me
.isCreate
,
367 subject
= gettext('Unused Disk');
368 } else if (me
.isCreate
) {
369 subject
= gettext('Mount Point');
371 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
376 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
383 success: function(response
, options
) {
384 ipanel
.setVMConfig(response
.result
.data
);
387 let value
= response
.result
.data
[me
.confid
];
388 let mp
= PVE
.Parser
.parseLxcMountPoint(value
);
390 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
394 ipanel
.setMountPoint(mp
);
395 me
.isValid(); // trigger validation