]>
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
.forEachMP((bus
, i
) => {
91 let name
= "mp" + i
.toString();
92 if (!Ext
.isDefined(vmconfig
[name
])) {
93 me
.down('field[name=mpid]').setValue(i
);
100 setNodename: function(nodename
) {
102 let vm
= me
.getViewModel();
103 vm
.set('node', nodename
);
104 me
.down('#diskstorage').setNodename(nodename
);
108 xclass
: 'Ext.app.ViewController',
111 'field[name=mpid]': {
112 change: function(field
, value
) {
114 let view
= this.getView();
115 if (view
.confid
!== 'rootfs') {
116 view
.fireEvent('diskidchange', view
, `mp${value}`);
122 change: function(field
, newValue
) {
128 let rec
= field
.store
.getById(newValue
);
132 me
.getViewModel().set('type', rec
.data
.type
);
136 init: function(view
) {
138 let vm
= this.getViewModel();
140 vm
.set('confid', view
.confid
);
141 vm
.set('unused', view
.unused
);
142 vm
.set('node', view
.nodename
);
143 vm
.set('unpriv', view
.unprivileged
);
144 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
146 if (view
.isCreate
) { // can be array if created from unused disk
147 vm
.set('isIncludedInBackup', true);
148 if (view
.insideWizard
) {
149 view
.filterMountOptions();
152 if (view
.selectFree
) {
153 view
.setVMConfig(view
.vmconfig
);
162 showStorageSelector
: false,
170 quota: function(get) {
171 return !(get('type') === 'zfs' ||
172 get('type') === 'zfspool' ||
176 hasMP: function(get) {
177 return !!get('confid') && !get('unused');
179 isRoot: function(get) {
180 return get('confid') === 'rootfs';
182 isBind: function(get) {
183 return get('mptype') === 'bind';
185 isBindOrRoot: function(get) {
186 return get('isBind') || get('isRoot');
193 xtype
: 'proxmoxintegerfield',
195 fieldLabel
: gettext('Mount Point ID'),
197 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
205 validator: function(value
) {
206 let view
= this.up('inputpanel');
207 if (!view
.rendered
) {
210 if (Ext
.isDefined(view
.vmconfig
["mp"+value
])) {
211 return "Mount point is already in use.";
217 xtype
: 'pveDiskStorageSelector',
218 itemId
: 'diskstorage',
219 storageContent
: 'rootdir',
225 hidden
: '{hideStorSelector}',
226 disabled
: '{hideStorSelector}',
234 fieldLabel
: gettext('Disk image'),
237 hidden
: '{!hideStorSelector}',
247 emptyText
: gettext('/some/path'),
250 fieldLabel
: gettext('Path'),
253 disabled
: '{isRoot}',
257 xtype
: 'proxmoxcheckbox',
259 fieldLabel
: gettext('Backup'),
262 'data-qtip': gettext('Include volume in backup job'),
266 disabled
: '{isBindOrRoot}',
267 value
: '{isIncludedInBackup}',
274 xtype
: 'proxmoxcheckbox',
278 disabled
: '{!quota}',
280 fieldLabel
: gettext('Enable quota'),
282 disable: function() {
288 xtype
: 'proxmoxcheckbox',
293 disabled
: '{isRoot}',
295 fieldLabel
: gettext('Read-only'),
298 xtype
: 'proxmoxKVComboBox',
299 name
: 'mountoptions',
300 fieldLabel
: gettext('Mount options'),
303 ['lazytime', 'lazytime'],
304 ['noatime', 'noatime'],
306 ['noexec', 'noexec'],
307 ['nosuid', 'nosuid'],
317 xtype
: 'proxmoxKVComboBox',
322 ['__default__', Proxmox
.Utils
.defaultText
],
323 ['1', Proxmox
.Utils
.enabledText
],
324 ['0', Proxmox
.Utils
.disabledText
],
326 value
: '__default__',
328 disabled
: '{isBind}',
333 xtype
: 'proxmoxcheckbox',
334 inputValue
: '0', // reverses the logic
336 fieldLabel
: gettext('Skip replication'),
341 Ext
.define('PVE.lxc.MountPointEdit', {
342 extend
: 'Proxmox.window.Edit',
346 initComponent: function() {
349 let nodename
= me
.pveSelNode
.data
.node
;
351 throw "no node name specified";
354 let unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
356 me
.isCreate
= me
.confid
? unused
: true;
358 let ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
362 unprivileged
: me
.unprivileged
,
363 isCreate
: me
.isCreate
,
368 subject
= gettext('Unused Disk');
369 } else if (me
.isCreate
) {
370 subject
= gettext('Mount Point');
372 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
377 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
384 success: function(response
, options
) {
385 ipanel
.setVMConfig(response
.result
.data
);
388 let value
= response
.result
.data
[me
.confid
];
389 let mp
= PVE
.Parser
.parseLxcMountPoint(value
);
391 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
395 ipanel
.setMountPoint(mp
);
396 me
.isValid(); // trigger validation