[pve-devel] [PATCH v4 manager 1/3] Make CPU Model Selector a searchable grid view

Stefan Reiter s.reiter at proxmox.com
Tue Sep 10 19:11:44 CEST 2019


Uses a ComboGrid with search feature and a column for vendor. Can be
sorted by both columns.

Default sort is as given in this file, I tried to align it as
* AMD
* Intel
* Other
alphabetically and in QEMU order (as before, seems to be release date?)
within those "groups".

Doesn't work with value set in widget definition (would need to be
preferredValue), but we always call setValue() anyway (and if we don't,
value will be '', aka the default, which is correct too), so just remove
that from ProcessorEdit.js.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 www/manager6/form/CPUModelSelector.js | 193 +++++++++++++++++++++-----
 www/manager6/qemu/ProcessorEdit.js    |   1 -
 2 files changed, 159 insertions(+), 35 deletions(-)

diff --git a/www/manager6/form/CPUModelSelector.js b/www/manager6/form/CPUModelSelector.js
index 9eb5b0e9..dea6c44c 100644
--- a/www/manager6/form/CPUModelSelector.js
+++ b/www/manager6/form/CPUModelSelector.js
@@ -1,38 +1,163 @@
 Ext.define('PVE.form.CPUModelSelector', {
-    extend: 'Proxmox.form.KVComboBox',
+    extend: 'Proxmox.form.ComboGrid',
     alias: ['widget.CPUModelSelector'],
-    comboItems: [
-	['__default__', Proxmox.Utils.defaultText + ' (kvm64)'],
-	['486', '486'],
-	['athlon', 'athlon'],
-	['core2duo', 'core2duo'],
-	['coreduo', 'coreduo'],
-	['kvm32', 'kvm32'],
-	['kvm64', 'kvm64'],
-	['pentium', 'pentium'],
-	['pentium2', 'pentium2'],
-	['pentium3', 'pentium3'],
-	['phenom', 'phenom'],
-	['qemu32', 'qemu32'],
-	['qemu64', 'qemu64'],
-	['Conroe', 'Conroe'],
-	['Penryn', 'Penryn'],
-	['Nehalem', 'Nehalem'],
-	['Westmere', 'Westmere'],
-	['SandyBridge', 'SandyBridge'],
-	['IvyBridge', 'IvyBridge'],
-	['Haswell', 'Haswell'],
-	['Haswell-noTSX','Haswell-noTSX'],
-	['Broadwell', 'Broadwell'],
-	['Broadwell-noTSX','Broadwell-noTSX'],
-	['Skylake-Client','Skylake-Client'],
-	['Opteron_G1', 'Opteron_G1'],
-	['Opteron_G2', 'Opteron_G2'],
-	['Opteron_G3', 'Opteron_G3'],
-	['Opteron_G4', 'Opteron_G4'],
-	['Opteron_G5', 'Opteron_G5'],
-	['EPYC', 'EPYC'],
-	['host', 'host']
 
-    ]
+    valueField: 'value',
+    displayField: 'value',
+
+    emptyText: Proxmox.Utils.defaultText + ' (kvm64)',
+    allowBlank: true,
+
+    editable: true,
+    anyMatch: true,
+    forceSelection: true,
+    autoSelect: false,
+
+    deleteEmpty: true,
+
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Model'),
+		dataIndex: 'value',
+		hideable: false,
+		sortable: true,
+		flex: 2
+	    },
+	    {
+		header: gettext('Vendor'),
+		dataIndex: 'vendor',
+		hideable: false,
+		sortable: true,
+		flex: 1
+	    }
+	],
+	width: 320
+    },
+
+    store: {
+	fields: [ 'value', 'vendor' ],
+	data: [
+	    {
+		value: 'athlon',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'phenom',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'Opteron_G1',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'Opteron_G2',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'Opteron_G3',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'Opteron_G4',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'Opteron_G5',
+		vendor: 'AMD'
+	    },
+	    {
+		value: 'EPYC',
+		vendor: 'AMD'
+	    },
+	    {
+		value: '486',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'core2duo',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'coreduo',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'pentium',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'pentium2',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'pentium3',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Conroe',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Penryn',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Nehalem',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Westmere',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'SandyBridge',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'IvyBridge',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Haswell',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Haswell-noTSX',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Broadwell',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Broadwell-noTSX',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'Skylake-Client',
+		vendor: 'Intel'
+	    },
+	    {
+		value: 'kvm32',
+		vendor: 'Other'
+	    },
+	    {
+		value: 'kvm64',
+		vendor: 'Other'
+	    },
+	    {
+		value: 'qemu32',
+		vendor: 'Other'
+	    },
+	    {
+		value: 'qemu64',
+		vendor: 'Other'
+	    },
+	    {
+		value: 'host',
+		vendor: 'Other'
+	    }
+	]
+    }
 });
diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
index c62dc734..bc17e152 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -103,7 +103,6 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 	{
 	    xtype: 'CPUModelSelector',
 	    name: 'cputype',
-	    value: '__default__',
 	    fieldLabel: gettext('Type')
 	},
 	{
-- 
2.20.1





More information about the pve-devel mailing list