[pve-devel] [PATCH manager 1/2] add pveIntegerfield and use it
Dominik Csapak
d.csapak at proxmox.com
Wed Nov 2 16:16:56 CET 2016
this adds a subclass of Ext.form.field.Number with the settings for
Integers (allowDecimals: false and allowExponential: false and default
step size 1)
and use it where we only accept integers
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/ceph/Pool.js | 8 ++++----
www/manager6/dc/AuthEdit.js | 12 +++---------
www/manager6/form/ControllerSelector.js | 2 +-
www/manager6/form/IntegerField.js | 8 ++++++++
www/manager6/grid/FirewallOptions.js | 3 +--
www/manager6/ha/GroupEdit.js | 2 +-
www/manager6/ha/ResourceEdit.js | 8 ++------
www/manager6/lxc/Options.js | 3 +--
www/manager6/lxc/ResourceEdit.js | 11 ++++-------
www/manager6/qemu/CPUOptions.js | 4 ++--
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/MigrateAll.js | 2 +-
19 files changed, 41 insertions(+), 47 deletions(-)
create mode 100644 www/manager6/form/IntegerField.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 62eccbe..d35ac35 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -26,6 +26,7 @@ JSSRC= \
form/VLanField.js \
form/Checkbox.js \
form/TextField.js \
+ form/IntegerField.js \
form/RRDTypeSelector.js \
form/ComboGrid.js \
form/KVComboBox.js \
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index c4e8dff..b45596f 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -16,7 +16,7 @@ Ext.define('PVE.CephCreatePool', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Size'),
name: 'size',
value: 2,
@@ -25,7 +25,7 @@ Ext.define('PVE.CephCreatePool', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Min. Size'),
name: 'min_size',
value: 1,
@@ -34,7 +34,7 @@ Ext.define('PVE.CephCreatePool', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Crush RuleSet'),
name: 'crush_ruleset',
value: 0,
@@ -43,7 +43,7 @@ Ext.define('PVE.CephCreatePool', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: 'pg_num',
name: 'pg_num',
value: 64,
diff --git a/www/manager6/dc/AuthEdit.js b/www/manager6/dc/AuthEdit.js
index de51062..8198a1f 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: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'port',
fieldLabel: gettext('Port'),
minValue: 1,
@@ -147,13 +147,10 @@ Ext.define('PVE.dc.AuthEdit', {
});
column2.push({
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'oath_step',
value: '',
minValue: 10,
- step: 1,
- allowDecimals: false,
- allowBlank: true,
emptyText: PVE.Utils.defaultText + ' (30)',
submitEmptyText: false,
hidden: true,
@@ -161,14 +158,11 @@ Ext.define('PVE.dc.AuthEdit', {
});
column2.push({
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'oath_digits',
value: '',
minValue: 6,
maxValue: 8,
- step: 1,
- allowDecimals: false,
- allowBlank: true,
emptyText: PVE.Utils.defaultText + ' (6)',
submitEmptyText: false,
hidden: true,
diff --git a/www/manager6/form/ControllerSelector.js b/www/manager6/form/ControllerSelector.js
index bf8a53e..fa3df16 100644
--- a/www/manager6/form/ControllerSelector.js
+++ b/www/manager6/form/ControllerSelector.js
@@ -122,7 +122,7 @@ Ext.define('PVE.form.ControllerSelector', {
}
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'deviceid',
minValue: 0,
maxValue: PVE.form.ControllerSelector.maxIds.ide,
diff --git a/www/manager6/form/IntegerField.js b/www/manager6/form/IntegerField.js
new file mode 100644
index 0000000..2453415
--- /dev/null
+++ b/www/manager6/form/IntegerField.js
@@ -0,0 +1,8 @@
+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 26ee373..b624407 100644
--- a/www/manager6/grid/FirewallOptions.js
+++ b/www/manager6/grid/FirewallOptions.js
@@ -59,10 +59,9 @@ Ext.define('PVE.FirewallOptions', {
subject: text,
fieldDefaults: { labelWidth: labelWidth || 100 },
items: {
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: name,
minValue: minValue,
- decimalPrecision: 0,
fieldLabel: text,
emptyText: gettext('Default'),
getSubmitData: function() {
diff --git a/www/manager6/ha/GroupEdit.js b/www/manager6/ha/GroupEdit.js
index db9cf74..7f3da3f 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: 'numberfield',
+ xtype: 'pveIntegerfield',
minValue: 0,
maxValue: 1000,
listeners: {
diff --git a/www/manager6/ha/ResourceEdit.js b/www/manager6/ha/ResourceEdit.js
index 326d268..69c6e28 100644
--- a/www/manager6/ha/ResourceEdit.js
+++ b/www/manager6/ha/ResourceEdit.js
@@ -48,25 +48,21 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
validateExists: true
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'max_restart',
fieldLabel: gettext('Max. Restart'),
value: 1,
minValue: 0,
maxValue: 10,
- allowDecimals: false,
- allowExponential: false,
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'max_relocate',
fieldLabel: gettext('Max. Relocate'),
value: 1,
minValue: 0,
maxValue: 10,
- allowDecimals: false,
- allowExponential: false,
allowBlank: false
}
];
diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index 8871554..c5d42b1 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -78,9 +78,8 @@ Ext.define('PVE.lxc.Options', {
xtype: 'pveWindowEdit',
subject: gettext('TTY count'),
items: {
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'tty',
- decimalPrecision: 0,
minValue: 0,
maxValue: 6,
value: 2,
diff --git a/www/manager6/lxc/ResourceEdit.js b/www/manager6/lxc/ResourceEdit.js
index dd1639c..900c67a 100644
--- a/www/manager6/lxc/ResourceEdit.js
+++ b/www/manager6/lxc/ResourceEdit.js
@@ -119,13 +119,10 @@ Ext.define('PVE.lxc.CPUInputPanel', {
var column1 = [
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'cores',
minValue: 1,
maxValue: 128,
- step: 1,
- allowDecimals: false,
- allowExponential: false,
value: me.insideWizard ? 1 : '',
fieldLabel: gettext('Cores'),
allowBlank: true,
@@ -146,7 +143,7 @@ Ext.define('PVE.lxc.CPUInputPanel', {
emptyText: gettext('unlimited')
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'cpuunits',
fieldLabel: gettext('CPU units'),
value: 1024,
@@ -181,7 +178,7 @@ Ext.define('PVE.lxc.MemoryInputPanel', {
var items = [
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'memory',
minValue: 32,
maxValue: 512*1024,
@@ -192,7 +189,7 @@ Ext.define('PVE.lxc.MemoryInputPanel', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'swap',
minValue: 0,
maxValue: 128*1024,
diff --git a/www/manager6/qemu/CPUOptions.js b/www/manager6/qemu/CPUOptions.js
index 5ee7afb..aec9da6 100644
--- a/www/manager6/qemu/CPUOptions.js
+++ b/www/manager6/qemu/CPUOptions.js
@@ -17,7 +17,7 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
var items = [
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'vcpus',
minValue: 1,
maxValue: me.maxvcpus,
@@ -38,7 +38,7 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
emptyText: gettext('unlimited')
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'cpuunits',
fieldLabel: gettext('CPU units'),
minValue: 8,
diff --git a/www/manager6/qemu/HDThrottle.js b/www/manager6/qemu/HDThrottle.js
index 7506cff..400185e 100644
--- a/www/manager6/qemu/HDThrottle.js
+++ b/www/manager6/qemu/HDThrottle.js
@@ -111,7 +111,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
me.column2.push(me.mbps_wr_max);
- me.iops_rd = Ext.widget('numberfield', {
+ me.iops_rd = Ext.widget('pveIntegerfield', {
name: 'iops_rd',
minValue: 10,
step: 10,
@@ -122,7 +122,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
me.column1.push(me.iops_rd);
- me.iops_rd_max = Ext.widget('numberfield', {
+ me.iops_rd_max = Ext.widget('pveIntegerfield', {
name: 'iops_rd_max',
minValue: 10,
step: 10,
@@ -133,7 +133,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
me.column2.push(me.iops_rd_max);
- me.iops_wr = Ext.widget('numberfield', {
+ me.iops_wr = Ext.widget('pveIntegerfield', {
name: 'iops_wr',
minValue: 10,
step: 10,
@@ -144,7 +144,7 @@ Ext.define('PVE.qemu.HDThrottleInputPanel', {
me.column1.push(me.iops_wr);
- me.iops_wr_max = Ext.widget('numberfield', {
+ me.iops_wr_max = Ext.widget('pveIntegerfield', {
name: 'iops_wr_max',
minValue: 10,
step: 10,
diff --git a/www/manager6/qemu/MemoryEdit.js b/www/manager6/qemu/MemoryEdit.js
index e9ee432..4b9d889 100644
--- a/www/manager6/qemu/MemoryEdit.js
+++ b/www/manager6/qemu/MemoryEdit.js
@@ -93,7 +93,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
}
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'balloon',
disabled: true,
minValue: 0,
@@ -106,7 +106,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
allowBlank: false
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'shares',
disabled: true,
minValue: 0,
diff --git a/www/manager6/qemu/NetworkEdit.js b/www/manager6/qemu/NetworkEdit.js
index 9a4875d..a08abbb 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: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'queues',
fieldLabel: gettext('Multiqueues'),
minValue: 1,
diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
index be15354..87ef406 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -42,7 +42,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
me.column1 = [
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'sockets',
minValue: 1,
maxValue: 4,
@@ -58,7 +58,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
}
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'cores',
minValue: 1,
maxValue: 128,
diff --git a/www/manager6/storage/DirEdit.js b/www/manager6/storage/DirEdit.js
index e38c231..cd31fa4 100644
--- a/www/manager6/storage/DirEdit.js
+++ b/www/manager6/storage/DirEdit.js
@@ -61,7 +61,7 @@ Ext.define('PVE.storage.DirInputPanel', {
fieldLabel: gettext('Shared')
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Max Backups'),
name: 'maxfiles',
minValue: 0,
diff --git a/www/manager6/storage/GlusterFsEdit.js b/www/manager6/storage/GlusterFsEdit.js
index 3a04fb4..cd2c265 100644
--- a/www/manager6/storage/GlusterFsEdit.js
+++ b/www/manager6/storage/GlusterFsEdit.js
@@ -147,7 +147,7 @@ Ext.define('PVE.storage.GlusterFsInputPanel', {
fieldLabel: gettext('Enable')
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Max Backups'),
name: 'maxfiles',
minValue: 0,
diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
index 20ba83b..345370f 100644
--- a/www/manager6/storage/NFSEdit.js
+++ b/www/manager6/storage/NFSEdit.js
@@ -142,7 +142,7 @@ Ext.define('PVE.storage.NFSInputPanel', {
fieldLabel: gettext('Enable')
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
fieldLabel: gettext('Max Backups'),
name: 'maxfiles',
minValue: 0,
diff --git a/www/manager6/window/MigrateAll.js b/www/manager6/window/MigrateAll.js
index 525735b..e4b45ae 100644
--- a/www/manager6/window/MigrateAll.js
+++ b/www/manager6/window/MigrateAll.js
@@ -48,7 +48,7 @@ Ext.define('PVE.window.MigrateAll', {
onlineValidator: true
},
{
- xtype: 'numberfield',
+ xtype: 'pveIntegerfield',
name: 'maxworkers',
minValue: 1,
maxValue: 100,
--
2.1.4
More information about the pve-devel
mailing list