|
@@ -1,5 +1,5 @@
|
|
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
-import { useParams } from 'react-router-dom';
|
|
|
|
|
|
|
+import { useParams, useSearchParams } from 'react-router-dom';
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import { RefreshCw, AlertTriangle, Camera, Maximize, Minimize, WifiOff, ZoomIn, ZoomOut } from 'lucide-react';
|
|
import { RefreshCw, AlertTriangle, Camera, Maximize, Minimize, WifiOff, ZoomIn, ZoomOut } from 'lucide-react';
|
|
@@ -22,6 +22,9 @@ export function CameraPage() {
|
|
|
const { hasPermission, authEnabled, user } = useAuth();
|
|
const { hasPermission, authEnabled, user } = useAuth();
|
|
|
const { printerId } = useParams<{ printerId: string }>();
|
|
const { printerId } = useParams<{ printerId: string }>();
|
|
|
const id = parseInt(printerId || '0', 10);
|
|
const id = parseInt(printerId || '0', 10);
|
|
|
|
|
+ const [searchParams] = useSearchParams();
|
|
|
|
|
+ const fpsParam = parseInt(searchParams.get('fps') || '15', 10);
|
|
|
|
|
+ const fps = Math.min(Math.max(isNaN(fpsParam) ? 15 : fpsParam, 1), 30);
|
|
|
|
|
|
|
|
// Subscribe to the stream-token query so this page re-renders once the token
|
|
// Subscribe to the stream-token query so this page re-renders once the token
|
|
|
// arrives. useStreamTokenSync (mounted in App) already owns the fetch; this
|
|
// arrives. useStreamTokenSync (mounted in App) already owns the fetch; this
|
|
@@ -599,7 +602,7 @@ export function CameraPage() {
|
|
|
const currentUrl = transitioning || waitingForStreamToken
|
|
const currentUrl = transitioning || waitingForStreamToken
|
|
|
? ''
|
|
? ''
|
|
|
: streamMode === 'stream'
|
|
: streamMode === 'stream'
|
|
|
- ? appendToken(`/api/v1/printers/${id}/camera/stream?fps=15&t=${imageKey}`)
|
|
|
|
|
|
|
+ ? appendToken(`/api/v1/printers/${id}/camera/stream?fps=${fps}&t=${imageKey}`)
|
|
|
: appendToken(`/api/v1/printers/${id}/camera/snapshot?t=${imageKey}`);
|
|
: appendToken(`/api/v1/printers/${id}/camera/snapshot?t=${imageKey}`);
|
|
|
|
|
|
|
|
const isDisabled = streamLoading || transitioning || isReconnecting;
|
|
const isDisabled = streamLoading || transitioning || isReconnecting;
|