From ce7191fa18efdfd36d55378c0f3483fafebe9012 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 9 Apr 2024 09:27:51 -0500 Subject: [PATCH] clean up --- web/src/components/settings/MotionTuner.tsx | 80 ++++++++++----------- web/src/hooks/use-double-click.ts | 50 ------------- web/vite.config.ts | 12 ++-- 3 files changed, 46 insertions(+), 96 deletions(-) delete mode 100644 web/src/hooks/use-double-click.ts diff --git a/web/src/components/settings/MotionTuner.tsx b/web/src/components/settings/MotionTuner.tsx index aa0e3c6c5..70efbe883 100644 --- a/web/src/components/settings/MotionTuner.tsx +++ b/web/src/components/settings/MotionTuner.tsx @@ -16,6 +16,7 @@ import { useCallback, useMemo, useState } from "react"; import { Slider } from "@/components/ui/slider"; import { Label } from "@/components/ui/label"; import { useMotionContourArea, useMotionThreshold } from "@/api/ws"; +import { Skeleton } from "../ui/skeleton"; export default function MotionTuner() { const { data: config } = useSWR("config"); @@ -55,7 +56,6 @@ export default function MotionTuner() { if (cameraConfig && threshold != motionThreshold) { cameraConfig.motion.threshold = threshold; sendMotionThreshold(threshold); - console.log("setting motion threshold", threshold); } }, [cameraConfig, motionThreshold, sendMotionThreshold], @@ -66,7 +66,6 @@ export default function MotionTuner() { if (cameraConfig && contour_area != motionContourArea) { cameraConfig.motion.contour_area = contour_area; sendMotionContourArea(contour_area); - console.log("setting motion contour area", contour_area); } }, [cameraConfig, motionContourArea, sendMotionContourArea], @@ -76,11 +75,6 @@ export default function MotionTuner() { return ; } - // console.log("selected camera", selectedCamera); - // console.log("threshold", motionThreshold); - // console.log("contour area", motionContourArea); - // console.log(cameraConfig); - return ( <> Motion Detection Tuner @@ -105,41 +99,47 @@ export default function MotionTuner() { - -
-
- setMotionThreshold(value[0])} + {cameraConfig ? ( +
+ - +
+
+ setMotionThreshold(value[0])} + /> + +
+
+ setMotionContourArea(value[0])} + /> + +
+
-
- setMotionContourArea(value[0])} - /> - -
-
+ ) : ( + + )} ); } diff --git a/web/src/hooks/use-double-click.ts b/web/src/hooks/use-double-click.ts deleted file mode 100644 index db3048f20..000000000 --- a/web/src/hooks/use-double-click.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { useEffect, MutableRefObject } from "react"; - -/** - * A simple React hook for differentiating single and double clicks on the same component. - * - * @param ref Dom node to watch for double clicks - * @param latency The amount of time (in milliseconds) to wait before differentiating a single from a double click - * @param onSingleClick A callback function for single click events - * @param onDoubleClick A callback function for double click events - */ -const useDoubleClick = ({ - ref, - latency = 300, - onSingleClick = () => null, - onDoubleClick = () => null, -}: { - ref: MutableRefObject; - latency?: number; - onSingleClick?: (e: MouseEvent) => void; - onDoubleClick?: (e: MouseEvent) => void; -}) => { - useEffect(() => { - const clickRef = ref.current; - let clickCount = 0; - const handleClick = (e: MouseEvent) => { - clickCount += 1; - - setTimeout(() => { - if (clickCount === 1) onSingleClick(e); - else if (clickCount === 2) onDoubleClick(e); - - clickCount = 0; - }, latency); - }; - - // Add event listener for click events - if (clickRef) { - clickRef.addEventListener("click", handleClick); - } - - // Remove event listener - return () => { - if (clickRef) { - clickRef.removeEventListener("click", handleClick); - } - }; - }, [ref, latency, onSingleClick, onDoubleClick]); -}; - -export default useDoubleClick; diff --git a/web/vite.config.ts b/web/vite.config.ts index b914f76c9..5afefa331 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -12,24 +12,24 @@ export default defineConfig({ server: { proxy: { "/api": { - target: "http://192.168.5.4:5000", + target: "http://localhost:5000", ws: true, }, "/vod": { - target: "http://192.168.5.4:5000", + target: "http://localhost:5000", }, "/clips": { - target: "http://192.168.5.4:5000", + target: "http://localhost:5000", }, "/exports": { - target: "http://192.168.5.4:5000", + target: "http://localhost:5000", }, "/ws": { - target: "ws://192.168.5.4:5000", + target: "ws://localhost:5000", ws: true, }, "/live": { - target: "ws://192.168.5.4:5000", + target: "ws://localhost:5000", changeOrigin: true, ws: true, },