]>
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
);
144 showStorageSelector
: false,
152 quota: function(get) {
153 return !(get('type') === 'zfs' ||
154 get('type') === 'zfspool' ||
158 hasMP: function(get) {
159 return !!get('confid') && !get('unused');
161 isRoot: function(get) {
162 return get('confid') === 'rootfs';
164 isBind: function(get) {
165 return get('mptype') === 'bind';
167 isBindOrRoot: function(get) {
168 return get('isBind') || get('isRoot');
175 xtype
: 'proxmoxintegerfield',
177 fieldLabel
: gettext('Mount Point ID'),
179 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
187 validator: function(value
) {
188 var me
= this.up('inputpanel');
192 if (Ext
.isDefined(me
.vmconfig
["mp"+value
])) {
193 return "Mount point is already in use.";
195 /*jslint confusion: true*/
196 /* returns a string above */
201 xtype
: 'pveDiskStorageSelector',
202 itemId
: 'diskstorage',
203 storageContent
: 'rootdir',
209 hidden
: '{hideStorSelector}',
210 disabled
: '{hideStorSelector}',
218 fieldLabel
: gettext('Disk image'),
221 hidden
: '{!hideStorSelector}'
231 emptyText
: gettext('/some/path'),
234 fieldLabel
: gettext('Path'),
241 xtype
: 'proxmoxcheckbox',
243 fieldLabel
: gettext('Backup'),
246 disabled
: '{isBindOrRoot}'
253 xtype
: 'proxmoxcheckbox',
259 fieldLabel
: gettext('Enable quota'),
261 disable: function() {
267 xtype
: 'proxmoxcheckbox',
274 fieldLabel
: gettext('Read-only')
277 xtype
: 'proxmoxKVComboBox',
278 name
: 'mountoptions',
279 fieldLabel
: gettext('Mount options'),
282 ['noatime', 'noatime'],
284 ['noexec', 'noexec'],
295 xtype
: 'proxmoxKVComboBox',
300 ['__default__', Proxmox
.Utils
.defaultText
],
301 ['1', Proxmox
.Utils
.enabledText
],
302 ['0', Proxmox
.Utils
.disabledText
]
304 value
: '__default__',
311 xtype
: 'proxmoxcheckbox',
312 inputValue
: '0', // reverses the logic
314 fieldLabel
: gettext('Skip replication')
319 Ext
.define('PVE.lxc.MountPointEdit', {
320 extend
: 'Proxmox.window.Edit',
324 initComponent : function() {
327 var nodename
= me
.pveSelNode
.data
.node
;
329 throw "no node name specified";
332 var unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
334 me
.isCreate
= me
.confid
? unused
: true;
336 var ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
340 unprivileged
: me
.unprivileged
,
341 isCreate
: me
.isCreate
346 subject
= gettext('Unused Disk');
347 } else if (me
.isCreate
) {
348 subject
= gettext('Mount Point');
350 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
355 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
362 success: function(response
, options
) {
363 ipanel
.setVMConfig(response
.result
.data
);
365 /*jslint confusion: true*/
366 /*data is defined as array above*/
367 var value
= response
.result
.data
[me
.confid
];
368 /*jslint confusion: false*/
369 var mp
= PVE
.Parser
.parseLxcMountPoint(value
);
372 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
377 ipanel
.setMountPoint(mp
);
378 me
.isValid(); // trigger validation