2016-03-16 09:12:22 +01:00
Ext . define ( 'PVE.qemu.ProcessorInputPanel' , {
extend : 'PVE.panel.InputPanel' ,
alias : 'widget.PVE.qemu.ProcessorInputPanel' ,
onGetValues : function ( values ) {
var me = this ;
// build the cpu options:
2016-04-29 12:06:27 +02:00
me . cpu . cputype = values . cputype ;
delete values . cputype ;
2016-03-16 09:12:22 +01:00
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 = [ ] ;
}
if ( cpustring ) {
2016-04-29 12:06:27 +02:00
values . cpu = cpustring ;
2016-03-16 09:12:22 +01:00
} else {
del . push ( 'cpu' ) ;
}
2016-04-29 12:06:27 +02:00
var delarr = del . join ( ',' ) ;
if ( delarr ) {
values [ 'delete' ] = delarr ;
2016-03-16 09:12:22 +01:00
}
return values ;
} ,
initComponent : function ( ) {
var me = this ;
me . cpu = { } ;
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' ,
2016-04-05 11:10:52 +02:00
fieldLabel : gettext ( 'Enable NUMA' ) ,
2016-03-16 09:12:22 +01:00
name : 'numa' ,
2016-04-29 12:06:28 +02:00
uncheckedValue : 0
}
2016-03-16 09:12:22 +01:00
] ;
me . column2 = [
{
xtype : 'CPUModelSelector' ,
name : 'cputype' ,
2016-03-21 10:53:11 +01:00
value : '__default__' ,
2016-03-16 09:12:22 +01:00
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 data = response . result . data ;
2016-04-29 12:06:27 +02:00
var value = data . cpu ;
2016-03-16 09:12:22 +01:00
if ( value ) {
var cpu = PVE . Parser . parseQemuCpu ( value ) ;
ipanel . cpu = cpu ;
data . cputype = cpu . cputype ;
}
me . setValues ( data ) ;
}
} ) ;
}
} ) ;