diff --git a/svelte/src/filesystem/Filesystem.svelte b/svelte/src/filesystem/Filesystem.svelte index 3a8e055..5c8c561 100644 --- a/svelte/src/filesystem/Filesystem.svelte +++ b/svelte/src/filesystem/Filesystem.svelte @@ -7,7 +7,7 @@ import Breadcrumbs from "./Breadcrumbs.svelte"; import DetailsWindow from "./DetailsWindow.svelte"; import FilePreview from "./viewers/FilePreview.svelte"; import FSUploadWidget from "./upload_widget/FSUploadWidget.svelte"; -import { fs_path_url, type FSPath } from "./FilesystemAPI"; +import { fs_download, type FSPath } from "./FilesystemAPI"; import Menu from "./Menu.svelte"; import { FSNavigator } from "./FSNavigator" import { writable } from "svelte/store"; @@ -68,7 +68,7 @@ const keydown = (e: KeyboardEvent) => { } break; case "s": - download() + fs_download(nav.base) break; case "r": nav.shuffle = !nav.shuffle @@ -125,21 +125,6 @@ const keydown = (e: KeyboardEvent) => { e.preventDefault() } }; - -const download = () => { - const a = document.createElement("a") - - if (nav.base.type === "file") { - a.href = fs_path_url(nav.base.path) + "?attach" - a.download = nav.base.name - } else if (nav.base.type === "dir") { - a.href = fs_path_url(nav.base.path) + "?bulk_download" - a.download = nav.base.name+".zip" - } - - a.click() - a.remove() -} @@ -159,7 +144,7 @@ const download = () => { bind:details_visible={details_visible} edit_window={edit_window} bind:edit_visible={edit_visible} - on:download={download} + on:download={() => fs_download(nav.base)} />
@@ -169,7 +154,7 @@ const download = () => { upload_widget={upload_widget} edit_window={edit_window} on:open_sibling={e => nav.open_sibling(e.detail)} - on:download={download} + on:download={() => fs_download(nav.base)} on:details={() => details_visible = !details_visible} />
diff --git a/svelte/src/filesystem/FilesystemAPI.ts b/svelte/src/filesystem/FilesystemAPI.ts index 25f22d4..0fb54d1 100644 --- a/svelte/src/filesystem/FilesystemAPI.ts +++ b/svelte/src/filesystem/FilesystemAPI.ts @@ -351,3 +351,18 @@ export const fs_share_path = (path: FSNode[]): string => { return share_url } + +export const fs_download = (node: FSNode) => { + const a = document.createElement("a") + + if (node.type === "file") { + a.href = fs_path_url(node.path) + "?attach" + a.download = node.name + } else if (node.type === "dir") { + a.href = fs_path_url(node.path) + "?bulk_download" + a.download = node.name + ".zip" + } + + a.click() + a.remove() +} diff --git a/svelte/src/filesystem/filemanager/CompactView.svelte b/svelte/src/filesystem/filemanager/CompactView.svelte index 9b66214..38eeb3d 100644 --- a/svelte/src/filesystem/filemanager/CompactView.svelte +++ b/svelte/src/filesystem/filemanager/CompactView.svelte @@ -2,6 +2,7 @@ import { createEventDispatcher } from "svelte"; import { fs_encode_path, fs_node_icon } from "filesystem/FilesystemAPI" import type { FSNavigator } from "filesystem/FSNavigator"; +import { FileAction } from "./FileManagerLib"; let dispatch = createEventDispatcher() @@ -15,8 +16,8 @@ export let hide_edit = false {#each $nav.children as child, index (child.path)} dispatch("node_click", {index: index, original: e})} - on:contextmenu={e => dispatch("node_context", {index: index, original: e})} + on:click={e => dispatch("file", {index: index, action: FileAction.Click, original: e})} + on:contextmenu={e => dispatch("file", {index: index, action: FileAction.Context, original: e})} class="node" class:node_selected={child.fm_selected} class:hidden={child.name.startsWith(".") && !show_hidden} @@ -28,7 +29,7 @@ export let hide_edit = false {#if child.id} {dispatch("node_share_click", {index: index, original: e})}} + on:click={e => dispatch("file", {index: index, action: FileAction.Share, original: e})} class="button flat action_button" > share @@ -36,10 +37,20 @@ export let hide_edit = false {/if} {#if $nav.permissions.write && !hide_edit} - {/if} + + {/each} diff --git a/svelte/src/filesystem/filemanager/FileManager.svelte b/svelte/src/filesystem/filemanager/FileManager.svelte index 29624e0..dc42b75 100644 --- a/svelte/src/filesystem/filemanager/FileManager.svelte +++ b/svelte/src/filesystem/filemanager/FileManager.svelte @@ -1,11 +1,5 @@ -