[pve-devel] [PATCH manager v2 04/22] use IntegerField from widget toolkit

Dominik Csapak d.csapak at proxmox.com
Mon Jan 15 15:17:52 CET 2018


there we implemented deleteEmpty, which we can use in some cases.
this also fixes a bug in the ControllerSelector where
an empty field would be allowed (but should not)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile                   |  1 -
 www/manager6/ceph/Pool.js               |  6 +++---
 www/manager6/dc/AuthEdit.js             |  6 +++---
 www/manager6/form/ControllerSelector.js |  3 ++-
 www/manager6/form/IntegerField.js       |  8 --------
 www/manager6/grid/FirewallOptions.js    |  2 +-
 www/manager6/ha/GroupEdit.js            |  2 +-
 www/manager6/ha/ResourceEdit.js         |  4 ++--
 www/manager6/lxc/Options.js             | 15 +++------------
 www/manager6/lxc/ResourceEdit.js        |  9 +++++----
 www/manager6/qemu/CPUOptions.js         |  7 ++++---
 www/manager6/qemu/HDThrottle.js         |  8 ++++----
 www/manager6/qemu/MemoryEdit.js         |  4 ++--
 www/manager6/qemu/NetworkEdit.js        |  2 +-
 www/manager6/qemu/ProcessorEdit.js      |  4 ++--
 www/manager6/storage/DirEdit.js         |  2 +-
 www/manager6/storage/GlusterFsEdit.js   |  2 +-
 www/manager6/storage/NFSEdit.js         |  2 +-
 www/manager6/window/BulkAction.js       |  2 +-
 19 files changed, 37 insertions(+), 52 deletions(-)
 delete mode 100644 www/manager6/form/IntegerField.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index fdaf15d4..f9b6deb4 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -28,7 +28,6 @@ JSSRC= 				                 	\
 	data/RRDStore.js				\
 	form/VLanField.js				\
 	form/Checkbox.js				\
