mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 21:44:13 +03:00
* Get live camera view working * Get ptz working * Add button for ptz presets * Add camera feature buttons * Add button for camera audio * Cleanup * Cleanup mobile live * Only use landscape check on mobile
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import useOverlayState from "@/hooks/use-overlay-state";
|
|
import { FrigateConfig } from "@/types/frigateConfig";
|
|
import LiveCameraView from "@/views/live/LiveCameraView";
|
|
import LiveDashboardView from "@/views/live/LiveDashboardView";
|
|
import { useMemo } from "react";
|
|
import useSWR from "swr";
|
|
|
|
function Live() {
|
|
const { data: config } = useSWR<FrigateConfig>("config");
|
|
const [selectedCameraName, setSelectedCameraName] = useOverlayState("camera");
|
|
|
|
const cameras = useMemo(() => {
|
|
if (!config) {
|
|
return [];
|
|
}
|
|
|
|
return Object.values(config.cameras)
|
|
.filter((conf) => conf.ui.dashboard && conf.enabled)
|
|
.sort((aConf, bConf) => aConf.ui.order - bConf.ui.order);
|
|
}, [config]);
|
|
|
|
const selectedCamera = useMemo(
|
|
() => cameras.find((cam) => cam.name == selectedCameraName),
|
|
[cameras, selectedCameraName],
|
|
);
|
|
|
|
if (selectedCamera) {
|
|
return <LiveCameraView camera={selectedCamera} />;
|
|
}
|
|
|
|
return (
|
|
<LiveDashboardView
|
|
cameras={cameras}
|
|
onSelectCamera={setSelectedCameraName}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default Live;
|