Files
fnx_web/svelte/src/filesystem/filemanager/ListView.svelte

143 lines
3.3 KiB
Svelte
Raw Normal View History

2022-02-22 19:53:48 +01:00
<script>
import { createEventDispatcher } from "svelte";
import { formatDataVolume } from "../../util/Formatting.svelte";
import { fs_encode_path, fs_node_icon } from "../FilesystemUtil";
2022-02-22 19:53:48 +01:00
let dispatch = createEventDispatcher()
export let nav
2023-04-19 18:26:50 +02:00
export let show_hidden = false
export let large_icons = false
2024-07-11 13:30:46 +02:00
export let hide_edit = false
export let hide_branding = false
2022-02-22 19:53:48 +01:00
</script>
<div class="directory">
<tr>
<td></td>
<td>Name</td>
<td>Size</td>
<td>Actions</td>
2022-02-22 19:53:48 +01:00
</tr>
{#each $nav.children as child, index (child.path)}
2022-02-22 19:53:48 +01:00
<a
href={"/d"+fs_encode_path(child.path)}
2024-07-11 13:30:46 +02:00
on:click|preventDefault={() => dispatch("node_click", index)}
on:contextmenu={e => dispatch("node_context", {event: e, index: index})}
2022-02-22 19:53:48 +01:00
class="node"
2023-04-19 18:26:50 +02:00
class:node_selected={child.fm_selected}
class:hidden={child.name.startsWith(".") && !show_hidden}
>
2022-02-22 19:53:48 +01:00
<td>
<img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons alt="icon"/>
2022-02-22 19:53:48 +01:00
</td>
<td class="node_name">
{child.name}
</td>
<td class="node_size">
{#if child.type === "file"}
{formatDataVolume(child.file_size, 3)}
{/if}
</td>
2023-05-11 19:07:29 +02:00
<td class="node_icons">
<div class="icons_wrap">
{#if child.abuse_type !== undefined}
<i class="icon" title="This file / directory has received an abuse report. It cannot be shared">block</i>
{:else if child.id}
<a
href="/d/{child.id}"
on:click|preventDefault|stopPropagation={() => {dispatch("node_share_click", index)}}
class="button action_button"
>
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
</a>
{/if}
{#if child.properties && child.properties.branding_enabled && !hide_branding}
<button class="action_button" on:click|preventDefault|stopPropagation={() => dispatch("node_branding", index)}>
<i class="icon">palette</i>
</button>
{/if}
{#if $nav.permissions.update && !hide_edit}
<button class="action_button" on:click|preventDefault|stopPropagation={() => dispatch("node_settings", index)}>
<i class="icon">edit</i>
</button>
{/if}
</div>
</td>
2022-02-22 19:53:48 +01:00
</a>
{/each}
</div>
<style>
.directory {
display: table;
margin: 8px auto 16px auto;
2022-03-29 21:41:46 +02:00
background: var(--body_color);
2022-02-22 19:53:48 +01:00
border-collapse: collapse;
border-radius: 8px;
max-width: 99%;
2022-02-22 19:53:48 +01:00
width: 1000px;
}
.directory > * {
display: table-row;
}
.directory > * > * {
display: table-cell;
}
.node {
display: table-row;
text-decoration: none;
2024-03-15 13:59:34 +01:00
color: var(--body_text-color);
2022-02-22 19:53:48 +01:00
padding: 6px;
}
.node:not(:last-child) {
2022-03-29 21:41:46 +02:00
border-bottom: 1px solid var(--separator);
2022-02-22 19:53:48 +01:00
}
.node:hover:not(.node_selected) {
background: var(--input_hover_background);
2022-03-29 21:41:46 +02:00
color: var(--input_text);
2022-02-22 19:53:48 +01:00
text-decoration: none;
}
.node.node_selected {
background-color: var(--highlight_color) !important;
color: var(--highlight_text_color);
}
td {
vertical-align: middle;
}
.node_icon {
height: 32px;
width: 32px;
vertical-align: middle;
border-radius: 4px;
margin: 2px;
2022-02-22 19:53:48 +01:00
}
.node_name {
width: 100%;
line-height: 1.2em;
word-break: break-all;
}
.node_size {
min-width: 50px;
white-space: nowrap;
}
.icons_wrap {
display: flex;
flex-direction: row;
justify-content: end;
2023-05-11 19:07:29 +02:00
}
2023-04-19 18:26:50 +02:00
.hidden {
display: none;
}
/* Large icon mode only supported on wide screens */
@media (min-width: 500px) {
.node_icon.large_icons {
height: 64px;
width: 64px;
}
}
2022-02-22 19:53:48 +01:00
</style>