mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 02:40:44 -06:00
UI fixes (#11596)
* Fix using undefined search params * Fix calendar selection * Simplify
This commit is contained in:
parent
f7c3ddd380
commit
4236580672
@ -69,7 +69,7 @@ export default function AutoUpdatingCameraImage({
|
|||||||
<CameraImage
|
<CameraImage
|
||||||
camera={camera}
|
camera={camera}
|
||||||
onload={handleLoad}
|
onload={handleLoad}
|
||||||
searchParams={`cache=${key}&${searchParams}`}
|
searchParams={`cache=${key}${searchParams && `&${searchParams}`}`}
|
||||||
className={cameraClasses}
|
className={cameraClasses}
|
||||||
/>
|
/>
|
||||||
{showFps ? <span className="text-xs">Displaying at {fps}fps</span> : null}
|
{showFps ? <span className="text-xs">Displaying at {fps}fps</span> : null}
|
||||||
|
@ -3,6 +3,7 @@ import { Calendar } from "../ui/calendar";
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { FaCircle } from "react-icons/fa";
|
import { FaCircle } from "react-icons/fa";
|
||||||
import { getUTCOffset } from "@/utils/dateUtil";
|
import { getUTCOffset } from "@/utils/dateUtil";
|
||||||
|
import { type DayContentProps } from "react-day-picker";
|
||||||
|
|
||||||
type ReviewActivityCalendarProps = {
|
type ReviewActivityCalendarProps = {
|
||||||
reviewSummary?: ReviewSummary;
|
reviewSummary?: ReviewSummary;
|
||||||
@ -22,6 +23,28 @@ export default function ReviewActivityCalendar({
|
|||||||
return { from: tomorrow, to: future };
|
return { from: tomorrow, to: future };
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const modifiers = useMemo(() => {
|
||||||
|
if (!reviewSummary) {
|
||||||
|
return { alerts: [], detections: [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
const unreviewedDetections: Date[] = [];
|
||||||
|
const unreviewedAlerts: Date[] = [];
|
||||||
|
|
||||||
|
Object.entries(reviewSummary).forEach(([date, data]) => {
|
||||||
|
if (data.total_alert > data.reviewed_alert) {
|
||||||
|
unreviewedAlerts.push(new Date(date));
|
||||||
|
} else if (data.total_detection > data.reviewed_detection) {
|
||||||
|
unreviewedDetections.push(new Date(date));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
alerts: unreviewedAlerts,
|
||||||
|
detections: unreviewedDetections,
|
||||||
|
};
|
||||||
|
}, [reviewSummary]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Calendar
|
<Calendar
|
||||||
mode="single"
|
mode="single"
|
||||||
@ -29,46 +52,28 @@ export default function ReviewActivityCalendar({
|
|||||||
showOutsideDays={false}
|
showOutsideDays={false}
|
||||||
selected={selectedDay}
|
selected={selectedDay}
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
|
modifiers={modifiers}
|
||||||
components={{
|
components={{
|
||||||
DayContent: (date) => (
|
DayContent: ReviewActivityDay,
|
||||||
<ReviewActivityDay reviewSummary={reviewSummary} day={date.date} />
|
|
||||||
),
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReviewActivityDayProps = {
|
function ReviewActivityDay({ date, activeModifiers }: DayContentProps) {
|
||||||
reviewSummary?: ReviewSummary;
|
|
||||||
day: Date;
|
|
||||||
};
|
|
||||||
function ReviewActivityDay({ reviewSummary, day }: ReviewActivityDayProps) {
|
|
||||||
const dayActivity = useMemo(() => {
|
const dayActivity = useMemo(() => {
|
||||||
if (!reviewSummary) {
|
if (activeModifiers["alerts"]) {
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
const allActivity =
|
|
||||||
reviewSummary[
|
|
||||||
`${day.getFullYear()}-${("0" + (day.getMonth() + 1)).slice(-2)}-${("0" + day.getDate()).slice(-2)}`
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!allActivity) {
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allActivity.total_alert > allActivity.reviewed_alert) {
|
|
||||||
return "alert";
|
return "alert";
|
||||||
} else if (allActivity.total_detection > allActivity.reviewed_detection) {
|
} else if (activeModifiers["detections"]) {
|
||||||
return "detection";
|
return "detection";
|
||||||
} else {
|
} else {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
}, [reviewSummary, day]);
|
}, [activeModifiers]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center gap-0.5">
|
||||||
{day.getDate()}
|
{date.getDate()}
|
||||||
{dayActivity != "none" && (
|
{dayActivity != "none" && (
|
||||||
<FaCircle
|
<FaCircle
|
||||||
className={`size-2 ${dayActivity == "alert" ? "fill-severity_alert" : "fill-severity_detection"}`}
|
className={`size-2 ${dayActivity == "alert" ? "fill-severity_alert" : "fill-severity_detection"}`}
|
||||||
|
Loading…
Reference in New Issue
Block a user