add null check to HostSystemPage
This commit is contained in:
parent
9bbd36c434
commit
2e1a8bebae
@ -50,15 +50,15 @@ const HostSystemPage = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const mapCameraData = useCallback(() => {
|
const mapCameraData = useCallback(() => {
|
||||||
if (!data) return []
|
if (!data || !data.cameras) return []
|
||||||
return Object.entries(data.cameras).flatMap(([name, stats]) => {
|
return Object.entries(data.cameras).flatMap(([name, stats]) => {
|
||||||
return (['Ffmpeg', 'Capture', 'Detect'] as ProcessType[]).map(type => {
|
return (['Ffmpeg', 'Capture', 'Detect'] as ProcessType[]).map(type => {
|
||||||
const pid = type === ProcessType.Ffmpeg ? stats.ffmpeg_pid :
|
const pid = type === ProcessType.Ffmpeg ? stats.ffmpeg_pid :
|
||||||
type === ProcessType.Capture ? stats.capture_pid : stats.pid;
|
type === ProcessType.Capture ? stats.capture_pid : stats.pid;
|
||||||
const fps = type === ProcessType.Ffmpeg ? stats.camera_fps :
|
const fps = type === ProcessType.Ffmpeg ? stats.camera_fps :
|
||||||
type === ProcessType.Capture ? stats.process_fps : stats.detection_fps;
|
type === ProcessType.Capture ? stats.process_fps : stats.detection_fps;
|
||||||
const cpu = data.cpu_usages[pid]?.cpu;
|
const cpu = data.cpu_usages ? data.cpu_usages[pid]?.cpu : '0'
|
||||||
const mem = data.cpu_usages[pid]?.mem;
|
const mem = data.cpu_usages ? data.cpu_usages[pid]?.mem : '0'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cameraName: name,
|
cameraName: name,
|
||||||
@ -105,37 +105,43 @@ const HostSystemPage = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const gpuStats = Object.entries(data.gpu_usages).map(([name, stats]) => {
|
const gpuStats = () => {
|
||||||
return (
|
if (!data?.gpu_usages) return null
|
||||||
<Grid.Col key={name + stats.gpu} xs={7} sm={6} md={5} lg={4} p='0.2rem'>
|
|
||||||
|
return Object.entries(data.gpu_usages).map(([name, stats]) => (
|
||||||
|
<Grid.Col key={`${name}-${stats.gpu}`} xs={7} sm={6} md={5} lg={4} p="0.2rem">
|
||||||
<GpuStat
|
<GpuStat
|
||||||
name={name}
|
name={name}
|
||||||
decoder={stats.dec}
|
decoder={stats.dec}
|
||||||
encoder={stats.enc}
|
encoder={stats.enc}
|
||||||
gpu={stats.gpu}
|
gpu={stats.gpu}
|
||||||
mem={stats.mem}
|
mem={stats.mem}
|
||||||
onVaInfoClick={() => handleVaInfoClick()}
|
onVaInfoClick={handleVaInfoClick}
|
||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
)
|
))
|
||||||
})
|
};
|
||||||
|
|
||||||
const detectorsStats = Object.entries(data.detectors).map(([name, stats]) => {
|
const detectorsStats = () => {
|
||||||
const pid = stats.pid
|
if (!data?.detectors) return null
|
||||||
const cpu = data.cpu_usages[pid]?.cpu;
|
|
||||||
const mem = data.cpu_usages[pid]?.mem;
|
Object.entries(data.detectors).map(([name, stats]) => {
|
||||||
return (
|
const pid = stats.pid
|
||||||
<Grid.Col key={pid} xs={6} sm={5} md={4} lg={3} p='0.2rem'>
|
const cpu = data.cpu_usages ? data.cpu_usages[pid]?.cpu : '0'
|
||||||
<DetectorsStat
|
const mem = data.cpu_usages ? data.cpu_usages[pid]?.mem : '0'
|
||||||
name={name}
|
return (
|
||||||
pid={pid}
|
<Grid.Col key={pid} xs={6} sm={5} md={4} lg={3} p='0.2rem'>
|
||||||
inferenceSpeed={stats.inference_speed}
|
<DetectorsStat
|
||||||
cpu={cpu}
|
name={name}
|
||||||
mem={mem}
|
pid={pid}
|
||||||
/>
|
inferenceSpeed={stats.inference_speed}
|
||||||
</Grid.Col>
|
cpu={cpu}
|
||||||
)
|
mem={mem}
|
||||||
})
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleFfprobeClick = (cameraName: string) => openContextModal({
|
const handleFfprobeClick = (cameraName: string) => openContextModal({
|
||||||
modal: 'ffprobeModal',
|
modal: 'ffprobeModal',
|
||||||
@ -164,8 +170,8 @@ const HostSystemPage = () => {
|
|||||||
{storageStats}
|
{storageStats}
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid mt='sm' justify="center" mb='sm' align='stretch'>
|
<Grid mt='sm' justify="center" mb='sm' align='stretch'>
|
||||||
{gpuStats}
|
{gpuStats()}
|
||||||
{detectorsStats}
|
{detectorsStats()}
|
||||||
</Grid>
|
</Grid>
|
||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
value={selector}
|
value={selector}
|
||||||
|
|||||||
@ -35,17 +35,17 @@ export interface Stream {
|
|||||||
export interface FrigateStats {
|
export interface FrigateStats {
|
||||||
cameras: {
|
cameras: {
|
||||||
[cameraName: string]: CameraStat
|
[cameraName: string]: CameraStat
|
||||||
}
|
} | undefined
|
||||||
cpu_usages: {
|
cpu_usages: {
|
||||||
[processId: string]: ProcessStat
|
[processId: string]: ProcessStat
|
||||||
}
|
} | undefined
|
||||||
detection_fps: number
|
detection_fps: number
|
||||||
detectors: {
|
detectors: {
|
||||||
[detectorName: string]: DetectorStat
|
[detectorName: string]: DetectorStat
|
||||||
}
|
} | undefined
|
||||||
gpu_usages: {
|
gpu_usages: {
|
||||||
[gpuName: string]: GpuStat
|
[gpuName: string]: GpuStat
|
||||||
}
|
} | undefined
|
||||||
processes: Processes
|
processes: Processes
|
||||||
service: Service
|
service: Service
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user