Fix image upload

This commit is contained in:
space-nuko
2023-05-13 15:14:52 -05:00
parent f66df94c36
commit 0656ae1d3a
5 changed files with 92 additions and 45 deletions

View File

@@ -3,6 +3,7 @@
import type { WidgetLayout } from "$lib/stores/layoutState";
import type { Writable } from "svelte/store";
import type { ComfyGalleryNode, ComfyImageUploadNode, GalleryOutputEntry, MultiImageData } from "$lib/nodes/ComfyWidgetNodes";
import notify from "$lib/notify";
export let widget: WidgetLayout | null = null;
export let isMobile: boolean = false;
@@ -32,11 +33,27 @@
}
};
function onUploading() {
console.warn("ONUPLOAD!!!")
$nodeValue = []
}
function onChange(e: CustomEvent<GalleryOutputEntry[]>) {
console.warn("ONCHANGE!!!", e.detail)
$nodeValue = e.detail || []
}
function onUploaded(e: CustomEvent<GalleryOutputEntry[]>) {
console.warn("ONUPLOADED!!!", e.detail)
$nodeValue = e.detail || []
}
function onUploadError(e: CustomEvent<any>) {
console.warn("ONUPLOADERRO!!!", e.detail)
notify(`Error uploading image to ComfyUI: ${e.detail}`)
$nodeValue = []
}
function onClear(e: CustomEvent<GalleryOutputEntry[]>) {
console.warn("ONCLEAR!!!", e.detail)
$nodeValue = []
@@ -44,16 +61,19 @@
</script>
<div class="wrapper gradio-file comfy-image-upload" style={widget.attrs.style}>
{#if widget && node && nodeValue}
<ImageUpload value={$nodeValue}
{#if widget && node}
<ImageUpload value={$nodeValue || []}
bind:imgWidth
bind:imgHeight
bind:fileCount={node.properties.fileCount}
elem_classes={widget.attrs.classes.split(",")}
style={widget.attrs.style}
label={widget.attrs.title}
on:change={onChange}
on:clear={onClear}/>
on:uploading={onUploading}
on:uploaded={onUploaded}
on:upload_error={onUploadError}
on:clear={onClear}
on:change={onChange}/>
{/if}
</div>