feat: refresh create new machine ui

This commit is contained in:
BennyKok 2024-01-16 18:52:13 +08:00
parent 8628480362
commit b6be0bd462
5 changed files with 91 additions and 47 deletions

View File

@ -357,9 +357,15 @@ export function MachineList({
}, },
snapshot: { snapshot: {
fieldType: "snapshot", fieldType: "snapshot",
inputProps: {
showLabel: false,
},
}, },
models: { models: {
fieldType: "models", fieldType: "models",
inputProps: {
showLabel: false,
},
}, },
gpu: { gpu: {
fieldType: !userMetadata.betaFeaturesAccess fieldType: !userMetadata.betaFeaturesAccess

View File

@ -2,6 +2,12 @@
import type { AutoFormInputComponentProps } from "../ui/auto-form/types"; import type { AutoFormInputComponentProps } from "../ui/auto-form/types";
import { LoadingIcon } from "@/components/LoadingIcon"; import { LoadingIcon } from "@/components/LoadingIcon";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { import {
Command, Command,
@ -154,7 +160,13 @@ export function ModelPickerView({
field, field,
}: Pick<AutoFormInputComponentProps, "field">) { }: Pick<AutoFormInputComponentProps, "field">) {
return ( return (
<div className="flex gap-2 flex-col"> <Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger className="text-sm">
Models (ComfyUI Manager & Civitai)
</AccordionTrigger>
<AccordionContent>
<div className="flex gap-2 flex-col px-1">
<ComfyUIManagerModelRegistry field={field} /> <ComfyUIManagerModelRegistry field={field} />
<CivitaiModelRegistry field={field} /> <CivitaiModelRegistry field={field} />
{/* <span>{field.value.length} selected</span> */} {/* <span>{field.value.length} selected</span> */}
@ -170,6 +182,9 @@ export function ModelPickerView({
</ScrollArea> </ScrollArea>
)} )}
</div> </div>
</AccordionContent>
</AccordionItem>
</Accordion>
); );
} }
@ -307,7 +322,13 @@ export function ComfyUIManagerModelRegistry({
}; };
}, []); }, []);
return <ModelSelector field={field} modelList={modelList} label="common" />; return (
<ModelSelector
field={field}
modelList={modelList}
label="ComfyUI Manager"
/>
);
} }
export function ModelSelector({ export function ModelSelector({
@ -358,7 +379,7 @@ export function ModelSelector({
aria-expanded={open} aria-expanded={open}
className="w-full justify-between flex" className="w-full justify-between flex"
> >
Select {label} Add from {label}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
@ -371,7 +392,7 @@ export function ModelSelector({
> >
{isLoading && <LoadingIcon />} {isLoading && <LoadingIcon />}
</CommandInput> </CommandInput>
<CommandEmpty>No framework found.</CommandEmpty> <CommandEmpty>No models found.</CommandEmpty>
<CommandList className="pointer-events-auto"> <CommandList className="pointer-events-auto">
<CommandGroup> <CommandGroup>
{modelList?.models.map((model) => ( {modelList?.models.map((model) => (

View File

@ -2,6 +2,12 @@
import type { AutoFormInputComponentProps } from "../ui/auto-form/types"; import type { AutoFormInputComponentProps } from "../ui/auto-form/types";
import fetcher from "@/components/fetcher"; import fetcher from "@/components/fetcher";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { import {
Command, Command,
@ -27,7 +33,10 @@ export function SnapshotPickerView({
field, field,
}: Pick<AutoFormInputComponentProps, "field">) { }: Pick<AutoFormInputComponentProps, "field">) {
return ( return (
<div className="flex gap-2 flex-col"> <Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger className="text-sm">Custom Nodes</AccordionTrigger>
<AccordionContent className="flex gap-2 flex-col px-1">
<SnapshotPresetPicker field={field} /> <SnapshotPresetPicker field={field} />
<CustomNodesSelector field={field} /> <CustomNodesSelector field={field} />
{field.value && ( {field.value && (
@ -42,7 +51,9 @@ export function SnapshotPickerView({
/> />
// </ScrollArea> // </ScrollArea>
)} )}
</div> </AccordionContent>
</AccordionItem>
</Accordion>
); );
} }
@ -97,14 +108,16 @@ function SnapshotPresetPicker({
aria-expanded={open} aria-expanded={open}
className="w-full justify-between flex" className="w-full justify-between flex"
> >
{selected ? findItem(selected)?.label : "Select snapshot..."} {selected
? findItem(selected)?.label
: "Select snapshot (From deployments)"}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-[375px] p-0"> <PopoverContent className="w-[375px] p-0">
<Command> <Command>
<CommandInput placeholder="Search framework..." className="h-9" /> <CommandInput placeholder="Search snapshot..." className="h-9" />
<CommandEmpty>No framework found.</CommandEmpty> <CommandEmpty>No snapshot found.</CommandEmpty>
<CommandGroup> <CommandGroup>
{frameworks?.map((framework) => ( {frameworks?.map((framework) => (
<CommandItem <CommandItem
@ -188,7 +201,7 @@ function CustomNodesSelector({
aria-expanded={open} aria-expanded={open}
className="w-full justify-between flex" className="w-full justify-between flex"
> >
Select custom nodes... {keys.length} selected Add custom nodes - {keys.length} selected
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>

View File

@ -21,10 +21,12 @@ export default function AutoFormModelsPicker({
}: AutoFormInputComponentProps) { }: AutoFormInputComponentProps) {
return ( return (
<FormItem> <FormItem>
{fieldConfigItem.inputProps?.showLabel && (
<FormLabel> <FormLabel>
{label} {label}
{isRequired && <span className="text-destructive"> *</span>} {isRequired && <span className="text-destructive"> *</span>}
</FormLabel> </FormLabel>
)}
<FormControl> <FormControl>
<Suspense fallback={<LoadingIcon />}> <Suspense fallback={<LoadingIcon />}>
<ModelPickerView field={field} /> <ModelPickerView field={field} />

View File

@ -21,10 +21,12 @@ export default function AutoFormSnapshotPicker({
}: AutoFormInputComponentProps) { }: AutoFormInputComponentProps) {
return ( return (
<FormItem> <FormItem>
{fieldConfigItem.inputProps?.showLabel && (
<FormLabel> <FormLabel>
{label} {label}
{isRequired && <span className="text-destructive"> *</span>} {isRequired && <span className="text-destructive"> *</span>}
</FormLabel> </FormLabel>
)}
<FormControl> <FormControl>
<Suspense fallback={<LoadingIcon />}> <Suspense fallback={<LoadingIcon />}>
<SnapshotPickerView field={field} /> <SnapshotPickerView field={field} />