Don't fail to load when cameras stats are not available (#4877)

This commit is contained in:
Nicolas Mowen 2023-01-03 18:23:56 -07:00 committed by GitHub
parent ceab294840
commit 760d65b214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,6 +203,9 @@ export default function System() {
)}
<Heading size="lg">Cameras</Heading>
{!cameras ? (
<ActivityIndicator />
) : (
<div data-testid="cameras" className="grid grid-cols-1 3xl:grid-cols-3 md:grid-cols-2 gap-4">
{cameraNames.map((camera) => (
<div key={camera} className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow">
@ -224,26 +227,26 @@ export default function System() {
<Tbody>
<Tr key="capture" index="0">
<Td>Capture</Td>
<Td>{cameras[camera]['capture_pid'] || "- "}</Td>
<Td>{cameras[camera]['process_fps'] || "- "}</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]?.['cpu'] || "- "}%</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]?.['mem'] || "- "}%</Td>
<Td>{cameras[camera]['capture_pid'] || '- '}</Td>
<Td>{cameras[camera]['process_fps'] || '- '}</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]?.['mem'] || '- '}%</Td>
</Tr>
<Tr key="detect" index="1">
<Td>Detect</Td>
<Td>{cameras[camera]['pid'] || "- "}</Td>
<Td>{cameras[camera]['pid'] || '- '}</Td>
<Td>
{cameras[camera]['detection_fps']} ({cameras[camera]['skipped_fps']} skipped)
</Td>
<Td>{cpu_usages[cameras[camera]['pid']]?.['cpu'] || "- "}%</Td>
<Td>{cpu_usages[cameras[camera]['pid']]?.['mem'] || "- "}%</Td>
<Td>{cpu_usages[cameras[camera]['pid']]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[cameras[camera]['pid']]?.['mem'] || '- '}%</Td>
</Tr>
<Tr key="ffmpeg" index="2">
<Td>ffmpeg</Td>
<Td>{cameras[camera]['ffmpeg_pid'] || "- "}</Td>
<Td>{cameras[camera]['camera_fps'] || "- "}</Td>
<Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cpu'] || "- "}%</Td>
<Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['mem'] || "- "}%</Td>
<Td>{cameras[camera]['ffmpeg_pid'] || '- '}</Td>
<Td>{cameras[camera]['camera_fps'] || '- '}</Td>
<Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['mem'] || '- '}%</Td>
</Tr>
</Tbody>
</Table>
@ -251,6 +254,7 @@ export default function System() {
</div>
))}
</div>
)}
<p>System stats update automatically every {config.mqtt.stats_interval} seconds.</p>
</Fragment>