]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/IPConfigEdit.js
update shipped appliance info index
[pve-manager.git] / www / manager6 / qemu / IPConfigEdit.js
CommitLineData
01e02121
DC
1Ext.define('PVE.qemu.IPConfigPanel', {
2 extend: 'Proxmox.panel.InputPanel',
3 xtype: 'pveIPConfigPanel',
4
5 insideWizard: false,
6
7 vmconfig: {},
8
9 onGetValues: function(values) {
10 var me = this;
11
12 if (values.ipv4mode !== 'static') {
13 values.ip = values.ipv4mode;
14 }
15
16 if (values.ipv6mode !== 'static') {
17 values.ip6 = values.ipv6mode;
18 }
19
20 var params = {};
21
22 var cfg = PVE.Parser.printIPConfig(values);
23 if (cfg === '') {
399ffa76 24 params.delete = [me.confid];
01e02121
DC
25 } else {
26 params[me.confid] = cfg;
27 }
28 return params;
29 },
30
31 setVMConfig: function(config) {
32 var me = this;
33 me.vmconfig = config;
34 },
35
36 setIPConfig: function(confid, data) {
37 var me = this;
38
39 me.confid = confid;
40
41 if (data.ip === 'dhcp') {
42 data.ipv4mode = data.ip;
43 data.ip = '';
44 } else {
45 data.ipv4mode = 'static';
46 }
47 if (data.ip6 === 'dhcp' || data.ip6 === 'auto') {
48 data.ipv6mode = data.ip6;
49 data.ip6 = '';
50 } else {
51 data.ipv6mode = 'static';
52 }
53
54 me.ipconfig = data;
55 me.setValues(me.ipconfig);
56 },
57
8058410f 58 initComponent: function() {
01e02121
DC
59 var me = this;
60
61 me.ipconfig = {};
62
63 me.column1 = [
64 {
65 xtype: 'displayfield',
66 fieldLabel: gettext('Network Device'),
f6710aac 67 value: me.netid,
01e02121
DC
68 },
69 {
70 layout: {
71 type: 'hbox',
f6710aac 72 align: 'middle',
01e02121
DC
73 },
74 border: false,
75 margin: '0 0 5 0',
76 items: [
77 {
78 xtype: 'label',
f6710aac 79 text: gettext('IPv4') + ':',
01e02121
DC
80 },
81 {
82 xtype: 'radiofield',
83 boxLabel: gettext('Static'),
84 name: 'ipv4mode',
85 inputValue: 'static',
86 checked: false,
87 margin: '0 0 0 10',
88 listeners: {
89 change: function(cb, value) {
90 me.down('field[name=ip]').setDisabled(!value);
91 me.down('field[name=gw]').setDisabled(!value);
f6710aac
TL
92 },
93 },
01e02121
DC
94 },
95 {
96 xtype: 'radiofield',
97 boxLabel: gettext('DHCP'),
98 name: 'ipv4mode',
99 inputValue: 'dhcp',
100 checked: false,
f6710aac
TL
101 margin: '0 0 0 10',
102 },
103 ],
01e02121
DC
104 },
105 {
106 xtype: 'textfield',
107 name: 'ip',
108 vtype: 'IPCIDRAddress',
109 value: '',
110 disabled: true,
f6710aac 111 fieldLabel: gettext('IPv4/CIDR'),
01e02121
DC
112 },
113 {
114 xtype: 'textfield',
115 name: 'gw',
116 value: '',
117 vtype: 'IPAddress',
118 disabled: true,
f6710aac
TL
119 fieldLabel: gettext('Gateway') + ' (' + gettext('IPv4') +')',
120 },
01e02121
DC
121 ];
122
123 me.column2 = [
124 {
f6710aac 125 xtype: 'displayfield',
01e02121
DC
126 },
127 {
128 layout: {
129 type: 'hbox',
f6710aac 130 align: 'middle',
01e02121
DC
131 },
132 border: false,
133 margin: '0 0 5 0',
134 items: [
135 {
136 xtype: 'label',
f6710aac 137 text: gettext('IPv6') + ':',
01e02121
DC
138 },
139 {
140 xtype: 'radiofield',
141 boxLabel: gettext('Static'),
142 name: 'ipv6mode',
143 inputValue: 'static',
144 checked: false,
145 margin: '0 0 0 10',
146 listeners: {
147 change: function(cb, value) {
148 me.down('field[name=ip6]').setDisabled(!value);
149 me.down('field[name=gw6]').setDisabled(!value);
f6710aac
TL
150 },
151 },
01e02121
DC
152 },
153 {
154 xtype: 'radiofield',
155 boxLabel: gettext('DHCP'),
156 name: 'ipv6mode',
157 inputValue: 'dhcp',
158 checked: false,
f6710aac
TL
159 margin: '0 0 0 10',
160 },
ac7bf672
ML
161 {
162 xtype: 'radiofield',
163 boxLabel: gettext('SLAAC'),
164 name: 'ipv6mode',
165 inputValue: 'auto',
166 checked: false,
167 margin: '0 0 0 10',
168 },
f6710aac 169 ],
01e02121
DC
170 },
171 {
172 xtype: 'textfield',
173 name: 'ip6',
174 value: '',
175 vtype: 'IP6CIDRAddress',
176 disabled: true,
f6710aac 177 fieldLabel: gettext('IPv6/CIDR'),
01e02121
DC
178 },
179 {
180 xtype: 'textfield',
181 name: 'gw6',
182 vtype: 'IP6Address',
183 value: '',
184 disabled: true,
f6710aac
TL
185 fieldLabel: gettext('Gateway') + ' (' + gettext('IPv6') +')',
186 },
01e02121
DC
187 ];
188
189 me.callParent();
f6710aac 190 },
01e02121
DC
191});
192
193Ext.define('PVE.qemu.IPConfigEdit', {
194 extend: 'Proxmox.window.Edit',
195
196 isAdd: true,
197
8058410f 198 initComponent: function() {
01e02121
DC
199 var me = this;
200
201 // convert confid from netX to ipconfigX
202 var match = me.confid.match(/^net(\d+)$/);
203 if (match) {
204 me.netid = me.confid;
205 me.confid = 'ipconfig' + match[1];
206 }
207
208 var nodename = me.pveSelNode.data.node;
209 if (!nodename) {
210 throw "no node name specified";
211 }
212
ef725143 213 me.isCreate = !me.confid;
01e02121
DC
214
215 var ipanel = Ext.create('PVE.qemu.IPConfigPanel', {
216 confid: me.confid,
217 netid: me.netid,
f6710aac 218 nodename: nodename,
01e02121
DC
219 });
220
221 Ext.applyIf(me, {
222 subject: gettext('Network Config'),
f6710aac 223 items: ipanel,
01e02121
DC
224 });
225
226 me.callParent();
227
228 me.load({
229 success: function(response, options) {
230 me.vmconfig = response.result.data;
231 var ipconfig = {};
232 var value = me.vmconfig[me.confid];
233 if (value) {
234 ipconfig = PVE.Parser.parseIPConfig(me.confid, value);
235 if (!ipconfig) {
236 Ext.Msg.alert(gettext('Error'), gettext('Unable to parse network configuration'));
237 me.close();
238 return;
239 }
240 }
241 ipanel.setIPConfig(me.confid, ipconfig);
242 ipanel.setVMConfig(me.vmconfig);
f6710aac 243 },
01e02121 244 });
f6710aac 245 },
01e02121 246});