diff --git a/src/blossom-drive-client/Upload.ts b/src/blossom-drive-client/Upload.ts index 6dde528..2b4ba56 100644 --- a/src/blossom-drive-client/Upload.ts +++ b/src/blossom-drive-client/Upload.ts @@ -23,6 +23,12 @@ export default class Upload extends EventEmitter { /** file id -> server -> status */ progress: Record> = {}; + get totalProgress() { + return ( + Object.values(this.progress).reduce((v, u) => v + Object.values(u).filter((s) => !!s.blob).length, 0) / + (this.files.length * this.servers.length) + ); + } constructor(drive: Drive | EncryptedDrive, basePath: string, servers: string[], signer: Signer) { super(); @@ -71,6 +77,7 @@ export default class Upload extends EventEmitter { const token = await BlossomClient.getUploadAuth(_file, this.signer, `Upload ${_file.name}`); if (!this.progress[upload.id]) this.progress[upload.id] = {}; + this.emit("progress", this.progress); for (const server of this.servers) { try { @@ -81,10 +88,10 @@ export default class Upload extends EventEmitter { size: blob.size, type: upload.file.type || mime.getType(upload.file.name) || blob.type || "", }); - this.emit("progress", this.progress); } catch (error) { if (error instanceof Error) this.progress[upload.id][server] = { error }; } + this.emit("progress", this.progress); } } diff --git a/src/components/UploadDetailsModal/UploadDetailsModal.svelte b/src/components/UploadDetailsModal/UploadDetailsModal.svelte new file mode 100644 index 0000000..ecf0932 --- /dev/null +++ b/src/components/UploadDetailsModal/UploadDetailsModal.svelte @@ -0,0 +1,51 @@ + + + +

+ Uploading {upload.files.length} files to {upload.drive.name} +

+
+ {#each upload.files as file} + + {/each} +
+ {#if !running} + + {/if} +
diff --git a/src/components/UploadDetailsModal/UploadFileDetails.svelte b/src/components/UploadDetailsModal/UploadFileDetails.svelte new file mode 100644 index 0000000..1d172d5 --- /dev/null +++ b/src/components/UploadDetailsModal/UploadFileDetails.svelte @@ -0,0 +1,34 @@ + + +
+
+

{file.path}

+
+ {#if progress} + {#each Object.entries(progress) as [url, status]} + {#if status.blob} + + {:else if status.error} + + {:else} + + {/if} + {/each} + {:else} + + {/if} +
+ {#if servers !== 0 && servers !== upload.servers.length} + + {/if} +
diff --git a/src/components/UploadDrawer.svelte b/src/components/UploadDrawer.svelte index df75e3b..4634827 100644 --- a/src/components/UploadDrawer.svelte +++ b/src/components/UploadDrawer.svelte @@ -1,7 +1,12 @@ {#if $uploads.length > 0} @@ -21,13 +26,23 @@ {#if $drawerOpen}
{#each $uploads as upload} - + { + selectedUpload = upload; + uploadDetails = true; + }} + /> {/each}
{/if}
{/if} +{#if uploadDetails} + +{/if} +