diff --git a/web/src/icons/SelectOnly.jsx b/web/src/icons/SelectOnly.jsx
new file mode 100644
index 000000000..f0aca6bd8
--- /dev/null
+++ b/web/src/icons/SelectOnly.jsx
@@ -0,0 +1,21 @@
+import { h } from 'preact';
+import { memo } from 'preact/compat';
+
+export function SelectOnly({ className = 'h-5 w-5', stroke = 'currentColor', fill = 'none', onClick = () => {} }) {
+ return (
+
+ );
+}
+
+export default memo(SelectOnly);
diff --git a/web/src/routes/Cameras.jsx b/web/src/routes/Cameras.jsx
index 2298b992e..18128f738 100644
--- a/web/src/routes/Cameras.jsx
+++ b/web/src/routes/Cameras.jsx
@@ -5,24 +5,41 @@ import CameraImage from '../components/CameraImage';
import AudioIcon from '../icons/Audio';
import ClipIcon from '../icons/Clip';
import MotionIcon from '../icons/Motion';
+import SettingsIcon from '../icons/Settings';
import SnapshotIcon from '../icons/Snapshot';
import { useAudioState, useDetectState, useRecordingsState, useSnapshotsState } from '../api/ws';
import { useMemo } from 'preact/hooks';
import useSWR from 'swr';
+import { useRef, useState } from 'react';
+import { useResizeObserver } from '../hooks';
+import Dialog from '../components/Dialog';
+import Switch from '../components/Switch';
+import Heading from '../components/Heading';
+import Button from '../components/Button';
export default function Cameras() {
const { data: config } = useSWR('config');
+ const containerRef = useRef(null);
+ const [{ width: containerWidth }] = useResizeObserver(containerRef);
+ // Add scrollbar width (when visible) to the available observer width to eliminate screen juddering.
+ // https://github.com/blakeblackshear/frigate/issues/1657
+ let scrollBarWidth = 0;
+ if (window.innerWidth && document.body.offsetWidth) {
+ scrollBarWidth = window.innerWidth - document.body.offsetWidth;
+ }
+ const availableWidth = scrollBarWidth ? containerWidth + scrollBarWidth : containerWidth;
+
return !config ? (
-
+
+
);
}
-function SortedCameras({ config, unsortedCameras }) {
+function SortedCameras({ config, unsortedCameras, availableWidth }) {
const sortedCameras = useMemo(
() =>
Object.entries(unsortedCameras)
@@ -34,17 +51,20 @@ function SortedCameras({ config, unsortedCameras }) {
return (
{sortedCameras.map(([camera, conf]) => (
-
+
))}
);
}
-function Camera({ name, config }) {
+function Camera({ name, config, availableWidth }) {
const { payload: detectValue, send: sendDetect } = useDetectState(name);
const { payload: recordValue, send: sendRecordings } = useRecordingsState(name);
const { payload: snapshotValue, send: sendSnapshots } = useSnapshotsState(name);
const { payload: audioValue, send: sendAudio } = useAudioState(name);
+
+ const [cameraOptions, setCameraOptions] = useState('');
+
const href = `/cameras/${name}`;
const buttons = useMemo(() => {
return [
@@ -56,7 +76,15 @@ function Camera({ name, config }) {
return `${name.replaceAll('_', ' ')}`;
}, [name]);
const icons = useMemo(
- () => [
+ () => (availableWidth < 448 ? [
+ {
+ icon: SettingsIcon,
+ color: 'gray',
+ onClick: () => {
+ setCameraOptions(config.name);
+ },
+ },
+ ] : [
{
name: `Toggle detect ${detectValue === 'ON' ? 'off' : 'on'}`,
icon: MotionIcon,
@@ -95,17 +123,64 @@ function Camera({ name, config }) {
},
}
: null,
- ].filter((button) => button != null),
- [config, audioValue, sendAudio, detectValue, sendDetect, recordValue, sendRecordings, snapshotValue, sendSnapshots]
+ ]).filter((button) => button != null),
+ [config, availableWidth, setCameraOptions, audioValue, sendAudio, detectValue, sendDetect, recordValue, sendRecordings, snapshotValue, sendSnapshots]
);
return (
-
}
- />
+
+ {cameraOptions && (
+
+ )}
+
+ }
+ />
+
);
}
diff --git a/web/src/routes/__tests__/Cameras.test.jsx b/web/src/routes/__tests__/Cameras.test.jsx
index 7dfaa8d53..faa3b2bc9 100644
--- a/web/src/routes/__tests__/Cameras.test.jsx
+++ b/web/src/routes/__tests__/Cameras.test.jsx
@@ -1,5 +1,6 @@
import { h } from 'preact';
import * as CameraImage from '../../components/CameraImage';
+import * as Hooks from '../../hooks';
import * as WS from '../../api/ws';
import Cameras from '../Cameras';
import { fireEvent, render, screen, waitForElementToBeRemoved } from 'testing-library';
@@ -8,6 +9,7 @@ describe('Cameras Route', () => {
beforeEach(() => {
vi.spyOn(CameraImage, 'default').mockImplementation(() =>
);
vi.spyOn(WS, 'useWs').mockImplementation(() => ({ value: { payload: 'OFF' }, send: vi.fn() }));
+ vi.spyOn(Hooks, 'useResizeObserver').mockImplementation(() => [{ width: 1000 }]);
});
test('shows an ActivityIndicator if not yet loaded', async () => {
diff --git a/web/src/routes/__tests__/Recording.test.jsx b/web/src/routes/__tests__/Recording.test.jsx
index 8dc33fdaf..2351eaf81 100644
--- a/web/src/routes/__tests__/Recording.test.jsx
+++ b/web/src/routes/__tests__/Recording.test.jsx
@@ -1,6 +1,7 @@
import { h } from 'preact';
import * as CameraImage from '../../components/CameraImage';
import * as WS from '../../api/ws';
+import * as Hooks from '../../hooks';
import Cameras from '../Cameras';
import { render, screen, waitForElementToBeRemoved } from 'testing-library';
@@ -8,6 +9,7 @@ describe('Recording Route', () => {
beforeEach(() => {
vi.spyOn(CameraImage, 'default').mockImplementation(() =>
);
vi.spyOn(WS, 'useWs').mockImplementation(() => ({ value: { payload: 'OFF' }, send: jest.fn() }));
+ vi.spyOn(Hooks, 'useResizeObserver').mockImplementation(() => [{ width: 1000 }]);
});
test('shows an ActivityIndicator if not yet loaded', async () => {