public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values
@ 2022-03-10 14:31 Dominik Csapak
  2022-03-11  9:13 ` Matthias Heiserer
  2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2022-03-10 14:31 UTC (permalink / raw)
  To: pve-devel

Sometimes, total can be zero (e.g. for swap when it's not used), which
leads to the usage being NaN. This led to the progressbar not being
updated for InfoWidgets, leaving a spurious '0%' as text.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/panel/StatusView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/panel/StatusView.js b/src/panel/StatusView.js
index 4a60dae..e2e81e2 100644
--- a/src/panel/StatusView.js
+++ b/src/panel/StatusView.js
@@ -47,7 +47,7 @@ Ext.define('Proxmox.panel.StatusView', {
 	     */
 	    if (used.used !== undefined &&
 		used.total !== undefined) {
-		return used.used/used.total;
+		return used.total > 0 ? used.used/used.total : 0;
 	    }
 	}
 
-- 
2.30.2





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

end of thread, other threads:[~2022-04-26  6:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 14:31 [pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values Dominik Csapak
2022-03-11  9:13 ` Matthias Heiserer
2022-03-11  9:52   ` Dominik Csapak
2022-04-26  6:29 ` [pve-devel] applied: " Thomas Lamprecht

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