From 4aeca626bd76458583dbdfed7b12a932e076300b Mon Sep 17 00:00:00 2001 From: ThisModernDay Date: Sun, 22 Oct 2023 12:54:21 -0400 Subject: [PATCH] =?UTF-8?q?Added=20three=20button=20locations=20that=20are?= =?UTF-8?q?=20now=20selectable=20in=20the=20settings=20menu=20under=20'Cha?= =?UTF-8?q?nge=20Reboot=20Server=20Button=20Location'=20locations=20availa?= =?UTF-8?q?ble=20are=20'Menu=20Bar=20Top=20Icon'=20this=20places=20a=20sma?= =?UTF-8?q?ll=20=E2=9A=A1=20in=20the=20top=20right=20corner=20next=20to=20?= =?UTF-8?q?settings.=20'Small=20Button'=20This=20places=20the=20button=20a?= =?UTF-8?q?s=20a=20small=20button=20next=20to=20View=20History.=20'Main=20?= =?UTF-8?q?Menu'=20This=20places=20the=20button=20under=20Load=20Default?= =?UTF-8?q?=20on=20the=20main=20menu.=20I=20also=20added=20a=20toggle=20in?= =?UTF-8?q?=20the=20Settings=20Menu=20so=20you=20can=20choose=20whether=20?= =?UTF-8?q?it=20confirms=20you=20wanting=20to=20reboot=20the=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/scripts/ui.js | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 416b73c2c..9b20f5cf5 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -46,6 +46,7 @@ export function $el(tag, propsOrChildren, children) { return element; } + function dragElement(dragEl, settings) { var posDiffX = 0, posDiffY = 0, @@ -165,6 +166,7 @@ function dragElement(dragEl, settings) { document.onmouseup = null; document.onmousemove = null; } + } export class ComfyDialog { @@ -618,6 +620,11 @@ export class ComfyUI { }, [ $el("span.drag-handle"), $el("span", {$: (q) => (this.queueSize = q)}), + $el("button.comfy-reboot-server-button-icon", {id: "comfy-reboot-server-icon", textContent: "⚡", onclick: () => { + if (!confirmReboot.value || confirm("Are you sure you'd like to reboot the server?")) { + api.fetchApi("/reboot") + } + }}), $el("button.comfy-settings-btn", {textContent: "⚙️", onclick: () => this.settings.show()}), ]), $el("button.comfy-queue-btn", { @@ -704,6 +711,13 @@ export class ComfyUI { this.history.toggle(); }, }), + $el("button", { + id: "comfy-reboot-server-button-small", textContent: "Reboot Server", onclick: () => { + if (!confirmReboot.value || confirm("Are you sure you'd like to reboot the server?")) { + api.fetchApi("/reboot") + } + } + }) ]), this.queue.element, this.history.element, @@ -789,14 +803,16 @@ export class ComfyUI { } }), $el("button", { - id: "comfy-reboot-server-button", textContent: "Reboot Server", onclick: () => { - if (!confirmClear.value || confirm("Are you sure you'd like to reboot the server?")) { + id: "comfy-reboot-server-button-large", textContent: "Reboot Server", onclick: () => { + if (!confirmReboot.value || confirm("Are you sure you'd like to reboot the server?")) { api.fetchApi("/reboot") } } }) + ]); + const devMode = this.settings.addSetting({ id: "Comfy.DevMode", name: "Enable Dev mode Options", @@ -805,6 +821,38 @@ export class ComfyUI { onChange: function(value) { document.getElementById("comfy-dev-save-api-button").style.display = value ? "block" : "none"}, }); + const changeRebootLocation = this.settings.addSetting({ + id: "Comfy.RebootLocation", + name: "Change Reboot Server Button Location", + type: "combo", + options: ['Menu Bar Top Icon', 'Small Button', 'Main Menu'], + defaultValue: 'Main Menu', + onChange: (value) => { + if( value == 'Menu Bar Top Icon') { + document.querySelector('#comfy-reboot-server-icon').style.display = "" + } else { + document.querySelector('#comfy-reboot-server-icon').style.display = "none" + } + if(value == 'Small Button') { + document.querySelector('#comfy-reboot-server-button-small').style.display = "" + } else { + document.querySelector('#comfy-reboot-server-button-small').style.display = "none" + } + if(value == 'Main Menu') { + document.querySelector('#comfy-reboot-server-button-large').style.display = "" + } else { + document.querySelector('#comfy-reboot-server-button-large').style.display = "none" + } + } + }); + + const confirmReboot = this.settings.addSetting({ + id: "Comfy.ConfirmReboot", + name: "Require confirmation when rebooting server", + type: "boolean", + defaultValue: true, + }); + dragElement(this.menuContainer, this.settings); this.setStatus({exec_info: {queue_remaining: "X"}});