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

121 lines
2.5 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_node_icon } from "../FilesystemUtil";
2022-02-22 19:53:48 +01:00
let dispatch = createEventDispatcher()
export let state
2023-04-19 18:26:50 +02:00
export let show_hidden = false
2022-02-22 19:53:48 +01:00
</script>
<div class="directory">
<tr>
<td></td>
<td>Name</td>
<td>Size</td>
<td></td>
2022-02-22 19:53:48 +01:00
</tr>
{#each state.children as child, index (child.path)}
<a
2023-04-19 19:47:08 +02:00
href={state.path_root+child.path_uri}
2022-02-22 19:53:48 +01:00
on:click|preventDefault={() => {dispatch("node_click", index)}}
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, 32, 32)} class="node_icon" 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">
{#if child.id}
2023-05-11 19:07:29 +02:00
<a href="/d/{child.id}" on:click|stopPropagation class="button small_button">
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
</a>
{/if}
2023-05-11 19:07:29 +02:00
{#if state.permissions.update}
<button class="small_button" on:click|preventDefault|stopPropagation={() => {dispatch("node_settings", index)}}>
<i class="icon">edit</i>
2023-05-11 19:07:29 +02:00
</button>
{/if}
</td>
2022-02-22 19:53:48 +01:00
</a>
{/each}
</div>
<style>
.directory {
display: table;
position: relative;
overflow: hidden;
margin: 8px auto 16px auto;
text-align: left;
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;
2022-11-07 17:10:17 +01:00
max-width: 100%;
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;
color: var(--text-color);
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) {
2022-03-29 21:41:46 +02:00
background: var(--input_background);
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 {
padding: 4px;
vertical-align: middle;
}
.node_icon {
height: 32px;
width: 32px;
vertical-align: middle;
border-radius: 4px;
2022-02-22 19:53:48 +01:00
}
.node_name {
width: 100%;
overflow: hidden;
line-height: 1.2em;
word-break: break-all;
}
.node_size {
min-width: 50px;
white-space: nowrap;
}
2023-05-11 19:07:29 +02:00
.node_icons {
white-space: nowrap;
text-align: right;
}
2023-04-19 18:26:50 +02:00
.hidden {
display: none;
}
2022-02-22 19:53:48 +01:00
</style>