]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: ceph status: avoid messing with internal state of warning grid
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 8 Mar 2023 16:52:31 +0000 (17:52 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 8 Mar 2023 16:54:19 +0000 (17:54 +0100)
inline the transformation for the health store and also avoid setting
raw data from the outside

and drop some bogus comments along the way, first one should mostly
use "why?" not "what happens?" comments and second, commenting
straight forward things always makes one pause and recheck everything
far to often, as a comment indicates there something non-obvious
happening.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/ceph/Status.js

index 09e7fd1f268ea765bd849b745f7eaca8b5e433b6..46338b4ad8241e53706e5c421708d34ac7613670 100644 (file)
@@ -77,6 +77,21 @@ Ext.define('PVE.node.CephStatus', {
                        trackRemoved: false,
                        data: [],
                    },
+                   updateHealth: function(health) {
+                       let checks = health.checks || {};
+
+                       let checkRecords = Object.keys(checks).sort().map(key => {
+                           let check = checks[key];
+                           return {
+                               id: key,
+                               summary: check.summary.message,
+                               detail: check.detail.reduce((acc, v) => `${acc}\n${v.message}`, ''),
+                               severity: check.severity,
+                           };
+                       });
+
+                       this.getStore().loadRawData(checkRecords, false);
+                   },
                    emptyText: gettext('No Warnings/Errors'),
                    columns: [
                        {
@@ -256,22 +271,6 @@ Ext.define('PVE.node.CephStatus', {
        },
     ],
 
-    generateCheckData: function(health) {
-       var result = [];
-       let checks = health.checks || {};
-
-       Object.keys(checks).sort().forEach(key => {
-           let check = checks[key];
-           result.push({
-               id: key,
-               summary: check.summary.message,
-               detail: check.detail.reduce((acc, v) => `${acc}\n${v.message}`, ''),
-               severity: check.severity,
-           });
-       });
-       return result;
-    },
-
     updateAll: function(store, records, success) {
        if (!success || records.length === 0) {
            return;
@@ -283,13 +282,10 @@ Ext.define('PVE.node.CephStatus', {
 
        // add health panel
        me.down('#overallhealth').updateHealth(PVE.Utils.render_ceph_health(rec.data.health || {}));
-       // add errors to gridstore
-       me.down('#warnings').getStore().loadRawData(me.generateCheckData(rec.data.health || {}), false);
+       me.down('#warnings').updateHealth(rec.data.health || {}); // add errors to gridstore
 
-       // update services
        me.getComponent('services').updateAll(me.metadata || {}, rec.data);
 
-       // update detailstatus panel
        me.getComponent('statusdetail').updateAll(me.metadata || {}, rec.data);
 
        // add performance data