ui: ceph status: avoid messing with internal state of warning grid

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>
This commit is contained in:
Thomas Lamprecht 2023-03-08 17:52:31 +01:00
parent 616d54de16
commit b8febbcc60

View 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