update mock review event generator

This commit is contained in:
Josh Hawkins 2024-02-20 16:27:39 -06:00
parent 1aa788b759
commit de96206bff
2 changed files with 30 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import ActivityIndicator from "@/components/ui/activity-indicator";
import { useApiHost } from "@/api";
import TimelineScrubber from "@/components/playground/TimelineScrubber";
import EventReviewTimeline from "@/components/timeline/EventReviewTimeline";
import { ReviewSegment } from "@/types/review";
import { ReviewData, ReviewSegment, ReviewSeverity } from "@/types/review";
// Color data
const colors = [
@ -59,14 +59,39 @@ function eventsToScrubberItems(events: Event[]): ScrubberItem[] {
}));
}
const generateRandomEvent = (): Event => {
const generateRandomEvent = (): ReviewSegment => {
const start_time = Math.floor(Date.now() / 1000) - Math.random() * 60 * 60;
const end_time = Math.floor(start_time + Math.random() * 60 * 10);
const severities = ["motion", "detection", "alert"];
const severities: ReviewSeverity[] = [
"significant_motion",
"detection",
"alert",
];
const severity = severities[Math.floor(Math.random() * severities.length)];
const has_been_reviewed = Math.random() < 0.2;
const id = new Date(start_time * 1000).toISOString(); // Date string as mock ID
return { id, start_time, end_time, severity, has_been_reviewed };
// You need to provide values for camera, thumb_path, and data
const camera = "CameraXYZ";
const thumb_path = "/path/to/thumb";
const data: ReviewData = {
audio: [],
detections: [],
objects: [],
significant_motion_areas: [],
zones: [],
};
return {
id,
start_time,
end_time,
severity,
has_been_reviewed,
camera,
thumb_path,
data,
};
};
function UIPlayground() {

View File

@ -11,7 +11,7 @@ export interface ReviewSegment {
export type ReviewSeverity = "alert" | "detection" | "significant_motion";
type ReviewData = {
export type ReviewData = {
audio: string[];
detections: string[];
objects: string[];