various bug fixes

* paste action
- prevent opening upload popup
- ensure rendering after widget_value update

* view api update
- support annotated_filepath

* maskeditor layout
- prevent covering button by hidden div
This commit is contained in:
ltdrdata 2023-04-26 20:36:58 +09:00
parent d40e08cb5f
commit 5cc97cf2bf
3 changed files with 19 additions and 14 deletions

View File

@ -196,8 +196,13 @@ class PromptServer():
@routes.get("/view") @routes.get("/view")
async def view_image(request): async def view_image(request):
if "filename" in request.rel_url.query: if "filename" in request.rel_url.query:
type = request.rel_url.query.get("type", "output") filename = request.rel_url.query["filename"]
output_dir = folder_paths.get_directory_by_type(type) filename,output_dir = folder_paths.annotated_filepath(filename)
if output_dir is None:
type = request.rel_url.query.get("type", "output")
output_dir = folder_paths.get_directory_by_type(type)
if output_dir is None: if output_dir is None:
return web.Response(status=400) return web.Response(status=400)
@ -207,9 +212,9 @@ class PromptServer():
return web.Response(status=403) return web.Response(status=403)
output_dir = full_output_dir output_dir = full_output_dir
filename = request.rel_url.query["filename"]
filename = os.path.basename(filename) filename = os.path.basename(filename)
file = os.path.join(output_dir, filename) file = os.path.join(output_dir, filename)
print(f"{filename} / {file} / {os.path.isfile(file)}")
if os.path.isfile(file): if os.path.isfile(file):
return web.FileResponse(file, headers={"Content-Disposition": f"filename=\"{filename}\""}) return web.FileResponse(file, headers={"Content-Disposition": f"filename=\"{filename}\""})

View File

@ -172,8 +172,8 @@ class MaskEditorDialog extends ComfyDialog {
this.element.appendChild(imgCanvas); this.element.appendChild(imgCanvas);
this.element.appendChild(maskCanvas); this.element.appendChild(maskCanvas);
this.element.appendChild(placeholder); // must below z-index than bottom_panel to avoid covering button
this.element.appendChild(bottom_panel); this.element.appendChild(bottom_panel);
this.element.appendChild(placeholder);
bottom_panel.appendChild(clearButton); bottom_panel.appendChild(clearButton);
bottom_panel.appendChild(saveButton); bottom_panel.appendChild(saveButton);

View File

@ -168,15 +168,6 @@ export class ComfyApp {
content: "Paste (Clipspace)", content: "Paste (Clipspace)",
callback: () => { callback: () => {
if(ComfyApp.clipspace != null) { if(ComfyApp.clipspace != null) {
if(ComfyApp.clipspace.widgets != null && this.widgets != null) {
ComfyApp.clipspace.widgets.forEach(({ type, name, value }) => {
const prop = Object.values(this.widgets).find(obj => obj.type === type && obj.name === name);
if (prop) {
prop.callback(value);
}
});
}
// image paste // image paste
if(ComfyApp.clipspace.imgs != undefined && this.imgs != undefined && this.widgets != null) { if(ComfyApp.clipspace.imgs != undefined && this.imgs != undefined && this.widgets != null) {
var filename = ""; var filename = "";
@ -207,7 +198,16 @@ export class ComfyApp {
} }
} }
} }
this.trigger('changed');
// ensure render after update widget_value
if(ComfyApp.clipspace.widgets != null && this.widgets != null) {
ComfyApp.clipspace.widgets.forEach(({ type, name, value }) => {
const prop = Object.values(this.widgets).find(obj => obj.type === type && obj.name === name);
if (prop && prop.type != 'button') {
prop.callback(value);
}
});
}
} }
} }
} }