Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix(cluster-health): storage items multiply (#3206)

Meier Lukas11149348fcbe
diff --git a/packages/integrations/src/proxmox/proxmox-integration.ts b/packages/integrations/src/proxmox/proxmox-integration.ts
index 3f185ab20..cdf6c8064 100644
--- a/packages/integrations/src/proxmox/proxmox-integration.ts
+++ b/packages/integrations/src/proxmox/proxmox-integration.ts
@@ -69,6 +69,7 @@ const mapResource = (resource: Proxmox.clusterResourcesResources): Resource | nu
const mapComputeResource = (resource: Proxmox.clusterResourcesResources): Omit<ComputeResourceBase<string>, "type"> => {
return {
+ id: resource.id,
cpu: {
utilization: resource.cpu ?? 0,
cores: resource.maxcpu ?? 0,
@@ -114,6 +115,7 @@ const mapVmResource = (resource: Proxmox.clusterResourcesResources): LxcResource
const mapStorageResource = (resource: Proxmox.clusterResourcesResources): StorageResource => {
return {
+ id: resource.id,
type: "storage",
name: resource.storage ?? "",
node: resource.node ?? "",
diff --git a/packages/integrations/src/proxmox/proxmox-types.ts b/packages/integrations/src/proxmox/proxmox-types.ts
index af0db647b..12808db05 100644
--- a/packages/integrations/src/proxmox/proxmox-types.ts
+++ b/packages/integrations/src/proxmox/proxmox-types.ts
@@ -7,6 +7,7 @@ interface ResourceBase<TType extends string> {
}
export interface ComputeResourceBase<TType extends string> extends ResourceBase<TType> {
+ id: string;
cpu: {
utilization: number; // previously cpu (0-1)
cores: number; // previously cpuCores
@@ -40,6 +41,7 @@ export interface QemuResource extends ComputeResourceBase<"qemu"> {
}
export interface StorageResource extends ResourceBase<"storage"> {
+ id: string;
storagePlugin: string;
used: number; // previously disk
total: number; // previously maxDisk
diff --git a/packages/widgets/src/health-monitoring/cluster/resource-table.tsx b/packages/widgets/src/health-monitoring/cluster/resource-table.tsx
index 8f3637f19..1b0d4fe6f 100644
--- a/packages/widgets/src/health-monitoring/cluster/resource-table.tsx
+++ b/packages/widgets/src/health-monitoring/cluster/resource-table.tsx
@@ -38,34 +38,40 @@ export const ResourceTable = ({ type, data, isTiny }: ResourceTableProps) => {
</TableTr>
</TableThead>
<TableTbody>
- {data.map((item) => {
- return (
- <ResourcePopover key={item.name} item={item}>
- <Popover.Target>
- <TableTr fz={isTiny ? "8px" : "xs"}>
- <td>
- <Group wrap="nowrap" gap={isTiny ? 8 : "xs"}>
- <Indicator size={isTiny ? 4 : 8} children={null} color={item.isRunning ? "green" : "yellow"} />
- <Text lineClamp={1} fz={isTiny ? "8px" : "xs"}>
- {item.name}
- </Text>
- </Group>
- </td>
- {item.type === "storage" ? (
- <td style={{ WebkitLineClamp: "1" }}>{item.node}</td>
- ) : (
- <>
- <td style={{ whiteSpace: "nowrap" }}>{(item.cpu.utilization * 100).toFixed(1)}%</td>
- <td style={{ whiteSpace: "nowrap" }}>
- {(item.memory.total ? (item.memory.used / item.memory.total) * 100 : 0).toFixed(1)}%
- </td>
- </>
- )}
- </TableTr>
- </Popover.Target>
- </ResourcePopover>
- );
- })}
+ {data
+ .sort((itemA, itemB) => {
+ const nodeResult = itemA.node.localeCompare(itemB.node);
+ if (nodeResult !== 0) return nodeResult;
+ return itemA.name.localeCompare(itemB.name);
+ })
+ .map((item) => {
+ return (
+ <ResourcePopover key={item.id} item={item}>
+ <Popover.Target>
+ <TableTr fz={isTiny ? "8px" : "xs"}>
+ <td>
+ <Group wrap="nowrap" gap={isTiny ? 8 : "xs"}>
+ <Indicator size={isTiny ? 4 : 8} children={null} color={item.isRunning ? "green" : "yellow"} />
+ <Text lineClamp={1} fz={isTiny ? "8px" : "xs"}>
+ {item.name}
+ </Text>
+ </Group>
+ </td>
+ {item.type === "storage" ? (
+ <td style={{ WebkitLineClamp: "1" }}>{item.node}</td>
+ ) : (
+ <>
+ <td style={{ whiteSpace: "nowrap" }}>{(item.cpu.utilization * 100).toFixed(1)}%</td>
+ <td style={{ whiteSpace: "nowrap" }}>
+ {(item.memory.total ? (item.memory.used / item.memory.total) * 100 : 0).toFixed(1)}%
+ </td>
+ </>
+ )}
+ </TableTr>
+ </Popover.Target>
+ </ResourcePopover>
+ );
+ })}
</TableTbody>
</Table>
);