Skip to content

Commit c37a0e3

Browse files
fix: health-check widget sorting & last seen (#1363)
Co-authored-by: Yossi Hillali <[email protected]>
1 parent 32b0059 commit c37a0e3

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

packages/api/src/router/widgets/health-monitoring.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const healthMonitoringRouter = createTRPCRouter({
3636
emit.next({
3737
integrationId: integration.id,
3838
healthInfo,
39-
timestamp: new Date(0),
39+
timestamp: new Date(),
4040
});
4141
});
4242
unsubscribes.push(unsubscribe);

packages/widgets/src/health-monitoring/component.tsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function HealthMonitoringWidget({ options, integrationIds }: Widg
7979
}
8080
const newData = prevData.map((item) =>
8181
item.integrationId === data.integrationId
82-
? { ...item, healthInfo: data.healthInfo, timestamp: new Date(0) }
82+
? { ...item, healthInfo: data.healthInfo, timestamp: data.timestamp }
8383
: item,
8484
);
8585
return newData.filter(
@@ -323,19 +323,21 @@ interface SmartData {
323323
}
324324

325325
export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: SmartData[]) => {
326-
return fileSystems.map((fileSystem) => {
327-
const baseDeviceName = fileSystem.deviceName.replace(/[0-9]+$/, "");
328-
const smartDisk = smartData.find((smart) => smart.deviceName === baseDeviceName);
326+
return fileSystems
327+
.map((fileSystem) => {
328+
const baseDeviceName = fileSystem.deviceName.replace(/[0-9]+$/, "");
329+
const smartDisk = smartData.find((smart) => smart.deviceName === baseDeviceName);
329330

330-
return {
331-
deviceName: smartDisk?.deviceName ?? fileSystem.deviceName,
332-
used: fileSystem.used,
333-
available: fileSystem.available,
334-
percentage: fileSystem.percentage,
335-
temperature: smartDisk?.temperature ?? 0,
336-
overallStatus: smartDisk?.overallStatus ?? "",
337-
};
338-
});
331+
return {
332+
deviceName: smartDisk?.deviceName ?? fileSystem.deviceName,
333+
used: fileSystem.used,
334+
available: fileSystem.available,
335+
percentage: fileSystem.percentage,
336+
temperature: smartDisk?.temperature ?? 0,
337+
overallStatus: smartDisk?.overallStatus ?? "",
338+
};
339+
})
340+
.sort((fileSystemA, fileSystemB) => fileSystemA.deviceName.localeCompare(fileSystemB.deviceName));
339341
};
340342

341343
const CpuRing = ({ cpuUtilization }: { cpuUtilization: number }) => {

0 commit comments

Comments
 (0)