mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
Fix calendar selection (#11959)
This commit is contained in:
parent
2934c7817d
commit
b49cda274d
@ -4,6 +4,7 @@ import { useMemo } from "react";
|
||||
import { FaCircle } from "react-icons/fa";
|
||||
import { getUTCOffset } from "@/utils/dateUtil";
|
||||
import { type DayContentProps } from "react-day-picker";
|
||||
import { LAST_24_HOURS_KEY } from "@/types/filter";
|
||||
|
||||
type ReviewActivityCalendarProps = {
|
||||
reviewSummary?: ReviewSummary;
|
||||
@ -32,10 +33,23 @@ export default function ReviewActivityCalendar({
|
||||
const unreviewedAlerts: Date[] = [];
|
||||
|
||||
Object.entries(reviewSummary).forEach(([date, data]) => {
|
||||
if (date == LAST_24_HOURS_KEY) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = date.split("-");
|
||||
const cal = new Date(date);
|
||||
|
||||
cal.setFullYear(
|
||||
parseInt(parts[0]),
|
||||
parseInt(parts[1]) - 1,
|
||||
parseInt(parts[2]),
|
||||
);
|
||||
|
||||
if (data.total_alert > data.reviewed_alert) {
|
||||
unreviewedAlerts.push(new Date(date));
|
||||
unreviewedAlerts.push(cal);
|
||||
} else if (data.total_detection > data.reviewed_detection) {
|
||||
unreviewedDetections.push(new Date(date));
|
||||
unreviewedDetections.push(cal);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -8,3 +8,5 @@ export type FilterList = {
|
||||
labels?: string[];
|
||||
zones?: string[];
|
||||
};
|
||||
|
||||
export const LAST_24_HOURS_KEY = "last24Hours";
|
||||
|
@ -49,7 +49,7 @@ import scrollIntoView from "scroll-into-view-if-needed";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { toast } from "sonner";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { FilterList } from "@/types/filter";
|
||||
import { FilterList, LAST_24_HOURS_KEY } from "@/types/filter";
|
||||
import { GiSoundWaves } from "react-icons/gi";
|
||||
|
||||
type EventViewProps = {
|
||||
@ -96,7 +96,7 @@ export default function EventView({
|
||||
|
||||
let summary;
|
||||
if (filter?.before == undefined) {
|
||||
summary = reviewSummary["last24Hours"];
|
||||
summary = reviewSummary[LAST_24_HOURS_KEY];
|
||||
} else {
|
||||
const day = new Date(filter.before * 1000);
|
||||
const key = `${day.getFullYear()}-${("0" + (day.getMonth() + 1)).slice(-2)}-${("0" + day.getDate()).slice(-2)}`;
|
||||
|
Loading…
Reference in New Issue
Block a user