merge: sync v2 stack base with dev

This commit is contained in:
ajnart committed 2026-09-10 19:53:57 +02:00
commit 0b8e2e0927
83 files changed
+25795 -23624

No files matched your search

@@ -9,6 +9,12 @@ describe("normalizeStorageDeviceName", () => {
expect(normalizeStorageDeviceName("/dev/sda")).toBe("/dev/sda");
});
test("strips partition suffixes from unprefixed device names (OpenMediaVault)", () => {
expect(normalizeStorageDeviceName("sda1")).toBe("sda");
expect(normalizeStorageDeviceName("sda")).toBe("sda");
expect(normalizeStorageDeviceName("nvme0n1p1")).toBe("nvme0n1");
});
test("preserves Synology-style volume names", () => {
expect(normalizeStorageDeviceName("volume_1")).toBe("volume_1");
expect(normalizeStorageDeviceName("volume_2")).toBe("volume_2");
@@ -139,4 +145,36 @@ describe("matchFileSystemAndSmart", () => {
overallStatus: "",
});
});
test("joins unprefixed OMV partitions with their base device SMART data", () => {
const result = matchFileSystemAndSmart(
[
{ deviceName: "sda1", used: "3.13 GiB", available: "26853056512", percentage: 12 },
{ deviceName: "sdb1", used: "396.24 GiB", available: "1542365618176", percentage: 22 },
],
[
{ deviceName: "sda", temperature: 0, overallStatus: "BAD_STATUS" },
{ deviceName: "sdb", temperature: 33, overallStatus: "GOOD" },
],
);
expect(result).toEqual([
{
deviceName: "sda",
used: "3.13 GiB",
available: "26853056512",
percentage: 12,
temperature: 0,
overallStatus: "BAD_STATUS",
},
{
deviceName: "sdb",
used: "396.24 GiB",
available: "1542365618176",
percentage: 22,
temperature: 33,
overallStatus: "GOOD",
},
]);
});
});
@@ -5,10 +5,16 @@ interface StorageVolumeEntry {
const partitionSuffixPatterns: ReadonlyArray<{ pattern: RegExp; baseGroupIndex: number }> = [
// SCSI/SATA/VirtIO: /dev/sda1 -> /dev/sda
{ pattern: /^(\/dev\/(?:sd|vd|hd|xvd)[a-z]+)[0-9]+$/, baseGroupIndex: 1 },
// SCSI/SATA/VirtIO without device node prefix: sda1 -> sda (OMV reports unprefixed names)
{ pattern: /^((?:sd|vd)[a-z]+)[0-9]+$/, baseGroupIndex: 1 },
// NVMe: /dev/nvme0n1p2 -> /dev/nvme0n1
{ pattern: /^(\/dev\/nvme[0-9]+n[0-9]+)p[0-9]+$/, baseGroupIndex: 1 },
// NVMe without device node prefix: nvme0n1p2 -> nvme0n1
{ pattern: /^(nvme[0-9]+n[0-9]+)p[0-9]+$/, baseGroupIndex: 1 },
// eMMC: /dev/mmcblk0p1 -> /dev/mmcblk0
{ pattern: /^(\/dev\/mmcblk[0-9]+)p[0-9]+$/, baseGroupIndex: 1 },
// eMMC without device node prefix: mmcblk0p1 -> mmcblk0
{ pattern: /^(mmcblk[0-9]+)p[0-9]+$/, baseGroupIndex: 1 },
];
export const normalizeStorageDeviceName = (deviceName: string): string => {
@@ -28,7 +34,7 @@ export const toScopedStorageVolumeValue = (integrationId: string, value: string)
return `${integrationId}:${volumeName}`;
};
const storageDeviceNamesMatch = (leftDeviceName: string, rightDeviceName: string): boolean => {
export const storageDeviceNamesMatch = (leftDeviceName: string, rightDeviceName: string): boolean => {
return (
leftDeviceName === rightDeviceName ||
normalizeStorageDeviceName(leftDeviceName) === normalizeStorageDeviceName(rightDeviceName)
@@ -18,16 +18,18 @@ const isClusterIntegration = (integration: { kind: IntegrationKind }) =>
integration.kind === "proxmox" || integration.kind === "mock";
export default function HealthMonitoringWidget(props: WidgetComponentProps<"healthMonitoring">) {
const { data: integrations = [] } = clientApi.integration.byIds.useQuery(props.integrationIds);
const { data: integrations, isPending, isError } = clientApi.integration.byIds.useQuery(props.integrationIds);
const t = useI18n();
const clusterIntegrationId = integrations.find(isClusterIntegration)?.id;
if (isPending || isError) return null;
const clusterIntegrationId = integrations?.find(isClusterIntegration)?.id;
if (!clusterIntegrationId) {
return <SystemHealthMonitoring {...props} />;
}
const otherIntegrationIds = integrations
const otherIntegrationIds = (integrations ?? [])
// We want to have the mock integration also in the system tab, so we use it for both
.filter((integration) => integration.kind !== "proxmox")
.map((integration) => integration.id);
@@ -36,7 +36,7 @@ import { formatBytes } from "@homarr/common";
import type { TranslationFunction } from "@homarr/translation";
import { useI18n } from "@homarr/translation/client";
import { filterStorageVolumes, normalizeStorageDeviceName } from "../filter-storage-volumes";
import { filterStorageVolumes, storageDeviceNamesMatch } from "../filter-storage-volumes";
import { WidgetEmptyState } from "../common/empty-state";
import type { WidgetComponentProps } from "../definition";
import { CpuRing } from "./rings/cpu-ring";
@@ -296,12 +296,7 @@ interface SmartData {
export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: SmartData[]) => {
return fileSystems
.map((fileSystem) => {
const normalizedFileSystemName = normalizeStorageDeviceName(fileSystem.deviceName);
const smartDisk = smartData.find(
(smart) =>
smart.deviceName === fileSystem.deviceName ||
normalizeStorageDeviceName(smart.deviceName) === normalizedFileSystemName,
);
const smartDisk = smartData.find((smart) => storageDeviceNamesMatch(smart.deviceName, fileSystem.deviceName));
return {
deviceName: smartDisk?.deviceName ?? fileSystem.deviceName,
@@ -10,7 +10,7 @@ import { useI18n } from "@homarr/translation/client";
import { WidgetEmptyState } from "../common/empty-state";
import type { WidgetComponentProps } from "../definition";
import { filterStorageVolumes } from "../filter-storage-volumes";
import { filterStorageVolumes, storageDeviceNamesMatch } from "../filter-storage-volumes";
import { NoIntegrationDataError } from "../errors/no-data-integration";
type DisplayMode = WidgetComponentProps<"systemDisks">["options"]["displayMode"];
@@ -140,7 +140,7 @@ export default function SystemResources({ integrationIds, options }: WidgetCompo
return (
<Stack gap="xs" p="xs" h="100%">
{fileSystem.map((item) => {
const smartItem = smart.find((smart) => smart.deviceName === item.deviceName);
const smartItem = smart.find((smart) => storageDeviceNamesMatch(smart.deviceName, item.deviceName));
return (
<SystemDiskCard