Miscellaneous fixes (#22924)

* apply annotation offset to frigate+ submission frame time

* fix broken docs links with hash fragments that resolve wrong on reload

* undo

* use recording snapshot for frigate+ frame submission from VideoControls

rather than a canvas grab/paint, which may not always align with an ffmpeg snapshot due to keyframes

* add more docs links

- display docs link for main sections on collapsible fields

* dialog button consistency
This commit is contained in:
Josh Hawkins 2026-04-20 08:19:09 -05:00 committed by GitHub
parent 043c746a8b
commit 1a5d15ba81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 147 additions and 30 deletions

View File

@ -4,7 +4,8 @@
"noPreviewFoundFor": "No Preview Found for {{cameraName}}", "noPreviewFoundFor": "No Preview Found for {{cameraName}}",
"submitFrigatePlus": { "submitFrigatePlus": {
"title": "Submit this frame to Frigate+?", "title": "Submit this frame to Frigate+?",
"submit": "Submit" "submit": "Submit",
"previewError": "Could not load snapshot preview. The recording may not be available at this time."
}, },
"livePlayerRequiredIOSVersion": "iOS 17.1 or greater is required for this live stream type.", "livePlayerRequiredIOSVersion": "iOS 17.1 or greater is required for this live stream type.",
"streamOffline": { "streamOffline": {

View File

@ -31,6 +31,8 @@ const ffmpeg: SectionConfigOverrides = {
"inputs.output_args": "/configuration/ffmpeg_presets#output-args-presets", "inputs.output_args": "/configuration/ffmpeg_presets#output-args-presets",
"output_args.record": "/configuration/ffmpeg_presets#output-args-presets", "output_args.record": "/configuration/ffmpeg_presets#output-args-presets",
"inputs.roles": "/configuration/cameras/#setting-up-camera-inputs", "inputs.roles": "/configuration/cameras/#setting-up-camera-inputs",
apple_compatibility:
"/configuration/camera_specific#h265-cameras-via-safari",
}, },
restartRequired: [], restartRequired: [],
fieldOrder: [ fieldOrder: [

View File

@ -27,10 +27,12 @@ const lpr: SectionConfigOverrides = {
], ],
fieldDocs: { fieldDocs: {
enhancement: "/configuration/license_plate_recognition#enhancement", enhancement: "/configuration/license_plate_recognition#enhancement",
debug_save_plates:
"/configuration/license_plate_recognition/#how-do-i-debug-lpr-issues",
}, },
restartRequired: [], restartRequired: [],
fieldOrder: ["enabled", "min_area", "enhancement", "expire_time"], fieldOrder: ["enabled", "min_area", "enhancement", "expire_time"],
hiddenFields: [], hiddenFields: ["expire_time"],
advancedFields: ["expire_time", "enhancement"], advancedFields: ["expire_time", "enhancement"],
overrideFields: ["enabled", "min_area", "enhancement"], overrideFields: ["enabled", "min_area", "enhancement"],
}, },

View File

@ -3,6 +3,11 @@ import type { SectionConfigOverrides } from "./types";
const onvif: SectionConfigOverrides = { const onvif: SectionConfigOverrides = {
base: { base: {
sectionDocs: "/configuration/cameras#setting-up-camera-ptz-controls", sectionDocs: "/configuration/cameras#setting-up-camera-ptz-controls",
fieldDocs: {
autotracking: "/configuration/autotracking",
"autotracking.calibrate_on_startup":
"/configuration/autotracking#calibration",
},
fieldOrder: [ fieldOrder: [
"host", "host",
"port", "port",

View File

@ -45,6 +45,10 @@ const review: SectionConfigOverrides = {
fieldDocs: { fieldDocs: {
"alerts.labels": "/configuration/review/#alerts-and-detections", "alerts.labels": "/configuration/review/#alerts-and-detections",
"detections.labels": "/configuration/review/#alerts-and-detections", "detections.labels": "/configuration/review/#alerts-and-detections",
genai: "/configuration/genai/genai_review",
"genai.image_source": "/configuration/genai/genai_review#image-source",
"genai.additional_concerns":
"/configuration/genai/genai_review#additional-concerns",
}, },
restartRequired: [], restartRequired: [],
fieldOrder: ["alerts", "detections", "genai", "genai.enabled"], fieldOrder: ["alerts", "detections", "genai", "genai.enabled"],

View File

@ -9,11 +9,13 @@ import {
import { Children, useState, useEffect, useRef } from "react"; import { Children, useState, useEffect, useRef } from "react";
import type { ReactNode } from "react"; import type { ReactNode } from "react";
import RestartRequiredIndicator from "@/components/indicators/RestartRequiredIndicator"; import RestartRequiredIndicator from "@/components/indicators/RestartRequiredIndicator";
import { LuChevronDown, LuChevronRight } from "react-icons/lu"; import { LuChevronDown, LuChevronRight, LuExternalLink } from "react-icons/lu";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { getTranslatedLabel } from "@/utils/i18n"; import { getTranslatedLabel } from "@/utils/i18n";
import { requiresRestartForFieldPath } from "@/utils/configUtil"; import { requiresRestartForFieldPath } from "@/utils/configUtil";
import { useDocDomain } from "@/hooks/use-doc-domain";
import { ConfigFormContext } from "@/types/configForm"; import { ConfigFormContext } from "@/types/configForm";
import { import {
buildTranslationPath, buildTranslationPath,
@ -178,6 +180,7 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
"views/settings", "views/settings",
"common", "common",
]); ]);
const { getLocaleDocUrl } = useDocDomain();
const objectRequiresRestart = requiresRestartForFieldPath( const objectRequiresRestart = requiresRestartForFieldPath(
fieldPath, fieldPath,
restartRequired, restartRequired,
@ -300,6 +303,17 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
schemaDescription; schemaDescription;
inferredDescription = inferredDescription ?? fallbackDescription; inferredDescription = inferredDescription ?? fallbackDescription;
const pathStringSegments =
path?.filter((segment): segment is string => typeof segment === "string") ??
[];
const fieldDocsKey = translationPath || pathStringSegments.join(".");
const fieldDocsPath = fieldDocsKey
? formContext?.fieldDocs?.[fieldDocsKey]
: undefined;
const fieldDocsUrl = fieldDocsPath
? getLocaleDocUrl(fieldDocsPath)
: undefined;
const renderGroupedFields = (items: (typeof properties)[number][]) => { const renderGroupedFields = (items: (typeof properties)[number][]) => {
if (!items.length) { if (!items.length) {
return null; return null;
@ -466,6 +480,20 @@ export function ObjectFieldTemplate(props: ObjectFieldTemplateProps) {
{inferredDescription} {inferredDescription}
</p> </p>
)} )}
{fieldDocsUrl && (
<div className="mt-1 flex items-center text-xs text-primary-variant">
<Link
to={fieldDocsUrl}
target="_blank"
rel="noopener noreferrer"
className="inline"
onClick={(e) => e.stopPropagation()}
>
{t("readTheDocumentation", { ns: "common" })}
<LuExternalLink className="ml-2 inline-flex size-3" />
</Link>
</div>
)}
</div> </div>
{isOpen ? ( {isOpen ? (
<LuChevronDown className="h-4 w-4 shrink-0" /> <LuChevronDown className="h-4 w-4 shrink-0" />

View File

@ -113,18 +113,19 @@ export function DebugReplayContent({
{isDesktop && <SelectSeparator className="my-4 bg-secondary" />} {isDesktop && <SelectSeparator className="my-4 bg-secondary" />}
<DialogFooter <DialogFooter
className={isDesktop ? "" : "mt-3 flex flex-col-reverse gap-4"} className={isDesktop ? "" : "mt-3 flex flex-col-reverse gap-2"}
> >
<div <Button
className={`cursor-pointer p-2 text-center ${isDesktop ? "" : "w-full"}`} className={isDesktop ? "" : "w-full"}
aria-label={t("button.cancel", { ns: "common" })}
variant="outline"
onClick={onCancel} onClick={onCancel}
> >
{t("button.cancel", { ns: "common" })} {t("button.cancel", { ns: "common" })}
</div> </Button>
<Button <Button
className={isDesktop ? "" : "w-full"} className={isDesktop ? "" : "w-full"}
variant="select" variant="select"
size="sm"
disabled={isStarting} disabled={isStarting}
onClick={() => { onClick={() => {
if (selectedOption === "timeline") { if (selectedOption === "timeline") {

View File

@ -1043,20 +1043,21 @@ export function ExportContent({
{isDesktop && <SelectSeparator className="my-4 bg-secondary" />} {isDesktop && <SelectSeparator className="my-4 bg-secondary" />}
<DialogFooter <DialogFooter
className={isDesktop ? "" : "mt-3 flex flex-col-reverse gap-4"} className={isDesktop ? "" : "mt-3 flex flex-col-reverse gap-2"}
> >
<div <Button
className={`cursor-pointer p-2 text-center ${isDesktop ? "" : "w-full"}`} className={isDesktop ? "" : "w-full"}
aria-label={t("button.cancel", { ns: "common" })}
variant="outline"
onClick={onCancel} onClick={onCancel}
> >
{t("button.cancel", { ns: "common" })} {t("button.cancel", { ns: "common" })}
</div> </Button>
{activeTab === "export" ? ( {activeTab === "export" ? (
<Button <Button
className={isDesktop ? "" : "w-full"} className={isDesktop ? "" : "w-full"}
aria-label={t("export.selectOrExport")} aria-label={t("export.selectOrExport")}
variant="select" variant="select"
size="sm"
disabled={isStartingExport} disabled={isStartingExport}
onClick={async () => { onClick={async () => {
if (selectedOption == "timeline") { if (selectedOption == "timeline") {

View File

@ -197,24 +197,21 @@ export function ShareTimestampContent({
{isDesktop && <Separator className="my-4 bg-secondary" />} {isDesktop && <Separator className="my-4 bg-secondary" />}
<DialogFooter <DialogFooter
className={cn("mt-4", !isDesktop && "flex flex-col-reverse gap-4")} className={cn("mt-4", !isDesktop && "flex flex-col-reverse gap-2")}
> >
{onCancel && ( {onCancel && (
<button <Button
type="button" className={cn(!isDesktop && "w-full")}
className={cn( aria-label={t("button.cancel", { ns: "common" })}
"cursor-pointer p-2 text-center", variant="outline"
!isDesktop && "w-full",
)}
onClick={onCancel} onClick={onCancel}
> >
{t("button.cancel", { ns: "common" })} {t("button.cancel", { ns: "common" })}
</button> </Button>
)} )}
<Button <Button
className={cn(!isDesktop && "w-full")} className={cn(!isDesktop && "w-full")}
variant="select" variant="select"
size="sm"
onClick={() => onShareTimestamp(Math.floor(selectedTimestamp))} onClick={() => onShareTimestamp(Math.floor(selectedTimestamp))}
> >
{t("recording.shareTimestamp.button", { ns: "components/dialog" })} {t("recording.shareTimestamp.button", { ns: "components/dialog" })}

View File

@ -636,6 +636,13 @@ export function TrackingDetails({
return axios.post(`/${event.camera}/plus/${currentTime}`); return axios.post(`/${event.camera}/plus/${currentTime}`);
}, [event.camera, currentTime]); }, [event.camera, currentTime]);
const getSnapshotUrlForPlus = useCallback(() => {
if (!currentTime) {
return undefined;
}
return `${apiHost}api/${event.camera}/recordings/${currentTime}/snapshot.jpg?height=500`;
}, [apiHost, event.camera, currentTime]);
if (!config) { if (!config) {
return <ActivityIndicator />; return <ActivityIndicator />;
} }
@ -683,6 +690,7 @@ export function TrackingDetails({
onTimeUpdate={handleTimeUpdate} onTimeUpdate={handleTimeUpdate}
onSeekToTime={handleSeekToTime} onSeekToTime={handleSeekToTime}
onUploadFrame={onUploadFrameToPlus} onUploadFrame={onUploadFrameToPlus}
getSnapshotUrl={getSnapshotUrlForPlus}
onPlaying={() => setIsVideoLoading(false)} onPlaying={() => setIsVideoLoading(false)}
setFullResolution={setFullResolution} setFullResolution={setFullResolution}
toggleFullscreen={toggleFullscreen} toggleFullscreen={toggleFullscreen}
@ -867,6 +875,7 @@ export function TrackingDetails({
getZoneColor={getZoneColor} getZoneColor={getZoneColor}
effectiveTime={effectiveTime} effectiveTime={effectiveTime}
isTimelineActive={isWithinEventRange} isTimelineActive={isWithinEventRange}
annotationOffset={annotationOffset}
/> />
</div> </div>
); );
@ -890,6 +899,7 @@ type LifecycleIconRowProps = {
getZoneColor: (zoneName: string) => number[] | undefined; getZoneColor: (zoneName: string) => number[] | undefined;
effectiveTime?: number; effectiveTime?: number;
isTimelineActive?: boolean; isTimelineActive?: boolean;
annotationOffset: number;
}; };
function LifecycleIconRow({ function LifecycleIconRow({
@ -900,6 +910,7 @@ function LifecycleIconRow({
getZoneColor, getZoneColor,
effectiveTime, effectiveTime,
isTimelineActive, isTimelineActive,
annotationOffset,
}: LifecycleIconRowProps) { }: LifecycleIconRowProps) {
const { t } = useTranslation(["views/explore", "components/player"]); const { t } = useTranslation(["views/explore", "components/player"]);
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
@ -1206,7 +1217,7 @@ function LifecycleIconRow({
className="cursor-pointer" className="cursor-pointer"
onSelect={async () => { onSelect={async () => {
const resp = await axios.post( const resp = await axios.post(
`/${item.camera}/plus/${item.timestamp}`, `/${item.camera}/plus/${item.timestamp + annotationOffset / 1000}`,
); );
if (resp && resp.status == 200) { if (resp && resp.status == 200) {

View File

@ -53,6 +53,7 @@ type HlsVideoPlayerProps = {
onSeekToTime?: (timestamp: number, play?: boolean) => void; onSeekToTime?: (timestamp: number, play?: boolean) => void;
setFullResolution?: React.Dispatch<React.SetStateAction<VideoResolutionType>>; setFullResolution?: React.Dispatch<React.SetStateAction<VideoResolutionType>>;
onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined; onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined;
getSnapshotUrl?: (playTime: number) => string | undefined;
toggleFullscreen?: () => void; toggleFullscreen?: () => void;
onError?: (error: RecordingPlayerError) => void; onError?: (error: RecordingPlayerError) => void;
isDetailMode?: boolean; isDetailMode?: boolean;
@ -78,6 +79,7 @@ export default function HlsVideoPlayer({
onSeekToTime, onSeekToTime,
setFullResolution, setFullResolution,
onUploadFrame, onUploadFrame,
getSnapshotUrl,
toggleFullscreen, toggleFullscreen,
onError, onError,
isDetailMode = false, isDetailMode = false,
@ -331,6 +333,13 @@ export default function HlsVideoPlayer({
videoRef.current.playbackRate = rate; videoRef.current.playbackRate = rate;
} }
}} }}
getSnapshotUrl={() => {
const frameTime = getVideoTime();
if (!frameTime || !getSnapshotUrl) {
return undefined;
}
return getSnapshotUrl(frameTime);
}}
onUploadFrame={async () => { onUploadFrame={async () => {
const frameTime = getVideoTime(); const frameTime = getVideoTime();

View File

@ -1,4 +1,5 @@
import { useCallback, useMemo, useRef, useState } from "react"; import { useCallback, useMemo, useRef, useState } from "react";
import { LuFolderX } from "react-icons/lu";
import { isDesktop, isMobileOnly, isSafari } from "react-device-detect"; import { isDesktop, isMobileOnly, isSafari } from "react-device-detect";
import { LuPause, LuPlay } from "react-icons/lu"; import { LuPause, LuPlay } from "react-icons/lu";
import { import {
@ -71,6 +72,7 @@ type VideoControlsProps = {
onSeek: (diff: number) => void; onSeek: (diff: number) => void;
onSetPlaybackRate: (rate: number) => void; onSetPlaybackRate: (rate: number) => void;
onUploadFrame?: () => void; onUploadFrame?: () => void;
getSnapshotUrl?: () => string | undefined;
toggleFullscreen?: () => void; toggleFullscreen?: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>; containerRef?: React.MutableRefObject<HTMLDivElement | null>;
}; };
@ -92,6 +94,7 @@ export default function VideoControls({
onSeek, onSeek,
onSetPlaybackRate, onSetPlaybackRate,
onUploadFrame, onUploadFrame,
getSnapshotUrl,
toggleFullscreen, toggleFullscreen,
containerRef, containerRef,
}: VideoControlsProps) { }: VideoControlsProps) {
@ -288,6 +291,7 @@ export default function VideoControls({
} }
}} }}
onUploadFrame={onUploadFrame} onUploadFrame={onUploadFrame}
getSnapshotUrl={getSnapshotUrl}
containerRef={containerRef} containerRef={containerRef}
fullscreen={fullscreen} fullscreen={fullscreen}
/> />
@ -306,6 +310,7 @@ type FrigatePlusUploadButtonProps = {
onOpen: () => void; onOpen: () => void;
onClose: () => void; onClose: () => void;
onUploadFrame: () => void; onUploadFrame: () => void;
getSnapshotUrl?: () => string | undefined;
containerRef?: React.MutableRefObject<HTMLDivElement | null>; containerRef?: React.MutableRefObject<HTMLDivElement | null>;
fullscreen?: boolean; fullscreen?: boolean;
}; };
@ -314,12 +319,14 @@ function FrigatePlusUploadButton({
onOpen, onOpen,
onClose, onClose,
onUploadFrame, onUploadFrame,
getSnapshotUrl,
containerRef, containerRef,
fullscreen, fullscreen,
}: FrigatePlusUploadButtonProps) { }: FrigatePlusUploadButtonProps) {
const { t } = useTranslation(["components/player"]); const { t } = useTranslation(["components/player"]);
const [videoImg, setVideoImg] = useState<string>(); const [previewUrl, setPreviewUrl] = useState<string>();
const [previewError, setPreviewError] = useState(false);
return ( return (
<AlertDialog <AlertDialog
@ -334,6 +341,13 @@ function FrigatePlusUploadButton({
className="size-5 cursor-pointer" className="size-5 cursor-pointer"
onClick={() => { onClick={() => {
onOpen(); onOpen();
setPreviewError(false);
const snapshotUrl = getSnapshotUrl?.();
if (snapshotUrl) {
setPreviewUrl(snapshotUrl);
return;
}
if (video) { if (video) {
const videoSize = [video.clientWidth, video.clientHeight]; const videoSize = [video.clientWidth, video.clientHeight];
@ -345,7 +359,7 @@ function FrigatePlusUploadButton({
if (context) { if (context) {
context.drawImage(video, 0, 0, videoSize[0], videoSize[1]); context.drawImage(video, 0, 0, videoSize[0], videoSize[1]);
setVideoImg(canvas.toDataURL("image/webp")); setPreviewUrl(canvas.toDataURL("image/webp"));
} }
} }
}} }}
@ -362,14 +376,29 @@ function FrigatePlusUploadButton({
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle>{t("submitFrigatePlus.title")}</AlertDialogTitle> <AlertDialogTitle>{t("submitFrigatePlus.title")}</AlertDialogTitle>
</AlertDialogHeader> </AlertDialogHeader>
<img className="aspect-video w-full object-contain" src={videoImg} /> {previewError ? (
<div className="flex aspect-video w-full flex-col items-center justify-center gap-2 text-center text-muted-foreground">
<LuFolderX className="size-12" />
<span>{t("submitFrigatePlus.previewError")}</span>
</div>
) : (
<img
className="aspect-video w-full object-contain"
src={previewUrl}
onError={() => setPreviewError(true)}
/>
)}
<AlertDialogFooter> <AlertDialogFooter>
<AlertDialogAction className="bg-selected" onClick={onUploadFrame}>
{t("submitFrigatePlus.submit")}
</AlertDialogAction>
<AlertDialogCancel> <AlertDialogCancel>
{t("button.cancel", { ns: "common" })} {t("button.cancel", { ns: "common" })}
</AlertDialogCancel> </AlertDialogCancel>
<AlertDialogAction
className="bg-selected text-white"
onClick={onUploadFrame}
disabled={previewError}
>
{t("submitFrigatePlus.submit")}
</AlertDialogAction>
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>

View File

@ -181,6 +181,21 @@ export default function DynamicVideoPlayer({
[camera, controller], [camera, controller],
); );
const getSnapshotUrlForPlus = useCallback(
(playTime: number) => {
if (!controller) {
return undefined;
}
const time = controller.getProgress(playTime);
if (!time) {
return undefined;
}
return `${apiHost}api/${camera}/recordings/${time}/snapshot.jpg?height=500`;
},
[apiHost, camera, controller],
);
// state of playback player // state of playback player
const recordingParams = useMemo( const recordingParams = useMemo(
@ -312,6 +327,7 @@ export default function DynamicVideoPlayer({
}} }}
setFullResolution={setFullResolution} setFullResolution={setFullResolution}
onUploadFrame={onUploadFrameToPlus} onUploadFrame={onUploadFrameToPlus}
getSnapshotUrl={getSnapshotUrlForPlus}
toggleFullscreen={toggleFullscreen} toggleFullscreen={toggleFullscreen}
onError={(error) => { onError={(error) => {
if (error == "stalled" && !isScrubbing) { if (error == "stalled" && !isScrubbing) {

View File

@ -487,7 +487,7 @@ export default function TriggerView({
<> <>
<div className="mb-5 flex flex-row items-center justify-between gap-2"> <div className="mb-5 flex flex-row items-center justify-between gap-2">
<div className="flex flex-col items-start"> <div className="flex flex-col items-start">
<Heading as="h4" className="mb-2"> <Heading as="h4" className="mb-1">
{t("triggers.management.title")} {t("triggers.management.title")}
</Heading> </Heading>
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
@ -495,6 +495,17 @@ export default function TriggerView({
camera: cameraName, camera: cameraName,
})} })}
</p> </p>
<div className="mt-1 flex items-center text-sm text-primary-variant">
<Link
to={getLocaleDocUrl("configuration/semantic_search")}
target="_blank"
rel="noopener noreferrer"
className="inline"
>
{t("readTheDocumentation", { ns: "common" })}{" "}
<LuExternalLink className="ml-2 inline-flex size-3" />
</Link>
</div>
</div> </div>
<Button <Button
className="flex items-center gap-2 self-start sm:self-auto" className="flex items-center gap-2 self-start sm:self-auto"