import { h } from 'preact'; import Box from './components/Box'; import Heading from './components/Heading'; import Link from './components/Link'; import Switch from './components/Switch'; import { route } from 'preact-router'; import { useCallback, useContext } from 'preact/hooks'; import { ApiHost, Config } from './context'; export default function Camera({ camera, url }) { const config = useContext(Config); const apiHost = useContext(ApiHost); if (!(camera in config.cameras)) { return
{`No camera named ${camera}`}
; } const cameraConfig = config.cameras[camera]; const { pathname, searchParams } = new URL(`${window.location.protocol}//${window.location.host}${url}`); const searchParamsString = searchParams.toString(); const handleSetOption = useCallback( (id, value) => { searchParams.set(id, value ? 1 : 0); route(`${pathname}?${searchParams.toString()}`, true); }, [searchParams] ); function getBoolean(id) { return Boolean(parseInt(searchParams.get(id), 10)); } return (
{camera} Mask & Zone creator
Tracked objects
{cameraConfig.objects.track.map((objectType) => { return ( {objectType} ); })}
); }