public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH] Signed-off-by: David Gonzalo Rodriguez <z80user@gmail.com>
@ 2026-05-27 14:41 David Gonzalo Rodriguez
  2026-05-27 15:44 ` Stoiko Ivanov
  0 siblings, 1 reply; 2+ messages in thread
From: David Gonzalo Rodriguez @ 2026-05-27 14:41 UTC (permalink / raw)
  To: pve-devel; +Cc: David Gonzalo Rodriguez

Fix the unit to show GiB on the user interface as default, it will show
"useSI" on the right units if is setup on the variable as true or false
The use a ternary expression here would produce incorrect results.
usually "useSI" is an object instead true or false.
---
 pve-common   |  1 +
 src/Utils.js | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 160000 pve-common

diff --git a/pve-common b/pve-common
new file mode 160000
index 0000000..971bb05
--- /dev/null
+++ b/pve-common
@@ -0,0 +1 @@
+Subproject commit 971bb05bf9ef4897083d8366e459a92b2b36c763
diff --git a/src/Utils.js b/src/Utils.js
index 7643316..71e027a 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -808,17 +808,35 @@ Ext.define('Proxmox.Utils', {
             ];
             let order = 0;
             let commaDigits = 2;
-            const baseValue = useSI ? 1000 : 1024;
+
+// Do not use a ternary expression here and on the next check.
+// `useSI` may not exist and implicit truthy/falsy conversion
+// would produce incorrect results.
+            let baseValue = 1024;
+            if (useSI === true) {
+                baseValue = 1000;
+            }
+            if (useSI === false) {
+                baseValue = 1024;
+            }
             while (size >= baseValue && order < unitsSI.length) {
                 size = size / baseValue;
                 order++;
             }
 
-            let unit = useSI ? unitsSI[order] : unitsIEC[order];
+            unit = unitsIEC[order];
+            if (useSI === true) {
+                unit = unitsSI[order];
+            }
+            if (useSI === false) {
+                unit = unitsIEC[order];
+            }
             if (order === 0) {
                 commaDigits = 0;
             }
             return `${size.toFixed(commaDigits)} ${unit}`;
+
+
         },
 
         SizeUnits: {
-- 
2.47.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-27 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 14:41 [PATCH] Signed-off-by: David Gonzalo Rodriguez <z80user@gmail.com> David Gonzalo Rodriguez
2026-05-27 15:44 ` Stoiko Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal