From 5259d51c04fe21cf6b04094f796d8e8e2f2a1e0e Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 7 Jul 2023 15:09:55 +0300 Subject: [PATCH] UI Improvement: Full-width birdseye (if no PTZ cameras) (#6817) * Refactor video player div class names in Birdseye.jsx to be more responsive * let's JSMpegPlayer dont takes up the entire screen * Update Birdseye.jsx * Add useState hook and toggle button for dynamic width adjustment and refactor code for readability in env.js and Birdseye.jsx * fix stupid typo * Swapped the controls around * Remove useless comments Co-authored-by: Nicolas Mowen * Add button styles to the Birdseye component's toggle width button --------- Co-authored-by: Nicolas Mowen --- web/src/routes/Birdseye.jsx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/web/src/routes/Birdseye.jsx b/web/src/routes/Birdseye.jsx index 4ed800437..b43c3b137 100644 --- a/web/src/routes/Birdseye.jsx +++ b/web/src/routes/Birdseye.jsx @@ -6,7 +6,7 @@ import Heading from '../components/Heading'; import WebRtcPlayer from '../components/WebRtcPlayer'; import '../components/MsePlayer'; import useSWR from 'swr'; -import { useMemo } from 'preact/hooks'; +import { useMemo, useState } from 'preact/hooks'; import CameraControlPanel from '../components/CameraControlPanel'; import { baseUrl } from '../api/baseUrl'; @@ -26,16 +26,19 @@ export default function Birdseye() { .map(([_, camera]) => camera.name); }, [config]); + const [isMaxWidth, setIsMaxWidth] = useState(false); + if (!config || !sourceIsLoaded) { return ; } let player; + const playerClass = isMaxWidth ? 'max-w-5xl xl:w-1/2' : 'w-full'; if (viewSource == 'mse' && config.birdseye.restream) { if ('MediaSource' in window) { player = ( -
+
); } - } else if (viewSource == 'webrtc' && config.birdseye.restream) { + } else if (viewSource == 'webrtc' ) { player = ( -
+
@@ -63,7 +66,7 @@ export default function Birdseye() { } else { player = ( -
+
@@ -77,26 +80,37 @@ export default function Birdseye() { Birdseye + + {config.birdseye.restream && ( )}
- {player} +
{/* Use dynamic class */} + {player} +
{ptzCameras.length ? ( -
+
Control Panel {ptzCameras.map((camera) => (