change submit to plus to use a question with yes/no

This commit is contained in:
Josh Hawkins 2025-04-17 08:08:20 -05:00 committed by Nicolas Mowen
parent c7e9b72949
commit c0ce0c1587
2 changed files with 65 additions and 44 deletions

View File

@ -15,15 +15,11 @@
"desc": "Objects in locations you want to avoid are not false positives. Submitting them as false positives will confuse the model." "desc": "Objects in locations you want to avoid are not false positives. Submitting them as false positives will confuse the model."
}, },
"review": { "review": {
"true": { "question": {
"label": "Confirm this label for Frigate Plus", "label": "Confirm this label for Frigate Plus",
"true_one": "This is a {{label}}", "ask_a": "Is this object a <code>{{label}}</code>?",
"true_other": "This is an {{label}}" "ask_an": "Is this object an <code>{{label}}</code>?",
}, "ask_full": "Is this object a <code>{{untranslatedLabel}}</code> ({{translatedLabel}})?"
"false": {
"label": "Do not confirm this label for Frigate Plus",
"false_one": "This is not a {{label}}",
"false_other": "This is not an {{label}}"
}, },
"state": { "state": {
"submitted": "Submitted" "submitted": "Submitted"

View File

@ -73,7 +73,7 @@ import { LuInfo, LuSearch } from "react-icons/lu";
import { TooltipPortal } from "@radix-ui/react-tooltip"; import { TooltipPortal } from "@radix-ui/react-tooltip";
import { FaPencilAlt } from "react-icons/fa"; import { FaPencilAlt } from "react-icons/fa";
import TextEntryDialog from "@/components/overlay/dialog/TextEntryDialog"; import TextEntryDialog from "@/components/overlay/dialog/TextEntryDialog";
import { useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { TbFaceId } from "react-icons/tb"; import { TbFaceId } from "react-icons/tb";
import { useIsAdmin } from "@/hooks/use-is-admin"; import { useIsAdmin } from "@/hooks/use-is-admin";
import FaceSelectionDialog from "../FaceSelectionDialog"; import FaceSelectionDialog from "../FaceSelectionDialog";
@ -1017,7 +1017,7 @@ export function ObjectSnapshotTab({
search, search,
onEventUploaded, onEventUploaded,
}: ObjectSnapshotTabProps) { }: ObjectSnapshotTabProps) {
const { t } = useTranslation(["components/dialog"]); const { t, i18n } = useTranslation(["components/dialog"]);
type SubmissionState = "reviewing" | "uploading" | "submitted"; type SubmissionState = "reviewing" | "uploading" | "submitted";
const [imgRef, imgLoaded, onImgLoad] = useImageLoaded(); const [imgRef, imgLoaded, onImgLoad] = useImageLoaded();
@ -1128,42 +1128,67 @@ export function ObjectSnapshotTab({
</div> </div>
</div> </div>
<div className="flex flex-row justify-center gap-2 md:justify-end"> <div className="flex w-full flex-1 flex-col justify-center gap-2 md:ml-8 md:w-auto md:justify-end">
{state == "reviewing" && ( {state == "reviewing" && (
<> <>
<Button <div>
className="bg-success" {i18n.language === "en" ? (
aria-label={t("explore.plus.review.true.label")} // English with a/an logic plus label
onClick={() => { <>
setState("uploading"); {/^[aeiou]/i.test(search?.label || "") ? (
onSubmitToPlus(false); <Trans
}} ns="components/dialog"
> values={{ label: search?.label }}
{/^[aeiou]/i.test(search?.label || "") >
? t("explore.plus.review.true.true_other", { explore.plus.review.question.ask_an
label: search?.label, </Trans>
}) ) : (
: t("explore.plus.review.true.true_one", { <Trans
label: search?.label, ns="components/dialog"
})} values={{ label: search?.label }}
</Button> >
<Button explore.plus.review.question.ask_a
className="text-white" </Trans>
aria-label={t("explore.plus.review.false.label")} )}
variant="destructive" </>
onClick={() => { ) : (
setState("uploading"); // For other languages
onSubmitToPlus(true); <Trans
}} ns="components/dialog"
> values={{
{/^[aeiou]/i.test(search?.label || "") untranslatedLabel: search?.label,
? t("explore.plus.review.false.false_other", { translatedLabel: t(
label: search?.label, "filter.label." + search?.label,
}) ),
: t("explore.plus.review.false.false_one", { }}
label: search?.label, >
})} explore.plus.review.question.ask_full
</Button> </Trans>
)}
</div>
<div className="flex w-full flex-row gap-2">
<Button
className="flex-1 bg-success"
aria-label={t("button.yes", { ns: "common" })}
onClick={() => {
setState("uploading");
onSubmitToPlus(false);
}}
>
{t("button.yes", { ns: "common" })}
</Button>
<Button
className="flex-1 text-white"
aria-label={t("button.no", { ns: "common" })}
variant="destructive"
onClick={() => {
setState("uploading");
onSubmitToPlus(true);
}}
>
{t("button.no", { ns: "common" })}
</Button>
</div>
</> </>
)} )}
{state == "uploading" && <ActivityIndicator />} {state == "uploading" && <ActivityIndicator />}