mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-06-14 06:48:00 +00:00

The last processor editing commit broke various parts of the cpu editor window. Most noticeably switching between the default and non-default cpu types dealt with empty values wrongly and tried to delete the 'cputype' property rather than the cputype portion of the cpu property string.
130 lines
2.4 KiB
JavaScript
130 lines
2.4 KiB
JavaScript
Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|
extend: 'PVE.panel.InputPanel',
|
|
alias: 'widget.PVE.qemu.ProcessorInputPanel',
|
|
|
|
onGetValues: function(values) {
|
|
var me = this;
|
|
|
|
// build the cpu options:
|
|
me.cpu.cputype = values['cputype'];
|
|
delete values['cputype'];
|
|
var cpustring = PVE.Parser.printQemuCpu(me.cpu);
|
|
|
|
// remove cputype delete request:
|
|
var del = values['delete'];
|
|
delete values['delete'];
|
|
if (del) {
|
|
del = del.split(',');
|
|
Ext.Array.remove(del, 'cputype');
|
|
} else {
|
|
del = [];
|
|
}
|
|
console.log(del);
|
|
|
|
if (cpustring) {
|
|
values['cpu'] = cpustring;
|
|
} else {
|
|
del.push('cpu');
|
|
}
|
|
|
|
del = del.join(',');
|
|
if (del) {
|
|
values['delete'] = del;
|
|
}
|
|
|
|
return values;
|
|
},
|
|
|
|
initComponent : function() {
|
|
var me = this;
|
|
|
|
me.column1 = [
|
|
{
|
|
xtype: 'numberfield',
|
|
name: 'sockets',
|
|
minValue: 1,
|
|
maxValue: 4,
|
|
value: '1',
|
|
fieldLabel: gettext('Sockets'),
|
|
allowBlank: false,
|
|
listeners: {
|
|
change: function(f, value) {
|
|
var sockets = me.down('field[name=sockets]').getValue();
|
|
var cores = me.down('field[name=cores]').getValue();
|
|
me.down('field[name=totalcores]').setValue(sockets*cores);
|
|
}
|
|
}
|
|
},
|
|
{
|
|
xtype: 'numberfield',
|
|
name: 'cores',
|
|
minValue: 1,
|
|
maxValue: 128,
|
|
value: '1',
|
|
fieldLabel: gettext('Cores'),
|
|
allowBlank: false,
|
|
listeners: {
|
|
change: function(f, value) {
|
|
var sockets = me.down('field[name=sockets]').getValue();
|
|
var cores = me.down('field[name=cores]').getValue();
|
|
me.down('field[name=totalcores]').setValue(sockets*cores);
|
|
}
|
|
}
|
|
},
|
|
{
|
|
xtype: 'pvecheckbox',
|
|
fieldLabel: gettext('Enable numa'),
|
|
name: 'numa',
|
|
uncheckedValue: 0,
|
|
},
|
|
|
|
];
|
|
|
|
|
|
me.column2 = [
|
|
{
|
|
xtype: 'CPUModelSelector',
|
|
name: 'cputype',
|
|
value: '',
|
|
fieldLabel: gettext('Type')
|
|
},
|
|
{
|
|
xtype: 'displayfield',
|
|
fieldLabel: gettext('Total cores'),
|
|
name: 'totalcores',
|
|
value: '1'
|
|
}
|
|
|
|
];
|
|
|
|
me.callParent();
|
|
}
|
|
});
|
|
|
|
Ext.define('PVE.qemu.ProcessorEdit', {
|
|
extend: 'PVE.window.Edit',
|
|
|
|
initComponent : function() {
|
|
var me = this;
|
|
|
|
var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel')
|
|
|
|
Ext.apply(me, {
|
|
subject: gettext('Processors'),
|
|
items: ipanel
|
|
});
|
|
|
|
me.callParent();
|
|
|
|
me.load({
|
|
success: function(response, options) {
|
|
var value = response.result.data['cpu'];
|
|
var cpu = PVE.Parser.parseQemuCpu(value);
|
|
ipanel.cpu = cpu;
|
|
if (value)
|
|
me.setValues({ cputype: cpu.cputype });
|
|
}
|
|
});
|
|
}
|
|
});
|