Skip to content

Commit 4e59897

Browse files
Merge pull request #4 from anedyaio/dev
Disable camera stats display and add auto-start stream option
2 parents 969943d + 562825e commit 4e59897

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/components/dashboard-builder/PropertiesPanel.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ export default function PropertiesPanel() {
236236
/>
237237
<Label htmlFor="showNetworkStatsBtn" className="font-normal cursor-pointer text-sm">Show Network Stats Button</Label>
238238
</div>
239+
<div className="flex items-center gap-2">
240+
<input
241+
type="checkbox"
242+
id="autoStart"
243+
className="w-4 h-4 rounded border-input text-primary focus:ring-primary cursor-pointer"
244+
checked={draftConfig.autoStart === true}
245+
onChange={(e) => handleConfigChange({ autoStart: e.target.checked })}
246+
/>
247+
<Label htmlFor="autoStart" className="font-normal cursor-pointer text-sm">Auto Start Stream on Open</Label>
248+
</div>
239249
</div>
240250
</div>
241251
)}

src/components/dashboard-builder/widgets/CameraViewerWidget.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function CameraViewerWidget({ config, nodeId, isEditMode }: Camer
4545
const [connectionProgress, setConnectionProgress] = useState('CONNECTING...');
4646

4747
const [isFullscreen, setIsFullscreen] = useState(false);
48-
const [showStats, setShowStats] = useState(true);
48+
const [showStats, setShowStats] = useState(false);
4949
const [networkStats, setNetworkStats] = useState({ bitrate: 0, fps: 0, packetLoss: 0, resolution: '' });
5050
const lastBytesReceived = useRef(0);
5151
const lastTimestamp = useRef(0);
@@ -318,6 +318,13 @@ export default function CameraViewerWidget({ config, nodeId, isEditMode }: Camer
318318
};
319319
}, [stopStream]);
320320

321+
useEffect(() => {
322+
if (!isEditMode && config?.config?.autoStart === true && status === 'ready') {
323+
startStream();
324+
}
325+
// eslint-disable-next-line react-hooks/exhaustive-deps
326+
}, [nodeId, isEditMode]);
327+
321328
useEffect(() => {
322329
const onFullscreenChange = () => setIsFullscreen(!!document.fullscreenElement);
323330
document.addEventListener('fullscreenchange', onFullscreenChange);

0 commit comments

Comments
 (0)