fix: omv invalid temperature when not available (#2322)

This commit is contained in:
Manuel
2025-02-23 12:34:04 +01:00
committed by GitHub
parent 4f09363823
commit 5dc5d9e04a
4 changed files with 17 additions and 5 deletions

13
.run/typecheck.run.xml Normal file
View File

@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="typecheck" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="typecheck" />
</scripts>
<node-interpreter value="project" />
<package-manager value="pnpm" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -21,7 +21,7 @@ export interface HealthMonitoring {
}[]; }[];
smart: { smart: {
deviceName: string; deviceName: string;
temperature: number; temperature: number | null;
overallStatus: string; overallStatus: string;
}[]; }[];
} }

View File

@@ -40,7 +40,7 @@ export const smartSchema = z.object({
// Convert string to number if necessary // Convert string to number if necessary
const temp = typeof val === "string" ? parseFloat(val) : val; const temp = typeof val === "string" ? parseFloat(val) : val;
if (isNaN(temp)) { if (isNaN(temp)) {
throw new Error("Invalid temperature value"); return null;
} }
return temp; return temp;
}), }),

View File

@@ -64,12 +64,11 @@ export const SystemHealthMonitoring = ({ options, integrationIds }: WidgetCompon
if (!prevData) { if (!prevData) {
return undefined; return undefined;
} }
const newData = prevData.map((item) => return prevData.map((item) =>
item.integrationId === data.integrationId item.integrationId === data.integrationId
? { ...item, healthInfo: data.healthInfo, updatedAt: data.timestamp } ? { ...item, healthInfo: data.healthInfo, updatedAt: data.timestamp }
: item, : item,
); );
return newData;
}); });
}, },
}, },
@@ -294,7 +293,7 @@ interface FileSystem {
interface SmartData { interface SmartData {
deviceName: string; deviceName: string;
temperature: number; temperature: number | null;
overallStatus: string; overallStatus: string;
} }