mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
frontend button
This commit is contained in:
parent
b431b8a4be
commit
9fe2f2d5bc
@ -27,7 +27,13 @@ import { baseUrl } from "@/api/baseUrl";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import { ASPECT_VERTICAL_LAYOUT, ASPECT_WIDE_LAYOUT } from "@/types/record";
|
import { ASPECT_VERTICAL_LAYOUT, ASPECT_WIDE_LAYOUT } from "@/types/record";
|
||||||
import { FaHistory, FaImage, FaRegListAlt, FaVideo } from "react-icons/fa";
|
import {
|
||||||
|
FaChevronDown,
|
||||||
|
FaHistory,
|
||||||
|
FaImage,
|
||||||
|
FaRegListAlt,
|
||||||
|
FaVideo,
|
||||||
|
} from "react-icons/fa";
|
||||||
import { FaRotate } from "react-icons/fa6";
|
import { FaRotate } from "react-icons/fa6";
|
||||||
import ObjectLifecycle from "./ObjectLifecycle";
|
import ObjectLifecycle from "./ObjectLifecycle";
|
||||||
import {
|
import {
|
||||||
@ -47,6 +53,12 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import Chip from "@/components/indicators/Chip";
|
import Chip from "@/components/indicators/Chip";
|
||||||
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
import { capitalizeFirstLetter } from "@/utils/stringUtil";
|
||||||
import useGlobalMutation from "@/hooks/use-global-mutate";
|
import useGlobalMutation from "@/hooks/use-global-mutate";
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/components/ui/dropdown-menu";
|
||||||
|
|
||||||
const SEARCH_TABS = [
|
const SEARCH_TABS = [
|
||||||
"details",
|
"details",
|
||||||
@ -309,33 +321,36 @@ function ObjectDetailsTab({
|
|||||||
});
|
});
|
||||||
}, [desc, search, mutate]);
|
}, [desc, search, mutate]);
|
||||||
|
|
||||||
const regenerateDescription = useCallback(() => {
|
const regenerateDescription = useCallback(
|
||||||
if (!search) {
|
(source: "snapshot" | "thumbnails") => {
|
||||||
return;
|
if (!search) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.put(`events/${search.id}/description/regenerate`)
|
.put(`events/${search.id}/description/regenerate?source=${source}`)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.status == 200) {
|
if (resp.status == 200) {
|
||||||
toast.success(
|
toast.success(
|
||||||
`A new description has been requested from ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")}. Depending on the speed of your provider, the new description may take some time to regenerate.`,
|
`A new description has been requested from ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")}. Depending on the speed of your provider, the new description may take some time to regenerate.`,
|
||||||
|
{
|
||||||
|
position: "top-center",
|
||||||
|
duration: 7000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
toast.error(
|
||||||
|
`Failed to call ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")} for a new description`,
|
||||||
{
|
{
|
||||||
position: "top-center",
|
position: "top-center",
|
||||||
duration: 7000,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
})
|
},
|
||||||
.catch(() => {
|
[search, config],
|
||||||
toast.error(
|
);
|
||||||
`Failed to call ${capitalizeFirstLetter(config?.genai.provider ?? "Generative AI")} for a new description`,
|
|
||||||
{
|
|
||||||
position: "top-center",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}, [search, config]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
@ -403,7 +418,33 @@ function ObjectDetailsTab({
|
|||||||
/>
|
/>
|
||||||
<div className="flex w-full flex-row justify-end gap-2">
|
<div className="flex w-full flex-row justify-end gap-2">
|
||||||
{config?.genai.enabled && (
|
{config?.genai.enabled && (
|
||||||
<Button onClick={regenerateDescription}>Regenerate</Button>
|
<div className="flex items-center">
|
||||||
|
<Button
|
||||||
|
className="rounded-r-none border-r-0"
|
||||||
|
onClick={() => regenerateDescription("thumbnails")}
|
||||||
|
>
|
||||||
|
Regenerate
|
||||||
|
</Button>
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button className="rounded-l-none border-l-0 px-2">
|
||||||
|
<FaChevronDown className="size-3" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => regenerateDescription("snapshot")}
|
||||||
|
>
|
||||||
|
Regenerate With Snapshot
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => regenerateDescription("thumbnails")}
|
||||||
|
>
|
||||||
|
Regenerate With Thumbnails
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
<Button variant="select" onClick={updateDescription}>
|
<Button variant="select" onClick={updateDescription}>
|
||||||
Save
|
Save
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user