multiple workflows (combo version)

This commit is contained in:
TomoyukiMizuma 2023-08-18 16:08:03 +09:00
parent bc0360291f
commit 0d80c1f831
3 changed files with 33 additions and 14 deletions

View File

@ -1602,13 +1602,12 @@ export class ComfyApp {
this.runningNodeId = null; this.runningNodeId = null;
} }
switchWorkflow() { switchWorkflow(seleted_id) {
const workflow_count = 3; const workflow_count = 5;
try { try {
let current_workflow = "workflow_" + this.workflow_current_id; let current_workflow = "workflow_" + this.workflow_current_id;
this.workflow_current_id += 1; this.workflow_current_id = Math.min(Math.max(seleted_id, 0), workflow_count - 1);
this.workflow_current_id %= workflow_count;
let next_workflow = "workflow_" + this.workflow_current_id; let next_workflow = "workflow_" + this.workflow_current_id;
localStorage.setItem("workflow_current_id", this.workflow_current_id); localStorage.setItem("workflow_current_id", this.workflow_current_id);

View File

@ -756,12 +756,19 @@ export class ComfyUI {
} }
} }
}), }),
$el("button", { $el("select", {
id: "comfy-switch-workflow-button", textContent: "Workflow", onclick: () => { id: "comfy-switch-workflow-combo", onchange: (event) => {
app.switchWorkflow(); app.switchWorkflow(event.target.selectedIndex);
document.getElementById("comfy-switch-workflow-button").textContent = "Workflow " + app.workflow_current_id;
} }
}), },
[
$el("option", {value:'workflow_0'}, 'Workflow 0'),
$el("option", {value:'workflow_1'}, 'Workflow 1'),
$el("option", {value:'workflow_2'}, 'Workflow 2'),
$el("option", {value:'workflow_3'}, 'Workflow 3'),
$el("option", {value:'workflow_4'}, 'Workflow 4'),
]
),
]); ]);
const devMode = this.settings.addSetting({ const devMode = this.settings.addSetting({
@ -779,9 +786,14 @@ export class ComfyUI {
setStatus(status) { setStatus(status) {
this.queueSize.textContent = "Queue size: " + (status ? status.exec_info.queue_remaining : "ERR"); this.queueSize.textContent = "Queue size: " + (status ? status.exec_info.queue_remaining : "ERR");
const switch_btn = document.getElementById("comfy-switch-workflow-button"); const switch_workflow_combo = document.getElementById("comfy-switch-workflow-combo");
if (typeof app != "undefined") {
// This assignment is actually only needed when launching the app.
switch_workflow_combo.selectedIndex = app.workflow_current_id;
}
if (status) { if (status) {
switch_btn.disabled = status.exec_info.queue_remaining ? true : false; switch_workflow_combo.disabled = status.exec_info.queue_remaining ? true : false;
if ( if (
this.lastQueueSize != 0 && this.lastQueueSize != 0 &&
status.exec_info.queue_remaining == 0 && status.exec_info.queue_remaining == 0 &&
@ -792,7 +804,7 @@ export class ComfyUI {
this.lastQueueSize = status.exec_info.queue_remaining; this.lastQueueSize = status.exec_info.queue_remaining;
} }
else { else {
switch_btn.disabled = false; switch_workflow_combo.disabled = false;
} }
} }
} }

View File

@ -102,6 +102,7 @@ body {
} }
.comfy-menu button, .comfy-menu button,
.comfy-menu select,
.comfy-modal button { .comfy-modal button {
font-size: 20px; font-size: 20px;
} }
@ -117,11 +118,13 @@ body {
color: var(--descrip-text) !important; color: var(--descrip-text) !important;
} }
.comfy-menu > button { .comfy-menu > button,
.comfy-menu > select {
width: 100%; width: 100%;
} }
.comfy-menu > button, .comfy-menu > button,
.comfy-menu > select,
.comfy-menu-btns button, .comfy-menu-btns button,
.comfy-menu .comfy-list button, .comfy-menu .comfy-list button,
.comfy-modal button { .comfy-modal button {
@ -134,6 +137,7 @@ body {
} }
.comfy-menu > button:hover, .comfy-menu > button:hover,
.comfy-menu > select:hover,
.comfy-menu-btns button:hover, .comfy-menu-btns button:hover,
.comfy-menu .comfy-list button:hover, .comfy-menu .comfy-list button:hover,
.comfy-modal button:hover, .comfy-modal button:hover,
@ -142,11 +146,15 @@ body {
cursor: pointer; cursor: pointer;
} }
button#comfy-switch-workflow-button:disabled { select#comfy-switch-workflow-combo:disabled {
filter: brightness(1.0); filter: brightness(1.0);
cursor: not-allowed; cursor: not-allowed;
} }
.comfy-menu select {
text-align-last: center
}
.comfy-menu span.drag-handle { .comfy-menu span.drag-handle {
width: 10px; width: 10px;
height: 20px; height: 20px;