From 2a8a1a1b1b746602f5de3ec71ff63e538f358aa5 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 22 Oct 2024 08:12:41 -0500 Subject: [PATCH] actions component in search footer thumbnail --- .../components/card/SearchThumbnailFooter.tsx | 219 +++--------------- 1 file changed, 26 insertions(+), 193 deletions(-) diff --git a/web/src/components/card/SearchThumbnailFooter.tsx b/web/src/components/card/SearchThumbnailFooter.tsx index b21361b18..8c4fb82b5 100644 --- a/web/src/components/card/SearchThumbnailFooter.tsx +++ b/web/src/components/card/SearchThumbnailFooter.tsx @@ -1,38 +1,10 @@ -import { useCallback, useState } from "react"; import TimeAgo from "../dynamic/TimeAgo"; import useSWR from "swr"; import { FrigateConfig } from "@/types/frigateConfig"; import { useFormattedTimestamp } from "@/hooks/use-date-utils"; -import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; -import ActivityIndicator from "../indicators/activity-indicator"; import { SearchResult } from "@/types/search"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "../ui/alert-dialog"; -import { LuCamera, LuDownload, LuMoreVertical, LuTrash2 } from "react-icons/lu"; -import FrigatePlusIcon from "@/components/icons/FrigatePlusIcon"; -import { FrigatePlusDialog } from "../overlay/dialog/FrigatePlusDialog"; -import { Event } from "@/types/event"; -import { FaArrowsRotate } from "react-icons/fa6"; -import { baseUrl } from "@/api/baseUrl"; -import axios from "axios"; -import { toast } from "sonner"; -import { MdImageSearch } from "react-icons/md"; -import { isMobileOnly } from "react-device-detect"; -import { buttonVariants } from "../ui/button"; +import ActivityIndicator from "../indicators/activity-indicator"; +import SearchResultActions from "../menu/SearchResultActions"; import { cn } from "@/lib/utils"; type SearchThumbnailProps = { @@ -52,31 +24,7 @@ export default function SearchThumbnailFooter({ }: SearchThumbnailProps) { const { data: config } = useSWR("config"); - // interactions - - const [showFrigatePlus, setShowFrigatePlus] = useState(false); - const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); - - const handleDelete = useCallback(() => { - axios - .delete(`events/${searchResult.id}`) - .then((resp) => { - if (resp.status == 200) { - toast.success("Tracked object deleted successfully.", { - position: "top-center", - }); - refreshResults(); - } - }) - .catch(() => { - toast.error("Failed to delete tracked object.", { - position: "top-center", - }); - }); - }, [searchResult, refreshResults]); - // date - const formattedDate = useFormattedTimestamp( searchResult.start_time, config?.ui.time_format == "24hour" ? "%b %-d, %H:%M" : "%b %-d, %I:%M %p", @@ -84,146 +32,31 @@ export default function SearchThumbnailFooter({ ); return ( - <> - setDeleteDialogOpen(!deleteDialogOpen)} - > - - - Confirm Delete - - - Are you sure you want to delete this tracked object? - - - Cancel - - Delete - - - - - setShowFrigatePlus(false)} - onEventUploaded={() => { - searchResult.plus_id = "submitted"; - }} - /> - -
4 && - "items-start sm:flex-col sm:gap-2 lg:flex-row lg:items-center lg:gap-1", +
4 && + "items-start sm:flex-col sm:gap-2 lg:flex-row lg:items-center lg:gap-1", + )} + > +
+ {searchResult.end_time ? ( + + ) : ( +
+ +
)} - > -
- {searchResult.end_time ? ( - - ) : ( -
- -
- )} - {formattedDate} -
-
- {!isMobileOnly && - config?.plus?.enabled && - searchResult.has_snapshot && - searchResult.end_time && - !searchResult.plus_id && ( - - - setShowFrigatePlus(true)} - /> - - Submit to Frigate+ - - )} - - {config?.semantic_search?.enabled && ( - - - - - Find similar - - )} - - - - - - - {searchResult.has_clip && ( - - - - Download video - - - )} - {searchResult.has_snapshot && ( - - - - Download snapshot - - - )} - - - View object lifecycle - - - {isMobileOnly && - config?.plus?.enabled && - searchResult.has_snapshot && - searchResult.end_time && - !searchResult.plus_id && ( - setShowFrigatePlus(true)} - > - - Submit to Frigate+ - - )} - setDeleteDialogOpen(true)} - > - - Delete - - - -
+ {formattedDate}
- +
+ +
+
); }