]>
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 setVMConfig: function(vmconfig
) {
80 let vm
= me
.getViewModel();
81 me
.vmconfig
= vmconfig
;
82 vm
.set('unpriv', vmconfig
.unprivileged
);
84 PVE
.Utils
.forEachMP((bus
, i
) => {
85 let name
= "mp" + i
.toString();
86 if (!Ext
.isDefined(vmconfig
[name
])) {
87 me
.down('field[name=mpid]').setValue(i
);
94 setNodename: function(nodename
) {
96 let vm
= me
.getViewModel();
97 vm
.set('node', nodename
);
98 me
.down('#diskstorage').setNodename(nodename
);
102 xclass
: 'Ext.app.ViewController',
105 'field[name=mpid]': {
106 change: function(field
, value
) {
111 change: function(field
, newValue
) {
117 let rec
= field
.store
.getById(newValue
);
121 me
.getViewModel().set('type', rec
.data
.type
);
125 init: function(view
) {
127 let vm
= this.getViewModel();
129 vm
.set('confid', view
.confid
);
130 vm
.set('unused', view
.unused
);
131 vm
.set('node', view
.nodename
);
132 vm
.set('unpriv', view
.unprivileged
);
133 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
135 if (view
.isCreate
) { // can be array if created from unused disk
136 vm
.set('isIncludedInBackup', true);
137 if (view
.insideWizard
) {
138 view
.filterMountOptions();
148 showStorageSelector
: false,
156 quota: function(get) {
157 return !(get('type') === 'zfs' ||
158 get('type') === 'zfspool' ||
162 hasMP: function(get) {
163 return !!get('confid') && !get('unused');
165 isRoot: function(get) {
166 return get('confid') === 'rootfs';
168 isBind: function(get) {
169 return get('mptype') === 'bind';
171 isBindOrRoot: function(get) {
172 return get('isBind') || get('isRoot');
179 xtype
: 'proxmoxintegerfield',
181 fieldLabel
: gettext('Mount Point ID'),
183 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
191 validator: function(value
) {
192 let view
= this.up('inputpanel');
193 if (!view
.rendered
) {
196 if (Ext
.isDefined(view
.vmconfig
["mp"+value
])) {
197 return "Mount point is already in use.";
203 xtype
: 'pveDiskStorageSelector',
204 itemId
: 'diskstorage',
205 storageContent
: 'rootdir',
211 hidden
: '{hideStorSelector}',
212 disabled
: '{hideStorSelector}',
220 fieldLabel
: gettext('Disk image'),
223 hidden
: '{!hideStorSelector}',
233 emptyText
: gettext('/some/path'),
236 fieldLabel
: gettext('Path'),
239 disabled
: '{isRoot}',
243 xtype
: 'proxmoxcheckbox',
245 fieldLabel
: gettext('Backup'),
248 'data-qtip': gettext('Include volume in backup job'),
252 disabled
: '{isBindOrRoot}',
253 value
: '{isIncludedInBackup}',
260 xtype
: 'proxmoxcheckbox',
264 disabled
: '{!quota}',
266 fieldLabel
: gettext('Enable quota'),
268 disable: function() {
274 xtype
: 'proxmoxcheckbox',
279 disabled
: '{isRoot}',
281 fieldLabel
: gettext('Read-only'),
284 xtype
: 'proxmoxKVComboBox',
285 name
: 'mountoptions',
286 fieldLabel
: gettext('Mount options'),
289 ['noatime', 'noatime'],
291 ['noexec', 'noexec'],
292 ['nosuid', 'nosuid'],
302 xtype
: 'proxmoxKVComboBox',
307 ['__default__', Proxmox
.Utils
.defaultText
],
308 ['1', Proxmox
.Utils
.enabledText
],
309 ['0', Proxmox
.Utils
.disabledText
],
311 value
: '__default__',
313 disabled
: '{isBind}',
318 xtype
: 'proxmoxcheckbox',
319 inputValue
: '0', // reverses the logic
321 fieldLabel
: gettext('Skip replication'),
326 Ext
.define('PVE.lxc.MountPointEdit', {
327 extend
: 'Proxmox.window.Edit',
331 initComponent: function() {
334 let nodename
= me
.pveSelNode
.data
.node
;
336 throw "no node name specified";
339 let unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
341 me
.isCreate
= me
.confid
? unused
: true;
343 let ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
347 unprivileged
: me
.unprivileged
,
348 isCreate
: me
.isCreate
,
353 subject
= gettext('Unused Disk');
354 } else if (me
.isCreate
) {
355 subject
= gettext('Mount Point');
357 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
362 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
369 success: function(response
, options
) {
370 ipanel
.setVMConfig(response
.result
.data
);
373 let value
= response
.result
.data
[me
.confid
];
374 let mp
= PVE
.Parser
.parseLxcMountPoint(value
);
376 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
380 ipanel
.setMountPoint(mp
);
381 me
.isValid(); // trigger validation