import { h } from 'preact';
import AutoUpdatingCameraImage from './components/AutoUpdatingCameraImage';
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 { useApiHost, useConfig } from './api';
export default function Camera({ camera, url }) {
const { data: config } = useConfig();
const apiHost = useApiHost();
if (!config) {
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}
);
})}
);
}