add spec-ctrl cpu flag checkbox

also make the mechanism for the flag checkboxes generic

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-01-16 14:51:21 +01:00 committed by Fabian Grünbichler
parent c6c8e2fcea
commit 76f56b02ad

View File

@ -5,15 +5,27 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
insideWizard: false, insideWizard: false,
// defines the possible cpu flags and their labels
flagsAvail: ['pcid', 'spec-ctrl'],
flagLabels: ['PCID', 'SPEC-CTRL'],
onGetValues: function(values) { onGetValues: function(values) {
var me = this; var me = this;
// build the cpu options: // build the cpu options:
me.cpu.cputype = values.cputype; me.cpu.cputype = values.cputype;
// as long as flags is not a textfield, we var flags = [];
// have to manuall set the value
me.cpu.flags = (values.flags) ? '+pcid' : undefined; me.flagsAvail.forEach(function(flag) {
if (values[flag]) {
flags.push('+' + flag.toString());
}
delete values[flag];
});
me.cpu.flags = flags.length ? flags.join(';') : undefined;
delete values.cputype; delete values.cputype;
delete values.flags; delete values.flags;
var cpustring = PVE.Parser.printQemuCpu(me.cpu); var cpustring = PVE.Parser.printQemuCpu(me.cpu);
@ -102,19 +114,19 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
fieldLabel: gettext('Total cores'), fieldLabel: gettext('Total cores'),
name: 'totalcores', name: 'totalcores',
value: '1' value: '1'
}, }
{ ];
// will be a textfield probably someday,
// so we name it flags me.flagsAvail.forEach(function(flag, i) {
me.column2.push({
hidden: me.insideWizard, hidden: me.insideWizard,
disabled: me.insideWizard, disabled: me.insideWizard,
xtype: 'pvecheckbox', xtype: 'pvecheckbox',
fieldLabel: 'PCID', fieldLabel: me.flagLabels[i] || flag,
name: 'flags', name: flag,
uncheckedValue: 0 uncheckedValue: 0
} });
});
];
me.callParent(); me.callParent();
} }
@ -143,9 +155,14 @@ Ext.define('PVE.qemu.ProcessorEdit', {
var cpu = PVE.Parser.parseQemuCpu(value); var cpu = PVE.Parser.parseQemuCpu(value);
ipanel.cpu = cpu; ipanel.cpu = cpu;
data.cputype = cpu.cputype; data.cputype = cpu.cputype;
/*jslint confusion: true*/ if (cpu.flags) {
// .flags is boolean and string var flags = cpu.flags.split(';');
data.flags = (cpu.flags === '+pcid'); flags.forEach(function(flag) {
var sign = flag.substr(0,1);
flag = flag.substr(1);
data[flag] = (sign === '+');
});
}
} }
me.setValues(data); me.setValues(data);
} }