]>
Commit | Line | Data |
---|---|---|
aff192e6 DM |
1 | Ext.define('PVE.qemu.ProcessorInputPanel', { |
2 | extend: 'PVE.panel.InputPanel', | |
3 | alias: 'widget.PVE.qemu.ProcessorInputPanel', | |
4 | ||
0f2c29ad WB |
5 | onGetValues: function(values) { |
6 | var me = this; | |
730b2558 WB |
7 | |
8 | // build the cpu options: | |
0f2c29ad | 9 | me.cpu.cputype = values['cputype']; |
730b2558 WB |
10 | delete values['cputype']; |
11 | var cpustring = PVE.Parser.printQemuCpu(me.cpu); | |
12 | ||
13 | // remove cputype delete request: | |
14 | var del = values['delete']; | |
15 | delete values['delete']; | |
16 | if (del) { | |
17 | del = del.split(','); | |
18 | Ext.Array.remove(del, 'cputype'); | |
19 | } else { | |
20 | del = []; | |
21 | } | |
730b2558 WB |
22 | |
23 | if (cpustring) { | |
24 | values['cpu'] = cpustring; | |
25 | } else { | |
26 | del.push('cpu'); | |
27 | } | |
28 | ||
29 | del = del.join(','); | |
30 | if (del) { | |
31 | values['delete'] = del; | |
32 | } | |
33 | ||
34 | return values; | |
0f2c29ad WB |
35 | }, |
36 | ||
aff192e6 DM |
37 | initComponent : function() { |
38 | var me = this; | |
39 | ||
d4575fb0 WB |
40 | me.cpu = {}; |
41 | ||
aff192e6 DM |
42 | me.column1 = [ |
43 | { | |
44 | xtype: 'numberfield', | |
45 | name: 'sockets', | |
46 | minValue: 1, | |
47 | maxValue: 4, | |
48 | value: '1', | |
0070ee37 | 49 | fieldLabel: gettext('Sockets'), |
aff192e6 DM |
50 | allowBlank: false, |
51 | listeners: { | |
52 | change: function(f, value) { | |
53 | var sockets = me.down('field[name=sockets]').getValue(); | |
54 | var cores = me.down('field[name=cores]').getValue(); | |
55 | me.down('field[name=totalcores]').setValue(sockets*cores); | |
56 | } | |
57 | } | |
58 | }, | |
59 | { | |
60 | xtype: 'numberfield', | |
61 | name: 'cores', | |
62 | minValue: 1, | |
d0efa75d | 63 | maxValue: 128, |
aff192e6 | 64 | value: '1', |
0070ee37 | 65 | fieldLabel: gettext('Cores'), |
aff192e6 DM |
66 | allowBlank: false, |
67 | listeners: { | |
68 | change: function(f, value) { | |
69 | var sockets = me.down('field[name=sockets]').getValue(); | |
70 | var cores = me.down('field[name=cores]').getValue(); | |
71 | me.down('field[name=totalcores]').setValue(sockets*cores); | |
72 | } | |
73 | } | |
919b9c1f AD |
74 | }, |
75 | { | |
76 | xtype: 'pvecheckbox', | |
77 | fieldLabel: gettext('Enable numa'), | |
78 | name: 'numa', | |
79 | uncheckedValue: 0, | |
80 | }, | |
81 | ||
aff192e6 DM |
82 | ]; |
83 | ||
84 | ||
85 | me.column2 = [ | |
86 | { | |
87 | xtype: 'CPUModelSelector', | |
0f2c29ad | 88 | name: 'cputype', |
aff192e6 | 89 | value: '', |
4af2c66c | 90 | fieldLabel: gettext('Type') |
aff192e6 DM |
91 | }, |
92 | { | |
93 | xtype: 'displayfield', | |
0070ee37 | 94 | fieldLabel: gettext('Total cores'), |
aff192e6 DM |
95 | name: 'totalcores', |
96 | value: '1' | |
97 | } | |
98 | ||
99 | ]; | |
100 | ||
101 | me.callParent(); | |
102 | } | |
103 | }); | |
104 | ||
105 | Ext.define('PVE.qemu.ProcessorEdit', { | |
106 | extend: 'PVE.window.Edit', | |
107 | ||
108 | initComponent : function() { | |
109 | var me = this; | |
110 | ||
0f2c29ad WB |
111 | var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel') |
112 | ||
aff192e6 | 113 | Ext.apply(me, { |
6b21ab95 | 114 | subject: gettext('Processors'), |
0f2c29ad | 115 | items: ipanel |
aff192e6 DM |
116 | }); |
117 | ||
118 | me.callParent(); | |
119 | ||
0f2c29ad WB |
120 | me.load({ |
121 | success: function(response, options) { | |
b73df817 WB |
122 | var data = response.result.data; |
123 | var value = data['cpu']; | |
124 | if (value) { | |
125 | var cpu = PVE.Parser.parseQemuCpu(value); | |
126 | ipanel.cpu = cpu; | |
127 | data.cputype = cpu.cputype; | |
128 | } | |
129 | me.setValues(data); | |
0f2c29ad WB |
130 | } |
131 | }); | |
aff192e6 | 132 | } |
0070ee37 | 133 | }); |