]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/CreateWizard.js
1 Ext
.define('PVE.lxc.CreateWizard', {
2 extend
: 'PVE.window.Wizard',
3 mixins
: ['Proxmox.Mixin.CBind'],
17 subject
: gettext('LXC Container'),
22 title
: gettext('General'),
23 onlineHelp
: 'pct_general',
26 xtype
: 'pveNodeSelector',
29 selectCurNode
: '{!nodename}',
30 preferredValue
: '{nodename}'
35 fieldLabel
: gettext('Node'),
40 xtype
: 'pveGuestIDSelector',
41 name
: 'vmid', // backend only knows vmid
48 xtype
: 'proxmoxtextfield',
52 fieldLabel
: gettext('Hostname'),
57 xtype
: 'proxmoxcheckbox',
61 value
: '{unprivileged}'
63 fieldLabel
: gettext('Unprivileged container')
68 xtype
: 'pvePoolSelector',
69 fieldLabel
: gettext('Resource Pool'),
76 inputType
: 'password',
79 fieldLabel
: gettext('Password'),
82 change: function(f
, value
) {
84 f
.up().down('field[name=confirmpw]').validate();
90 inputType
: 'password',
93 fieldLabel
: gettext('Confirm password'),
96 validator: function(value
) {
97 var pw
= this.up().down('field[name=password]').getValue();
99 return "Passwords do not match!";
105 xtype
: 'proxmoxtextfield',
106 name
: 'ssh-public-keys',
108 fieldLabel
: gettext('SSH public key'),
110 validator: function(value
) {
111 var pwfield
= this.up().down('field[name=password]');
113 var key
= PVE
.Parser
.parseSSHKey(value
);
115 return "Failed to recognize ssh key";
117 pwfield
.allowBlank
= true;
119 pwfield
.allowBlank
= false;
124 afterRender: function() {
125 if (!window
.FileReader
) {
126 // No FileReader support in this browser
129 var cancel = function(ev
) {
131 if (ev
.preventDefault
) {
136 field
.inputEl
.on('dragover', cancel
);
137 field
.inputEl
.on('dragenter', cancel
);
138 field
.inputEl
.on('drop', function(ev
) {
140 if (ev
.preventDefault
) {
143 var files
= ev
.dataTransfer
.files
;
144 PVE
.Utils
.loadSSHKeyFromFile(files
[0], function(v
) {
153 hidden
: !window
.FileReader
,
154 text
: gettext('Load SSH Key File'),
156 change: function(btn
, e
, value
) {
158 var field
= this.up().down('proxmoxtextfield[name=ssh-public-keys]');
159 PVE
.Utils
.loadSSHKeyFromFile(e
.target
.files
[0], function(v
) {
170 title
: gettext('Template'),
171 onlineHelp
: 'pct_container_images',
174 xtype
: 'pveStorageSelector',
176 fieldLabel
: gettext('Storage'),
177 storageContent
: 'vztmpl',
182 nodename
: '{nodename}'
186 xtype
: 'pveFileSelector',
188 storageContent
: 'vztmpl',
189 fieldLabel
: gettext('Template'),
191 storage
: '{storage}',
192 nodename
: '{nodename}'
199 xtype
: 'pveLxcMountPointInputPanel',
200 title
: gettext('Root Disk'),
205 nodename
: '{nodename}',
206 unprivileged
: '{unprivileged}'
211 xtype
: 'pveLxcCPUInputPanel',
212 title
: gettext('CPU'),
216 xtype
: 'pveLxcMemoryInputPanel',
217 title
: gettext('Memory'),
221 xtype
: 'pveLxcNetworkInputPanel',
222 title
: gettext('Network'),
225 nodename
: '{nodename}'
230 xtype
: 'pveLxcDNSInputPanel',
231 title
: gettext('DNS'),
235 title
: gettext('Confirm'),
248 {header
: 'Key', width
: 150, dataIndex
: 'key'},
249 {header
: 'Value', flex
: 1, dataIndex
: 'value'}
255 xtype
: 'proxmoxcheckbox',
259 boxLabel
: gettext('Start after created')
263 show: function(panel
) {
264 var wizard
= this.up('window');
265 var kv
= wizard
.getValues();
267 Ext
.Object
.each(kv
, function(key
, value
) {
268 if (key
=== 'delete' || key
=== 'tmplstorage') { // ignore
271 if (key
=== 'password') { // don't show pw
274 var html
= Ext
.htmlEncode(Ext
.JSON
.encode(value
));
275 data
.push({ key
: key
, value
: value
});
278 var summarystore
= panel
.down('grid').getStore();
279 summarystore
.suspendEvents();
280 summarystore
.removeAll();
281 summarystore
.add(data
);
283 summarystore
.resumeEvents();
284 summarystore
.fireEvent('refresh');
287 onSubmit: function() {
288 var wizard
= this.up('window');
289 var kv
= wizard
.getValues();
292 var nodename
= kv
.nodename
;
294 delete kv
.tmplstorage
;
296 if (!kv
.pool
.length
) {
300 if (!kv
.password
.length
&& kv
['ssh-public-keys']) {
304 Proxmox
.Utils
.API2Request({
305 url
: '/nodes/' + nodename
+ '/lxc',
306 waitMsgTarget
: wizard
,
309 success: function(response
, opts
){
310 var upid
= response
.result
.data
;
312 var win
= Ext
.create('Proxmox.window.TaskViewer', {
318 failure: function(response
, opts
) {
319 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);