feat: update plugin ui
This commit is contained in:
parent
1dc04a8752
commit
f7f9da7f68
@ -1,6 +1,4 @@
|
|||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import folder_paths
|
import folder_paths
|
||||||
@ -25,8 +23,6 @@ api = None
|
|||||||
api_task = None
|
api_task = None
|
||||||
prompt_metadata = {}
|
prompt_metadata = {}
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
def post_prompt(json_data):
|
def post_prompt(json_data):
|
||||||
prompt_server = server.PromptServer.instance
|
prompt_server = server.PromptServer.instance
|
||||||
json_data = prompt_server.trigger_on_prompt(json_data)
|
json_data = prompt_server.trigger_on_prompt(json_data)
|
||||||
@ -75,7 +71,6 @@ def randomSeed(num_digits=15):
|
|||||||
|
|
||||||
@server.PromptServer.instance.routes.post("/comfyui-deploy/run")
|
@server.PromptServer.instance.routes.post("/comfyui-deploy/run")
|
||||||
async def comfy_deploy_run(request):
|
async def comfy_deploy_run(request):
|
||||||
print("hi")
|
|
||||||
prompt_server = server.PromptServer.instance
|
prompt_server = server.PromptServer.instance
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
|
|
||||||
@ -87,7 +82,7 @@ async def comfy_deploy_run(request):
|
|||||||
|
|
||||||
prompt = {
|
prompt = {
|
||||||
"prompt": workflow_api,
|
"prompt": workflow_api,
|
||||||
"client_id": "fake_client" #api.client_id
|
"client_id": "comfy_deploy_instance" #api.client_id
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -151,7 +146,7 @@ prompt_server = server.PromptServer.instance
|
|||||||
|
|
||||||
send_json = prompt_server.send_json
|
send_json = prompt_server.send_json
|
||||||
async def send_json_override(self, event, data, sid=None):
|
async def send_json_override(self, event, data, sid=None):
|
||||||
print("INTERNAL:", event, data, sid)
|
# print("INTERNAL:", event, data, sid)
|
||||||
|
|
||||||
prompt_id = data.get('prompt_id')
|
prompt_id = data.get('prompt_id')
|
||||||
|
|
||||||
|
@ -105,7 +105,12 @@ const ext = {
|
|||||||
function addButton() {
|
function addButton() {
|
||||||
const menu = document.querySelector(".comfy-menu");
|
const menu = document.querySelector(".comfy-menu");
|
||||||
|
|
||||||
|
const deployContainer = document.createElement("div");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const deploy = document.createElement("button");
|
const deploy = document.createElement("button");
|
||||||
|
deploy.style.position = "relative";
|
||||||
deploy.textContent = "Deploy";
|
deploy.textContent = "Deploy";
|
||||||
deploy.className = "sharebtn";
|
deploy.className = "sharebtn";
|
||||||
deploy.onclick = async () => {
|
deploy.onclick = async () => {
|
||||||
@ -191,15 +196,29 @@ function addButton() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = document.createElement("button");
|
const config = document.createElement("img");
|
||||||
config.textContent = "Config";
|
// config.style.padding = "0px 10px";
|
||||||
deploy.className = "sharebtn";
|
config.style.height = "100%";
|
||||||
config.onclick = () => {
|
config.style.position = "absolute";
|
||||||
|
config.style.right = "10px";
|
||||||
|
config.style.top = "0px";
|
||||||
|
|
||||||
|
// set aspect ratio to square
|
||||||
|
config.style.width = "20px";
|
||||||
|
config.src = "https://api.iconify.design/material-symbols-light:settings.svg?color=%23888888";
|
||||||
|
config.onclick = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
configDialog.show();
|
configDialog.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deploy.append(
|
||||||
|
config
|
||||||
|
)
|
||||||
|
|
||||||
|
deploy.style.order = "99";
|
||||||
|
|
||||||
menu.append(deploy);
|
menu.append(deploy);
|
||||||
menu.append(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.registerExtension(ext);
|
app.registerExtension(ext);
|
||||||
@ -241,13 +260,30 @@ export class InfoDialog extends ComfyDialog {
|
|||||||
export const infoDialog = new InfoDialog()
|
export const infoDialog = new InfoDialog()
|
||||||
|
|
||||||
export class ConfigDialog extends ComfyDialog {
|
export class ConfigDialog extends ComfyDialog {
|
||||||
|
|
||||||
|
container = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.element.classList.add("comfy-normal-modal");
|
this.element.classList.add("comfy-normal-modal");
|
||||||
|
|
||||||
|
this.container = document.createElement("div");
|
||||||
|
this.element.querySelector(".comfy-modal-content").prepend(this.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
createButtons() {
|
createButtons() {
|
||||||
return [
|
return [
|
||||||
|
$el("div", {
|
||||||
|
type: "div",
|
||||||
|
style: {
|
||||||
|
display: "flex",
|
||||||
|
gap: "6px",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
width: "100%",
|
||||||
|
},
|
||||||
|
onclick: () => this.save(),
|
||||||
|
},
|
||||||
|
[
|
||||||
$el("button", {
|
$el("button", {
|
||||||
type: "button",
|
type: "button",
|
||||||
textContent: "Save",
|
textContent: "Save",
|
||||||
@ -257,7 +293,9 @@ export class ConfigDialog extends ComfyDialog {
|
|||||||
type: "button",
|
type: "button",
|
||||||
textContent: "Close",
|
textContent: "Close",
|
||||||
onclick: () => this.close(),
|
onclick: () => this.close(),
|
||||||
}),
|
})
|
||||||
|
]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,15 +312,21 @@ export class ConfigDialog extends ComfyDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.textElement.innerHTML = `
|
// this.element.style.whiteSpace = "nowrap";
|
||||||
<div style="width: 600px;">
|
// this.textElement.style.overflow = "hidden";
|
||||||
<label style="color: white;">
|
this.container.style.color = "white";
|
||||||
|
// this.textElement.style.padding = "10px";
|
||||||
|
|
||||||
|
this.container.innerHTML = `
|
||||||
|
<div style="width: 400px; display: flex; gap: 18px; flex-direction: column;">
|
||||||
|
<h3 style="margin: 0px;">Comfy Deploy Config</h3>
|
||||||
|
<label style="color: white; width: 100%;">
|
||||||
Endpoint:
|
Endpoint:
|
||||||
<input id="endpoint" style="width: 100%;" type="text" value="${localStorage.getItem("endpoint") || ""}">
|
<input id="endpoint" style="margin-top: 8px; width: 100%; height:30px;" type="text" value="${localStorage.getItem("endpoint") || ""}">
|
||||||
</label>
|
</label>
|
||||||
<label style="color: white;">
|
<label style="color: white;">
|
||||||
API Key:
|
API Key:
|
||||||
<input id="apiKey" style="width: 100%;" type="text" value="${localStorage.getItem("apiKey") || ""}">
|
<input id="apiKey" style="margin-top: 8px; width: 100%; height:30px;" type="password" value="${localStorage.getItem("apiKey") || ""}">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user