Update component.jsx
Changed to accommodate multiple datastores or a specific datastore supplied in services.yaml
This commit is contained in:
parent
1e556e105d
commit
2f28b7790e
@ -29,7 +29,15 @@ export default function Component({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const datastoreUsage = datastoreData.data ? (datastoreData.data[0].used / datastoreData.data[0].total) * 100 : 0;
|
// check for presence of datastore key
|
||||||
|
const hasDatastore = !!widget.datastore;
|
||||||
|
// return index of specified datastore
|
||||||
|
const datastoreIndex = hasDatastore ? datastoreData.data.findIndex(function(ds) { return ds.store == widget.datastore }) : -1;
|
||||||
|
// calculate usage for specified datastore, unless no match, then calculate for all datastores returned by API
|
||||||
|
const datastoreUsage = (datastoreIndex > -1)
|
||||||
|
? (datastoreData.data[datastoreIndex].used / datastoreData.data[datastoreIndex].total) * 100
|
||||||
|
: ((datastoreData.data.reduce((sum, datastore) => sum + datastore.used, 0) / (datastoreData.data.reduce((sum, datastore) => sum + datastore.total, 0)))) * 100;
|
||||||
|
|
||||||
const cpuUsage = hostData.data.cpu * 100;
|
const cpuUsage = hostData.data.cpu * 100;
|
||||||
const memoryUsage = (hostData.data.memory.used / hostData.data.memory.total) * 100;
|
const memoryUsage = (hostData.data.memory.used / hostData.data.memory.total) * 100;
|
||||||
const failedTasks = tasksData.total >= 100 ? "99+" : tasksData.total;
|
const failedTasks = tasksData.total >= 100 ? "99+" : tasksData.total;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user