-
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
2 changed files
with
50 additions
and
11 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
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,47 @@ | ||
<script lang="ts"> | ||
import { Button, Spinner, Tooltip } from "flowbite-svelte"; | ||
import { DownloadOutline } from "flowbite-svelte-icons"; | ||
import type Drive from "../../../blossom-drive-client/Drive"; | ||
import { MultiDownload } from "../../../helpers/multi-download"; | ||
import type TreeFile from "../../../blossom-drive-client/FileTree/TreeFile"; | ||
import type TreeFolder from "../../../blossom-drive-client/FileTree/TreeFolder"; | ||
import { servers } from "../../../services/servers"; | ||
export let drive: Drive; | ||
export let path: string; | ||
export let selected: string[]; | ||
$: subTree = drive.getFolder(path); | ||
let loading = false; | ||
async function download() { | ||
loading = true; | ||
const download = new MultiDownload(drive, $servers); | ||
const entries: (TreeFile | TreeFolder)[] = []; | ||
for (const entry of subTree) { | ||
if (selected.includes(entry.name)) entries.push(entry); | ||
} | ||
download.on("log", (message) => console.log(download.id, message)); | ||
if (entries.length > 0) await download.start(entries); | ||
else await download.start([subTree]); | ||
loading = false; | ||
} | ||
</script> | ||
|
||
<Button | ||
size="sm" | ||
class="!p-2" | ||
color="alternative" | ||
on:click={download} | ||
disabled={subTree.children.length === 0 || loading} | ||
> | ||
{#if loading} | ||
<Spinner size="5" /> | ||
{:else} | ||
<DownloadOutline /> | ||
{/if} | ||
</Button> | ||
<Tooltip placement="bottom">Download</Tooltip> |