Skip to content

Commit

Permalink
Hide PTZ Controls in Birdseye when no cameras support it (blakeblacks…
Browse files Browse the repository at this point in the history
…hear#6353)

* Refactor filter logic to exclude cameras with empty onvif host address

* Refactor filter logic to exclude cameras with empty onvif host address-2

* Apply suggestions from code review

Co-authored-by: Nicolas Mowen <[email protected]>

---------

Co-authored-by: Nicolas Mowen <[email protected]>
  • Loading branch information
skrashevich and NickM-27 committed May 4, 2023
1 parent 03b45c1 commit 02f5773
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions web/src/routes/Birdseye.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Birdseye() {
}

return Object.entries(config.cameras)
.filter(([_, conf]) => conf.onvif?.host)
.filter(([_, conf]) => conf.onvif?.host && conf.onvif.host != '')
.map(([_, camera]) => camera.name);
}, [config]);

Expand All @@ -37,7 +37,7 @@ export default function Birdseye() {
if ('MediaSource' in window) {
player = (
<Fragment>
<div className="max-w-5xl xl:w-1/2">
<div className={ptzCameras.length ? 'max-w-5xl xl:w-1/2' : 'max-w-5xl'}>
<MsePlayer camera="birdseye" />
</div>
</Fragment>
Expand All @@ -54,15 +54,15 @@ export default function Birdseye() {
} else if (viewSource == 'webrtc' && config.birdseye.restream) {
player = (
<Fragment>
<div className="max-w-5xl xl:w-1/2">
<div className={ptzCameras.length ? 'max-w-5xl xl:w-1/2' : 'max-w-5xl'}>
<WebRtcPlayer camera="birdseye" />
</div>
</Fragment>
);
} else {
player = (
<Fragment>
<div className="max-w-7xl xl:w-1/2">
<div className={ptzCameras.length ? 'max-w-5xl xl:w-1/2' : 'max-w-5xl'}>
<JSMpegPlayer camera="birdseye" />
</div>
</Fragment>
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function Birdseye() {
<div className="xl:flex justify-between">
{player}

{ptzCameras && (
{ptzCameras.length ? (
<div className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 w-full sm:w-min xl:h-min xl:w-1/2">
<Heading size="sm">Control Panel</Heading>
{ptzCameras.map((camera) => (
Expand All @@ -104,7 +104,7 @@ export default function Birdseye() {
</div>
))}
</div>
)}
) : null}
</div>
</div>
);
Expand Down

0 comments on commit 02f5773

Please sign in to comment.