mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-26 15:38:58 +03:00
Add ability to manually run Review Descriptions from the UI / API (#24222)
* Add ability to manually run Review Descriptions from the UI / API * Fix not handling None type for call
This commit is contained in:
@@ -21,7 +21,9 @@ import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||
import { useReviewDescriptions } from "@/hooks/use-review-descriptions";
|
||||
import MultiExportDialog from "../overlay/MultiExportDialog";
|
||||
import { MdAutoAwesome } from "react-icons/md";
|
||||
|
||||
type ReviewActionGroupProps = {
|
||||
selectedReviews: ReviewSegment[];
|
||||
@@ -45,6 +47,13 @@ export default function ReviewActionGroup({
|
||||
(review) => review.has_been_reviewed,
|
||||
);
|
||||
|
||||
const { canGenerateDescription, generateDescription } =
|
||||
useReviewDescriptions();
|
||||
|
||||
// only a single item can be sent through the descriptions process at a time
|
||||
const showGenerateDescription =
|
||||
selectedReviews.length == 1 && canGenerateDescription(selectedReviews[0]);
|
||||
|
||||
const onToggleReviewed = useCallback(async () => {
|
||||
const ids = selectedReviews.map((review) => review.id);
|
||||
await axios.post(`reviews/viewed`, {
|
||||
@@ -166,6 +175,24 @@ export default function ReviewActionGroup({
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
{showGenerateDescription && (
|
||||
<Button
|
||||
className="flex items-center gap-2 p-2"
|
||||
aria-label={t("recording.button.generateDescription")}
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
generateDescription(selectedReviews[0]);
|
||||
onClearSelected();
|
||||
}}
|
||||
>
|
||||
<MdAutoAwesome className="text-secondary-foreground" />
|
||||
{isDesktop && (
|
||||
<div className="text-primary">
|
||||
{t("recording.button.generateDescription")}
|
||||
</div>
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
{selectedReviews.length >= 2 &&
|
||||
selectedReviews.length <= MAX_BATCH_EXPORT_ITEMS && (
|
||||
<MultiExportDialog
|
||||
|
||||
Reference in New Issue
Block a user