mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-10 14:57:47 +00:00
ui: ProcessorEdit: fix total core calculation and use view model
Clean up the code in ProcessorEdit with a view model and fix a bug while at it - previously, pressing the 'Reset' button on the form would always set the value of the total core count field to 1, so mark 'totalcores' with 'isFormField: false' to avoid reset. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
01ac98c702
commit
b839766e7d
@ -5,28 +5,18 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|||||||
|
|
||||||
insideWizard: false,
|
insideWizard: false,
|
||||||
|
|
||||||
|
viewModel: {
|
||||||
|
data: {
|
||||||
|
socketCount: 1,
|
||||||
|
coreCount: 1,
|
||||||
|
},
|
||||||
|
formulas: {
|
||||||
|
totalCoreCount: get => get('socketCount') * get('coreCount'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
controller: {
|
controller: {
|
||||||
xclass: 'Ext.app.ViewController',
|
xclass: 'Ext.app.ViewController',
|
||||||
|
|
||||||
updateCores: function() {
|
|
||||||
var me = this.getView();
|
|
||||||
var sockets = me.down('field[name=sockets]').getValue();
|
|
||||||
var cores = me.down('field[name=cores]').getValue();
|
|
||||||
me.down('field[name=totalcores]').setValue(sockets*cores);
|
|
||||||
var vcpus = me.down('field[name=vcpus]');
|
|
||||||
vcpus.setMaxValue(sockets*cores);
|
|
||||||
vcpus.setEmptyText(sockets*cores);
|
|
||||||
vcpus.validate();
|
|
||||||
},
|
|
||||||
|
|
||||||
control: {
|
|
||||||
'field[name=sockets]': {
|
|
||||||
change: 'updateCores'
|
|
||||||
},
|
|
||||||
'field[name=cores]': {
|
|
||||||
change: 'updateCores'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onGetValues: function(values) {
|
onGetValues: function(values) {
|
||||||
@ -86,7 +76,10 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|||||||
maxValue: 4,
|
maxValue: 4,
|
||||||
value: '1',
|
value: '1',
|
||||||
fieldLabel: gettext('Sockets'),
|
fieldLabel: gettext('Sockets'),
|
||||||
allowBlank: false
|
allowBlank: false,
|
||||||
|
bind: {
|
||||||
|
value: '{socketCount}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'proxmoxintegerfield',
|
xtype: 'proxmoxintegerfield',
|
||||||
@ -95,8 +88,11 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|||||||
maxValue: 128,
|
maxValue: 128,
|
||||||
value: '1',
|
value: '1',
|
||||||
fieldLabel: gettext('Cores'),
|
fieldLabel: gettext('Cores'),
|
||||||
allowBlank: false
|
allowBlank: false,
|
||||||
}
|
bind: {
|
||||||
|
value: '{coreCount}',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
column2: [
|
column2: [
|
||||||
@ -109,8 +105,11 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|||||||
xtype: 'displayfield',
|
xtype: 'displayfield',
|
||||||
fieldLabel: gettext('Total cores'),
|
fieldLabel: gettext('Total cores'),
|
||||||
name: 'totalcores',
|
name: 'totalcores',
|
||||||
value: '1'
|
isFormField: false,
|
||||||
}
|
bind: {
|
||||||
|
value: '{totalCoreCount}',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
advancedColumn1: [
|
advancedColumn1: [
|
||||||
@ -123,7 +122,11 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
|||||||
fieldLabel: gettext('VCPUs'),
|
fieldLabel: gettext('VCPUs'),
|
||||||
deleteEmpty: true,
|
deleteEmpty: true,
|
||||||
allowBlank: true,
|
allowBlank: true,
|
||||||
emptyText: '1'
|
emptyText: '1',
|
||||||
|
bind: {
|
||||||
|
emptyText: '{totalCoreCount}',
|
||||||
|
maxValue: '{totalCoreCount}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'numberfield',
|
xtype: 'numberfield',
|
||||||
|
Loading…
Reference in New Issue
Block a user