]> git.proxmox.com Git - proxmox-backup.git/commitdiff
'available' field in rrd data in the API and change usage of 'total'
authorDaniel Tschlatscher <d.tschlatscher@proxmox.com>
Wed, 9 Nov 2022 14:25:23 +0000 (15:25 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 24 Nov 2022 12:26:27 +0000 (13:26 +0100)
The API now exposes the field 'available' as well, with which the
unprivileged total is calculated in all corresponsing views in the
frontend.
The rrd charts now also display the total as the unprivileged total
if available, otherwise the absolute total is used.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
src/api2/admin/datastore.rs
www/dashboard/DataStoreStatistics.js
www/datastore/DataStoreListSummary.js
www/datastore/Summary.js

index e66e1c0bb5ff1969c90d5c740e53bffbf6d2b618..c8e86b07077e2c40b7a87009b801bd3e60e82989 100644 (file)
@@ -1804,6 +1804,7 @@ pub fn get_rrd_stats(
 
     let mut rrd_fields = vec![
         "total",
+        "available",
         "used",
         "read_ios",
         "read_bytes",
index 38f7a2feb1d68391ac579a5a557d6c512925021a..0510fc7d517bc54f258285f1095e3173b4873ee7 100644 (file)
@@ -3,7 +3,12 @@ Ext.define('pbs-datastore-statistics', {
 
     fields: [
        'store',
-       'total',
+       {
+           name: 'total',
+           calculate: function(data) {
+               return data.avail + data.used;
+           },
+       },
        'used',
        'avail',
        'estimated-full-date',
index c7b67d5663a79d5f7100124df8f32c12bd357374..bec0562de6bb60a7c6863cc0cbfdca407e1df1ba 100644 (file)
@@ -52,10 +52,11 @@ Ext.define('PBS.datastore.DataStoreListSummary', {
            vm.set('maintenance', '');
        }
 
-       let usage = statusData.used/statusData.total;
+       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(statusData.total, true),
+           Proxmox.Utils.format_size(total, true),
        );
 
        let usagePanel = me.lookup('usage');
index 94be9559a6b6a364759d1059a31392fcc3a15be8..d67e81cca07953c937d1913820c189defa2210d6 100644 (file)
@@ -3,6 +3,20 @@ Ext.define('pve-rrd-datastore', {
     fields: [
        'used',
        'total',
+       {
+           name: 'unpriv-total', // Can't resuse 'total' here as that creates a stack overflow
+           calculate: function(data) {
+               let used = data.used;
+               let avail = data.available;
+
+               if (avail && used) {
+                   return avail + used;
+               }
+
+               return data.total;
+           },
+       },
+       'available',
        'read_ios',
        'read_bytes',
        'write_ios',
@@ -66,8 +80,8 @@ Ext.define('PBS.DataStoreInfo', {
            let vm = me.getViewModel();
 
            let counts = store.getById('counts').data.value;
-           let total = store.getById('total').data.value;
            let used = store.getById('used').data.value;
+           let total = store.getById('avail').data.value + used;
 
            let usage = Proxmox.Utils.render_size_usage(used, total, true);
            vm.set('usagetext', usage);
@@ -236,7 +250,7 @@ Ext.define('PBS.DataStoreSummary', {
        {
            xtype: 'proxmoxRRDChart',
            title: gettext('Storage usage (bytes)'),
-           fields: ['total', 'used'],
+           fields: ['unpriv-total', 'used'],
            fieldTitles: [gettext('Total'), gettext('Storage usage')],
        },
        {