mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-10 10:33:11 +03:00
publish websocket on config save
This commit is contained in:
parent
688bef22f2
commit
98453a5cd9
@ -30,6 +30,7 @@ import { Trans, useTranslation } from "react-i18next";
|
||||
import { useDocDomain } from "@/hooks/use-doc-domain";
|
||||
import NameAndIdFields from "../input/NameAndIdFields";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { useMotionMaskState } from "@/api/ws";
|
||||
|
||||
type MotionMaskEditPaneProps = {
|
||||
polygons?: Polygon[];
|
||||
@ -71,6 +72,11 @@ export default function MotionMaskEditPane({
|
||||
}
|
||||
}, [polygons, activePolygonIndex]);
|
||||
|
||||
const { send: sendMotionMaskState } = useMotionMaskState(
|
||||
polygon?.camera || "",
|
||||
polygon?.name || "",
|
||||
);
|
||||
|
||||
const cameraConfig = useMemo(() => {
|
||||
if (polygon?.camera && config) {
|
||||
return config.cameras[polygon.camera];
|
||||
@ -232,6 +238,8 @@ export default function MotionMaskEditPane({
|
||||
},
|
||||
);
|
||||
updateConfig();
|
||||
// Publish the enabled state through websocket
|
||||
sendMotionMaskState(enabled ? "ON" : "OFF");
|
||||
} else {
|
||||
toast.error(
|
||||
t("toast.save.error.title", {
|
||||
@ -268,6 +276,7 @@ export default function MotionMaskEditPane({
|
||||
setIsLoading,
|
||||
cameraConfig,
|
||||
t,
|
||||
sendMotionMaskState,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import NameAndIdFields from "../input/NameAndIdFields";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { useObjectMaskState } from "@/api/ws";
|
||||
|
||||
type ObjectMaskEditPaneProps = {
|
||||
polygons?: Polygon[];
|
||||
@ -77,6 +78,11 @@ export default function ObjectMaskEditPane({
|
||||
}
|
||||
}, [polygons, activePolygonIndex]);
|
||||
|
||||
const { send: sendObjectMaskState } = useObjectMaskState(
|
||||
polygon?.camera || "",
|
||||
polygon?.name || "",
|
||||
);
|
||||
|
||||
const cameraConfig = useMemo(() => {
|
||||
if (polygon?.camera && config) {
|
||||
return config.cameras[polygon.camera];
|
||||
@ -253,6 +259,8 @@ export default function ObjectMaskEditPane({
|
||||
},
|
||||
);
|
||||
updateConfig();
|
||||
// Publish the enabled state through websocket
|
||||
sendObjectMaskState(enabled ? "ON" : "OFF");
|
||||
} else {
|
||||
toast.error(
|
||||
t("toast.save.error.title", {
|
||||
@ -292,6 +300,7 @@ export default function ObjectMaskEditPane({
|
||||
setIsLoading,
|
||||
cameraConfig,
|
||||
t,
|
||||
sendObjectMaskState,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ import { LuExternalLink } from "react-icons/lu";
|
||||
import { useDocDomain } from "@/hooks/use-doc-domain";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import NameAndIdFields from "../input/NameAndIdFields";
|
||||
import { useZoneState } from "@/api/ws";
|
||||
|
||||
type ZoneEditPaneProps = {
|
||||
polygons?: Polygon[];
|
||||
@ -88,6 +89,11 @@ export default function ZoneEditPane({
|
||||
}
|
||||
}, [polygons, activePolygonIndex]);
|
||||
|
||||
const { send: sendZoneState } = useZoneState(
|
||||
polygon?.camera || "",
|
||||
polygon?.name || "",
|
||||
);
|
||||
|
||||
const cameraConfig = useMemo(() => {
|
||||
if (polygon?.camera && config) {
|
||||
return config.cameras[polygon.camera];
|
||||
@ -475,6 +481,8 @@ export default function ZoneEditPane({
|
||||
},
|
||||
);
|
||||
updateConfig();
|
||||
// Publish the enabled state through websocket
|
||||
sendZoneState(enabled ? "ON" : "OFF");
|
||||
} else {
|
||||
toast.error(
|
||||
t("toast.save.error.title", {
|
||||
@ -515,6 +523,7 @@ export default function ZoneEditPane({
|
||||
setIsLoading,
|
||||
cameraConfig,
|
||||
t,
|
||||
sendZoneState,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user