]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/MPEdit.js
c7c3870a33bae32698f0837a636165345173dd07
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();
34 confid
= "mp"+values
.mpid
;
35 } else if (me
.isCreate
) {
36 values
.file
= values
.hdstorage
+ ':' + values
.disksize
;
39 // delete unnecessary fields
41 delete values
.hdstorage
;
42 delete values
.disksize
;
43 delete values
.diskformat
;
46 res
[confid
] = PVE
.Parser
.printLxcMountPoint(values
);
51 setMountPoint: function(mp
) {
53 var vm
= this.getViewModel();
54 vm
.set('mptype', mp
.type
);
58 setVMConfig: function(vmconfig
) {
60 var vm
= me
.getViewModel();
61 me
.vmconfig
= vmconfig
;
62 vm
.set('unpriv', vmconfig
.unprivileged
);
65 PVE
.Utils
.forEachMP(function(bus
, i
) {
66 var name
= "mp" + i
.toString();
67 if (!Ext
.isDefined(vmconfig
[name
])) {
68 me
.down('field[name=mpid]').setValue(i
);
74 setNodename: function(nodename
) {
76 var vm
= me
.getViewModel();
77 vm
.set('node', nodename
);
79 me
.down('#diskstorage').setNodename(nodename
);
83 xclass
: 'Ext.app.ViewController',
87 change: function(field
, value
) {
92 change: function(field
, newValue
) {
98 var rec
= field
.store
.getById(newValue
);
103 var vm
= me
.getViewModel();
104 vm
.set('type', rec
.data
.type
);
110 init: function(view
) {
112 var vm
= this.getViewModel();
113 vm
.set('confid', view
.confid
);
114 vm
.set('unused', view
.unused
);
115 vm
.set('node', view
.nodename
);
116 vm
.set('unpriv', view
.unprivileged
);
117 vm
.set('hideStorSelector', view
.unused
|| !view
.isCreate
);
126 showStorageSelector
: false,
134 quota: function(get) {
135 return !(get('type') === 'zfs' ||
136 get('type') === 'zfspool' ||
140 hasMP: function(get) {
141 return !!get('confid') && !get('unused');
143 isRoot: function(get) {
144 return get('confid') === 'rootfs';
146 isBind: function(get) {
147 return get('mptype') === 'bind';
149 isBindOrRoot: function(get) {
150 return get('isBind') || get('isRoot');
157 xtype
: 'proxmoxintegerfield',
159 fieldLabel
: gettext('Mount Point ID'),
161 maxValue
: PVE
.Utils
.mp_counts
.mps
- 1,
169 validator: function(value
) {
170 var me
= this.up('inputpanel');
174 if (Ext
.isDefined(me
.vmconfig
["mp"+value
])) {
175 return "Mount point is already in use.";
177 /*jslint confusion: true*/
178 /* returns a string above */
183 xtype
: 'pveDiskStorageSelector',
184 itemId
: 'diskstorage',
185 storageContent
: 'rootdir',
191 hidden
: '{hideStorSelector}',
192 disabled
: '{hideStorSelector}',
200 fieldLabel
: gettext('Disk image'),
203 hidden
: '{!hideStorSelector}'
213 emptyText
: gettext('/some/path'),
216 fieldLabel
: gettext('Path'),
223 xtype
: 'proxmoxcheckbox',
225 fieldLabel
: gettext('Backup'),
228 disabled
: '{isBindOrRoot}'
235 xtype
: 'proxmoxcheckbox',
241 fieldLabel
: gettext('Enable quota'),
243 disable: function() {
249 xtype
: 'proxmoxcheckbox',
256 fieldLabel
: gettext('Read-only')
262 xtype
: 'proxmoxKVComboBox',
267 ['__default__', Proxmox
.Utils
.defaultText
],
268 ['1', Proxmox
.Utils
.enabledText
],
269 ['0', Proxmox
.Utils
.disabledText
]
271 value
: '__default__',
278 xtype
: 'proxmoxcheckbox',
279 inputValue
: '0', // reverses the logic
281 fieldLabel
: gettext('Skip replication')
286 Ext
.define('PVE.lxc.MountPointEdit', {
287 extend
: 'Proxmox.window.Edit',
291 initComponent : function() {
294 var nodename
= me
.pveSelNode
.data
.node
;
296 throw "no node name specified";
299 var unused
= me
.confid
&& me
.confid
.match(/^unused\d+$/);
301 me
.isCreate
= me
.confid
? unused
: true;
303 var ipanel
= Ext
.create('PVE.lxc.MountPointInputPanel', {
307 unprivileged
: me
.unprivileged
,
308 isCreate
: me
.isCreate
313 subject
= gettext('Unused Disk');
314 } else if (me
.isCreate
) {
315 subject
= gettext('Mount Point');
317 subject
= gettext('Mount Point') + ' (' + me
.confid
+ ')';
322 defaultFocus
: me
.confid
!== 'rootfs' ? 'textfield[name=mp]' : 'tool',
329 success: function(response
, options
) {
330 ipanel
.setVMConfig(response
.result
.data
);
332 /*jslint confusion: true*/
333 /*data is defined as array above*/
334 var value
= response
.result
.data
[me
.confid
];
335 /*jslint confusion: false*/
336 var mp
= PVE
.Parser
.parseLxcMountPoint(value
);
339 Ext
.Msg
.alert(gettext('Error'), 'Unable to parse mount point options');
344 ipanel
.setMountPoint(mp
);
345 me
.isValid(); // trigger validation