mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-30 10:37:42 +03:00
add switch to frontend
This commit is contained in:
parent
d435d6628b
commit
8102f070ee
@ -150,6 +150,10 @@
|
|||||||
"title": "Streams",
|
"title": "Streams",
|
||||||
"desc": "Disabling a camera completely stops Frigate's processing of this camera's streams. Detection, recording, and debugging will be unavailable.<br /> <em>Note: This does not disable go2rtc restreams.</em>"
|
"desc": "Disabling a camera completely stops Frigate's processing of this camera's streams. Detection, recording, and debugging will be unavailable.<br /> <em>Note: This does not disable go2rtc restreams.</em>"
|
||||||
},
|
},
|
||||||
|
"genai": {
|
||||||
|
"title": "Generative AI",
|
||||||
|
"desc": "Temporarily enable/disable Generative AI for this camera. When disabled, AI generated descriptions will not be requested for tracked objects on this camera."
|
||||||
|
},
|
||||||
"review": {
|
"review": {
|
||||||
"title": "Review",
|
"title": "Review",
|
||||||
"desc": "Enable/disable alerts and detections for this camera. When disabled, no new review items will be generated.",
|
"desc": "Enable/disable alerts and detections for this camera. When disabled, no new review items will be generated.",
|
||||||
|
|||||||
@ -68,6 +68,7 @@ function useValue(): useValueReturn {
|
|||||||
autotracking,
|
autotracking,
|
||||||
alerts,
|
alerts,
|
||||||
detections,
|
detections,
|
||||||
|
genai,
|
||||||
} = state["config"];
|
} = state["config"];
|
||||||
cameraStates[`${name}/recordings/state`] = record ? "ON" : "OFF";
|
cameraStates[`${name}/recordings/state`] = record ? "ON" : "OFF";
|
||||||
cameraStates[`${name}/enabled/state`] = enabled ? "ON" : "OFF";
|
cameraStates[`${name}/enabled/state`] = enabled ? "ON" : "OFF";
|
||||||
@ -89,6 +90,7 @@ function useValue(): useValueReturn {
|
|||||||
cameraStates[`${name}/review_detections/state`] = detections
|
cameraStates[`${name}/review_detections/state`] = detections
|
||||||
? "ON"
|
? "ON"
|
||||||
: "OFF";
|
: "OFF";
|
||||||
|
cameraStates[`${name}/genai/state`] = genai ? "ON" : "OFF";
|
||||||
});
|
});
|
||||||
|
|
||||||
setWsState((prevState) => ({
|
setWsState((prevState) => ({
|
||||||
@ -276,6 +278,17 @@ export function useDetectionsState(camera: string): {
|
|||||||
return { payload: payload as ToggleableSetting, send };
|
return { payload: payload as ToggleableSetting, send };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useGenAIState(camera: string): {
|
||||||
|
payload: ToggleableSetting;
|
||||||
|
send: (payload: ToggleableSetting, retain?: boolean) => void;
|
||||||
|
} {
|
||||||
|
const {
|
||||||
|
value: { payload },
|
||||||
|
send,
|
||||||
|
} = useWs(`${camera}/genai/state`, `${camera}/genai/set`);
|
||||||
|
return { payload: payload as ToggleableSetting, send };
|
||||||
|
}
|
||||||
|
|
||||||
export function usePtzCommand(camera: string): {
|
export function usePtzCommand(camera: string): {
|
||||||
payload: string;
|
payload: string;
|
||||||
send: (payload: string, retain?: boolean) => void;
|
send: (payload: string, retain?: boolean) => void;
|
||||||
|
|||||||
@ -64,6 +64,7 @@ export interface FrigateCameraState {
|
|||||||
autotracking: boolean;
|
autotracking: boolean;
|
||||||
alerts: boolean;
|
alerts: boolean;
|
||||||
detections: boolean;
|
detections: boolean;
|
||||||
|
genai: boolean;
|
||||||
};
|
};
|
||||||
motion: boolean;
|
motion: boolean;
|
||||||
objects: ObjectType[];
|
objects: ObjectType[];
|
||||||
|
|||||||
@ -29,7 +29,12 @@ import { cn } from "@/lib/utils";
|
|||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { useAlertsState, useDetectionsState, useEnabledState } from "@/api/ws";
|
import {
|
||||||
|
useAlertsState,
|
||||||
|
useDetectionsState,
|
||||||
|
useEnabledState,
|
||||||
|
useGenAIState,
|
||||||
|
} from "@/api/ws";
|
||||||
import CameraEditForm from "@/components/settings/CameraEditForm";
|
import CameraEditForm from "@/components/settings/CameraEditForm";
|
||||||
import { LuPlus } from "react-icons/lu";
|
import { LuPlus } from "react-icons/lu";
|
||||||
import {
|
import {
|
||||||
@ -142,6 +147,9 @@ export default function CameraSettingsView({
|
|||||||
const { payload: detectionsState, send: sendDetections } =
|
const { payload: detectionsState, send: sendDetections } =
|
||||||
useDetectionsState(selectedCamera);
|
useDetectionsState(selectedCamera);
|
||||||
|
|
||||||
|
const { payload: genAIState, send: sendGenAI } =
|
||||||
|
useGenAIState(selectedCamera);
|
||||||
|
|
||||||
const handleCheckedChange = useCallback(
|
const handleCheckedChange = useCallback(
|
||||||
(isChecked: boolean) => {
|
(isChecked: boolean) => {
|
||||||
if (!isChecked) {
|
if (!isChecked) {
|
||||||
@ -402,6 +410,36 @@ export default function CameraSettingsView({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{config?.genai?.enabled && (
|
||||||
|
<>
|
||||||
|
<Separator className="my-2 flex bg-secondary" />
|
||||||
|
|
||||||
|
<Heading as="h4" className="my-2">
|
||||||
|
<Trans ns="views/settings">camera.genai.title</Trans>
|
||||||
|
</Heading>
|
||||||
|
|
||||||
|
<div className="mb-5 mt-2 flex max-w-5xl flex-col gap-2 space-y-3 text-sm text-primary-variant">
|
||||||
|
<div className="flex flex-row items-center">
|
||||||
|
<Switch
|
||||||
|
id="alerts-enabled"
|
||||||
|
className="mr-3"
|
||||||
|
checked={genAIState == "ON"}
|
||||||
|
onCheckedChange={(isChecked) => {
|
||||||
|
sendGenAI(isChecked ? "ON" : "OFF");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<Label htmlFor="genai-enabled">
|
||||||
|
<Trans>button.enabled</Trans>
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 text-sm text-muted-foreground">
|
||||||
|
<Trans ns="views/settings">camera.genai.desc</Trans>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<Separator className="my-2 flex bg-secondary" />
|
<Separator className="my-2 flex bg-secondary" />
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user