]> git.proxmox.com Git - proxmox-backup.git/commitdiff
ui: datastore summary handle non-existent values
authorGabriel Goller <g.goller@proxmox.com>
Mon, 11 Dec 2023 08:59:01 +0000 (09:59 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 11 Dec 2023 12:08:51 +0000 (13:08 +0100)
Correctly display missing 'avail' and 'used' attributes in the
datatstore summary. This simply sets it to 0, so that we don't get any
errors in the console.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
www/datastore/DataStoreListSummary.js

index 968239b0e960e287a2eb448313655cdb132de514..b908034d8041aeff3f564a1d44f5aa810e6de672 100644 (file)
@@ -52,12 +52,20 @@ Ext.define('PBS.datastore.DataStoreListSummary', {
            vm.set('maintenance', '');
        }
 
-       let total = statusData.avail + statusData.used;
-       let usage = statusData.used / total;
-       let usagetext = Ext.String.format(gettext('{0} of {1}'),
-           Proxmox.Utils.format_size(statusData.used, true),
-           Proxmox.Utils.format_size(total, true),
-       );
+       let usagetext;
+       let usage;
+
+       if (Object.hasOwn(statusData, 'avail') && Object.hasOwn(statusData, 'used')) {
+           let total = statusData.avail + statusData.used;
+           usage = statusData.used / total;
+           usagetext = Ext.String.format(gettext('{0} of {1}'),
+               Proxmox.Utils.format_size(statusData.used, true),
+               Proxmox.Utils.format_size(total, true),
+           );
+       } else {
+           usagetext = Ext.String.format(gettext('{0} of {1}'), 0, 0);
+           usage = 0;
+       }
 
        let usagePanel = me.lookup('usage');
        usagePanel.updateValue(usage, usagetext);