Make no models view more specific

This commit is contained in:
Nicolas Mowen 2025-10-23 11:03:52 -06:00
parent b3b990b636
commit 0d744757b0
2 changed files with 34 additions and 29 deletions

View File

@ -52,9 +52,16 @@
"categorizeImageAs": "Classify Image As:", "categorizeImageAs": "Classify Image As:",
"categorizeImage": "Classify Image", "categorizeImage": "Classify Image",
"noModels": { "noModels": {
"title": "No Classification Models", "object": {
"description": "Create a custom model to classify objects or monitor state changes in your cameras.", "title": "No Object Classification Models",
"buttonText": "Create Classification Model" "description": "Create a custom model to classify detected objects.",
"buttonText": "Create Object Model"
},
"state": {
"title": "No State Classification Models",
"description": "Create a custom model to monitor and classify state changes in specific camera areas.",
"buttonText": "Create State Model"
}
}, },
"wizard": { "wizard": {
"title": "Create New Classification", "title": "Create New Classification",

View File

@ -75,21 +75,6 @@ export default function ModelSelectionView({
return <ActivityIndicator />; return <ActivityIndicator />;
} }
if (classificationConfigs.length == 0) {
return (
<>
<ClassificationModelWizardDialog
open={newModel}
onClose={() => {
setNewModel(false);
refreshConfig();
}}
/>
<NoModelsView onCreateModel={() => setNewModel(true)} />;
</>
);
}
return ( return (
<div className="flex size-full flex-col p-2"> <div className="flex size-full flex-col p-2">
<ClassificationModelWizardDialog <ClassificationModelWizardDialog
@ -109,7 +94,6 @@ export default function ModelSelectionView({
value={pageToggle} value={pageToggle}
onValueChange={(value: ModelType) => { onValueChange={(value: ModelType) => {
if (value) { if (value) {
// Restrict viewer navigation
setPageToggle(value); setPageToggle(value);
} }
}} }}
@ -142,31 +126,45 @@ export default function ModelSelectionView({
</div> </div>
</div> </div>
<div className="flex size-full gap-2 p-2"> <div className="flex size-full gap-2 p-2">
{selectedClassificationConfigs.map((config) => ( {selectedClassificationConfigs.length === 0 ? (
<ModelCard <NoModelsView
key={config.name} onCreateModel={() => setNewModel(true)}
config={config} modelType={pageToggle}
onClick={() => onClick(config)}
/> />
))} ) : (
selectedClassificationConfigs.map((config) => (
<ModelCard
key={config.name}
config={config}
onClick={() => onClick(config)}
/>
))
)}
</div> </div>
</div> </div>
); );
} }
function NoModelsView({ onCreateModel }: { onCreateModel: () => void }) { function NoModelsView({
onCreateModel,
modelType,
}: {
onCreateModel: () => void;
modelType: ModelType;
}) {
const { t } = useTranslation(["views/classificationModel"]); const { t } = useTranslation(["views/classificationModel"]);
const typeKey = modelType === "objects" ? "object" : "state";
return ( return (
<div className="flex size-full items-center justify-center"> <div className="flex size-full items-center justify-center">
<div className="flex flex-col items-center gap-2"> <div className="flex flex-col items-center gap-2">
<MdModelTraining className="size-8" /> <MdModelTraining className="size-8" />
<Heading as="h4">{t("noModels.title")}</Heading> <Heading as="h4">{t(`noModels.${typeKey}.title`)}</Heading>
<div className="mb-3 text-center text-secondary-foreground"> <div className="mb-3 text-center text-secondary-foreground">
{t("noModels.description")} {t(`noModels.${typeKey}.description`)}
</div> </div>
<Button size="sm" variant="select" onClick={onCreateModel}> <Button size="sm" variant="select" onClick={onCreateModel}>
{t("noModels.buttonText")} {t(`noModels.${typeKey}.buttonText`)}
</Button> </Button>
</div> </div>
</div> </div>