diff --git a/web-plugin/index.js b/web-plugin/index.js index d269693..38fb9f7 100644 --- a/web-plugin/index.js +++ b/web-plugin/index.js @@ -192,11 +192,13 @@ const ext = { registerCustomNodes() { /** @type {LGraphNode}*/ - class ComfyDeploy { - color = LGraphCanvas.node_colors.yellow.color; - bgcolor = LGraphCanvas.node_colors.yellow.bgcolor; - groupcolor = LGraphCanvas.node_colors.yellow.groupcolor; + class ComfyDeploy extends LGraphNode { constructor() { + super(); + this.color = LGraphCanvas.node_colors.yellow.color; + this.bgcolor = LGraphCanvas.node_colors.yellow.bgcolor; + this.groupcolor = LGraphCanvas.node_colors.yellow.groupcolor; + if (!this.properties) { this.properties = {}; this.properties.workflow_name = ""; @@ -204,65 +206,75 @@ const ext = { this.properties.version = ""; } - ComfyWidgets.STRING( - this, + this.addWidget( + "text", "workflow_name", - [ - "", - { - default: this.properties.workflow_name, - multiline: false, - }, - ], - app, + this.properties.workflow_name, + (v) => { + this.properties.workflow_name = v; + }, + { multiline: false } ); - ComfyWidgets.STRING( - this, + this.addWidget( + "text", "workflow_id", - [ - "", - { - default: this.properties.workflow_id, - multiline: false, - }, - ], - app, + this.properties.workflow_id, + (v) => { + this.properties.workflow_id = v; + }, + { multiline: false } ); - ComfyWidgets.STRING( - this, + this.addWidget( + "text", "version", - ["", { default: this.properties.version, multiline: false }], - app, + this.properties.version, + (v) => { + this.properties.version = v; + }, + { multiline: false } ); - // this.widgets.forEach((w) => { - // // w.computeSize = () => [200,10] - // w.computedHeight = 2; - // }) - this.widgets_start_y = 10; - this.setSize(this.computeSize()); - - // const config = { }; - - // console.log(this); this.serialize_widgets = true; this.isVirtualNode = true; } + + onExecute() { + // This method is called when the node is executed + // You can add any necessary logic here + } + + onSerialize(o) { + // This method is called when the node is being serialized + // Ensure all necessary data is saved + if (!o.properties) { + o.properties = {}; + } + o.properties.workflow_name = this.properties.workflow_name; + o.properties.workflow_id = this.properties.workflow_id; + o.properties.version = this.properties.version; + } + + onConfigure(o) { + // This method is called when the node is being configured (e.g., when loading a saved graph) + // Ensure all necessary data is restored + if (o.properties) { + this.properties = { ...this.properties, ...o.properties }; + this.widgets[0].value = this.properties.workflow_name || ""; + this.widgets[1].value = this.properties.workflow_id || ""; + this.widgets[2].value = this.properties.version || "1"; + } + } } - // Load default visibility - - LiteGraph.registerNodeType( - "ComfyDeploy", - Object.assign(ComfyDeploy, { - title_mode: LiteGraph.NORMAL_TITLE, - title: "Comfy Deploy", - collapsable: true, - }), - ); + // Register the node type + LiteGraph.registerNodeType("ComfyDeploy", Object.assign(ComfyDeploy, { + title: "Comfy Deploy", + title_mode: LiteGraph.NORMAL_TITLE, + collapsable: true, + })); ComfyDeploy.category = "deploy"; }, @@ -431,10 +443,10 @@ function createDynamicUIHtml(data) {
These nodes are not found with any matching custom_nodes in the ComfyUI Manager Database
${data.missing_nodes - .map((node) => { - return `${node}
`; - }) - .join("")} + .map((node) => { + return `${node}
`; + }) + .join("")} `; } @@ -442,17 +454,14 @@ function createDynamicUIHtml(data) { Object.values(data.custom_nodes).forEach((node) => { html += `${node.hash}
- ${ - node.warning - ? `${node.warning}
` - : "" - } + ${node.warning + ? `${node.warning}
` + : "" + }${item.name}
`; }); @@ -484,9 +492,8 @@ function createDynamicUIHtml(data) { Object.entries(data.files).forEach(([section, items]) => { html += `${item.name}
`; }); @@ -1006,14 +1013,12 @@ export class LoadingDialog extends ComfyDialog { showLoading(title, message) { this.show(`