2023-05-17 15:34:56 +02:00
|
|
|
<script>
|
|
|
|
import { createEventDispatcher } from "svelte";
|
2023-11-15 16:40:55 +01:00
|
|
|
import { generate_share_url } from "./Sharebar.svelte";
|
2023-05-17 19:27:46 +02:00
|
|
|
import { copy_text } from "../util/Util.svelte";
|
2023-05-19 21:45:42 +02:00
|
|
|
import FileStats from "./FileStats.svelte";
|
2023-05-17 15:34:56 +02:00
|
|
|
|
|
|
|
let dispatch = createEventDispatcher()
|
|
|
|
|
2023-05-17 22:46:27 +02:00
|
|
|
export let fs_navigator
|
2023-05-17 15:34:56 +02:00
|
|
|
export let state = {
|
|
|
|
base: {
|
|
|
|
type: "",
|
|
|
|
path: "",
|
|
|
|
},
|
|
|
|
children: [],
|
|
|
|
shuffle: false
|
|
|
|
}
|
|
|
|
|
2023-05-25 17:06:17 +02:00
|
|
|
export let view = "file"
|
2023-05-17 15:34:56 +02:00
|
|
|
export let details_visible = false
|
|
|
|
export let edit_window
|
|
|
|
export let edit_visible = false
|
|
|
|
|
2023-05-17 19:27:46 +02:00
|
|
|
$: share_url = generate_share_url(state.path)
|
|
|
|
let link_copied = false
|
2023-11-16 12:17:36 +01:00
|
|
|
export const copy_link = () => {
|
2023-05-17 19:27:46 +02:00
|
|
|
if (share_url === "") {
|
2023-05-25 14:47:36 +02:00
|
|
|
edit_window.edit(state.base, "share", true)
|
2023-05-17 19:27:46 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_text(share_url)
|
|
|
|
link_copied = true
|
|
|
|
setTimeout(() => {link_copied = false}, 60000)
|
|
|
|
}
|
2023-05-17 22:46:27 +02:00
|
|
|
let share = async () => {
|
2023-05-17 19:27:46 +02:00
|
|
|
if (share_url === "") {
|
2023-05-29 22:15:46 +02:00
|
|
|
edit_window.edit(state.base, true, "share")
|
2023-05-17 19:27:46 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-05-25 14:47:36 +02:00
|
|
|
if (navigator.share) {
|
2023-05-17 22:46:27 +02:00
|
|
|
await navigator.share({
|
2023-05-17 19:27:46 +02:00
|
|
|
title: state.base.name,
|
|
|
|
text: "I would like to share '" + state.base.name + "' with you",
|
|
|
|
url: share_url
|
|
|
|
})
|
2023-05-25 14:47:36 +02:00
|
|
|
} else {
|
2023-11-15 16:40:55 +01:00
|
|
|
alert("Navigator does not support sharing, use copy link button to copy the link instead")
|
2023-05-17 19:27:46 +02:00
|
|
|
}
|
|
|
|
}
|
2023-11-15 16:40:55 +01:00
|
|
|
|
|
|
|
let expanded = false
|
|
|
|
let expand = e => {
|
|
|
|
e.preventDefault()
|
|
|
|
e.stopPropagation()
|
|
|
|
expanded = !expanded
|
|
|
|
}
|
2023-05-17 15:34:56 +02:00
|
|
|
</script>
|
|
|
|
|
2023-11-15 16:40:55 +01:00
|
|
|
<div class="toolbar" class:expanded>
|
|
|
|
<div class="stats_container" on:click={expand} on:keypress={expand} role="button" tabindex="0">
|
|
|
|
<button class="button_expand" on:click={expand}>
|
|
|
|
{#if expanded}
|
|
|
|
<i class="icon">expand_more</i>
|
|
|
|
{:else}
|
|
|
|
<i class="icon">expand_less</i>
|
|
|
|
{/if}
|
|
|
|
</button>
|
|
|
|
<FileStats state={state}/>
|
|
|
|
</div>
|
2023-05-17 15:34:56 +02:00
|
|
|
|
|
|
|
<div class="separator"></div>
|
2023-11-15 15:50:54 +01:00
|
|
|
<div class="grid">
|
|
|
|
|
|
|
|
<div class="button_row">
|
|
|
|
<button on:click={() => {fs_navigator.open_sibling(-1)}}>
|
|
|
|
<i class="icon">skip_previous</i>
|
|
|
|
</button>
|
|
|
|
<button on:click={() => {state.shuffle = !state.shuffle}} class:button_highlight={state.shuffle}>
|
|
|
|
<i class="icon">shuffle</i>
|
|
|
|
</button>
|
|
|
|
<button on:click={() => {fs_navigator.open_sibling(1)}}>
|
|
|
|
<i class="icon">skip_next</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if state.path[0].id === "me"}
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={() => dispatch("search")} class:button_highlight={view === "search"}>
|
|
|
|
<i class="icon">search</i>
|
|
|
|
<span>Search</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if state.base.type === "file"}
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={() => dispatch("download")}>
|
|
|
|
<i class="icon">save</i>
|
|
|
|
<span>Download</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if share_url !== ""}
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={copy_link} class:button_highlight={link_copied}>
|
|
|
|
<i class="icon">content_copy</i>
|
|
|
|
<span><u>C</u>opy Link</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={share}>
|
|
|
|
<i class="icon">share</i>
|
|
|
|
<span>Share</span>
|
2023-11-15 16:40:55 +01:00
|
|
|
</button>
|
2023-11-15 15:50:54 +01:00
|
|
|
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={() => details_visible = !details_visible} class:button_highlight={details_visible}>
|
|
|
|
<i class="icon">help</i>
|
|
|
|
<span>Deta<u>i</u>ls</span>
|
2023-05-17 15:34:56 +02:00
|
|
|
</button>
|
2023-05-17 19:27:46 +02:00
|
|
|
|
2024-02-16 11:49:38 +01:00
|
|
|
{#if state.base.id !== "me" && state.permissions.update === true}
|
2023-11-16 12:17:36 +01:00
|
|
|
<button on:click={() => edit_window.edit(state.base, true)} class:button_highlight={edit_visible}>
|
|
|
|
<i class="icon">edit</i>
|
|
|
|
<span><u>E</u>dit</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2023-05-17 15:34:56 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.toolbar {
|
2023-11-15 15:50:54 +01:00
|
|
|
flex: 0 0 auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
overflow-y: scroll;
|
2023-11-15 16:40:55 +01:00
|
|
|
transition: max-height 0.3s;
|
2023-11-15 15:50:54 +01:00
|
|
|
}
|
|
|
|
.grid {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(8em, 1fr));
|
2023-05-17 15:34:56 +02:00
|
|
|
}
|
|
|
|
|
2023-11-15 15:50:54 +01:00
|
|
|
.separator {
|
2023-05-17 15:34:56 +02:00
|
|
|
height: 2px;
|
|
|
|
width: 100%;
|
|
|
|
background-color: var(--separator);
|
|
|
|
}
|
|
|
|
|
|
|
|
.button_row {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.button_row > * {
|
|
|
|
flex: 1 1 auto;
|
2023-11-16 12:17:36 +01:00
|
|
|
justify-content: center;
|
2023-05-17 15:34:56 +02:00
|
|
|
}
|
2023-11-15 16:40:55 +01:00
|
|
|
|
|
|
|
.stats_container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
.button_expand {
|
|
|
|
display: none;
|
|
|
|
}
|
2023-11-16 12:17:36 +01:00
|
|
|
@media (max-width: 600px) {
|
2023-11-15 16:40:55 +01:00
|
|
|
.toolbar {
|
|
|
|
overflow-y: hidden;
|
|
|
|
max-height: 2.5em;
|
|
|
|
}
|
|
|
|
.toolbar.expanded {
|
|
|
|
overflow-y: scroll;
|
2023-11-16 12:17:36 +01:00
|
|
|
max-height: 40vh;
|
2023-11-15 16:40:55 +01:00
|
|
|
}
|
|
|
|
.stats_container {
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.button_expand {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-17 15:34:56 +02:00
|
|
|
</style>
|