]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/ProcessorEdit.js
use windowEdit from widget toolkit
[pve-manager.git] / www / manager6 / qemu / ProcessorEdit.js
CommitLineData
59e85a54
DM
1Ext.define('PVE.qemu.ProcessorInputPanel', {
2 extend: 'PVE.panel.InputPanel',
42902182 3 alias: 'widget.pveQemuProcessorPanel',
c8802a60 4 onlineHelp: 'qm_cpu',
59e85a54 5
1eeb6f17
DC
6 insideWizard: false,
7
76f56b02
DC
8 // defines the possible cpu flags and their labels
9 flagsAvail: ['pcid', 'spec-ctrl'],
10 flagLabels: ['PCID', 'SPEC-CTRL'],
11
59e85a54
DM
12 onGetValues: function(values) {
13 var me = this;
14
15 // build the cpu options:
ec0bd652 16 me.cpu.cputype = values.cputype;
1eeb6f17 17
76f56b02
DC
18 var flags = [];
19
20 me.flagsAvail.forEach(function(flag) {
21 if (values[flag]) {
22 flags.push('+' + flag.toString());
23 }
24 delete values[flag];
25 });
26
27 me.cpu.flags = flags.length ? flags.join(';') : undefined;
28
ec0bd652 29 delete values.cputype;
1eeb6f17 30 delete values.flags;
59e85a54
DM
31 var cpustring = PVE.Parser.printQemuCpu(me.cpu);
32
33 // remove cputype delete request:
34 var del = values['delete'];
35 delete values['delete'];
36 if (del) {
37 del = del.split(',');
38 Ext.Array.remove(del, 'cputype');
39 } else {
40 del = [];
41 }
42
43 if (cpustring) {
ec0bd652 44 values.cpu = cpustring;
59e85a54
DM
45 } else {
46 del.push('cpu');
47 }
48
ec0bd652
DC
49 var delarr = del.join(',');
50 if (delarr) {
51 values['delete'] = delarr;
59e85a54
DM
52 }
53
54 return values;
55 },
56
57 initComponent : function() {
58 var me = this;
59
60 me.cpu = {};
61
62 me.column1 = [
63 {
bf96f60d 64 xtype: 'proxmoxintegerfield',
59e85a54
DM
65 name: 'sockets',
66 minValue: 1,
67 maxValue: 4,
68 value: '1',
69 fieldLabel: gettext('Sockets'),
70 allowBlank: false,
71 listeners: {
72 change: function(f, value) {
73 var sockets = me.down('field[name=sockets]').getValue();
74 var cores = me.down('field[name=cores]').getValue();
75 me.down('field[name=totalcores]').setValue(sockets*cores);
76 }
77 }
78 },
79 {
bf96f60d 80 xtype: 'proxmoxintegerfield',
59e85a54
DM
81 name: 'cores',
82 minValue: 1,
83 maxValue: 128,
84 value: '1',
85 fieldLabel: gettext('Cores'),
86 allowBlank: false,
87 listeners: {
88 change: function(f, value) {
89 var sockets = me.down('field[name=sockets]').getValue();
90 var cores = me.down('field[name=cores]').getValue();
91 me.down('field[name=totalcores]').setValue(sockets*cores);
92 }
93 }
94 },
95 {
896c0d50 96 xtype: 'proxmoxcheckbox',
185a77e5 97 fieldLabel: gettext('Enable NUMA'),
59e85a54 98 name: 'numa',
22f2f9d6
DC
99 uncheckedValue: 0
100 }
59e85a54
DM
101
102 ];
103
104
105 me.column2 = [
106 {
107 xtype: 'CPUModelSelector',
108 name: 'cputype',
ac7db8f7 109 value: '__default__',
59e85a54
DM
110 fieldLabel: gettext('Type')
111 },
112 {
113 xtype: 'displayfield',
114 fieldLabel: gettext('Total cores'),
115 name: 'totalcores',
116 value: '1'
76f56b02
DC
117 }
118 ];
119
120 me.flagsAvail.forEach(function(flag, i) {
121 me.column2.push({
1eeb6f17
DC
122 hidden: me.insideWizard,
123 disabled: me.insideWizard,
896c0d50 124 xtype: 'proxmoxcheckbox',
76f56b02
DC
125 fieldLabel: me.flagLabels[i] || flag,
126 name: flag,
1eeb6f17 127 uncheckedValue: 0
76f56b02
DC
128 });
129 });
59e85a54
DM
130
131 me.callParent();
132 }
133});
134
135Ext.define('PVE.qemu.ProcessorEdit', {
9fccc702 136 extend: 'Proxmox.window.Edit',
59e85a54
DM
137
138 initComponent : function() {
139 var me = this;
140
a764c5f7 141 var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel');
59e85a54
DM
142
143 Ext.apply(me, {
144 subject: gettext('Processors'),
145 items: ipanel
146 });
147
148 me.callParent();
149
150 me.load({
151 success: function(response, options) {
152 var data = response.result.data;
ec0bd652 153 var value = data.cpu;
59e85a54
DM
154 if (value) {
155 var cpu = PVE.Parser.parseQemuCpu(value);
156 ipanel.cpu = cpu;
157 data.cputype = cpu.cputype;
76f56b02
DC
158 if (cpu.flags) {
159 var flags = cpu.flags.split(';');
160 flags.forEach(function(flag) {
161 var sign = flag.substr(0,1);
162 flag = flag.substr(1);
163 data[flag] = (sign === '+');
164 });
165 }
59e85a54
DM
166 }
167 me.setValues(data);
168 }
169 });
170 }
171});