mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-03 06:50:58 +00:00
refactor: add friendly zone names to timeline entries and clean up unused code
This commit is contained in:
parent
06e2fc0aa0
commit
91b267a2b6
@ -131,6 +131,19 @@ class TimelineProcessor(threading.Thread):
|
|||||||
):
|
):
|
||||||
timeline_entry[Timeline.class_type] = "entered_zone"
|
timeline_entry[Timeline.class_type] = "entered_zone"
|
||||||
timeline_entry[Timeline.data]["zones"] = event_data["current_zones"]
|
timeline_entry[Timeline.data]["zones"] = event_data["current_zones"]
|
||||||
|
|
||||||
|
zones_friendly = []
|
||||||
|
for z in event_data["current_zones"]:
|
||||||
|
zone_cfg = camera_config.zones.get(z)
|
||||||
|
if zone_cfg is not None and getattr(
|
||||||
|
zone_cfg, "friendly_name", None
|
||||||
|
):
|
||||||
|
zones_friendly.append(zone_cfg.friendly_name)
|
||||||
|
else:
|
||||||
|
zones_friendly.append(z)
|
||||||
|
|
||||||
|
timeline_entry[Timeline.data]["zones_friendly_names"] = zones_friendly
|
||||||
|
|
||||||
save = True
|
save = True
|
||||||
elif prev_event_data["stationary"] != event_data["stationary"]:
|
elif prev_event_data["stationary"] != event_data["stationary"]:
|
||||||
timeline_entry[Timeline.class_type] = (
|
timeline_entry[Timeline.class_type] = (
|
||||||
|
|||||||
@ -8,9 +8,6 @@ import {
|
|||||||
import { TooltipPortal } from "@radix-ui/react-tooltip";
|
import { TooltipPortal } from "@radix-ui/react-tooltip";
|
||||||
import { getLifecycleItemDescription } from "@/utils/lifecycleUtil";
|
import { getLifecycleItemDescription } from "@/utils/lifecycleUtil";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { resolveZoneName } from "@/hooks/use-zone-friendly-name";
|
|
||||||
import { FrigateConfig } from "@/types/frigateConfig";
|
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
type ObjectPathProps = {
|
type ObjectPathProps = {
|
||||||
positions?: Position[];
|
positions?: Position[];
|
||||||
@ -45,30 +42,16 @@ export function ObjectPath({
|
|||||||
visible = true,
|
visible = true,
|
||||||
}: ObjectPathProps) {
|
}: ObjectPathProps) {
|
||||||
const { t } = useTranslation(["views/explore"]);
|
const { t } = useTranslation(["views/explore"]);
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
|
||||||
const getAbsolutePositions = useCallback(() => {
|
const getAbsolutePositions = useCallback(() => {
|
||||||
if (!imgRef.current || !positions) return [];
|
if (!imgRef.current || !positions) return [];
|
||||||
const imgRect = imgRef.current.getBoundingClientRect();
|
const imgRect = imgRef.current.getBoundingClientRect();
|
||||||
return positions.map((pos) => {
|
return positions.map((pos) => ({
|
||||||
if (config && pos.lifecycle_item?.data?.zones) {
|
x: pos.x * imgRect.width,
|
||||||
pos.lifecycle_item = {
|
y: pos.y * imgRect.height,
|
||||||
...pos.lifecycle_item,
|
timestamp: pos.timestamp,
|
||||||
data: {
|
lifecycle_item: pos.lifecycle_item,
|
||||||
...pos.lifecycle_item.data,
|
}));
|
||||||
zones_friendly_names: pos.lifecycle_item.data.zones.map((zone) => {
|
}, [positions, imgRef]);
|
||||||
return resolveZoneName(config, zone);
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
x: pos.x * imgRect.width,
|
|
||||||
y: pos.y * imgRect.height,
|
|
||||||
timestamp: pos.timestamp,
|
|
||||||
lifecycle_item: pos.lifecycle_item,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}, [imgRef, positions, config]);
|
|
||||||
|
|
||||||
const generateStraightPath = useCallback((points: Position[]) => {
|
const generateStraightPath = useCallback((points: Position[]) => {
|
||||||
if (!points || points.length < 2) return "";
|
if (!points || points.length < 2) return "";
|
||||||
|
|||||||
@ -269,6 +269,10 @@ export function PolygonCanvas({
|
|||||||
const updatedPolygons = [...polygons];
|
const updatedPolygons = [...polygons];
|
||||||
const activePolygon = updatedPolygons[activePolygonIndex];
|
const activePolygon = updatedPolygons[activePolygonIndex];
|
||||||
|
|
||||||
|
if (!activePolygon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// add default points order for already completed polygons
|
// add default points order for already completed polygons
|
||||||
if (!activePolygon.pointsOrder && activePolygon.isFinished) {
|
if (!activePolygon.pointsOrder && activePolygon.isFinished) {
|
||||||
updatedPolygons[activePolygonIndex] = {
|
updatedPolygons[activePolygonIndex] = {
|
||||||
|
|||||||
@ -31,7 +31,6 @@ import { Link } from "react-router-dom";
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { usePersistence } from "@/hooks/use-persistence";
|
import { usePersistence } from "@/hooks/use-persistence";
|
||||||
import { isDesktop } from "react-device-detect";
|
import { isDesktop } from "react-device-detect";
|
||||||
import { resolveZoneName } from "@/hooks/use-zone-friendly-name";
|
|
||||||
|
|
||||||
type DetailStreamProps = {
|
type DetailStreamProps = {
|
||||||
reviewItems?: ReviewSegment[];
|
reviewItems?: ReviewSegment[];
|
||||||
@ -655,16 +654,6 @@ function LifecycleItem({
|
|||||||
const { t } = useTranslation("views/events");
|
const { t } = useTranslation("views/events");
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
|
||||||
item = {
|
|
||||||
...item,
|
|
||||||
data: {
|
|
||||||
...item.data,
|
|
||||||
zones_friendly_names: item?.data?.zones?.map((zone) => {
|
|
||||||
return resolveZoneName(config, zone);
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const aspectRatio = useMemo(() => {
|
const aspectRatio = useMemo(() => {
|
||||||
if (!config || !item?.camera) {
|
if (!config || !item?.camera) {
|
||||||
return 16 / 9;
|
return 16 / 9;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user