]>
Commit | Line | Data |
---|---|---|
aff192e6 DM |
1 | // fixme: howto avoid jslint type confusion? |
2 | /*jslint confusion: true */ | |
3 | Ext.define('PVE.qemu.CreateWizard', { | |
4 | extend: 'PVE.window.Wizard', | |
aff192e6 DM |
5 | |
6 | initComponent: function() { | |
7 | var me = this; | |
8 | ||
aff192e6 DM |
9 | var summarystore = Ext.create('Ext.data.Store', { |
10 | model: 'KeyValue', | |
11 | sorters: [ | |
12 | { | |
13 | property : 'key', | |
14 | direction: 'ASC' | |
15 | } | |
16 | ] | |
17 | }); | |
18 | ||
19 | var cdpanel = Ext.create('PVE.qemu.CDInputPanel', { | |
0070ee37 | 20 | title: gettext('CD/DVD'), |
aff192e6 | 21 | confid: 'ide2', |
4388ec5c DM |
22 | fieldDefaults: { |
23 | labelWidth: 160 | |
24 | }, | |
aff192e6 DM |
25 | insideWizard: true |
26 | }); | |
27 | ||
28 | var hdpanel = Ext.create('PVE.qemu.HDInputPanel', { | |
f3bb9bb6 | 29 | title: gettext('Hard Disk'), |
aff192e6 DM |
30 | create: true, |
31 | insideWizard: true | |
32 | }); | |
33 | ||
34 | var networkpanel = Ext.create('PVE.qemu.NetworkInputPanel', { | |
f3bb9bb6 | 35 | title: gettext('Network'), |
aff192e6 DM |
36 | insideWizard: true |
37 | }); | |
38 | ||
39 | Ext.applyIf(me, { | |
58eb5905 | 40 | subject: gettext('Virtual Machine'), |
aff192e6 DM |
41 | items: [ |
42 | { | |
43 | xtype: 'inputpanel', | |
f3bb9bb6 | 44 | title: gettext('General'), |
aff192e6 DM |
45 | column1: [ |
46 | { | |
47 | xtype: 'PVE.form.NodeSelector', | |
48 | name: 'nodename', | |
91b0d3c2 | 49 | selectCurNode: true, |
f3bb9bb6 | 50 | fieldLabel: gettext('Node'), |
aff192e6 DM |
51 | allowBlank: false, |
52 | onlineValidator: true, | |
53 | listeners: { | |
54 | change: function(f, value) { | |
55 | networkpanel.setNodename(value); | |
56 | hdpanel.setNodename(value); | |
57 | cdpanel.setNodename(value); | |
58 | } | |
59 | } | |
60 | }, | |
61 | { | |
04f5d98e | 62 | xtype: 'pveVMIDSelector', |
aff192e6 | 63 | name: 'vmid', |
e893439e DM |
64 | value: '', |
65 | loadNextFreeVMID: true, | |
04f5d98e | 66 | validateExists: false |
aff192e6 DM |
67 | }, |
68 | { | |
69 | xtype: 'textfield', | |
70 | name: 'name', | |
b2fe56d8 | 71 | vtype: 'DnsName', |
aff192e6 | 72 | value: '', |
f3bb9bb6 | 73 | fieldLabel: gettext('Name'), |
aff192e6 DM |
74 | allowBlank: true |
75 | } | |
76 | ], | |
6caab4e0 DM |
77 | column2: [ |
78 | { | |
79 | xtype: 'pvePoolSelector', | |
80 | fieldLabel: gettext('Resource Pool'), | |
81 | name: 'pool', | |
82 | value: '', | |
83 | allowBlank: true | |
b34b68c2 | 84 | } |
6caab4e0 | 85 | ], |
aff192e6 DM |
86 | onGetValues: function(values) { |
87 | if (!values.name) { | |
88 | delete values.name; | |
89 | } | |
6caab4e0 DM |
90 | if (!values.pool) { |
91 | delete values.pool; | |
92 | } | |
aff192e6 DM |
93 | return values; |
94 | } | |
95 | }, | |
96 | { | |
0070ee37 | 97 | title: gettext('OS'), |
aff192e6 DM |
98 | xtype: 'PVE.qemu.OSTypeInputPanel' |
99 | }, | |
100 | cdpanel, | |
101 | hdpanel, | |
102 | { | |
103 | xtype: 'PVE.qemu.ProcessorInputPanel', | |
0070ee37 | 104 | title: gettext('CPU') |
aff192e6 DM |
105 | }, |
106 | { | |
107 | xtype: 'PVE.qemu.MemoryInputPanel', | |
108 | insideWizard: true, | |
f3bb9bb6 | 109 | title: gettext('Memory') |
aff192e6 DM |
110 | }, |
111 | networkpanel, | |
112 | { | |
f3bb9bb6 | 113 | title: gettext('Confirm'), |
aff192e6 DM |
114 | layout: 'fit', |
115 | items: [ | |
116 | { | |
f3bb9bb6 | 117 | title: gettext('Settings'), |
aff192e6 DM |
118 | xtype: 'grid', |
119 | store: summarystore, | |
120 | columns: [ | |
121 | {header: 'Key', width: 150, dataIndex: 'key'}, | |
122 | {header: 'Value', flex: 1, dataIndex: 'value'} | |
123 | ] | |
124 | } | |
125 | ], | |
126 | listeners: { | |
127 | show: function(panel) { | |
128 | var form = me.down('form').getForm(); | |
129 | var kv = me.getValues(); | |
130 | var data = []; | |
131 | Ext.Object.each(kv, function(key, value) { | |
132 | if (key === 'delete') { // ignore | |
133 | return; | |
134 | } | |
135 | var html = Ext.htmlEncode(Ext.JSON.encode(value)); | |
136 | data.push({ key: key, value: value }); | |
137 | }); | |
138 | summarystore.suspendEvents(); | |
139 | summarystore.removeAll(); | |
140 | summarystore.add(data); | |
141 | summarystore.sort(); | |
142 | summarystore.resumeEvents(); | |
143 | summarystore.fireEvent('datachanged', summarystore); | |
144 | ||
145 | } | |
146 | }, | |
147 | onSubmit: function() { | |
148 | var kv = me.getValues(); | |
149 | delete kv['delete']; | |
150 | ||
151 | var nodename = kv.nodename; | |
152 | delete kv.nodename; | |
153 | ||
154 | PVE.Utils.API2Request({ | |
155 | url: '/nodes/' + nodename + '/qemu', | |
156 | waitMsgTarget: me, | |
157 | method: 'POST', | |
158 | params: kv, | |
159 | success: function(response){ | |
160 | me.close(); | |
161 | }, | |
162 | failure: function(response, opts) { | |
f3bb9bb6 | 163 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); |
aff192e6 DM |
164 | } |
165 | }); | |
166 | } | |
167 | } | |
168 | ] | |
169 | }); | |
170 | ||
171 | me.callParent(); | |
172 | } | |
173 | }); | |
174 | ||
175 | ||
176 | ||
177 |