-	form/IntegerField.js				\
 	form/RRDTypeSelector.js				\
 	form/KVComboBox.js				\
 	form/Boolean.js					\
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index cd84ee6d..33726f9a 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -16,7 +16,7 @@ Ext.define('PVE.CephCreatePool', {
 	    allowBlank: false
 	},
 	{
-	    xtype: 'pveIntegerField',
+	    xtype: 'proxmoxintegerfield',
 	    fieldLabel: gettext('Size'),
 	    name: 'size',
 	    value: 3,
@@ -25,7 +25,7 @@ Ext.define('PVE.CephCreatePool', {
 	    allowBlank: false
 	},
 	{
-	    xtype: 'pveIntegerField',
+	    xtype: 'proxmoxintegerfield',
 	    fieldLabel: gettext('Min. Size'),
 	    name: 'min_size',
 	    value: 2,
@@ -40,7 +40,7 @@ Ext.define('PVE.CephCreatePool', {
 	    allowBlank: false
 	},
 	{
-	    xtype: 'pveIntegerField',
+	    xtype: 'proxmoxintegerfield',
 	    fieldLabel: 'pg_num',
 	    name: 'pg_num',
 	    value: 64,
diff --git a/www/manager6/dc/AuthEdit.js b/www/manager6/dc/AuthEdit.js
index 612436d1..ebbb799c 100644
--- a/www/manager6/dc/AuthEdit.js
+++ b/www/manager6/dc/AuthEdit.js
@@ -106,7 +106,7 @@ Ext.define('PVE.dc.AuthEdit', {
 		    name: 'server2'
 		},
 		{
-                    xtype: 'pveIntegerField',
+                    xtype: 'proxmoxintegerfield',
                     name: 'port',
                     fieldLabel: gettext('Port'),
                     minValue: 1,
@@ -147,7 +147,7 @@ Ext.define('PVE.dc.AuthEdit', {
         });
 
 	column2.push({
-            xtype: 'pveIntegerField',
+            xtype: 'proxmoxintegerfield',
             name: 'oath_step',
 	    value: '',
 	    minValue: 10,
@@ -158,7 +158,7 @@ Ext.define('PVE.dc.AuthEdit', {
         });
 
 	column2.push({
-            xtype: 'pveIntegerField',
+            xtype: 'proxmoxintegerfield',
             name: 'oath_digits',
 	    value: '',
 	    minValue: 6,
diff --git a/www/manager6/form/ControllerSelector.js b/www/manager6/form/ControllerSelector.js
index 1d1ca556..bc00eebf 100644
--- a/www/manager6/form/ControllerSelector.js
+++ b/www/manager6/form/ControllerSelector.js
@@ -117,12 +117,13 @@ Ext.define('PVE.form.ControllerSelector', {
 		    }
 		},
 		{
-		    xtype: 'pveIntegerField',
+		    xtype: 'proxmoxintegerfield',
 		    name: 'deviceid',
 		    minValue: 0,
 		    maxValue: PVE.form.ControllerSelector.maxIds.ide,
 		    value: '0',
 		    flex: 1,
+		    allowBlank: false,
 		    validator: function(value) {
 			/*jslint confusion: true */
 			if (!me.rendered) {
diff --git a/www/manager6/form/IntegerField.js b/www/manager6/form/IntegerField.js
deleted file mode 100644
index 23011c44..00000000
--- a/www/manager6/form/IntegerField.js
+++ /dev/null
@@ -1,8 +0,0 @@
-Ext.define('PVE.form.IntegerField',{
-    extend: 'Ext.form.field.Number',
-    alias: 'widget.pveIntegerField',
-
-    allowDecimals: false,
-    allowExponential: false,
-    step: 1
-});
diff --git a/www/manager6/grid/FirewallOptions.js b/www/manager6/grid/FirewallOptions.js
index 60c09ee5..72e0f6d4 100644
--- a/www/manager6/grid/FirewallOptions.js
+++ b/www/manager6/grid/FirewallOptions.js
@@ -59,7 +59,7 @@ Ext.define('PVE.FirewallOptions', {
 		    subject: text,
 		    fieldDefaults: { labelWidth: labelWidth || 100 },
 		    items: {
-			xtype: 'pveIntegerField',
+			xtype: 'proxmoxintegerfield',
 			name: name,
 			minValue: minValue,
 			fieldLabel: text,
diff --git a/www/manager6/ha/GroupEdit.js b/www/manager6/ha/GroupEdit.js
index 0f7e41c3..fdaab4cb 100644
--- a/www/manager6/ha/GroupEdit.js
+++ b/www/manager6/ha/GroupEdit.js
@@ -78,7 +78,7 @@ Ext.define('PVE.ha.GroupInputPanel', {
 		    sortable: true,
 		    stopSelection: true,
 		    widget: {
-			xtype: 'pveIntegerField',
+			xtype: 'proxmoxintegerfield',
 			minValue: 0,
 			maxValue: 1000,
 			isFormField: false,
diff --git a/www/manager6/ha/ResourceEdit.js b/www/manager6/ha/ResourceEdit.js
index d21d6bd0..ec029494 100644
--- a/www/manager6/ha/ResourceEdit.js
+++ b/www/manager6/ha/ResourceEdit.js
@@ -88,7 +88,7 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 		validateExists: true
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'max_restart',
 		fieldLabel: gettext('Max. Restart'),
 		value: 1,
@@ -97,7 +97,7 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 		allowBlank: false
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'max_relocate',
 		fieldLabel: gettext('Max. Relocate'),
 		value: 1,
diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index 4a438877..4a855d52 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -81,23 +81,14 @@ Ext.define('PVE.lxc.Options', {
 		    xtype: 'pveWindowEdit',
 		    subject: gettext('TTY count'),
 		    items: {
-			xtype: 'pveIntegerField',
+			xtype: 'proxmoxintegerfield',
 			name: 'tty',
 			minValue: 0,
 			maxValue: 6,
 			value: 2,
 			fieldLabel: gettext('TTY count'),
-			allowEmpty: gettext('Default'),
-			getSubmitData: function() {
-			    var me = this;
-			    var val = me.getSubmitValue();
-			    if (val !== null && val !== '' && val !== '2') {
-				return { tty: val };
-			    } else {
-				return { 'delete' : 'tty' };
-			    }
-			}
-
+			emptyText: gettext('Default'),
+			deleteEmpty: true
 		    }
 		} : undefined
 	    },
diff --git a/www/manager6/lxc/ResourceEdit.js b/www/manager6/lxc/ResourceEdit.js
index 641d8636..4666df8f 100644
--- a/www/manager6/lxc/ResourceEdit.js
+++ b/www/manager6/lxc/ResourceEdit.js
@@ -60,13 +60,14 @@ Ext.define('PVE.lxc.CPUInputPanel', {
 
 	var column1 = [
             {
-                xtype: 'pveIntegerField',
+                xtype: 'proxmoxintegerfield',
                 name: 'cores',
 		minValue: 1,
 		maxValue: 128,
 		value: me.insideWizard ? 1 : '',
 		fieldLabel: gettext('Cores'),
 		allowBlank: true,
+		deleteEmpty: true,
                 emptyText: gettext('unlimited')
             }
 	];
@@ -84,7 +85,7 @@ Ext.define('PVE.lxc.CPUInputPanel', {
                 emptyText: gettext('unlimited')
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'cpuunits',
 		fieldLabel: gettext('CPU units'),
 		value: 1024,
@@ -119,7 +120,7 @@ Ext.define('PVE.lxc.MemoryInputPanel', {
 
 	var items = [
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'memory',
 		minValue: 16,
 		maxValue: 512*1024,
@@ -130,7 +131,7 @@ Ext.define('PVE.lxc.MemoryInputPanel', {
 		allowBlank: false
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'swap',
 		minValue: 0,
 		maxValue: 128*1024,
diff --git a/www/manager6/qemu/CPUOptions.js b/www/manager6/qemu/CPUOptions.js
index 3cadf226..3c75990b 100644
--- a/www/manager6/qemu/CPUOptions.js
+++ b/www/manager6/qemu/CPUOptions.js
@@ -5,7 +5,6 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
     onGetValues: function(values) {
 	var me = this;
 
-	PVE.Utils.delete_if_default(values, 'vcpus', '', 0);
 	PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
 	PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
 
@@ -17,12 +16,13 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
 
         var items = [
             {
-                xtype: 'pveIntegerField',
+                xtype: 'proxmoxintegerfield',
                 name: 'vcpus',
                 minValue: 1,
                 maxValue: me.maxvcpus,
                 value: '',
                 fieldLabel: gettext('VCPUs'),
+		deleteEmpty: true,
                 allowBlank: true,
                 emptyText: me.maxvcpus
             },
@@ -38,12 +38,13 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
                 emptyText: gettext('unlimited')
             },
 	    {
-                xtype: 'pveIntegerField',
+                xtype: 'proxmoxintegerfield',
                 name: 'cpuunits',
                 fieldLabel: gettext('CPU units'),
                 minValue: 8,
                 maxValue: 500000,
                 value: '1024',
+		deleteEmpty: true,
                 allowBlank: true
             }
 	];
diff --git a/www/manager6/qemu/HDThrottle.js b/www/manager6/qemu/HDThrottle.js
index 8d2af2a6..1cae658f 100644
--- a/www/manager6/qemu/HDThrottle.js
+++ b/www/manager6/qemu/HDThrottle.js
@@ -109,7 +109,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
 
         me.column2.push(me.mbps_wr_max);
 
-        me.iops_rd = Ext.widget('pveIntegerField', {
+        me.iops_rd = Ext.widget('proxmoxintegerfield', {
             name: 'iops_rd',
             minValue: 10,
             step: 10,
@@ -120,7 +120,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
 
         me.column1.push(me.iops_rd);
 
-        me.iops_rd_max = Ext.widget('pveIntegerField', {
+        me.iops_rd_max = Ext.widget('proxmoxintegerfield', {
             name: 'iops_rd_max',
             minValue: 10,
             step: 10,
@@ -131,7 +131,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
 
         me.column2.push(me.iops_rd_max);
 
-        me.iops_wr = Ext.widget('pveIntegerField', {
+        me.iops_wr = Ext.widget('proxmoxintegerfield', {
             name: 'iops_wr',
             minValue: 10,
             step: 10,
@@ -142,7 +142,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
 
         me.column1.push(me.iops_wr);
 
-        me.iops_wr_max = Ext.widget('pveIntegerField', {
+        me.iops_wr_max = Ext.widget('proxmoxintegerfield', {
             name: 'iops_wr_max',
             minValue: 10,
             step: 10,
diff --git a/www/manager6/qemu/MemoryEdit.js b/www/manager6/qemu/MemoryEdit.js
index f979d409..93b1b717 100644
--- a/www/manager6/qemu/MemoryEdit.js
+++ b/www/manager6/qemu/MemoryEdit.js
@@ -109,7 +109,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		}
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'balloon',
 		disabled: true,
 		minValue: 0,
@@ -122,7 +122,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		allowBlank: false
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'shares',
 		disabled: true,
 		minValue: 0,
diff --git a/www/manager6/qemu/NetworkEdit.js b/www/manager6/qemu/NetworkEdit.js
index 9339d846..bc72c1fc 100644
--- a/www/manager6/qemu/NetworkEdit.js
+++ b/www/manager6/qemu/NetworkEdit.js
@@ -149,7 +149,7 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
 		allowBlank: true
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'queues',
 		fieldLabel: 'Multiqueue',
 		minValue: 1,
diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
index a14e5c87..b6439388 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -49,7 +49,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 
 	me.column1 = [
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'sockets',
 		minValue: 1,
 		maxValue: 4,
@@ -65,7 +65,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 		}
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		name: 'cores',
 		minValue: 1,
 		maxValue: 128,
diff --git a/www/manager6/storage/DirEdit.js b/www/manager6/storage/DirEdit.js
index 4e196431..74255072 100644
--- a/www/manager6/storage/DirEdit.js
+++ b/www/manager6/storage/DirEdit.js
@@ -62,7 +62,7 @@ Ext.define('PVE.storage.DirInputPanel', {
 		fieldLabel: gettext('Shared')
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		fieldLabel: gettext('Max Backups'),
 		disabled: true,
 		name: 'maxfiles',
diff --git a/www/manager6/storage/GlusterFsEdit.js b/www/manager6/storage/GlusterFsEdit.js
index 1d135690..ac6cde63 100644
--- a/www/manager6/storage/GlusterFsEdit.js
+++ b/www/manager6/storage/GlusterFsEdit.js
@@ -148,7 +148,7 @@ Ext.define('PVE.storage.GlusterFsInputPanel', {
 		fieldLabel: gettext('Enable')
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		fieldLabel: gettext('Max Backups'),
 		disabled: true,
 		name: 'maxfiles',
diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
index 728a3ffd..954cceb3 100644
--- a/www/manager6/storage/NFSEdit.js
+++ b/www/manager6/storage/NFSEdit.js
@@ -143,7 +143,7 @@ Ext.define('PVE.storage.NFSInputPanel', {
 		fieldLabel: gettext('Enable')
 	    },
 	    {
-		xtype: 'pveIntegerField',
+		xtype: 'proxmoxintegerfield',
 		fieldLabel: gettext('Max Backups'),
 		disabled: true,
 		name: 'maxfiles',
diff --git a/www/manager6/window/BulkAction.js b/www/manager6/window/BulkAction.js
index 87e972b3..f7885cda 100644
--- a/www/manager6/window/BulkAction.js
+++ b/www/manager6/window/BulkAction.js
@@ -73,7 +73,7 @@ Ext.define('PVE.window.BulkAction', {
 		    onlineValidator: true
 		},
 		{
-		    xtype: 'pveIntegerField',
+		    xtype: 'proxmoxintegerfield',
 		    name: 'maxworkers',
 		    minValue: 1,
 		    maxValue: 100,
-- 
2.11.0





More information about the pve-devel mailing list