mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
|
import { cn } from "@/lib/utils";
|
|
import {
|
|
CustomClassificationModelConfig,
|
|
FrigateConfig,
|
|
} from "@/types/frigateConfig";
|
|
import { useMemo } from "react";
|
|
import { isMobile } from "react-device-detect";
|
|
import useSWR from "swr";
|
|
|
|
type ModelSelectionViewProps = {
|
|
onClick: (model: CustomClassificationModelConfig) => void;
|
|
};
|
|
export default function ModelSelectionView({
|
|
onClick,
|
|
}: ModelSelectionViewProps) {
|
|
const { data: config } = useSWR<FrigateConfig>("config", {
|
|
revalidateOnFocus: false,
|
|
});
|
|
|
|
const classificationConfigs = useMemo(() => {
|
|
if (!config) {
|
|
return [];
|
|
}
|
|
|
|
return Object.values(config.classification.custom);
|
|
}, [config]);
|
|
|
|
if (!config) {
|
|
return <ActivityIndicator />;
|
|
}
|
|
|
|
if (classificationConfigs.length == 0) {
|
|
return <div>You need to setup a custom model configuration.</div>;
|
|
}
|
|
|
|
return (
|
|
<div className="size-full p-2">
|
|
{classificationConfigs.map((config) => (
|
|
<div
|
|
className={cn(
|
|
"flex w-72 cursor-pointer flex-col gap-2 rounded-lg bg-card p-2 outline outline-[3px]",
|
|
isMobile && "w-full",
|
|
false
|
|
? "shadow-selected outline-selected"
|
|
: "outline-transparent duration-500",
|
|
)}
|
|
onClick={() => onClick(config)}
|
|
onContextMenu={() => {
|
|
// e.stopPropagation();
|
|
// e.preventDefault();
|
|
// handleClickEvent(true);
|
|
}}
|
|
>
|
|
<div className="size-48"></div>
|
|
<div className="smart-capitalize">
|
|
{config.name} ({config.state_config != null ? "State" : "Object"}{" "}
|
|
Classification)
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|