Update mode for gallery, ranges for properties
This commit is contained in:
@@ -4,6 +4,8 @@ import { Watch } from "@litegraph-ts/nodes-basic";
|
||||
import type { SerializedPrompt } from "$lib/components/ComfyApp";
|
||||
import { toast } from '@zerodevx/svelte-toast'
|
||||
import type { GalleryOutput } from "./ComfyWidgetNodes";
|
||||
import { get } from "svelte/store";
|
||||
import queueState from "$lib/stores/queueState";
|
||||
|
||||
export interface ComfyQueueEventsProperties extends Record<any, any> {
|
||||
prompt: SerializedPrompt | null
|
||||
@@ -32,14 +34,27 @@ export class ComfyQueueEvents extends ComfyGraphNode {
|
||||
this.setOutputData(2, this.properties.prompt)
|
||||
}
|
||||
|
||||
override beforeQueued() {
|
||||
this.setProperty("value", null)
|
||||
this.triggerSlot(0, "bang")
|
||||
private getActionParams(subgraph: string | null): any {
|
||||
let queue = get(queueState)
|
||||
let remaining = 0;
|
||||
|
||||
if (typeof queue.queueRemaining === "number")
|
||||
remaining = queue.queueRemaining
|
||||
|
||||
return {
|
||||
queueRemaining: remaining,
|
||||
subgraph
|
||||
}
|
||||
}
|
||||
|
||||
override afterQueued(p: SerializedPrompt) {
|
||||
override beforeQueued(subgraph: string | null) {
|
||||
this.setProperty("value", null)
|
||||
this.triggerSlot(0, this.getActionParams(subgraph))
|
||||
}
|
||||
|
||||
override afterQueued(p: SerializedPrompt, subgraph: string | null) {
|
||||
this.setProperty("value", p)
|
||||
this.triggerSlot(1, "bang")
|
||||
this.triggerSlot(1, this.getActionParams(subgraph))
|
||||
}
|
||||
|
||||
override onSerialize(o: SerializedLGraphNode) {
|
||||
|
||||
@@ -20,8 +20,8 @@ export type DefaultWidgetLayout = {
|
||||
export default class ComfyGraphNode extends LGraphNode {
|
||||
isBackendNode?: boolean;
|
||||
|
||||
beforeQueued?(): void;
|
||||
afterQueued?(prompt: SerializedPrompt): void;
|
||||
beforeQueued?(subgraph: string | null): void;
|
||||
afterQueued?(prompt: SerializedPrompt, subgraph: string | null): void;
|
||||
onExecuted?(output: any): void;
|
||||
|
||||
defaultWidgets?: DefaultWidgetLayout
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LiteGraph, type ContextMenuItem, type LGraphNode, type Vector2, LConnectionKind, LLink, LGraphCanvas, type SlotType, TitleMode, type SlotLayout, LGraph, type INodeInputSlot, type ITextWidget, type INodeOutputSlot, type SerializedLGraphNode, BuiltInSlotType } from "@litegraph-ts/core";
|
||||
import { LiteGraph, type ContextMenuItem, type LGraphNode, type Vector2, LConnectionKind, LLink, LGraphCanvas, type SlotType, TitleMode, type SlotLayout, LGraph, type INodeInputSlot, type ITextWidget, type INodeOutputSlot, type SerializedLGraphNode, BuiltInSlotType, type PropertyLayout } from "@litegraph-ts/core";
|
||||
import ComfyGraphNode from "./ComfyGraphNode";
|
||||
import ComboWidget from "$lib/widgets/ComboWidget.svelte";
|
||||
import RangeWidget from "$lib/widgets/RangeWidget.svelte";
|
||||
@@ -397,13 +397,15 @@ export type GalleryOutputEntry = {
|
||||
}
|
||||
|
||||
export interface ComfyGalleryProperties extends ComfyWidgetProperties {
|
||||
index: number
|
||||
index: number,
|
||||
updateMode: "replace" | "append"
|
||||
}
|
||||
|
||||
export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
|
||||
override properties: ComfyGalleryProperties = {
|
||||
defaultValue: [],
|
||||
index: 0
|
||||
index: 0,
|
||||
updateMode: "replace"
|
||||
}
|
||||
|
||||
static slotLayout: SlotLayout = {
|
||||
@@ -417,6 +419,10 @@ export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
|
||||
]
|
||||
}
|
||||
|
||||
static propertyLayout: PropertyLayout = [
|
||||
{ name: "updateMode", defaultValue: "replace", type: "enum", options: { values: ["replace", "append"] } }
|
||||
]
|
||||
|
||||
override svelteComponentType = GalleryWidget
|
||||
override copyFromInputLink = false;
|
||||
override outputIndex = null;
|
||||
@@ -442,9 +448,13 @@ export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
|
||||
|
||||
const galleryItems: GradioFileData[] = this.convertItems(link.data)
|
||||
|
||||
// const currentValue = get(this.value)
|
||||
// this.setValue(currentValue.concat(galleryItems))
|
||||
this.setValue(galleryItems)
|
||||
if (this.properties.updateMode === "append") {
|
||||
const currentValue = get(this.value)
|
||||
this.setValue(currentValue.concat(galleryItems))
|
||||
}
|
||||
else {
|
||||
this.setValue(galleryItems)
|
||||
}
|
||||
}
|
||||
this.setProperty("index", 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user