frigate/web/src/utils/lifecycleUtil.ts
Josh Hawkins f97629433d
Fixes (#18877)
* Object labels with spaces should use correct i18n keys

* Add Hungarian

* Ensure onvif move request has a valid speed before removing

When autotracking zooming is set to `disabled` (or is left out of the config), move_request["Speed"] may not exist, depending on the camera

* Add another frame cache debug log
2025-06-25 16:45:24 -05:00

76 lines
2.2 KiB
TypeScript

import { ObjectLifecycleSequence } from "@/types/timeline";
import { t } from "i18next";
import { getTranslatedLabel } from "./i18n";
export function getLifecycleItemDescription(
lifecycleItem: ObjectLifecycleSequence,
) {
const rawLabel = Array.isArray(lifecycleItem.data.sub_label)
? lifecycleItem.data.sub_label[0]
: lifecycleItem.data.sub_label || lifecycleItem.data.label;
const label = getTranslatedLabel(rawLabel);
switch (lifecycleItem.class_type) {
case "visible":
return t("objectLifecycle.lifecycleItemDesc.visible", {
ns: "views/explore",
label,
});
case "entered_zone":
return t("objectLifecycle.lifecycleItemDesc.entered_zone", {
ns: "views/explore",
label,
zones: lifecycleItem.data.zones.join(" and ").replaceAll("_", " "),
});
case "active":
return t("objectLifecycle.lifecycleItemDesc.active", {
ns: "views/explore",
label,
});
case "stationary":
return t("objectLifecycle.lifecycleItemDesc.stationary", {
ns: "views/explore",
label,
});
case "attribute": {
let title = "";
if (
lifecycleItem.data.attribute == "face" ||
lifecycleItem.data.attribute == "license_plate"
) {
title = t(
"objectLifecycle.lifecycleItemDesc.attribute.faceOrLicense_plate",
{
ns: "views/explore",
label,
attribute: lifecycleItem.data.attribute.replaceAll("_", " "),
},
);
} else {
title = t("objectLifecycle.lifecycleItemDesc.attribute.other", {
ns: "views/explore",
label: lifecycleItem.data.label,
attribute: lifecycleItem.data.attribute.replaceAll("_", " "),
});
}
return title;
}
case "gone":
return t("objectLifecycle.lifecycleItemDesc.gone", {
ns: "views/explore",
label,
});
case "heard":
return t("objectLifecycle.lifecycleItemDesc.heard", {
ns: "views/explore",
label,
});
case "external":
return t("objectLifecycle.lifecycleItemDesc.external", {
ns: "views/explore",
label,
});
}
}