From 9e10b914c932fdf55ee7a5a1736f66eb75644aa6 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:53:01 -0500 Subject: [PATCH] Add ability to add legacy birdseye to camera groups (#10404) * initial try * add birdseye * remove vite * cleanup * memoize * remove console * ensure birdseye is actually enabled in config * birdseye first in select list and fix jsmpeg player size --- .../components/filter/CameraGroupSelector.tsx | 7 +++- .../components/player/BirdseyeLivePlayer.tsx | 40 ++++++++++--------- web/src/pages/Live.tsx | 9 +++++ web/src/pages/UIPlayground.tsx | 10 +++++ web/src/views/live/LiveDashboardView.tsx | 15 ++++++- 5 files changed, 61 insertions(+), 20 deletions(-) diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx index b36406e4d..326ce7946 100644 --- a/web/src/components/filter/CameraGroupSelector.tsx +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -146,6 +146,8 @@ function NewGroupDialog({ open, setOpen, currentGroups }: NewGroupDialogProps) { const { data: config, mutate: updateConfig } = useSWR("config"); + const birdseyeConfig = useMemo(() => config?.birdseye, [config]); + // add fields const [editState, setEditState] = useState<"none" | "add" | "edit">("none"); @@ -298,7 +300,10 @@ function NewGroupDialog({ open, setOpen, currentGroups }: NewGroupDialogProps) { - {Object.keys(config?.cameras ?? {}).map((camera) => ( + {[ + ...(birdseyeConfig?.enabled ? ["birdseye"] : []), + ...Object.keys(config?.cameras ?? {}), + ].map((camera) => ( - - + player = ( + ); } else if (liveMode == "mse") { if ("MediaSource" in window || "ManagedMediaSource" in window) { - return ( -
- -
+ player = ( + ); } else { - return ( + player = (
MSE is only supported on iOS 17.1+. You'll need to update if available or use jsmpeg / webRTC streams. See the docs for more info. @@ -35,16 +32,23 @@ export default function BirdseyeLivePlayer({ ); } } else if (liveMode == "jsmpeg") { - return ( -
- -
+ player = ( + ); } else { - ; + player = ; } + + return ( +
+
+
+
{player}
+
+ ); } diff --git a/web/src/pages/Live.tsx b/web/src/pages/Live.tsx index 848283eb0..2233c29cd 100644 --- a/web/src/pages/Live.tsx +++ b/web/src/pages/Live.tsx @@ -11,6 +11,14 @@ function Live() { const [selectedCameraName, setSelectedCameraName] = useOverlayState("camera"); const [cameraGroup] = useOverlayState("cameraGroup"); + const includesBirdseye = useMemo(() => { + if (config && cameraGroup) { + return config.camera_groups[cameraGroup].cameras.includes("birdseye"); + } else { + return false; + } + }, [config, cameraGroup]); + const cameras = useMemo(() => { if (!config) { return []; @@ -40,6 +48,7 @@ function Live() { return ( ); diff --git a/web/src/pages/UIPlayground.tsx b/web/src/pages/UIPlayground.tsx index be8531e4e..76ac6fe95 100644 --- a/web/src/pages/UIPlayground.tsx +++ b/web/src/pages/UIPlayground.tsx @@ -22,6 +22,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer"; // Color data const colors = [ @@ -184,6 +185,7 @@ function UIPlayground() { }; const [isEventsReviewTimeline, setIsEventsReviewTimeline] = useState(true); + const birdseyeConfig = config?.birdseye; return ( <> @@ -243,6 +245,14 @@ function UIPlayground() {
+
+ {birdseyeConfig && ( + + )} +