mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-18 02:56:44 +03:00
Clean up design of classification card
This commit is contained in:
parent
cb9dd09929
commit
72896f4631
@ -41,8 +41,8 @@
|
|||||||
"invalidName": "Invalid name. Names can only include letters, numbers, spaces, apostrophes, underscores, and hyphens."
|
"invalidName": "Invalid name. Names can only include letters, numbers, spaces, apostrophes, underscores, and hyphens."
|
||||||
},
|
},
|
||||||
"train": {
|
"train": {
|
||||||
"title": "Train",
|
"title": "Recent Classifications",
|
||||||
"aria": "Select Train"
|
"aria": "Select Recent Classifications"
|
||||||
},
|
},
|
||||||
"categories": "Classes",
|
"categories": "Classes",
|
||||||
"createCategory": {
|
"createCategory": {
|
||||||
|
|||||||
@ -72,59 +72,58 @@ export function ClassificationCard({
|
|||||||
}, [showArea, imageLoaded]);
|
}, [showArea, imageLoaded]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
<div
|
className={cn(
|
||||||
|
"relative flex size-48 cursor-pointer flex-col overflow-hidden rounded-lg outline outline-[3px]",
|
||||||
|
selected
|
||||||
|
? "shadow-selected outline-selected"
|
||||||
|
: "outline-transparent duration-500",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
ref={imgRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative flex cursor-pointer flex-col rounded-lg outline outline-[3px]",
|
"absolute bottom-0 left-0 right-0 top-0 size-full",
|
||||||
className,
|
imgClassName,
|
||||||
selected
|
isMobile && "w-full",
|
||||||
? "shadow-selected outline-selected"
|
|
||||||
: "outline-transparent duration-500",
|
|
||||||
)}
|
)}
|
||||||
>
|
onLoad={() => setImageLoaded(true)}
|
||||||
<div className="relative w-full select-none overflow-hidden rounded-lg">
|
src={`${baseUrl}${data.filepath}`}
|
||||||
<img
|
onClick={(e) => {
|
||||||
ref={imgRef}
|
e.stopPropagation();
|
||||||
onLoad={() => setImageLoaded(true)}
|
onClick(data, e.metaKey || e.ctrlKey);
|
||||||
className={cn("size-44", imgClassName, isMobile && "w-full")}
|
}}
|
||||||
src={`${baseUrl}${data.filepath}`}
|
/>
|
||||||
onClick={(e) => {
|
{false && imageArea != undefined && (
|
||||||
e.stopPropagation();
|
<div className="absolute bottom-1 right-1 z-10 rounded-lg bg-black/50 px-2 py-1 text-xs text-white">
|
||||||
onClick(data, e.metaKey || e.ctrlKey);
|
{t("information.pixels", { ns: "common", area: imageArea })}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{imageArea != undefined && (
|
|
||||||
<div className="absolute bottom-1 right-1 z-10 rounded-lg bg-black/50 px-2 py-1 text-xs text-white">
|
|
||||||
{t("information.pixels", { ns: "common", area: imageArea })}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="select-none p-2">
|
)}
|
||||||
<div className="flex w-full flex-row items-center justify-between gap-2">
|
<div className="absolute bottom-0 left-0 right-0 flex h-12 select-none gap-2 bg-gradient-to-t from-black/60 to-transparent p-2">
|
||||||
<div className="flex flex-col items-start text-xs text-primary-variant">
|
<div className="flex w-full flex-row items-center justify-between gap-2">
|
||||||
<div className="smart-capitalize">
|
<div className="text-xs flex flex-col items-start text-white">
|
||||||
{data.name == "unknown" ? t("details.unknown") : data.name}
|
<div className="smart-capitalize">
|
||||||
|
{data.name == "unknown" ? t("details.unknown") : data.name}
|
||||||
|
</div>
|
||||||
|
{data.score && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"",
|
||||||
|
scoreStatus == "match" && "text-success",
|
||||||
|
scoreStatus == "potential" && "text-orange-400",
|
||||||
|
scoreStatus == "unknown" && "text-danger",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{Math.round(data.score * 100)}%
|
||||||
</div>
|
</div>
|
||||||
{data.score && (
|
)}
|
||||||
<div
|
</div>
|
||||||
className={cn(
|
<div className="flex flex-row items-start justify-end gap-5 md:gap-4">
|
||||||
"",
|
{children}
|
||||||
scoreStatus == "match" && "text-success",
|
|
||||||
scoreStatus == "potential" && "text-orange-400",
|
|
||||||
scoreStatus == "unknown" && "text-danger",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{Math.round(data.score * 100)}%
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row items-start justify-end gap-5 md:gap-4">
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,15 +20,14 @@ import {
|
|||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from "@/components/ui/tooltip";
|
||||||
import { isDesktop, isMobile } from "react-device-detect";
|
import { isDesktop, isMobile } from "react-device-detect";
|
||||||
import { LuPlus } from "react-icons/lu";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import React, { ReactNode, useCallback, useMemo, useState } from "react";
|
import React, { ReactNode, useCallback, useMemo, useState } from "react";
|
||||||
import TextEntryDialog from "./dialog/TextEntryDialog";
|
import TextEntryDialog from "./dialog/TextEntryDialog";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { MdCategory } from "react-icons/md";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { Separator } from "../ui/separator";
|
||||||
|
|
||||||
type ClassificationSelectionDialogProps = {
|
type ClassificationSelectionDialogProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -97,7 +96,7 @@ export default function ClassificationSelectionDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className ?? ""}>
|
<div className={className ?? "flex"}>
|
||||||
{newClass && (
|
{newClass && (
|
||||||
<TextEntryDialog
|
<TextEntryDialog
|
||||||
open={true}
|
open={true}
|
||||||
@ -128,23 +127,22 @@ export default function ClassificationSelectionDialog({
|
|||||||
isMobile && "gap-2 pb-4",
|
isMobile && "gap-2 pb-4",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<SelectorItem
|
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
|
||||||
onClick={() => setNewClass(true)}
|
|
||||||
>
|
|
||||||
<LuPlus />
|
|
||||||
{t("createCategory.new")}
|
|
||||||
</SelectorItem>
|
|
||||||
{classes.sort().map((category) => (
|
{classes.sort().map((category) => (
|
||||||
<SelectorItem
|
<SelectorItem
|
||||||
key={category}
|
key={category}
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
onClick={() => onCategorizeImage(category)}
|
onClick={() => onCategorizeImage(category)}
|
||||||
>
|
>
|
||||||
<MdCategory />
|
|
||||||
{category.replaceAll("_", " ")}
|
{category.replaceAll("_", " ")}
|
||||||
</SelectorItem>
|
</SelectorItem>
|
||||||
))}
|
))}
|
||||||
|
<Separator />
|
||||||
|
<SelectorItem
|
||||||
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
|
onClick={() => setNewClass(true)}
|
||||||
|
>
|
||||||
|
{t("createCategory.new")}
|
||||||
|
</SelectorItem>
|
||||||
</div>
|
</div>
|
||||||
</SelectorContent>
|
</SelectorContent>
|
||||||
</Selector>
|
</Selector>
|
||||||
|
|||||||
@ -60,7 +60,7 @@ export default function TrainFilterDialog({
|
|||||||
moreFiltersSelected ? "text-white" : "text-secondary-foreground",
|
moreFiltersSelected ? "text-white" : "text-secondary-foreground",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{isDesktop && t("more")}
|
{isDesktop && t("filter")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
const content = (
|
const content = (
|
||||||
@ -122,7 +122,7 @@ export default function TrainFilterDialog({
|
|||||||
return (
|
return (
|
||||||
<PlatformAwareSheet
|
<PlatformAwareSheet
|
||||||
trigger={trigger}
|
trigger={trigger}
|
||||||
title={t("more")}
|
title={t("filter")}
|
||||||
content={content}
|
content={content}
|
||||||
contentClassName={cn(
|
contentClassName={cn(
|
||||||
"w-auto lg:min-w-[275px] scrollbar-container h-full overflow-auto px-4",
|
"w-auto lg:min-w-[275px] scrollbar-container h-full overflow-auto px-4",
|
||||||
|
|||||||
@ -650,7 +650,7 @@ function DatasetGrid({
|
|||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<LuTrash2
|
<LuTrash2
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
className="size-5 cursor-pointer text-primary-variant hover:text-danger"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onDelete([image]);
|
onDelete([image]);
|
||||||
@ -817,22 +817,8 @@ function StateTrainGrid({
|
|||||||
image={data.filename}
|
image={data.filename}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
>
|
>
|
||||||
<TbCategoryPlus className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
<TbCategoryPlus className="size-7 cursor-pointer p-1 text-white hover:rounded-full hover:bg-primary-foreground" />
|
||||||
</ClassificationSelectionDialog>
|
</ClassificationSelectionDialog>
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger>
|
|
||||||
<LuTrash2
|
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onDelete([data.filename]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
{t("button.deleteClassificationAttempts")}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</ClassificationCard>
|
</ClassificationCard>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user