@@ -581,10 +628,12 @@ export default function ObjectLifecycle({
}}
role="button"
>
- {getIconForLabel(
- event.label,
- "size-6 text-primary dark:text-white",
- )}
+
+ {getIconForLabel(
+ event.label,
+ "size-6 text-primary dark:text-white",
+ )}
+
{getTranslatedLabel(event.label)}
@@ -602,147 +651,79 @@ export default function ObjectLifecycle({
{t("detail.noObjectDetailData", { ns: "views/events" })}
) : (
-
- {eventSequence.map((item, idx) => {
- const isActive =
- Math.abs((timeIndex ?? 0) - (item.timestamp ?? 0)) <= 0.5;
- const formattedEventTimestamp = config
- ? formatUnixTimestampToDateTime(item.timestamp ?? 0, {
- timezone: config.ui.timezone,
- date_format:
- config.ui.time_format == "24hour"
- ? t(
- "time.formattedTimestampHourMinuteSecond.24hour",
- { ns: "common" },
- )
- : t(
- "time.formattedTimestampHourMinuteSecond.12hour",
- { ns: "common" },
- ),
- time_style: "medium",
- date_style: "medium",
- })
- : "";
+
+
+
+
+ {eventSequence.map((item, idx) => {
+ const isActive =
+ Math.abs((timeIndex ?? 0) - (item.timestamp ?? 0)) <= 0.5;
+ const formattedEventTimestamp = config
+ ? formatUnixTimestampToDateTime(item.timestamp ?? 0, {
+ timezone: config.ui.timezone,
+ date_format:
+ config.ui.time_format == "24hour"
+ ? t(
+ "time.formattedTimestampHourMinuteSecond.24hour",
+ { ns: "common" },
+ )
+ : t(
+ "time.formattedTimestampHourMinuteSecond.12hour",
+ { ns: "common" },
+ ),
+ time_style: "medium",
+ date_style: "medium",
+ })
+ : "";
- const ratio =
- Array.isArray(item.data.box) && item.data.box.length >= 4
- ? (
- aspectRatio *
- (item.data.box[2] / item.data.box[3])
- ).toFixed(2)
- : "N/A";
- const areaPx =
- Array.isArray(item.data.box) && item.data.box.length >= 4
- ? Math.round(
- (config.cameras[event.camera]?.detect?.width ?? 0) *
- (config.cameras[event.camera]?.detect?.height ??
- 0) *
- (item.data.box[2] * item.data.box[3]),
- )
- : undefined;
- const areaPct =
- Array.isArray(item.data.box) && item.data.box.length >= 4
- ? (item.data.box[2] * item.data.box[3]).toFixed(4)
- : undefined;
+ const ratio =
+ Array.isArray(item.data.box) && item.data.box.length >= 4
+ ? (
+ aspectRatio *
+ (item.data.box[2] / item.data.box[3])
+ ).toFixed(2)
+ : "N/A";
+ const areaPx =
+ Array.isArray(item.data.box) && item.data.box.length >= 4
+ ? Math.round(
+ (config.cameras[event.camera]?.detect?.width ?? 0) *
+ (config.cameras[event.camera]?.detect?.height ??
+ 0) *
+ (item.data.box[2] * item.data.box[3]),
+ )
+ : undefined;
+ const areaPct =
+ Array.isArray(item.data.box) && item.data.box.length >= 4
+ ? (item.data.box[2] * item.data.box[3]).toFixed(4)
+ : undefined;
- return (
-
{
- setTimeIndex(item.timestamp ?? 0);
- handleSetBox(
- item.data.box ?? [],
- item.data.attribute_box,
- );
- setLifecycleZones(item.data.zones);
- setSelectedZone("");
- }}
- className={cn(
- "flex cursor-pointer flex-col gap-1 rounded-md p-2 text-sm text-primary-variant",
- isActive
- ? "bg-secondary-highlight font-semibold text-primary outline-[1.5px] -outline-offset-[1.1px] outline-primary/40 dark:font-normal"
- : "duration-500",
- )}
- >
-
-
-
-
-
-
{getLifecycleItemDescription(item)}
-
- {formattedEventTimestamp}
-
-
-
-
-
-
-
-
- {t(
- "objectLifecycle.lifecycleItemDesc.header.ratio",
- )}
-
-
- {ratio}
-
-
-
-
-
- {t(
- "objectLifecycle.lifecycleItemDesc.header.area",
- )}
-
- {areaPx !== undefined && areaPct !== undefined ? (
-
- px: {areaPx} · %: {areaPct}
-
- ) : (
- N/A
- )}
-
- {item.class_type === "entered_zone" && (
-
-
- {t(
- "objectLifecycle.lifecycleItemDesc.header.zones",
- )}
-
-
- {item.data.zones.map((zone, zidx) => (
-
{
- e.stopPropagation();
- setSelectedZone(zone);
- }}
- >
-
-
- {zone.replaceAll("_", " ")}
-
-
- ))}
-
-
- )}
-
-
-
- );
- })}
+ return (
+
{
+ setTimeIndex(item.timestamp ?? 0);
+ handleSetBox(
+ item.data.box ?? [],
+ item.data.attribute_box,
+ );
+ setLifecycleZones(item.data.zones);
+ setSelectedZone("");
+ }}
+ setSelectedZone={setSelectedZone}
+ getZoneColor={getZoneColor}
+ />
+ );
+ })}
+
)}
@@ -789,3 +770,117 @@ export function LifecycleIcon({
return null;
}
}
+
+type LifecycleIconRowProps = {
+ item: ObjectLifecycleSequence;
+ isActive?: boolean;
+ formattedEventTimestamp: string;
+ ratio: string;
+ areaPx?: number;
+ areaPct?: string;
+ onClick: () => void;
+ setSelectedZone: (z: string) => void;
+ getZoneColor: (zoneName: string) => number[] | undefined;
+};
+
+function LifecycleIconRow({
+ item,
+ isActive,
+ formattedEventTimestamp,
+ ratio,
+ areaPx,
+ areaPct,
+ onClick,
+ setSelectedZone,
+ getZoneColor,
+}: LifecycleIconRowProps) {
+ const { t } = useTranslation(["views/explore"]);
+
+ return (
+
+
+
+
+
+
+
+
+
{getLifecycleItemDescription(item)}
+
+
+
+ {t("objectLifecycle.lifecycleItemDesc.header.ratio")}
+
+ {ratio}
+
+
+
+ {t("objectLifecycle.lifecycleItemDesc.header.area")}
+
+ {areaPx !== undefined && areaPct !== undefined ? (
+
+ {t("information.pixels", { ns: "common", area: areaPx })} ·{" "}
+ {areaPct}%
+
+ ) : (
+ N/A
+ )}
+
+
+ {item.data?.zones && item.data.zones.length > 0 && (
+
+ {item.data.zones.map((zone, zidx) => {
+ const color = getZoneColor(zone)?.join(",") ?? "0,0,0";
+ return (
+ {
+ e.stopPropagation();
+ setSelectedZone(zone);
+ }}
+ style={{
+ borderColor: `rgba(${color}, 0.6)`,
+ background: `rgba(${color}, 0.08)`,
+ }}
+ >
+
+
+ {zone.replaceAll("_", " ")}
+
+
+ );
+ })}
+
+ )}
+
+
+
+
{formattedEventTimestamp}
+
+
+
+ );
+}