]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/MPEdit.js
1 /* hidden: boolean and string
2 * bind: function and object
3 * disabled: boolean and string
5 Ext
.define('PVE.lxc.MountPointInputPanel', {
6 extend
: 'Proxmox.panel.InputPanel',
7 xtype
: 'pveLxcMountPointInputPanel',
11 onlineHelp
: 'pct_container_storage',
13 unused
: false, // add unused disk imaged
17 vmconfig
: {}, // used to select unused disks
19 setUnprivileged: function(unprivileged
) {
21 var vm
= me
.getViewModel();
22 me
.unprivileged
= unprivileged
;
23 vm
.set('unpriv', unprivileged
);
26 onGetValues: function(values
) {
29 var confid
= me
.confid
|| "mp"+values
.mpid
;
30 me
.mp
.file
= me
.down('field[name=file]').getValue();
33 confid
= "mp"+values
.mpid
;
34 } else if (me
.isCreate
) {
35 me
.mp
.file
= values
.hdstorage
+ ':' + values
.disksize
;
38 // delete unnecessary fields
40 delete values
.hdstorage
;
41 delete values
.disksize
;
42 delete values
.diskformat
;
44 let mountopts
= (values
.mountoptions
|| []).join(';');
45 PVE
.Utils
.propertyStringSet(me
.mp
, values
.mp
, 'mp');
46 PVE
.Utils
.propertyStringSet(me
.mp
, values
.mountoptions
, 'mountoptions', mountopts
);
47 PVE
.Utils
.propertyStringSet(me
.mp
, values
.backup
, 'backup');
48 PVE
.Utils
.propertyStringSet(me
.mp
, values
.quota
, 'quota');
49 PVE
.Utils
.propertyStringSet(me
.mp
, values
.ro
, 'ro');
50 PVE
.Utils
.propertyStringSet(me
.mp
, values
.acl
, 'acl');
51 PVE
.Utils
.propertyStringSet(me
.mp
, values
.replicate
, 'replicate');
54 res
[confid
] = PVE
.Parser
.printLxcMountPoint(me
.mp
);
59 setMountPoint: function(mp
) {
61 var vm
= this.getViewModel();
62 vm
.set('mptype', mp
.type
);
63 if (mp
.mountoptions
) {
64 mp
.mountoptions
= mp
.mountoptions
.split(';');
68 if (this.confid
=== 'rootfs') {
69 var field
= me
.down('field[name=mountoptions]');
70 var forbidden
= ['nodev', 'noexec'];
71 var filtered
= field
.comboItems
.filter(e
=> !forbidden
.includes(e
[0]));
72 field
.setComboItems(filtered
);
78 setVMConfig: function(vmconfig
) {
80 var vm
= me
.getViewModel();
81 me
.vmconfig
= vmconfig
;
82 vm
.set('unpriv', vmconfig
.unprivileged
);
84 PVE
.Utils
.forEachMP(function(bus
, i
) {
85 var name
= "mp" + i
.toString();
86 if (!Ext
.isDefined(vmconfig
[name
])) {
87 me
.down('field[name=mpid]').setValue(i
);
93 setNodename: function(nodename
) {
95 var vm
= me
.getViewModel();
96 vm
.set('node', nodename
);
97 me
.down('#diskstorage').setNodename(nodename
);
101 xclass
: 'Ext.app.ViewController',
104 'field[name=mpid]': {
105 change: function(field
, value
) {
110 change: function(field
, newValue
) {
116 var rec
= field
.store
.getById(newValue
);
121 var vm
= me
.getViewModel();
122 vm
.set('type', rec
.data
.type
);
127 init: function(view
) {
129 var vm
= this.getViewModel();
131 vm
.set('confid', view
.confid
);
132 vm
.set('unused', view
.unused
);
133 vm
.set('node', view
.nodename
);
134 vm
.set('unpriv', view
.unprivileged
);
135 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
137 // can be array if created from unused disk
139 vm
.set('isIncludedInBackup', true);
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.";
199 /* returns a string above */
204 xtype
: 'pveDiskStorageSelector',
205 itemId
: 'diskstorage',
206 storageContent
: 'rootdir',
212 hidden
: '{hideStorSelector}',
213 disabled
: '{hideStorSelector}',
221 fieldLabel
: gettext('Disk image'),
224 hidden
: '{!hideStorSelector}',
234 emptyText
: gettext('/some/path'),
237 fieldLabel
: gettext('Path'),
240 disabled
: '{isRoot}',
244 xtype
: 'proxmoxcheckbox',
246 fieldLabel
: gettext('Backup'),
249 'data-qtip': gettext('Include volume in backup job'),
253 disabled
: '{isBindOrRoot}',
254 value
: '{isIncludedInBackup}',
261 xtype
: 'proxmoxcheckbox',
265 disabled
: '{!quota}',
267 fieldLabel
: gettext('Enable quota'),
269 disable: function() {
275 xtype
: 'proxmoxcheckbox',
280 disabled
: '{isRoot}',
282 fieldLabel
: gettext('Read-only'),
285 xtype
: 'proxmoxKVComboBox',
286 name
: 'mountoptions',
287 fieldLabel
: gettext('Mount options'),
290 ['noatime', 'noatime'],
292 ['noexec', 'noexec'],
293 ['nosuid', 'nosuid'],
303 xtype
: 'proxmoxKVComboBox',
308 ['__default__', Proxmox
.Utils
.defaultText
],
309 ['1', Proxmox
.Utils
.enabledText
],
310 ['0', Proxmox
.Utils
.disabledText
],
312 value
: '__default__',
314 disabled
: '{isBind}',
319 xtype
: 'proxmoxcheckbox',
320 inputValue
: '0', // reverses the logic
322 fieldLabel
: gettext('Skip replication'),
327 Ext
.define('PVE.lxc.MountPointEdit', {
328 extend
: 'Proxmox.window.Edit',
332 initComponent: function() {
335 var nodename
= me
.pveSelNode
.data
.node
;
337 throw "no node name specified";
340 var unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
342 me
.isCreate
= me
.confid
? unused
: true;
344 var ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
348 unprivileged
: me
.unprivileged
,
349 isCreate
: me
.isCreate
,
354 subject
= gettext('Unused Disk');
355 } else if (me
.isCreate
) {
356 subject
= gettext('Mount Point');
358 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
363 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
370 success: function(response
, options
) {
371 ipanel
.setVMConfig(response
.result
.data
);
373 /*data is defined as array above*/
374 var value
= response
.result
.data
[me
.confid
];
375 var mp
= PVE
.Parser
.parseLxcMountPoint(value
);
378 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
383 ipanel
.setMountPoint(mp
);
384 me
.isValid(); // trigger validation