|
1 | 1 | <script lang="ts">
|
2 |
| - import SpeedDialMenu from "../../components/SpeedDialMenu.svelte"; |
3 |
| - import { Button, CloseButton, Select, Spinner } from "flowbite-svelte"; |
4 |
| - import { TrashBinSolid } from "flowbite-svelte-icons"; |
| 2 | + import { Button, CloseButton, Select, Spinner, Tooltip } from "flowbite-svelte"; |
| 3 | + import { |
| 4 | + ArrowLeftToBracketOutline, |
| 5 | + CogOutline, |
| 6 | + DownloadOutline, |
| 7 | + EditOutline, |
| 8 | + FileImportOutline, |
| 9 | + FolderArrowRightOutline, |
| 10 | + FolderPlusOutline, |
| 11 | + InfoCircleOutline, |
| 12 | + LinkOutline, |
| 13 | + ListSolid, |
| 14 | + TrashBinOutline, |
| 15 | + TrashBinSolid, |
| 16 | + } from "flowbite-svelte-icons"; |
5 | 17 |
|
6 | 18 | import FileCard from "../../components/FileCard.svelte";
|
7 | 19 | import FolderCard from "../../components/FolderCard.svelte";
|
|
15 | 27 | import TreeFile from "../../blossom-drive-client/FileTree/TreeFile";
|
16 | 28 | import { joinPath } from "../../blossom-drive-client/FileTree/methods";
|
17 | 29 | import DriveEditModal from "../../components/DriveEditModal.svelte";
|
| 30 | + import NewFolderModal from "../../components/NewFolderModal.svelte"; |
| 31 | + import UploadFileModal from "../../components/UploadFileModal.svelte"; |
| 32 | + import { servers } from "../../services/servers"; |
| 33 | + import { getBlobURL } from "../../helpers/blob"; |
18 | 34 |
|
19 | 35 | export let currentPath: string;
|
20 | 36 | export let drive: Drive;
|
21 | 37 | $: readableDrive = getReadableDrive(drive);
|
22 | 38 | $: subTree = $readableDrive.getFolder(currentPath);
|
23 | 39 |
|
24 | 40 | let editModal = false;
|
| 41 | + let newFolderModal = false; |
| 42 | + let uploadFilesModal = false; |
25 | 43 |
|
26 | 44 | let detailsModal = false;
|
27 | 45 | let detailsFile: TreeFile | null = null;
|
| 46 | + function showDetailsModal() { |
| 47 | + if (selected[0]) { |
| 48 | + const file = subTree.get(selected[0]); |
| 49 | + if (file instanceof TreeFile) { |
| 50 | + detailsFile = file; |
| 51 | + detailsModal = true; |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +
|
28 | 56 | let confirmDelete = false;
|
29 | 57 | let selected: string[] = [];
|
30 | 58 | function toggleSelect(e: CustomEvent<string>) {
|
|
54 | 82 | await drive.save();
|
55 | 83 | }
|
56 | 84 |
|
| 85 | + function copySelectedLink() { |
| 86 | + if (selected[0]) { |
| 87 | + const file = subTree.get(selected[0]); |
| 88 | + if (file instanceof TreeFile) { |
| 89 | + const url = getBlobURL(file, $servers[0]); |
| 90 | + if (url) window.navigator.clipboard.writeText(url); |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | +
|
57 | 95 | async function deleteSelected() {
|
58 | 96 | for (const name of selected) drive.remove(joinPath(currentPath, name));
|
59 | 97 | selected = [];
|
|
152 | 190 | // handleEvent(draft);
|
153 | 191 | // await draft.publish();
|
154 | 192 | // }
|
| 193 | +
|
| 194 | + let folderInput: HTMLInputElement; |
| 195 | + let filesInput: HTMLInputElement; |
155 | 196 | </script>
|
156 | 197 |
|
157 | 198 | {#if !drive}
|
158 | 199 | <Spinner />
|
159 | 200 | {:else}
|
160 |
| - <main class="flex flex-grow flex-col gap-4 p-4" on:drop={drop} on:dragover={dragover}> |
161 |
| - <div class="flex gap-2"> |
162 |
| - <PathBreadcrumbs root={drive.name ?? "Drive"} /> |
163 |
| - <div class="flex-1" /> |
164 |
| - <Button on:click={() => (editModal = true)} color="alternative" size="xs">Edit</Button> |
| 201 | + <main class="flex flex-grow flex-col" on:drop={drop} on:dragover={dragover}> |
| 202 | + <div class="flex items-center gap-2 border-b border-gray-200 p-2 dark:border-gray-800"> |
| 203 | + <PathBreadcrumbs root={drive.name ?? "Drive"} class="mx-2" /> |
165 | 204 | <Button href="#/history/{drive.address}" color="alternative" size="xs">History</Button>
|
| 205 | + |
| 206 | + <div class="flex-1" /> |
| 207 | + |
| 208 | + {#if selected.length === 0} |
| 209 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => (newFolderModal = true)}> |
| 210 | + <FolderPlusOutline /> |
| 211 | + </Button> |
| 212 | + <Tooltip placement="bottom">Create Folder</Tooltip> |
| 213 | + |
| 214 | + <div class="h-8 border border-gray-200 dark:border-gray-800" /> |
| 215 | + |
| 216 | + <input class="hidden" type="file" webkitdirectory multiple bind:this={folderInput} /> |
| 217 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => folderInput.click()}> |
| 218 | + <FolderArrowRightOutline /> |
| 219 | + </Button> |
| 220 | + <Tooltip placement="bottom">Upload Folder</Tooltip> |
| 221 | + |
| 222 | + <input class="hidden" type="file" multiple bind:this={filesInput} /> |
| 223 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => filesInput.click()}> |
| 224 | + <FileImportOutline /> |
| 225 | + </Button> |
| 226 | + <Tooltip placement="bottom">Upload Files</Tooltip> |
| 227 | + {:else} |
| 228 | + {#if selected.length === 1} |
| 229 | + <Button size="sm" class="!p-2" color="alternative" disabled> |
| 230 | + <DownloadOutline /> |
| 231 | + </Button> |
| 232 | + <Tooltip placement="bottom">Download</Tooltip> |
| 233 | + |
| 234 | + <Button size="sm" class="!p-2" color="alternative" on:click={copySelectedLink}> |
| 235 | + <LinkOutline /> |
| 236 | + </Button> |
| 237 | + <Tooltip placement="bottom">Copy Link</Tooltip> |
| 238 | + |
| 239 | + <div class="h-8 border border-gray-200 dark:border-gray-800" /> |
| 240 | + |
| 241 | + <Button size="sm" class="!p-2" color="alternative" disabled> |
| 242 | + <ArrowLeftToBracketOutline /> |
| 243 | + </Button> |
| 244 | + <Tooltip placement="bottom">Move</Tooltip> |
| 245 | + |
| 246 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => (renameModal = true)}> |
| 247 | + <EditOutline /> |
| 248 | + </Button> |
| 249 | + <Tooltip placement="bottom">Rename</Tooltip> |
| 250 | + |
| 251 | + <Button size="sm" class="!p-2" color="alternative" on:click={showDetailsModal}> |
| 252 | + <InfoCircleOutline /> |
| 253 | + </Button> |
| 254 | + <Tooltip placement="bottom">Details</Tooltip> |
| 255 | + {/if} |
| 256 | + |
| 257 | + <div class="h-8 border border-gray-200 dark:border-gray-800" /> |
| 258 | + |
| 259 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => (confirmDelete = true)}> |
| 260 | + <TrashBinOutline /> |
| 261 | + </Button> |
| 262 | + <Tooltip placement="bottom">Delete</Tooltip> |
| 263 | + {/if} |
| 264 | + |
| 265 | + <div class="h-8 border border-gray-200 dark:border-gray-800" /> |
| 266 | + |
| 267 | + <Button size="sm" class="!p-2" color="alternative" disabled> |
| 268 | + <ListSolid /> |
| 269 | + </Button> |
| 270 | + <Tooltip placement="bottom">Change Layout</Tooltip> |
| 271 | + |
| 272 | + <Button size="sm" class="!p-2" color="alternative" on:click={() => (editModal = true)}> |
| 273 | + <CogOutline /> |
| 274 | + </Button> |
| 275 | + <Tooltip placement="bottom">Drive Settings</Tooltip> |
166 | 276 | </div>
|
167 |
| - <div class="flex items-center gap-2 rounded-lg border border-gray-200 p-1 dark:border-gray-800"> |
| 277 | + <div class="flex items-center gap-2 rounded-lg px-4 pt-2"> |
168 | 278 | {#if selected.length > 0}
|
169 | 279 | <p class="ml-2">{selected.length} selected</p>
|
170 | 280 | <Button size="sm" color="none" class="!p-2" on:click={() => (confirmDelete = true)}><TrashBinSolid /></Button>
|
|
180 | 290 | <Button size="sm" on:click={() => (filterType = "")} color="alternative">Clear Filter</Button>
|
181 | 291 | {/if}
|
182 | 292 | {/if}
|
| 293 | + |
| 294 | + <div class="mx-auto"></div> |
183 | 295 | </div>
|
184 |
| - <div class="flex flex-wrap items-start gap-4"> |
| 296 | + <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 297 | + <!-- svelte-ignore a11y-no-static-element-interactions --> |
| 298 | + <div class="flex flex-1 flex-wrap items-start gap-4 p-4" on:click={() => (selected = [])}> |
185 | 299 | {#each folders as folder}
|
186 | 300 | <FolderCard
|
187 | 301 | {folder}
|
|
225 | 339 | </div>
|
226 | 340 | </main>
|
227 | 341 | {/if}
|
228 |
| -<SpeedDialMenu drive={drive ?? undefined} path={currentPath} /> |
229 | 342 |
|
230 | 343 | {#if confirmDelete}
|
231 | 344 | <DeleteModal bind:open={confirmDelete} on:yes={deleteSelected} />
|
|
242 | 355 | {#if editModal}
|
243 | 356 | <DriveEditModal bind:open={editModal} drive={$readableDrive} />
|
244 | 357 | {/if}
|
| 358 | + |
| 359 | +{#if newFolderModal && drive} |
| 360 | + <NewFolderModal bind:open={newFolderModal} {drive} path={currentPath} /> |
| 361 | +{/if} |
| 362 | + |
| 363 | +{#if uploadFilesModal} |
| 364 | + <UploadFileModal bind:open={uploadFilesModal} {drive} path={currentPath} /> |
| 365 | +{/if} |
0 commit comments