Enhancement: Add support for specifying a datastore to PBS widget (#4614)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
choehn86 2025-04-28 11:00:02 -04:00 committed by GitHub
parent a35da39c03
commit 4a9ca62efd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -362,6 +362,9 @@ export function cleanServiceGroups(groups) {
// proxmox
node,
// proxmoxbackupserver
datastore,
// speedtest
bitratePrecision,
@ -437,6 +440,9 @@ export function cleanServiceGroups(groups) {
if (type === "proxmox") {
if (node) widget.node = node;
}
if (type === "proxmoxbackupserver") {
if (datastore) widget.datastore = datastore;
}
if (type === "kubernetes") {
if (namespace) widget.namespace = namespace;
if (app) widget.app = app;

View File

@ -29,7 +29,18 @@ export default function Component({ service }) {
);
}
const datastoreUsage = datastoreData.data ? (datastoreData.data[0].used / datastoreData.data[0].total) * 100 : 0;
const datastoreIndex = !!widget.datastore
? datastoreData.data.findIndex(function (ds) {
return ds.store == widget.datastore;
})
: -1;
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 memoryUsage = (hostData.data.memory.used / hostData.data.memory.total) * 100;
const failedTasks = tasksData.total >= 100 ? "99+" : tasksData.total;