[pve-devel] [PATCH manager v4 8/9] ui: ceph/Pools: improve number checking for target_size

Dominik Csapak d.csapak at proxmox.com
Tue Apr 20 10:15:22 CEST 2021


the field gives us a string, so the second condition could never
be true, instead parse to a float instead

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/ceph/Pool.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 236ed0bc..45333f4d 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -161,15 +161,20 @@ Ext.define('PVE.CephPoolInputPanel', {
 	    }
 	});
 
-	if (Ext.isNumber(values.target_size) && values.target_size !== 0) {
-	    values.target_size = values.target_size*1024*1024*1024;
+	let target_size = Number.parseFloat(values.target_size);
+
+	if (Ext.isNumber(target_size) && target_size !== 0) {
+	    values.target_size = (target_size*1024*1024*1024).toFixed(0);
 	}
+
 	return values;
     },
 
     setValues: function(values) {
-	if (Ext.isNumber(values.target_size) && values.target_size !== 0) {
-	    values.target_size = values.target_size/1024/1024/1024;
+	let target_size = Number.parseFloat(values.target_size);
+
+	if (Ext.isNumber(target_size) && target_size !== 0) {
+	    values.target_size = target_size/1024/1024/1024;
 	}
 
 	this.callParent([values]);
-- 
2.20.1






More information about the pve-devel mailing list