From c37a0e38d950ec24bd33a174a229ee20434fa6f9 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Wed, 23 Oct 2024 17:30:10 +0200 Subject: [PATCH] fix: health-check widget sorting & last seen (#1363) Co-authored-by: Yossi Hillali <950010+hillaliy@users.noreply.github.com> --- .../src/router/widgets/health-monitoring.ts | 2 +- .../src/health-monitoring/component.tsx | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/api/src/router/widgets/health-monitoring.ts b/packages/api/src/router/widgets/health-monitoring.ts index 2003a5bf6..28e0b9b6a 100644 --- a/packages/api/src/router/widgets/health-monitoring.ts +++ b/packages/api/src/router/widgets/health-monitoring.ts @@ -36,7 +36,7 @@ export const healthMonitoringRouter = createTRPCRouter({ emit.next({ integrationId: integration.id, healthInfo, - timestamp: new Date(0), + timestamp: new Date(), }); }); unsubscribes.push(unsubscribe); diff --git a/packages/widgets/src/health-monitoring/component.tsx b/packages/widgets/src/health-monitoring/component.tsx index 52a951c71..2c6f21fd7 100644 --- a/packages/widgets/src/health-monitoring/component.tsx +++ b/packages/widgets/src/health-monitoring/component.tsx @@ -79,7 +79,7 @@ export default function HealthMonitoringWidget({ options, integrationIds }: Widg } const newData = prevData.map((item) => item.integrationId === data.integrationId - ? { ...item, healthInfo: data.healthInfo, timestamp: new Date(0) } + ? { ...item, healthInfo: data.healthInfo, timestamp: data.timestamp } : item, ); return newData.filter( @@ -323,19 +323,21 @@ interface SmartData { } 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 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 ?? "", - }; - }); + 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)); }; const CpuRing = ({ cpuUtilization }: { cpuUtilization: number }) => {