mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-19 09:27:06 +03:00
frontend
This commit is contained in:
parent
f31b8bf60a
commit
060e9240c6
@ -200,6 +200,31 @@ export function useAutotrackingState(camera: string): {
|
|||||||
return { payload: payload as ToggleableSetting, send };
|
return { payload: payload as ToggleableSetting, send };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useAlertsState(camera: string): {
|
||||||
|
payload: ToggleableSetting;
|
||||||
|
send: (payload: ToggleableSetting, retain?: boolean) => void;
|
||||||
|
} {
|
||||||
|
const {
|
||||||
|
value: { payload },
|
||||||
|
send,
|
||||||
|
} = useWs(`${camera}/review/alerts/state`, `${camera}/review/alerts/set`);
|
||||||
|
return { payload: payload as ToggleableSetting, send };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDetectionsState(camera: string): {
|
||||||
|
payload: ToggleableSetting;
|
||||||
|
send: (payload: ToggleableSetting, retain?: boolean) => void;
|
||||||
|
} {
|
||||||
|
const {
|
||||||
|
value: { payload },
|
||||||
|
send,
|
||||||
|
} = useWs(
|
||||||
|
`${camera}/review/detections/state`,
|
||||||
|
`${camera}/review/detections/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;
|
||||||
|
|||||||
@ -172,10 +172,12 @@ export interface CameraConfig {
|
|||||||
};
|
};
|
||||||
review: {
|
review: {
|
||||||
alerts: {
|
alerts: {
|
||||||
|
enabled: boolean;
|
||||||
required_zones: string[];
|
required_zones: string[];
|
||||||
labels: string[];
|
labels: string[];
|
||||||
};
|
};
|
||||||
detections: {
|
detections: {
|
||||||
|
enabled: boolean;
|
||||||
required_zones: string[];
|
required_zones: string[];
|
||||||
labels: string[];
|
labels: string[];
|
||||||
};
|
};
|
||||||
|
|||||||
@ -27,6 +27,9 @@ import { LuExternalLink } from "react-icons/lu";
|
|||||||
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
||||||
import { MdCircle } from "react-icons/md";
|
import { MdCircle } from "react-icons/md";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { useAlertsState, useDetectionsState } from "@/api/ws";
|
||||||
|
|
||||||
type CameraSettingsViewProps = {
|
type CameraSettingsViewProps = {
|
||||||
selectedCamera: string;
|
selectedCamera: string;
|
||||||
@ -105,6 +108,11 @@ export default function CameraSettingsView({
|
|||||||
const watchedAlertsZones = form.watch("alerts_zones");
|
const watchedAlertsZones = form.watch("alerts_zones");
|
||||||
const watchedDetectionsZones = form.watch("detections_zones");
|
const watchedDetectionsZones = form.watch("detections_zones");
|
||||||
|
|
||||||
|
const { payload: alertsState, send: sendAlerts } =
|
||||||
|
useAlertsState(selectedCamera);
|
||||||
|
const { payload: detectionsState, send: sendDetections } =
|
||||||
|
useDetectionsState(selectedCamera);
|
||||||
|
|
||||||
const handleCheckedChange = useCallback(
|
const handleCheckedChange = useCallback(
|
||||||
(isChecked: boolean) => {
|
(isChecked: boolean) => {
|
||||||
if (!isChecked) {
|
if (!isChecked) {
|
||||||
@ -244,6 +252,49 @@ export default function CameraSettingsView({
|
|||||||
|
|
||||||
<Separator className="my-2 flex bg-secondary" />
|
<Separator className="my-2 flex bg-secondary" />
|
||||||
|
|
||||||
|
<Heading as="h4" className="my-2">
|
||||||
|
Review
|
||||||
|
</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"
|
||||||
|
disabled={alertsState == "OFF"}
|
||||||
|
checked={alertsState == "ON"}
|
||||||
|
onCheckedChange={(isChecked) => {
|
||||||
|
sendAlerts(isChecked ? "OFF" : "ON");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<Label htmlFor="alerts-enabled">Alerts</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<div className="flex flex-row items-center">
|
||||||
|
<Switch
|
||||||
|
id="detections-enabled"
|
||||||
|
className="mr-3"
|
||||||
|
disabled={detectionsState == "OFF"}
|
||||||
|
checked={detectionsState == "ON"}
|
||||||
|
onCheckedChange={(isChecked) => {
|
||||||
|
sendDetections(isChecked ? "OFF" : "ON");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<Label htmlFor="detections-enabled">Detections</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 text-sm text-muted-foreground">
|
||||||
|
Enable/disable alerts and detections for this camera. When
|
||||||
|
disabled, no new review items will be generated.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator className="my-2 flex bg-secondary" />
|
||||||
|
|
||||||
<Heading as="h4" className="my-2">
|
<Heading as="h4" className="my-2">
|
||||||
Review Classification
|
Review Classification
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user