import { h, Fragment } from 'preact'; import ActivityIndicator from '../components/ActivityIndicator'; import Button from '../components/Button'; import Heading from '../components/Heading'; import Link from '../components/Link'; import { useMqtt } from '../api/mqtt'; import useSWR from 'swr'; import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table'; import { useCallback } from 'preact/hooks'; const emptyObject = Object.freeze({}); export default function Debug() { const { data: config } = useSWR('config'); const { value: { payload: stats }, } = useMqtt('stats'); const { data: initialStats } = useSWR('stats'); const { detectors, service = {}, detection_fps: _, ...cameras } = stats || initialStats || emptyObject; const detectorNames = Object.keys(detectors || emptyObject); const detectorDataKeys = Object.keys(detectors ? detectors[detectorNames[0]] : emptyObject); const cameraNames = Object.keys(cameras || emptyObject); const cameraDataKeys = Object.keys(cameras[cameraNames[0]] || emptyObject); const handleCopyConfig = useCallback(() => { async function copy() { await window.navigator.clipboard.writeText(JSON.stringify(config, null, 2)); } copy(); }, [config]); return (
detector | {detectorDataKeys.map((name) => ({name.replace('_', ' ')} | ))}
---|---|
{detector} | {detectorDataKeys.map((name) => ({detectors[detector][name]} | ))}
camera | {cameraDataKeys.map((name) => ({name.replace('_', ' ')} | ))}
---|---|
{camera} | {cameraDataKeys.map((name) => ({cameras[camera][name]} | ))}
Debug stats update automatically every {config.mqtt.stats_interval} seconds.
{JSON.stringify(config, null, 2)}