]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
StatusView: fix usage calculation for fields without valid values
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 10 Mar 2022 14:31:37 +0000 (15:31 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 26 Apr 2022 06:28:28 +0000 (08:28 +0200)
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

index 4a60daeba0431db31c4b62ac753fc2a4df33a8a0..e2e81e292bf3ce613549cf85daec0c958edbeecb 100644 (file)
@@ -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;
            }
        }