fix typing

This commit is contained in:
Nicolas Mowen 2024-03-04 17:37:19 -07:00
parent 275dfe017e
commit 435aab09be
2 changed files with 14 additions and 19 deletions

View File

@ -9,9 +9,8 @@ import {
} from "react"; } from "react";
import MotionSegment from "./MotionSegment"; import MotionSegment from "./MotionSegment";
import { useEventUtils } from "@/hooks/use-event-utils"; import { useEventUtils } from "@/hooks/use-event-utils";
import { ReviewSegment, ReviewSeverity } from "@/types/review"; import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review";
import ReviewTimeline from "./ReviewTimeline"; import ReviewTimeline from "./ReviewTimeline";
import { MockMotionData } from "@/pages/UIPlayground";
export type MotionReviewTimelineProps = { export type MotionReviewTimelineProps = {
segmentDuration: number; segmentDuration: number;
@ -25,7 +24,7 @@ export type MotionReviewTimelineProps = {
minimapStartTime?: number; minimapStartTime?: number;
minimapEndTime?: number; minimapEndTime?: number;
events: ReviewSegment[]; events: ReviewSegment[];
motion_events: MockMotionData[]; motion_events: MotionData[];
severityType: ReviewSeverity; severityType: ReviewSeverity;
contentRef: RefObject<HTMLDivElement>; contentRef: RefObject<HTMLDivElement>;
onHandlebarDraggingChange?: (isDragging: boolean) => void; onHandlebarDraggingChange?: (isDragging: boolean) => void;

View File

@ -4,7 +4,12 @@ import useSWR from "swr";
import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateConfig } from "@/types/frigateConfig";
import ActivityIndicator from "@/components/indicators/activity-indicator"; import ActivityIndicator from "@/components/indicators/activity-indicator";
import EventReviewTimeline from "@/components/timeline/EventReviewTimeline"; import EventReviewTimeline from "@/components/timeline/EventReviewTimeline";
import { ReviewData, ReviewSegment, ReviewSeverity } from "@/types/review"; import {
MotionData,
ReviewData,
ReviewSegment,
ReviewSeverity,
} from "@/types/review";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import CameraActivityIndicator from "@/components/indicators/CameraActivityIndicator"; import CameraActivityIndicator from "@/components/indicators/CameraActivityIndicator";
import MotionReviewTimeline from "@/components/timeline/MotionReviewTimeline"; import MotionReviewTimeline from "@/components/timeline/MotionReviewTimeline";
@ -53,14 +58,7 @@ function ColorSwatch({ name, value }: { name: string; value: string }) {
); );
} }
export type MockMotionData = { function generateRandomMotionAudioData(): MotionData[] {
start_time: number;
end_time: number;
motionValue: number;
audioValue: number;
};
function generateRandomMotionAudioData(): MockMotionData[] {
const now = new Date(); const now = new Date();
const endTime = now.getTime() / 1000; const endTime = now.getTime() / 1000;
const startTime = endTime - 24 * 60 * 60; // 24 hours ago const startTime = endTime - 24 * 60 * 60; // 24 hours ago
@ -72,14 +70,12 @@ function generateRandomMotionAudioData(): MockMotionData[] {
startTimestamp < endTime; startTimestamp < endTime;
startTimestamp += interval startTimestamp += interval
) { ) {
const endTimestamp = startTimestamp + interval; const motion = Math.floor(Math.random() * 101); // Random number between 0 and 100
const motionValue = Math.floor(Math.random() * 101); // Random number between 0 and 100 const audio = Math.random() * -100; // Random negative value between -100 and 0
const audioValue = Math.random() * -100; // Random negative value between -100 and 0
data.push({ data.push({
start_time: startTimestamp, start_time: startTimestamp,
end_time: endTimestamp, motion,
motionValue, audio,
audioValue,
}); });
} }
@ -126,7 +122,7 @@ function UIPlayground() {
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
const contentRef = useRef<HTMLDivElement>(null); const contentRef = useRef<HTMLDivElement>(null);
const [mockEvents, setMockEvents] = useState<ReviewSegment[]>([]); const [mockEvents, setMockEvents] = useState<ReviewSegment[]>([]);
const [mockMotionData, setMockMotionData] = useState<MockMotionData[]>([]); const [mockMotionData, setMockMotionData] = useState<MotionData[]>([]);
const [handlebarTime, setHandlebarTime] = useState( const [handlebarTime, setHandlebarTime] = useState(
Math.floor(Date.now() / 1000) - 15 * 60, Math.floor(Date.now() / 1000) - 15 * 60,
); );