mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-24 23:57:41 +03:00
Cleanup
This commit is contained in:
parent
5dbff6f1b7
commit
8eed6bf0c0
@ -65,6 +65,10 @@ import {
|
|||||||
GroupedClassificationCard,
|
GroupedClassificationCard,
|
||||||
} from "@/components/card/ClassificationCard";
|
} from "@/components/card/ClassificationCard";
|
||||||
import { Event } from "@/types/event";
|
import { Event } from "@/types/event";
|
||||||
|
import SearchDetailDialog, {
|
||||||
|
SearchTab,
|
||||||
|
} from "@/components/overlay/detail/SearchDetailDialog";
|
||||||
|
import { SearchResult } from "@/types/search";
|
||||||
|
|
||||||
type ModelTrainingViewProps = {
|
type ModelTrainingViewProps = {
|
||||||
model: CustomClassificationModelConfig;
|
model: CustomClassificationModelConfig;
|
||||||
@ -889,53 +893,113 @@ function ObjectTrainGrid({
|
|||||||
};
|
};
|
||||||
}, [model]);
|
}, [model]);
|
||||||
|
|
||||||
|
// selection
|
||||||
|
|
||||||
|
const [selectedEvent, setSelectedEvent] = useState<Event>();
|
||||||
|
const [dialogTab, setDialogTab] = useState<SearchTab>("details");
|
||||||
|
|
||||||
|
// handlers
|
||||||
|
|
||||||
|
const handleClickEvent = useCallback(
|
||||||
|
(
|
||||||
|
group: ClassificationItemData[],
|
||||||
|
event: Event | undefined,
|
||||||
|
meta: boolean,
|
||||||
|
) => {
|
||||||
|
if (event && selectedImages.length == 0 && !meta) {
|
||||||
|
setSelectedEvent(event);
|
||||||
|
} else {
|
||||||
|
const anySelected =
|
||||||
|
group.find((item) => selectedImages.includes(item.filename)) !=
|
||||||
|
undefined;
|
||||||
|
|
||||||
|
if (anySelected) {
|
||||||
|
// deselect all
|
||||||
|
const toDeselect: string[] = [];
|
||||||
|
group.forEach((item) => {
|
||||||
|
if (selectedImages.includes(item.filename)) {
|
||||||
|
toDeselect.push(item.filename);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onClickImages(toDeselect, false);
|
||||||
|
} else {
|
||||||
|
// select all
|
||||||
|
onClickImages(
|
||||||
|
group.map((item) => item.filename),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[selectedImages, onClickImages],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<>
|
||||||
ref={contentRef}
|
<SearchDetailDialog
|
||||||
className="scrollbar-container flex flex-wrap gap-2 overflow-y-scroll p-1"
|
search={
|
||||||
>
|
selectedEvent ? (selectedEvent as unknown as SearchResult) : undefined
|
||||||
{Object.entries(groups).map(([key, group]) => {
|
}
|
||||||
const event = events?.find((ev) => ev.id == key);
|
page={dialogTab}
|
||||||
return (
|
setSimilarity={undefined}
|
||||||
<GroupedClassificationCard
|
setSearchPage={setDialogTab}
|
||||||
key={key}
|
setSearch={(search) => setSelectedEvent(search as unknown as Event)}
|
||||||
group={group}
|
setInputFocused={() => {}}
|
||||||
event={event}
|
/>
|
||||||
threshold={threshold}
|
|
||||||
selectedItems={selectedImages}
|
<div
|
||||||
i18nLibrary="views/classificationModel"
|
ref={contentRef}
|
||||||
onClick={() => {}}
|
className="scrollbar-container flex flex-wrap gap-2 overflow-y-scroll p-1"
|
||||||
onSelectEvent={() => {}}
|
>
|
||||||
>
|
{Object.entries(groups).map(([key, group]) => {
|
||||||
{(data) => (
|
const event = events?.find((ev) => ev.id == key);
|
||||||
<>
|
return (
|
||||||
<ClassificationSelectionDialog
|
<GroupedClassificationCard
|
||||||
classes={classes}
|
key={key}
|
||||||
modelName={model.name}
|
group={group}
|
||||||
image={data.filename}
|
event={event}
|
||||||
onRefresh={onRefresh}
|
threshold={threshold}
|
||||||
>
|
selectedItems={selectedImages}
|
||||||
<TbCategoryPlus className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
i18nLibrary="views/classificationModel"
|
||||||
</ClassificationSelectionDialog>
|
onClick={(data) => {
|
||||||
<Tooltip>
|
if (data) {
|
||||||
<TooltipTrigger>
|
onClickImages([data.filename], true);
|
||||||
<LuTrash2
|
} else {
|
||||||
className="size-5 cursor-pointer text-primary-variant hover:text-primary"
|
handleClickEvent(group, event, true);
|
||||||
onClick={(e) => {
|
}
|
||||||
e.stopPropagation();
|
}}
|
||||||
onDelete([data.filename]);
|
onSelectEvent={() => {}}
|
||||||
}}
|
>
|
||||||
/>
|
{(data) => (
|
||||||
</TooltipTrigger>
|
<>
|
||||||
<TooltipContent>
|
<ClassificationSelectionDialog
|
||||||
{t("button.deleteClassificationAttempts")}
|
classes={classes}
|
||||||
</TooltipContent>
|
modelName={model.name}
|
||||||
</Tooltip>
|
image={data.filename}
|
||||||
</>
|
onRefresh={onRefresh}
|
||||||
)}
|
>
|
||||||
</GroupedClassificationCard>
|
<TbCategoryPlus className="size-5 cursor-pointer text-primary-variant hover:text-primary" />
|
||||||
);
|
</ClassificationSelectionDialog>
|
||||||
})}
|
<Tooltip>
|
||||||
</div>
|
<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>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</GroupedClassificationCard>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user