2021-01-09 18:26:46 +01:00
|
|
|
import { h } from 'preact';
|
2021-01-30 17:52:37 +01:00
|
|
|
import ActivityIndicator from './components/ActivityIndicator';
|
2021-01-19 17:44:18 +01:00
|
|
|
import Box from './components/Box';
|
2021-01-25 18:49:00 +01:00
|
|
|
import CameraImage from './components/CameraImage';
|
2021-01-09 18:26:46 +01:00
|
|
|
import Events from './Events';
|
|
|
|
import Heading from './components/Heading';
|
|
|
|
import { route } from 'preact-router';
|
2021-01-26 16:04:03 +01:00
|
|
|
import { useConfig } from './api';
|
2021-01-09 18:26:46 +01:00
|
|
|
|
|
|
|
export default function Cameras() {
|
2021-01-26 16:04:03 +01:00
|
|
|
const { data: config, status } = useConfig();
|
2021-01-09 18:26:46 +01:00
|
|
|
|
2021-01-26 16:04:03 +01:00
|
|
|
if (!config) {
|
2021-01-09 18:26:46 +01:00
|
|
|
return <p>loading…</p>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="grid lg:grid-cols-2 md:grid-cols-1 gap-4">
|
|
|
|
{Object.keys(config.cameras).map((camera) => (
|
|
|
|
<Camera name={camera} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Camera({ name }) {
|
|
|
|
const href = `/cameras/${name}`;
|
|
|
|
|
|
|
|
return (
|
2021-01-19 17:44:18 +01:00
|
|
|
<Box
|
|
|
|
className="bg-white dark:bg-gray-700 shadow-lg rounded-lg p-4 hover:bg-gray-300 hover:dark:bg-gray-500 dark:hover:text-gray-900 dark:hover:text-gray-900"
|
|
|
|
href={href}
|
|
|
|
>
|
|
|
|
<Heading size="base">{name}</Heading>
|
2021-01-25 18:49:00 +01:00
|
|
|
<CameraImage camera={name} />
|
2021-01-19 17:44:18 +01:00
|
|
|
</Box>
|
2021-01-09 18:26:46 +01:00
|
|
|
);
|
|
|
|
}
|