]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/MPEdit.js
1 /*jslint confusion: true*/
2 /* hidden: boolean and string
3 * bind: function and object
4 * disabled: boolean and string
6 Ext
.define('PVE.lxc.MountPointInputPanel', {
7 extend
: 'Proxmox.panel.InputPanel',
8 xtype
: 'pveLxcMountPointInputPanel',
12 onlineHelp
: 'pct_container_storage',
14 unused
: false, // add unused disk imaged
18 vmconfig
: {}, // used to select unused disks
20 setUnprivileged: function(unprivileged
) {
22 var vm
= me
.getViewModel();
23 me
.unprivileged
= unprivileged
;
24 vm
.set('unpriv', unprivileged
);
27 onGetValues: function(values
) {
30 var confid
= me
.confid
|| "mp"+values
.mpid
;
31 me
.mp
.file
= me
.down('field[name=file]').getValue();
34 confid
= "mp"+values
.mpid
;
35 } else if (me
.isCreate
) {
36 me
.mp
.file
= values
.hdstorage
+ ':' + values
.disksize
;
39 // delete unnecessary fields
41 delete values
.hdstorage
;
42 delete values
.disksize
;
43 delete values
.diskformat
;
45 let mountopts
= (values
.mountoptions
|| []).join(';');
46 PVE
.Utils
.propertyStringSet(me
.mp
, values
.mp
, 'mp');
47 PVE
.Utils
.propertyStringSet(me
.mp
, values
.mountoptions
, 'mountoptions', mountopts
);
48 PVE
.Utils
.propertyStringSet(me
.mp
, values
.backup
, 'backup');
49 PVE
.Utils
.propertyStringSet(me
.mp
, values
.quota
, 'quota');
50 PVE
.Utils
.propertyStringSet(me
.mp
, values
.ro
, 'ro');
51 PVE
.Utils
.propertyStringSet(me
.mp
, values
.acl
, 'acl');
52 PVE
.Utils
.propertyStringSet(me
.mp
, values
.replicate
, 'replicate');
55 res
[confid
] = PVE
.Parser
.printLxcMountPoint(me
.mp
);
60 setMountPoint: function(mp
) {
62 var vm
= this.getViewModel();
63 vm
.set('mptype', mp
.type
);
64 if (mp
.mountoptions
) {
65 mp
.mountoptions
= mp
.mountoptions
.split(';');
69 if (this.confid
=== 'rootfs') {
70 var field
= me
.down('field[name=mountoptions]');
71 var forbidden
= ['nodev', 'noexec'];
72 var filtered
= field
.comboItems
.filter(e
=> !forbidden
.includes(e
[0]));
73 field
.setComboItems(filtered
);
79 setVMConfig: function(vmconfig
) {
81 var vm
= me
.getViewModel();
82 me
.vmconfig
= vmconfig
;
83 vm
.set('unpriv', vmconfig
.unprivileged
);
85 PVE
.Utils
.forEachMP(function(bus
, i
) {
86 var name
= "mp" + i
.toString();
87 if (!Ext
.isDefined(vmconfig
[name
])) {
88 me
.down('field[name=mpid]').setValue(i
);
94 setNodename: function(nodename
) {
96 var 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 var rec
= field
.store
.getById(newValue
);
122 var vm
= me
.getViewModel();
123 vm
.set('type', rec
.data
.type
);
128 init: function(view
) {
130 var vm
= this.getViewModel();
132 vm
.set('confid', view
.confid
);
133 vm
.set('unused', view
.unused
);
134 vm
.set('node', view
.nodename
);
135 vm
.set('unpriv', view
.unprivileged
);
136 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
138 // can be array if created from unused disk
140 vm
.set('isIncludedInBackup', true);
149 showStorageSelector
: false,
157 quota: function(get) {
158 return !(get('type') === 'zfs' ||
159 get('type') === 'zfspool' ||
163 hasMP: function(get) {
164 return !!get('confid') && !get('unused');
166 isRoot: function(get) {
167 return get('confid') === 'rootfs';
169 isBind: function(get) {
170 return get('mptype') === 'bind';
172 isBindOrRoot: function(get) {
173 return get('isBind') || get('isRoot');
180 xtype
: 'proxmoxintegerfield',
182 fieldLabel
: gettext('Mount Point ID'),
184 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
192 validator: function(value
) {
193 var me
= this.up('inputpanel');
197 if (Ext
.isDefined(me
.vmconfig
["mp"+value
])) {
198 return "Mount point is already in use.";
200 /*jslint confusion: true*/
201 /* returns a string above */
206 xtype
: 'pveDiskStorageSelector',
207 itemId
: 'diskstorage',
208 storageContent
: 'rootdir',
214 hidden
: '{hideStorSelector}',
215 disabled
: '{hideStorSelector}',
223 fieldLabel
: gettext('Disk image'),
226 hidden
: '{!hideStorSelector}'
236 emptyText
: gettext('/some/path'),
239 fieldLabel
: gettext('Path'),
246 xtype
: 'proxmoxcheckbox',
248 fieldLabel
: gettext('Backup'),
251 'data-qtip': gettext('Include volume in backup job'),
255 disabled
: '{isBindOrRoot}',
256 value
: '{isIncludedInBackup}'
263 xtype
: 'proxmoxcheckbox',
269 fieldLabel
: gettext('Enable quota'),
271 disable: function() {
277 xtype
: 'proxmoxcheckbox',
284 fieldLabel
: gettext('Read-only')
287 xtype
: 'proxmoxKVComboBox',
288 name
: 'mountoptions',
289 fieldLabel
: gettext('Mount options'),
292 ['noatime', 'noatime'],
294 ['noexec', 'noexec'],
305 xtype
: 'proxmoxKVComboBox',
310 ['__default__', Proxmox
.Utils
.defaultText
],
311 ['1', Proxmox
.Utils
.enabledText
],
312 ['0', Proxmox
.Utils
.disabledText
]
314 value
: '__default__',
321 xtype
: 'proxmoxcheckbox',
322 inputValue
: '0', // reverses the logic
324 fieldLabel
: gettext('Skip replication')
329 Ext
.define('PVE.lxc.MountPointEdit', {
330 extend
: 'Proxmox.window.Edit',
334 initComponent : function() {
337 var nodename
= me
.pveSelNode
.data
.node
;
339 throw "no node name specified";
342 var unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
344 me
.isCreate
= me
.confid
? unused
: true;
346 var ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
350 unprivileged
: me
.unprivileged
,
351 isCreate
: me
.isCreate
356 subject
= gettext('Unused Disk');
357 } else if (me
.isCreate
) {
358 subject
= gettext('Mount Point');
360 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
365 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
372 success: function(response
, options
) {
373 ipanel
.setVMConfig(response
.result
.data
);
375 /*jslint confusion: true*/
376 /*data is defined as array above*/
377 var value
= response
.result
.data
[me
.confid
];
378 /*jslint confusion: false*/
379 var mp
= PVE
.Parser
.parseLxcMountPoint(value
);
382 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
387 ipanel
.setMountPoint(mp
);
388 me
.isValid(); // trigger validation