2023-05-17 15:34:56 +02:00
|
|
|
<script>
|
2023-05-19 17:17:05 +02:00
|
|
|
import { tick } from "svelte";
|
|
|
|
import Spinner from "../../util/Spinner.svelte";
|
|
|
|
import { fs_node_type } from "../FilesystemUtil";
|
2023-05-17 15:34:56 +02:00
|
|
|
import FileManager from "../filemanager/FileManager.svelte";
|
|
|
|
import Audio from "./Audio.svelte";
|
2023-05-17 19:27:46 +02:00
|
|
|
import File from "./File.svelte";
|
2023-05-17 15:34:56 +02:00
|
|
|
import Image from "./Image.svelte";
|
|
|
|
import Pdf from "./PDF.svelte";
|
2023-05-17 19:27:46 +02:00
|
|
|
import Text from "./Text.svelte";
|
2023-05-17 15:34:56 +02:00
|
|
|
import Video from "./Video.svelte";
|
2023-05-19 17:17:05 +02:00
|
|
|
import Torrent from "./Torrent.svelte";
|
|
|
|
import Zip from "./Zip.svelte";
|
2023-05-17 15:34:56 +02:00
|
|
|
|
2023-05-17 22:46:27 +02:00
|
|
|
export let fs_navigator
|
2023-05-17 15:34:56 +02:00
|
|
|
export let toolbar_visible
|
|
|
|
export let edit_window
|
2023-05-19 17:17:05 +02:00
|
|
|
|
|
|
|
export let state
|
|
|
|
let viewer
|
|
|
|
let viewer_type = ""
|
|
|
|
|
|
|
|
export const state_update = async () => {
|
|
|
|
// Update the viewer area with the right viewer type
|
|
|
|
viewer_type = fs_node_type(state.base)
|
|
|
|
|
|
|
|
console.debug("Previewing file", state.base, "viewer type", viewer_type)
|
|
|
|
|
|
|
|
// Render the viewer component and set the file type
|
|
|
|
await tick()
|
|
|
|
if (viewer) {
|
|
|
|
viewer.update()
|
|
|
|
}
|
|
|
|
}
|
2023-05-17 15:34:56 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="file_preview checkers" class:toolbar_visible>
|
2023-05-19 17:17:05 +02:00
|
|
|
{#if viewer_type === ""}
|
|
|
|
<div class="center">
|
|
|
|
<Spinner></Spinner>
|
|
|
|
</div>
|
|
|
|
{:else if viewer_type === "dir"}
|
2023-05-17 15:34:56 +02:00
|
|
|
<FileManager
|
2023-05-17 22:46:27 +02:00
|
|
|
fs_navigator={fs_navigator}
|
2023-05-17 15:34:56 +02:00
|
|
|
state={state}
|
|
|
|
edit_window={edit_window}
|
|
|
|
on:loading
|
|
|
|
/>
|
2023-05-19 17:17:05 +02:00
|
|
|
{:else if viewer_type === "audio"}
|
2023-05-17 19:27:46 +02:00
|
|
|
<Audio state={state} on:open_sibling/>
|
2023-05-19 17:17:05 +02:00
|
|
|
{:else if viewer_type === "image"}
|
2023-05-17 19:27:46 +02:00
|
|
|
<Image state={state} on:open_sibling/>
|
2023-05-19 17:17:05 +02:00
|
|
|
{:else if viewer_type === "video"}
|
|
|
|
<Video state={state} bind:this={viewer} on:open_sibling/>
|
|
|
|
{:else if viewer_type === "pdf"}
|
2023-05-17 15:34:56 +02:00
|
|
|
<Pdf state={state}/>
|
2023-05-19 17:17:05 +02:00
|
|
|
{:else if viewer_type === "text"}
|
2023-05-17 19:27:46 +02:00
|
|
|
<Text state={state}/>
|
2023-05-19 17:17:05 +02:00
|
|
|
{:else if viewer_type === "torrent"}
|
|
|
|
<Torrent state={state} bind:this={viewer} on:loading on:download/>
|
|
|
|
{:else if viewer_type === "zip"}
|
|
|
|
<Zip state={state} bind:this={viewer} on:loading on:download />
|
2023-05-17 19:27:46 +02:00
|
|
|
{:else}
|
2023-05-17 19:31:42 +02:00
|
|
|
<File state={state} on:download/>
|
2023-05-17 15:34:56 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.file_preview {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
2023-05-19 17:17:05 +02:00
|
|
|
display: block;
|
2023-05-17 15:34:56 +02:00
|
|
|
min-height: 100px;
|
|
|
|
min-width: 100px;
|
2023-05-17 20:06:49 +02:00
|
|
|
transition: left 0.25s;
|
2023-05-19 17:17:05 +02:00
|
|
|
overflow: auto;
|
|
|
|
text-align: center;
|
|
|
|
border-radius: 8px;
|
2023-05-17 15:34:56 +02:00
|
|
|
border: 2px solid var(--separator);
|
|
|
|
}
|
|
|
|
|
|
|
|
.file_preview.toolbar_visible {
|
|
|
|
left: 8em;
|
|
|
|
}
|
2023-05-19 17:17:05 +02:00
|
|
|
|
|
|
|
.center{
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
margin: auto;
|
|
|
|
width: 100px;
|
|
|
|
max-width: 100%;
|
|
|
|
height: 100px;
|
|
|
|
max-height: 100%;
|
|
|
|
top: 50%;
|
|
|
|
transform: translateY(-50%);
|
|
|
|
}
|
2023-05-17 15:34:56 +02:00
|
|
|
</style>
|