-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
161 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/components/UploadDetailsModal/UploadDetailsModal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
import { Button, Modal, Progressbar } from "flowbite-svelte"; | ||
import { onMount } from "svelte"; | ||
import type Upload from "../../blossom-drive-client/Upload"; | ||
import { CheckOutline, ClockOutline } from "flowbite-svelte-icons"; | ||
import UploadFileDetails from "./UploadFileDetails.svelte"; | ||
export let open = false; | ||
export let upload: Upload; | ||
let running = upload.running; | ||
function updateRunning() { | ||
running = upload.running; | ||
} | ||
let complete = upload.complete; | ||
function updateComplete() { | ||
complete = upload.complete; | ||
} | ||
let progress = upload.progress; | ||
function updateProgress() { | ||
progress = upload.progress; | ||
} | ||
updateProgress(); | ||
onMount(() => { | ||
upload.on("progress", updateProgress); | ||
upload.on("complete", updateComplete); | ||
upload.on("start", updateRunning); | ||
return () => { | ||
upload.off("progress", updateProgress); | ||
upload.off("complete", updateComplete); | ||
upload.on("start", updateRunning); | ||
}; | ||
}); | ||
</script> | ||
|
||
<Modal bind:open size="lg" title="Upload Progress" outsideclose> | ||
<p class="text-base leading-relaxed text-gray-800 dark:text-gray-200"> | ||
Uploading {upload.files.length} files to {upload.drive.name} | ||
</p> | ||
<div class="flex flex-col gap-2"> | ||
{#each upload.files as file} | ||
<UploadFileDetails {upload} {file} progress={progress[file.id]} /> | ||
{/each} | ||
</div> | ||
{#if !running} | ||
<Button slot="footer" on:click={() => upload.upload()}>Start Upload</Button> | ||
{/if} | ||
</Modal> |
34 changes: 34 additions & 0 deletions
34
src/components/UploadDetailsModal/UploadFileDetails.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import { Progressbar, Spinner } from "flowbite-svelte"; | ||
import { CheckOutline, InfoCircleOutline } from "flowbite-svelte-icons"; | ||
import type Upload from "../../blossom-drive-client/Upload"; | ||
export let upload: Upload; | ||
export let file: Upload["files"][0]; | ||
export let progress: Upload["progress"][string] | undefined; | ||
$: servers = progress ? Object.keys(progress).length : 0; | ||
</script> | ||
|
||
<div class="flex flex-col gap-1"> | ||
<div class="flex gap-1"> | ||
<p>{file.path}</p> | ||
<div class="flex-1" /> | ||
{#if progress} | ||
{#each Object.entries(progress) as [url, status]} | ||
{#if status.blob} | ||
<CheckOutline class="h-6 w-6 text-green-500" /> | ||
{:else if status.error} | ||
<InfoCircleOutline class="h-6 w-6 text-red-500" /> | ||
{:else} | ||
<Spinner size="6" /> | ||
{/if} | ||
{/each} | ||
{:else} | ||
<Spinner size="6" /> | ||
{/if} | ||
</div> | ||
{#if servers !== 0 && servers !== upload.servers.length} | ||
<Progressbar progress={(servers / upload.servers.length) * 100} /> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts"> | ||
import { Progressbar, Spinner } from "flowbite-svelte"; | ||
import type Upload from "../blossom-drive-client/Upload"; | ||
import { onMount } from "svelte"; | ||
import { CheckOutline } from "flowbite-svelte-icons"; | ||
export let upload: Upload; | ||
let complete = upload.complete; | ||
function updateComplete() { | ||
complete = upload.complete; | ||
} | ||
let progress = upload.totalProgress; | ||
function updateProgress() { | ||
progress = upload.totalProgress; | ||
} | ||
updateProgress(); | ||
onMount(() => { | ||
upload.on("progress", updateProgress); | ||
upload.on("complete", updateComplete); | ||
return () => { | ||
upload.off("progress", updateProgress); | ||
upload.off("complete", updateComplete); | ||
}; | ||
}); | ||
</script> | ||
|
||
<button class="flex flex-col gap-1 rounded-md p-2 hover:bg-gray-300 dark:hover:bg-gray-700" on:click> | ||
<div class="flex justify-between"> | ||
<p>Uploaded {upload.files.length} files</p> | ||
{#if complete} | ||
<CheckOutline class="h-6 w-6 text-green-500" /> | ||
{:else} | ||
<Spinner size="6" /> | ||
{/if} | ||
</div> | ||
{#if !complete} | ||
<Progressbar progress={progress * 100} /> | ||
{/if} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters