import { FrigateConfig } from "@/types/frigateConfig"; import { GraphDataPoint } from "@/types/graph"; import { formatUnixTimestampToDateTime } from "@/utils/dateUtil"; import useSWR from "swr"; import ActivityIndicator from "../ui/activity-indicator"; type TimelineBarProps = { startTime: number; graphData: | { objects: number[]; motion: GraphDataPoint[]; } | undefined; onClick?: () => void; }; export default function TimelineBar({ startTime, graphData, onClick, }: TimelineBarProps) { const { data: config } = useSWR("config"); if (!config) { return ; } return (
{graphData != undefined && (
{getHourBlocks().map((idx) => { return (
); })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:00" : "%I:00%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:05" : "%I:05%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:10" : "%I:10%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:15" : "%I:15%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:20" : "%I:20%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:25" : "%I:25%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:30" : "%I:30%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:35" : "%I:35%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:40" : "%I:40%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:45" : "%I:45%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:50" : "%I:50%P", time_style: "medium", date_style: "medium", })}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config?.ui.time_format == "24hour" ? "%H:55" : "%I:55%P", time_style: "medium", date_style: "medium", })}
)}
{formatUnixTimestampToDateTime(startTime, { strftime_fmt: config.ui.time_format == "24hour" ? "%m/%d %H:%M" : "%m/%d %I:%M%P", time_style: "medium", date_style: "medium", })}
); } function getHourBlocks() { const arr = []; for (let x = 0; x <= 59; x++) { arr.push(x); } return arr; }