Skip to content

Commit

Permalink
fix: health-check widget sorting & last seen (#1363)
Browse files Browse the repository at this point in the history
Co-authored-by: Yossi Hillali <[email protected]>
  • Loading branch information
Meierschlumpf and hillaliy committed Oct 23, 2024
1 parent 32b0059 commit c37a0e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/router/widgets/health-monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const healthMonitoringRouter = createTRPCRouter({
emit.next({
integrationId: integration.id,
healthInfo,
timestamp: new Date(0),
timestamp: new Date(),
});
});
unsubscribes.push(unsubscribe);
Expand Down
28 changes: 15 additions & 13 deletions packages/widgets/src/health-monitoring/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 }) => {
Expand Down

0 comments on commit c37a0e3

Please sign in to comment.