feat: Initial commit for health monitoring widget with graphs (Work in Progress)

This commit is contained in:
SeDemal authored and Manuel committed 2025-04-10 21:51:00 +02:00
1 parent 94263c445b
commit 3b20c96c35
20 files changed
+665 -670

No files matched your search

@@ -1,53 +1,362 @@
"use client";
import { ScrollArea, Tabs } from "@mantine/core";
import { AreaChart, getFilteredChartTooltipPayload } from "@mantine/charts";
import type { DefaultMantineColor } from "@mantine/core";
import { Box, Group, Progress, Stack, Tabs, Text } from "@mantine/core";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { clientApi } from "@homarr/api/client";
import { humanFileSize } from "@homarr/common";
import type { HealthMonitoring } from "@homarr/integrations";
import type { TranslationFunction } from "@homarr/translation";
import { useI18n } from "@homarr/translation/client";
import type { WidgetComponentProps } from "../definition";
import { ClusterHealthMonitoring } from "./cluster/cluster-health";
import { SystemHealthMonitoring } from "./system-health";
import "@mantine/charts/styles.css";
import type { AtLeastOneOf } from "@homarr/common/types";
import { NoIntegrationSelectedError } from "../errors/no-integration-selected";
dayjs.extend(duration);
export default function HealthMonitoringWidget(props: WidgetComponentProps<"healthMonitoring">) {
const [integrations] = clientApi.integration.byIds.useSuspenseQuery(props.integrationIds);
const [healthData] = clientApi.widget.healthMonitoring.getHealthStatus.useSuspenseQuery(
{
integrationIds: props.integrationIds,
maxElements: Number(props.options.pointDensity),
pointCount: Number(props.options.pointDensity),
},
{
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
retry: false,
},
);
const utils = clientApi.useUtils();
clientApi.widget.healthMonitoring.subscribeHealthStatus.useSubscription(
{
integrationIds: props.integrationIds,
maxElements: Number(props.options.pointDensity),
},
{
onData(data) {
utils.widget.healthMonitoring.getHealthStatus.setData(
{
integrationIds: props.integrationIds,
maxElements: Number(props.options.pointDensity),
pointCount: Number(props.options.pointDensity),
},
(prevData) => {
if (!prevData) {
return undefined;
}
const newData = prevData.map((item) =>
item.integration.id === data.integration.id
? {
integration: item.integration,
healthInfo: {
timestamp: data.healthInfo.timestamp,
data: {
...data.healthInfo.data,
history: [...item.healthInfo.data.history, ...data.healthInfo.data.history].slice(
-Number(props.options.pointDensity),
) as AtLeastOneOf<HealthMonitoring["history"][number]>,
},
},
}
: item,
);
return newData;
},
);
},
},
);
const t = useI18n();
const proxmoxIntegrationId = integrations.find((integration) => integration.kind === "proxmox")?.id;
if (!proxmoxIntegrationId) {
return <SystemHealthMonitoring {...props} />;
}
const otherIntegrationIds = integrations
.filter((integration) => integration.kind !== "proxmox")
.map((integration) => integration.id);
if (otherIntegrationIds.length === 0) {
return <ClusterHealthMonitoring {...props} integrationId={proxmoxIntegrationId} />;
if (props.integrationIds.length === 0) {
throw new NoIntegrationSelectedError();
}
return (
<ScrollArea h="100%">
<Tabs defaultValue={props.options.defaultTab} variant="outline">
<Tabs.List grow>
<Tabs.Tab value="system" fz="xs">
<b>{t("widget.healthMonitoring.tab.system")}</b>
<Tabs
defaultValue={props.integrationIds[0]}
h="100%"
display="flex"
dir="vertical"
style={{ flexDirection: "column" }}
>
<Tabs.List flex={0} display={healthData.length > 1 ? "flex" : "none"}>
{healthData.map(({ integration }) => (
<Tabs.Tab value={integration.id} key={integration.id}>
{integration.name}
</Tabs.Tab>
<Tabs.Tab value="cluster" fz="xs">
<b>{t("widget.healthMonitoring.tab.cluster")}</b>
</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="system">
<SystemHealthMonitoring {...props} integrationIds={otherIntegrationIds} />
</Tabs.Panel>
<Tabs.Panel value="cluster">
<ClusterHealthMonitoring integrationId={proxmoxIntegrationId} {...props} />
</Tabs.Panel>
</Tabs>
</ScrollArea>
))}
</Tabs.List>
{healthData.map(({ integration, healthInfo: { data } }) => {
return (
<Tabs.Panel
value={integration.id}
key={integration.id}
flex="1 1 auto"
display="flex"
style={{ flexDirection: "column" }}
h="100%"
>
{props.options.systemInfo && (
<Box p="sm">
<Stack gap={2} align="center">
<Text fz="md" fw="bold">{data.system.name}</Text>
<Text fz="sm">{formatUptime(data.system.uptime, t)}</Text>
</Stack>
</Box>
)}
{props.options.cpu && (
<GridAreaChart columns={Number(props.options.cpuColumns)} data={data} series={["cpu"]} />
)}
{props.options.memory && data.system.type === "single" && (
<GridAreaChart columns={1} data={data} series={["memory"]} />
)}
{props.options.network && <GridAreaChart columns={1} data={data} series={["networkUp", "networkDown"]} />}
{props.options.fileSystem && (
<StorageEntries columns={1} fahrenheit={props.options.fahrenheit} storages={data.storage} />
)}
</Tabs.Panel>
);
})}
</Tabs>
);
}
type HistoryKeys = keyof Omit<HealthMonitoring["history"][number], "timestamp">;
const historyFormatTable = {
cpu: { key: "cpu", color: "blue", format: "percent", negative: false },
memory: { key: "memory", color: "orange", format: "humanFileSize", negative: false },
networkUp: { key: "network", color: "green", format: "humanFileSize", negative: false },
networkDown: { key: "network", color: "red", format: "humanFileSize", negative: true },
} satisfies Record<
HistoryKeys,
{
key: keyof Pick<HealthMonitoring, "cpu" | "memory" | "network">;
color: DefaultMantineColor;
format: "percent" | "humanFileSize";
negative: boolean;
}
>;
const dataToGraph = (data: HealthMonitoring, series: AtLeastOneOf<HistoryKeys>) => {
const referenceArray = data.history[0][series[0]];
// Check that all selected series have the same length
if (series.some((name) => data.history[0][name].length !== data.history[0][series[0]].length)) {
return null;
}
return referenceArray.map(({ id }) => ({
id,
negative: series.some((key) => historyFormatTable[key].negative),
graph: data.history.map((item) => ({
date: item.timestamp,
name: data[historyFormatTable[series[0]].key].find((element) => element.id === id)?.name ?? "",
...series.reduce(
(acc, key) => {
const value = item[key].find((element) => element.id === id)?.value ?? null;
const scale = data[historyFormatTable[key].key].find((element) => element.id === id)?.maxValue ?? 100;
acc[`original.${key}`] = value;
acc[`max.${key}`] = scale;
acc[`format.${key}`] = historyFormatTable[key].format;
acc[key] = value ? value / (scale / (historyFormatTable[key].negative ? -100 : 100)) : null;
return acc;
},
{} as Partial<Record<HistoryKeys | `${string}.${HistoryKeys}`, number | string | null>>,
),
})),
}));
};
interface GridAreaChartProps {
data: HealthMonitoring;
series: AtLeastOneOf<HistoryKeys>;
columns?: number;
}
const GridAreaChart = ({ data, series, columns = 1 }: GridAreaChartProps) => {
const formattedData = dataToGraph(data, series);
const formattedSeries = series.map((name) => ({
name,
color: historyFormatTable[name].color,
}));
if (!formattedData || formattedData.length === 0) return null;
return (
<Box
display="grid"
flex="1 1 auto"
w="100%"
style={{
gap: 7,
gridTemplateColumns: `repeat(${columns}, 1fr)`,
gridTemplateRows: "auto-fit",
height: "50px",
}}
>
{formattedData.map(({ id, negative, graph }) => {
return (
<AreaChart
data={graph}
key={id}
h="100%"
w="100%"
bg="var(--background-color)"
p={0}
yAxisProps={{ domain: [negative ? -100 : 0, 100] }}
dataKey="date"
series={formattedSeries}
gridAxis="none"
dotProps={{ r: 0 }}
activeDotProps={{ r: 3 }}
withYAxis={false}
withXAxis={false}
flex="1 1 auto"
style={{ borderRadius: "3cqmin", border: "1px red solid" }}
tooltipProps={{
content: ({ payload }) => <CustomTooltip payload={payload as Record<string, unknown>[] | undefined} />,
}}
/>
)
})}
</Box>
);
};
interface CustomTooltipProps {
payload: Record<string, unknown>[] | undefined;
}
const CustomTooltip = ({ payload }: CustomTooltipProps) => {
if (!payload) return;
// TODO: check why this is needed?
// const filteredData = getFilteredChartTooltipPayload(payload);
const filteredData = payload;
return (
<Box bg="var(--background-color)" p="md" style={{ borderRadius: "3cqmin" }}>
<Text>{((filteredData[0]?.payload ?? { name: "" }) as { name: string }).name}</Text>
{filteredData.map(({ dataKey, payload: subPayload }) => {
const values = subPayload as Record<string, number> & Record<`format.${string}`, string>;
const displayValue =
historyFormatTable[dataKey as keyof typeof historyFormatTable].format === "humanFileSize"
? `${humanFileSize(values[`original.${dataKey}`] ?? 0)}/${humanFileSize(values[`max.${dataKey}`] ?? 0)}`
: `${values[dataKey as string]?.toFixed()}%`;
return (
<Text key={dataKey as string} fz="md">
{`${dataKey}: ${displayValue}`}
</Text>
);
})}
</Box>
);
};
interface StorageEntriesProps {
columns: number;
fahrenheit: boolean;
storages: HealthMonitoring["storage"];
}
const StorageEntries = ({ columns, fahrenheit, storages }: StorageEntriesProps) => {
return (
<Box
display="grid"
p="xs"
w="100%"
style={{
gap: "0.5cqmin",
gridTemplateColumns: `repeat(${columns}, 1fr)`,
}}
>
{storages.map((storage) => {
const percentage = (storage.used / storage.size) * 100;
return (
<Stack
key={storage.name}
bg="var(--background-color)"
gap="xs"
w="100%"
flex="1 1 auto"
style={{ borderRadius: "3cqmin" }}
>
<Group w="100%" justify="space-between" gap="1cqmin">
<Text fz="md">{storage.name}</Text>
{storage.temp && (
<Group>
<Text fz="md">{temperatureFormatter(storage.temp, fahrenheit)}</Text>
</Group>
)}
<Text fz="md">{`${humanFileSize(storage.used)}/${humanFileSize(storage.size)}`}</Text>
</Group>
<Progress value={percentage} color={progressColor(percentage)} />
</Stack>
);
})}
</Box>
);
};
const temperatureFormatter = (temperature: number, fahrenheit: boolean) =>
fahrenheit ? `${temperature * (9 / 5) + 32}°F` : `${temperature}°C`;
export const progressColor = (percentage: number) => {
if (percentage < 40) return "green";
else if (percentage < 60) return "yellow";
else if (percentage < 90) return "orange";
else return "red";
};
export const formatUptime = (time: number, t: TranslationFunction) => {
const timeDiff = dayjs.duration(time, "milliseconds");
return t("widget.healthMonitoring.popover.uptime", {
months: `${Math.floor(timeDiff.as("months"))}`,
days: `${Math.floor(timeDiff.as("days"))}`,
//replace with timeDiff.hours() and timeDiff.minutes() once it's fixed
hours: `${Math.floor(timeDiff.as("hours") % 24)}`,
minutes: `${Math.floor(timeDiff.as("minutes") % 60)}`,
});
};
interface FileSystem {
deviceName: string;
used: string;
available: string;
percentage: number;
}
interface SmartData {
deviceName: string;
temperature: number;
overallStatus: string;
}
export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: SmartData[]) => {
return fileSystems
.map((fileSystem) => {
const baseDeviceName = fileSystem.deviceName.replace(/[0-9]+$/, "");
const smartDisk = smartData.find((smart) => smart.deviceName === baseDeviceName);
return {
deviceName: smartDisk?.deviceName ?? fileSystem.deviceName,
used: fileSystem.used,
available: fileSystem.available,
percentage: fileSystem.percentage,
temperature: smartDisk?.temperature ?? 0,
overallStatus: smartDisk?.overallStatus ?? "",
};
})
.sort((fileSystemA, fileSystemB) => fileSystemA.deviceName.localeCompare(fileSystemB.deviceName));
};
+20 -14
View File
@@ -1,6 +1,7 @@
import { IconHeartRateMonitor, IconServerOff } from "@tabler/icons-react";
import { getIntegrationKindsByCategory } from "@homarr/definitions";
import { z } from "zod";
import { createWidgetDefinition } from "../definition";
import { optionsBuilder } from "../options";
@@ -12,30 +13,35 @@ export const { definition, componentLoader } = createWidgetDefinition("healthMon
fahrenheit: factory.switch({
defaultValue: false,
}),
systemInfo: factory.switch({
defaultValue: true,
}),
cpu: factory.switch({
defaultValue: true,
}),
cpuDetailed: factory.switch({
defaultValue: true,
}),
cpuColumns: factory.number({
defaultValue: 2,
step: 1,
validate: z.number().min(1).max(4),
}),
memory: factory.switch({
defaultValue: true,
}),
network: factory.switch({
defaultValue: true,
}),
fileSystem: factory.switch({
defaultValue: true,
}),
defaultTab: factory.select({
defaultValue: "system",
options: [
{ value: "system", label: "System" },
{ value: "cluster", label: "Cluster" },
] as const,
pointDensity: factory.number({
defaultValue: 12,
step: 1,
validate: z.number().min(1).max(60),
}),
sectionIndicatorRequirement: factory.select({
defaultValue: "all",
options: [
{ value: "all", label: "All active" },
{ value: "any", label: "Any active" },
] as const,
}),
}));
}))
},
supportedIntegrations: getIntegrationKindsByCategory("healthMonitoring"),
errors: {
@@ -1,7 +0,0 @@
[data-mantine-color-scheme="light"] .card {
background-color: var(--mantine-color-gray-1);
}
[data-mantine-color-scheme="dark"] .card {
background-color: var(--mantine-color-dark-7);
}
@@ -1,322 +0,0 @@
"use client";
import {
ActionIcon,
Box,
Card,
Divider,
Flex,
Group,
Indicator,
List,
Modal,
Progress,
Stack,
Text,
Tooltip,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import {
IconBrain,
IconClock,
IconCpu,
IconCpu2,
IconFileReport,
IconInfoCircle,
IconServer,
IconTemperature,
IconVersions,
} from "@tabler/icons-react";
import combineClasses from "clsx";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { clientApi } from "@homarr/api/client";
import { useRequiredBoard } from "@homarr/boards/context";
import type { TranslationFunction } from "@homarr/translation";
import { useI18n } from "@homarr/translation/client";
import type { WidgetComponentProps } from "../definition";
import { CpuRing } from "./rings/cpu-ring";
import { CpuTempRing } from "./rings/cpu-temp-ring";
import { formatMemoryUsage, MemoryRing } from "./rings/memory-ring";
import classes from "./system-health.module.css";
dayjs.extend(duration);
export const SystemHealthMonitoring = ({
options,
integrationIds,
width,
}: WidgetComponentProps<"healthMonitoring">) => {
const t = useI18n();
const [healthData] = clientApi.widget.healthMonitoring.getSystemHealthStatus.useSuspenseQuery(
{
integrationIds,
},
{
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
retry: false,
},
);
const [opened, { open, close }] = useDisclosure(false);
const utils = clientApi.useUtils();
const board = useRequiredBoard();
clientApi.widget.healthMonitoring.subscribeSystemHealthStatus.useSubscription(
{ integrationIds },
{
onData(data) {
utils.widget.healthMonitoring.getSystemHealthStatus.setData({ integrationIds }, (prevData) => {
if (!prevData) {
return undefined;
}
return prevData.map((item) =>
item.integrationId === data.integrationId
? { ...item, healthInfo: data.healthInfo, updatedAt: data.timestamp }
: item,
);
});
},
},
);
const isTiny = width < 256;
return (
<Stack h="100%" gap="sm" className="health-monitoring">
{healthData.map(({ integrationId, integrationName, healthInfo, updatedAt }) => {
const disksData = matchFileSystemAndSmart(healthInfo.fileSystem, healthInfo.smart);
const memoryUsage = formatMemoryUsage(healthInfo.memAvailable, healthInfo.memUsed);
return (
<Stack
gap="sm"
key={integrationId}
h="100%"
className={`health-monitoring-information health-monitoring-${integrationName}`}
p="sm"
pos="relative"
>
<Box className="health-monitoring-information-card-section" pos="absolute" top={8} right={8}>
<Indicator
className="health-monitoring-updates-reboot-indicator"
inline
processing
styles={{ indicator: { pointerEvents: "none" } }}
color={healthInfo.rebootRequired ? "red" : healthInfo.availablePkgUpdates > 0 ? "blue" : "gray"}
position="top-end"
size={16}
label={healthInfo.availablePkgUpdates > 0 ? healthInfo.availablePkgUpdates : undefined}
disabled={!healthInfo.rebootRequired && healthInfo.availablePkgUpdates === 0}
>
<ActionIcon
className="health-monitoring-information-icon-avatar"
variant={"light"}
color="var(--mantine-color-text)"
size="sm"
radius={board.itemRadius}
>
<IconInfoCircle className="health-monitoring-information-icon" size={30} onClick={open} />
</ActionIcon>
</Indicator>
<Modal
opened={opened}
onClose={close}
size="auto"
title={t("widget.healthMonitoring.popover.information")}
centered
>
<Stack gap="10px" className="health-monitoring-modal-stack">
<Divider />
<List className="health-monitoring-information-list" center spacing="xs">
<List.Item className="health-monitoring-information-processor" icon={<IconCpu2 size={30} />}>
{t("widget.healthMonitoring.popover.processor", { cpuModelName: healthInfo.cpuModelName })}
</List.Item>
<List.Item className="health-monitoring-information-memory" icon={<IconBrain size={30} />}>
{t("widget.healthMonitoring.popover.memory", { memory: memoryUsage.memTotal.GB })}
</List.Item>
<List.Item className="health-monitoring-information-memory" icon={<IconBrain size={30} />}>
{t("widget.healthMonitoring.popover.memoryAvailable", {
memoryAvailable: memoryUsage.memFree.GB,
percent: String(memoryUsage.memFree.percent),
})}
</List.Item>
<List.Item className="health-monitoring-information-version" icon={<IconVersions size={30} />}>
{t("widget.healthMonitoring.popover.version", {
version: healthInfo.version,
})}
</List.Item>
<List.Item className="health-monitoring-information-uptime" icon={<IconClock size={30} />}>
{formatUptime(healthInfo.uptime, t)}
</List.Item>
<List.Item className="health-monitoring-information-load-average" icon={<IconCpu size={30} />}>
{t("widget.healthMonitoring.popover.loadAverage")}
</List.Item>
<List m="xs" withPadding center spacing="xs" icon={<IconCpu size={30} />}>
<List.Item className="health-monitoring-information-load-average-1min">
{t("widget.healthMonitoring.popover.minute")} {healthInfo.loadAverage["1min"]}%
</List.Item>
<List.Item className="health-monitoring-information-load-average-5min">
{t("widget.healthMonitoring.popover.minutes", { count: "5" })} {healthInfo.loadAverage["5min"]}%
</List.Item>
<List.Item className="health-monitoring-information-load-average-15min">
{t("widget.healthMonitoring.popover.minutes", { count: "15" })}{" "}
{healthInfo.loadAverage["15min"]}%
</List.Item>
</List>
</List>
</Stack>
</Modal>
</Box>
<Flex className="health-monitoring-information-card-elements" justify="center" align="center" wrap="wrap">
{options.cpu && <CpuRing cpuUtilization={healthInfo.cpuUtilization} isTiny={isTiny} />}
{options.cpu && (
<CpuTempRing fahrenheit={options.fahrenheit} cpuTemp={healthInfo.cpuTemp} isTiny={isTiny} />
)}
{options.memory && (
<MemoryRing available={healthInfo.memAvailable} used={healthInfo.memUsed} isTiny={isTiny} />
)}
</Flex>
{
<Text className="health-monitoring-status-update-time" c="dimmed" size="xs" ta="center">
{t("widget.healthMonitoring.popover.lastSeen", { lastSeen: dayjs(updatedAt).fromNow() })}
</Text>
}
{options.fileSystem &&
disksData.map((disk) => {
return (
<Card
className={combineClasses(
`health-monitoring-disk-card health-monitoring-disk-card-${integrationName}`,
classes.card,
)}
style={{ overflow: "visible" }}
key={disk.deviceName}
radius={board.itemRadius}
p="xs"
>
<Stack gap="sm">
<Group
className="health-monitoring-disk-status"
justify="space-between"
align="center"
wrap="wrap"
gap={8}
>
<Group gap={4} wrap="nowrap">
<IconServer className="health-monitoring-disk-icon" size="1rem" />
<Text className="dihealth-monitoring-disk-name" size="xs">
{disk.deviceName}
</Text>
</Group>
<Group gap={4} wrap="nowrap">
<IconTemperature className="health-monitoring-disk-temperature-icon" size="1rem" />
<Text className="health-monitoring-disk-temperature-value" size="xs">
{options.fahrenheit
? `${(disk.temperature * 1.8 + 32).toFixed(1)}°F`
: `${disk.temperature}°C`}
</Text>
</Group>
<Group gap={4} wrap="nowrap">
<IconFileReport className="health-monitoring-disk-status-icon" size="1rem" />
<Text className="health-monitoring-disk-status-value" size="xs">
{disk.overallStatus ? disk.overallStatus : "N/A"}
</Text>
</Group>
</Group>
<Progress.Root className="health-monitoring-disk-use" radius={board.itemRadius} h="md">
<Tooltip label={disk.used}>
<Progress.Section
value={disk.percentage}
color={progressColor(disk.percentage)}
className="health-monitoring-disk-use-percentage"
>
<Progress.Label className="health-monitoring-disk-use-value" fz="xs">
{t("widget.healthMonitoring.popover.used")}
</Progress.Label>
</Progress.Section>
</Tooltip>
<Tooltip
label={
Number(disk.available) / 1024 ** 4 >= 1
? `${(Number(disk.available) / 1024 ** 4).toFixed(2)} TiB`
: `${(Number(disk.available) / 1024 ** 3).toFixed(2)} GiB`
}
>
<Progress.Section
className="health-monitoring-disk-available-percentage"
value={100 - disk.percentage}
color="default"
>
<Progress.Label className="health-monitoring-disk-available-value" fz="xs">
{t("widget.healthMonitoring.popover.available")}
</Progress.Label>
</Progress.Section>
</Tooltip>
</Progress.Root>
</Stack>
</Card>
);
})}
</Stack>
);
})}
</Stack>
);
};
export const formatUptime = (uptimeInSeconds: number, t: TranslationFunction) => {
const uptimeDuration = dayjs.duration(uptimeInSeconds, "seconds");
const months = uptimeDuration.months();
const days = uptimeDuration.days();
const hours = uptimeDuration.hours();
const minutes = uptimeDuration.minutes();
return t("widget.healthMonitoring.popover.uptime", {
months: String(months),
days: String(days),
hours: String(hours),
minutes: String(minutes),
});
};
export const progressColor = (percentage: number) => {
if (percentage < 40) return "green";
else if (percentage < 60) return "yellow";
else if (percentage < 90) return "orange";
else return "red";
};
interface FileSystem {
deviceName: string;
used: string;
available: string;
percentage: number;
}
interface SmartData {
deviceName: string;
temperature: number | null;
overallStatus: string;
}
export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: SmartData[]) => {
return fileSystems
.map((fileSystem) => {
const baseDeviceName = fileSystem.deviceName.replace(/[0-9]+$/, "");
const smartDisk = smartData.find((smart) => smart.deviceName === baseDeviceName);
return {
deviceName: smartDisk?.deviceName ?? fileSystem.deviceName,
used: fileSystem.used,
available: fileSystem.available,
percentage: fileSystem.percentage,
temperature: smartDisk?.temperature ?? 0,
overallStatus: smartDisk?.overallStatus ?? "",
};
})
.sort((fileSystemA, fileSystemB) => fileSystemA.deviceName.localeCompare(fileSystemB.deviceName));
};