]>
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 values
.file
= me
.down('field[name=file]').getValue();
32 if (values
.mountoptions
) {
33 values
.mountoptions
= values
.mountoptions
.join(';');
37 confid
= "mp"+values
.mpid
;
38 } else if (me
.isCreate
) {
39 values
.file
= values
.hdstorage
+ ':' + values
.disksize
;
42 // delete unnecessary fields
44 delete values
.hdstorage
;
45 delete values
.disksize
;
46 delete values
.diskformat
;
49 res
[confid
] = PVE
.Parser
.printLxcMountPoint(values
);
54 setMountPoint: function(mp
) {
56 var vm
= this.getViewModel();
57 vm
.set('mptype', mp
.type
);
58 if (mp
.mountoptions
) {
59 mp
.mountoptions
= mp
.mountoptions
.split(';');
62 if (this.confid
=== 'rootfs') {
63 var field
= me
.down('field[name=mountoptions]');
64 var forbidden
= ['nodev', 'noexec'];
65 var filtered
= field
.comboItems
.filter(e
=> !forbidden
.includes(e
[0]));
66 field
.setComboItems(filtered
);
72 setVMConfig: function(vmconfig
) {
74 var vm
= me
.getViewModel();
75 me
.vmconfig
= vmconfig
;
76 vm
.set('unpriv', vmconfig
.unprivileged
);
78 PVE
.Utils
.forEachMP(function(bus
, i
) {
79 var name
= "mp" + i
.toString();
80 if (!Ext
.isDefined(vmconfig
[name
])) {
81 me
.down('field[name=mpid]').setValue(i
);
87 setNodename: function(nodename
) {
89 var vm
= me
.getViewModel();
90 vm
.set('node', nodename
);
91 me
.down('#diskstorage').setNodename(nodename
);
95 xclass
: 'Ext.app.ViewController',
99 change: function(field
, value
) {
104 change: function(field
, newValue
) {
110 var rec
= field
.store
.getById(newValue
);
115 var vm
= me
.getViewModel();
116 vm
.set('type', rec
.data
.type
);
121 init: function(view
) {
123 var vm
= this.getViewModel();
124 vm
.set('confid', view
.confid
);
125 vm
.set('unused', view
.unused
);
126 vm
.set('node', view
.nodename
);
127 vm
.set('unpriv', view
.unprivileged
);
128 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
136 showStorageSelector
: false,
144 quota: function(get) {
145 return !(get('type') === 'zfs' ||
146 get('type') === 'zfspool' ||
150 hasMP: function(get) {
151 return !!get('confid') && !get('unused');
153 isRoot: function(get) {
154 return get('confid') === 'rootfs';
156 isBind: function(get) {
157 return get('mptype') === 'bind';
159 isBindOrRoot: function(get) {
160 return get('isBind') || get('isRoot');
167 xtype
: 'proxmoxintegerfield',
169 fieldLabel
: gettext('Mount Point ID'),
171 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
179 validator: function(value
) {
180 var me
= this.up('inputpanel');
184 if (Ext
.isDefined(me
.vmconfig
["mp"+value
])) {
185 return "Mount point is already in use.";
187 /*jslint confusion: true*/
188 /* returns a string above */
193 xtype
: 'pveDiskStorageSelector',
194 itemId
: 'diskstorage',
195 storageContent
: 'rootdir',
201 hidden
: '{hideStorSelector}',
202 disabled
: '{hideStorSelector}',
210 fieldLabel
: gettext('Disk image'),
213 hidden
: '{!hideStorSelector}'
223 emptyText
: gettext('/some/path'),
226 fieldLabel
: gettext('Path'),
233 xtype
: 'proxmoxcheckbox',
235 fieldLabel
: gettext('Backup'),
238 disabled
: '{isBindOrRoot}'
245 xtype
: 'proxmoxcheckbox',
251 fieldLabel
: gettext('Enable quota'),
253 disable: function() {
259 xtype
: 'proxmoxcheckbox',
266 fieldLabel
: gettext('Read-only')
269 xtype
: 'proxmoxKVComboBox',
270 name
: 'mountoptions',
271 fieldLabel
: gettext('Mount options'),
274 ['noatime', 'noatime'],
276 ['noexec', 'noexec'],
287 xtype
: 'proxmoxKVComboBox',
292 ['__default__', Proxmox
.Utils
.defaultText
],
293 ['1', Proxmox
.Utils
.enabledText
],
294 ['0', Proxmox
.Utils
.disabledText
]
296 value
: '__default__',
303 xtype
: 'proxmoxcheckbox',
304 inputValue
: '0', // reverses the logic
306 fieldLabel
: gettext('Skip replication')
311 Ext
.define('PVE.lxc.MountPointEdit', {
312 extend
: 'Proxmox.window.Edit',
316 initComponent : function() {
319 var nodename
= me
.pveSelNode
.data
.node
;
321 throw "no node name specified";
324 var unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
326 me
.isCreate
= me
.confid
? unused
: true;
328 var ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
332 unprivileged
: me
.unprivileged
,
333 isCreate
: me
.isCreate
338 subject
= gettext('Unused Disk');
339 } else if (me
.isCreate
) {
340 subject
= gettext('Mount Point');
342 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
347 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
354 success: function(response
, options
) {
355 ipanel
.setVMConfig(response
.result
.data
);
357 /*jslint confusion: true*/
358 /*data is defined as array above*/
359 var value
= response
.result
.data
[me
.confid
];
360 /*jslint confusion: false*/
361 var mp
= PVE
.Parser
.parseLxcMountPoint(value
);
364 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
369 ipanel
.setMountPoint(mp
);
370 me
.isValid(); // trigger validation