2024-07-11 13:30:46 +02:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte";
|
2024-09-11 14:18:03 +02:00
|
|
|
import { FSNavigator } from "../../filesystem/FSNavigator.ts"
|
2024-11-19 15:31:51 +01:00
|
|
|
import { fs_encode_path, fs_node_icon } from "../../filesystem/FilesystemAPI.mjs";
|
2024-09-11 14:18:03 +02:00
|
|
|
import Button from "../../layout/Button.svelte";
|
|
|
|
import CreateDirectory from "../../filesystem/filemanager/CreateDirectory.svelte";
|
|
|
|
import FSUploadWidget from "../../filesystem/upload_widget/FSUploadWidget.svelte";
|
2024-09-12 15:11:50 +02:00
|
|
|
import { drop_target } from "../../lib/DropTarget.ts"
|
2024-07-11 13:30:46 +02:00
|
|
|
|
2024-08-30 15:35:53 +02:00
|
|
|
const nav = new FSNavigator(false)
|
2024-09-10 15:22:26 +02:00
|
|
|
let upload_widget
|
|
|
|
var show_hidden = false
|
|
|
|
var creating_dir = false
|
|
|
|
|
|
|
|
onMount(() => nav.navigate("/me", false))
|
2024-07-11 13:30:46 +02:00
|
|
|
</script>
|
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
<div class="wrapper" use:drop_target={{upload: (files) => upload_widget.upload_files(files)}}>
|
|
|
|
<div class="toolbar">
|
2024-11-19 15:31:51 +01:00
|
|
|
{#if $nav.permissions.write}
|
2024-09-10 18:51:13 +02:00
|
|
|
<Button
|
|
|
|
click={() => upload_widget.pick_files()}
|
|
|
|
icon="cloud_upload"
|
|
|
|
title="Upload files to this directory"
|
|
|
|
label="Upload files"
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
click={() => {creating_dir = !creating_dir}}
|
|
|
|
highlight={creating_dir}
|
|
|
|
icon="create_new_folder"
|
|
|
|
title="Create folder"
|
|
|
|
label="Create folder"
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<div class="toolbar_spacer"></div>
|
|
|
|
|
2024-09-10 15:22:26 +02:00
|
|
|
<Button
|
2024-09-10 18:51:13 +02:00
|
|
|
click={() => {show_hidden = !show_hidden}}
|
|
|
|
highlight={show_hidden}
|
|
|
|
icon={show_hidden ? "visibility_off" : "visibility"}
|
|
|
|
title="Show hidden files and directories"
|
2024-09-10 15:22:26 +02:00
|
|
|
/>
|
|
|
|
<Button
|
2024-09-10 18:51:13 +02:00
|
|
|
click={() => nav.reload()}
|
|
|
|
icon="refresh"
|
|
|
|
title="Refresh directory listing"
|
2024-09-10 15:22:26 +02:00
|
|
|
/>
|
2024-09-10 18:51:13 +02:00
|
|
|
</div>
|
2024-09-10 15:22:26 +02:00
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
{#if creating_dir}
|
|
|
|
<CreateDirectory nav={nav} />
|
|
|
|
{/if}
|
2024-09-10 15:22:26 +02:00
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
<div class="directory">
|
|
|
|
{#each $nav.children as child (child.path)}
|
|
|
|
<a
|
|
|
|
href={"/d"+fs_encode_path(child.path)}
|
|
|
|
class="node"
|
|
|
|
class:node_selected={child.fm_selected}
|
|
|
|
class:hidden={child.name.startsWith(".")}
|
|
|
|
>
|
|
|
|
<img src={fs_node_icon(child, 64, 64)} class="node_icon" alt="icon"/>
|
2024-07-11 17:45:10 +02:00
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
<div class="node_name">
|
|
|
|
{child.name}
|
|
|
|
</div>
|
2024-07-11 17:45:10 +02:00
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
{#if child.id}
|
|
|
|
<a href="/d/{child.id}" class="button action_button">
|
|
|
|
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
|
|
|
|
</a>
|
|
|
|
{/if}
|
|
|
|
</a>
|
|
|
|
{/each}
|
|
|
|
</div>
|
2024-07-11 17:45:10 +02:00
|
|
|
</div>
|
|
|
|
|
2024-09-10 18:51:13 +02:00
|
|
|
<FSUploadWidget nav={nav} bind:this={upload_widget} />
|
2024-09-10 15:22:26 +02:00
|
|
|
|
2024-07-11 17:45:10 +02:00
|
|
|
<style>
|
2024-09-10 18:51:13 +02:00
|
|
|
.wrapper {
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
2024-09-10 15:22:26 +02:00
|
|
|
.toolbar {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
width: 100%;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
.toolbar > * { flex: 0 0 auto; }
|
|
|
|
.toolbar_spacer {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2024-07-11 17:45:10 +02:00
|
|
|
.directory {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
flex-wrap: wrap;
|
2024-08-29 15:44:17 +02:00
|
|
|
gap: 6px;
|
2024-09-10 15:22:26 +02:00
|
|
|
margin-top: 6px;
|
2024-07-11 17:45:10 +02:00
|
|
|
}
|
|
|
|
.node {
|
|
|
|
display: flex;
|
|
|
|
flex: 1 1 auto;
|
|
|
|
flex-direction: row;
|
|
|
|
align-content: center;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
text-decoration: none;
|
|
|
|
color: var(--body_text-color);
|
|
|
|
gap: 2px;
|
|
|
|
padding: 2px;
|
|
|
|
border-radius: 8px;
|
2024-08-13 11:58:11 +02:00
|
|
|
width: 250px;
|
2024-07-11 17:45:10 +02:00
|
|
|
max-width: 100%;
|
|
|
|
border: 1px solid var(--input_background);
|
|
|
|
}
|
|
|
|
.node:hover {
|
|
|
|
background: var(--input_hover_background);
|
|
|
|
color: var(--input_text);
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
.node > * {
|
|
|
|
flex: 0 0 auto;
|
|
|
|
}
|
|
|
|
.node_icon {
|
|
|
|
height: 32px;
|
|
|
|
width: 32px;
|
|
|
|
vertical-align: middle;
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
.node_name {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
word-break: break-all;
|
|
|
|
line-height: 1.2em;
|
|
|
|
}
|
|
|
|
.action_button {
|
|
|
|
margin: 0;
|
|
|
|
background: none;
|
|
|
|
color: var(--body_text_color);
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|