diff --git a/src/components/graph/selectionToolbox/nodeModelsMetadata/ModelForm.vue b/src/components/graph/selectionToolbox/nodeModelsMetadata/ModelForm.vue index 9eed9d535..e0afc7483 100644 --- a/src/components/graph/selectionToolbox/nodeModelsMetadata/ModelForm.vue +++ b/src/components/graph/selectionToolbox/nodeModelsMetadata/ModelForm.vue @@ -1,10 +1,9 @@ @@ -19,7 +18,7 @@ - + @@ -29,7 +28,7 @@ class="h-full" /> - {{ $t('nodeMetadata.models.fields.name') }} + {{ $t('nodeMetadata.models.fields.filename') }} @@ -82,7 +81,7 @@ severity="danger" text size="small" - @click="$emit('remove')" + @click="emit('remove')" /> + - diff --git a/src/components/graph/selectionToolbox/nodeModelsMetadata/NodeModelsPopover.vue b/src/components/graph/selectionToolbox/nodeModelsMetadata/NodeModelsPopover.vue index 39aa432a9..3c365ada1 100644 --- a/src/components/graph/selectionToolbox/nodeModelsMetadata/NodeModelsPopover.vue +++ b/src/components/graph/selectionToolbox/nodeModelsMetadata/NodeModelsPopover.vue @@ -1,8 +1,8 @@ - + - - {{ $t('nodeMetadata.models.title') }} + + {{ $t('nodeMetadata.models.title') }} @@ -27,17 +25,9 @@ icon="pi pi-plus" text size="small" - @click="nodeModels.push({ name: '', url: '', directory: '' })" + @click="addEmptyModel" /> - @@ -45,25 +35,34 @@ diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 7531ed7b7..8eda2ef71 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -83,13 +83,11 @@ "nodeMetadata": { "models": { "title": "Edit Node Models Metadata", - "save": "Save Models Metadata", "add": "Add Model", "remove": "Remove Model", - "modelUpdated": "Model updated", - "modelUpdateFailed": "Invalid model metadata. Node not updated.", + "success": "Node models metadata updated", "fields": { - "name": "Name", + "filename": "Filename", "directory": "Directory", "url": "URL" } diff --git a/src/utils/litegraphUtil.ts b/src/utils/litegraphUtil.ts index aa1ce0bc1..d09e0ac96 100644 --- a/src/utils/litegraphUtil.ts +++ b/src/utils/litegraphUtil.ts @@ -8,11 +8,33 @@ import { import type { IComboWidget } from '@comfyorg/litegraph/dist/types/widgets' import _ from 'lodash' +import { ModelFile } from '@/schemas/comfyWorkflowSchema' + type ImageNode = LGraphNode & { imgs: HTMLImageElement[] | undefined } type VideoNode = LGraphNode & { videoContainer: HTMLElement | undefined imgs: HTMLVideoElement[] | undefined } +type ModelNode = LGraphNode & { + properties: { + models?: ModelFile[] + } +} + +const MODEL_OUTPUT_TYPES = new Set([ + 'MODEL', + 'CLIP', + 'VAE', + 'CONTROL_NET', + 'UPSCALE_MODEL', + 'CLIP_VISION', + 'STYLE_MODEL', + 'GLIGEN', + 'HOOKS', + 'UPSCALE_MODEL', + 'PHOTOMAKER', + 'SAM_MODEL' +]) export function isImageNode(node: LGraphNode | undefined): node is ImageNode { if (!node) return false @@ -31,6 +53,13 @@ export function isAudioNode(node: LGraphNode | undefined): boolean { return !!node && node.previewMediaType === 'audio' } +export const isModelNode = (node: unknown): node is ModelNode => { + if (!isLGraphNode(node)) return false + if (node.properties?.models) return true + if (!node.outputs?.length) return false + return node.outputs.some((output) => MODEL_OUTPUT_TYPES.has(`${output.type}`)) +} + export function addToComboValues(widget: IComboWidget, value: string) { if (!widget.options) widget.options = { values: [] } if (!widget.options.values) widget.options.values = [] @@ -46,27 +75,6 @@ export const isLGraphNode = (item: unknown): item is LGraphNode => { export const isLGraphGroup = (item: unknown): item is LGraphGroup => { return item instanceof LGraphGroup } - -const modelOutputTypes = new Set([ - 'MODEL', - 'CLIP', - 'VAE', - 'CONTROL_NET', - 'UPSCALE_MODEL', - 'CLIP_VISION', - 'STYLE_MODEL', - 'GLIGEN', - 'HOOKS', - 'UPSCALE_MODEL', - 'PHOTOMAKER', - 'SAM_MODEL' -]) - -export const isModelNode = (node: LGraphNode): boolean => { - if (!node?.outputs?.length) return false - return node.outputs.some((output) => modelOutputTypes.has(`${output.type}`)) -} - /** * Get the color option of all canvas items if they are all the same. * @param items - The items to get the color option of.