Remove the need to provide a bucket ID to each API call

This commit is contained in:
2023-05-30 15:51:10 +02:00
parent 2647a22c91
commit 0299b730a5
23 changed files with 95 additions and 96 deletions

View File

@@ -1,6 +1,6 @@
<script>
import { createEventDispatcher, onMount } from 'svelte'
import { fs_file_url } from "../FilesystemUtil.js";
import { fs_path_url } from '../FilesystemUtil';
let dispatch = createEventDispatcher()
export let state
@@ -53,7 +53,7 @@ onMount(() => {
<audio
bind:this={player}
class="player"
src={fs_file_url(state.root.id, state.base.path)}
src={fs_path_url(state.base.path)}
autoplay="autoplay"
controls="controls"
on:pause={() => playing = false }

View File

@@ -9,7 +9,7 @@ export let state
<h1>{state.base.name}</h1>
<IconBlock icon_href={fs_thumbnail_url(state.root.id, state.base.path, 256, 256)}>
<IconBlock icon_href={fs_thumbnail_url(state.base.path, 256, 256)}>
Type: {state.base.file_type}<br/>
No preview is available for this file type. Download to view it locally.
<br/>

View File

@@ -18,9 +18,15 @@ export let edit_window
export let state
let viewer
let viewer_type = ""
let last_path = ""
$: state_update(state.base)
const state_update = async (base) => {
if (base.path === last_path) {
return
}
last_path = base.path
// Update the viewer area with the right viewer type
viewer_type = fs_node_type(base)

View File

@@ -1,5 +1,6 @@
<script>
import { fs_file_url } from "../FilesystemUtil.js";
import { fs_path_url } from "../FilesystemUtil";
export let state
let container
@@ -50,7 +51,7 @@ const mouseup = (e) => {
on:doubletap={() => {zoom = !zoom}}
on:mousedown={mousedown}
class="image" class:zoom
src={fs_file_url(state.root.id, state.base.path)}
src={fs_path_url(state.base.path)}
alt="no description available" />
</div>

View File

@@ -1,11 +1,12 @@
<script>
import { fs_file_url } from "../FilesystemUtil.js";
import { fs_path_url } from "../FilesystemUtil";
export let state
</script>
<iframe
class="container"
src={"/res/misc/pdf-viewer/web/viewer.html?file="+encodeURIComponent(fs_file_url(state.root.id, state.base.path))}
src={"/res/misc/pdf-viewer/web/viewer.html?file="+encodeURIComponent(fs_path_url(state.base.path))}
title="PDF viewer">
</iframe>

View File

@@ -1,5 +1,5 @@
<script>
import { fs_file_url } from "../FilesystemUtil";
import { fs_path_url } from "../FilesystemUtil";
export let state
let text_pre
@@ -14,7 +14,7 @@ export const set_file = file => {
return
}
fetch(fs_file_url(state.root.id, file.path)).then(resp => {
fetch(fs_path_url(file.path)).then(resp => {
if (!resp.ok) { return Promise.reject(resp.status) }
return resp.text()
}).then(resp => {

View File

@@ -6,7 +6,7 @@ import { copy_text } from "../../util/Util.svelte";
import TorrentItem from "./TorrentItem.svelte"
import IconBlock from "../../file_viewer/viewers/IconBlock.svelte";
import TextBlock from "../../file_viewer/viewers/TextBlock.svelte";
import { fs_file_url, fs_node_icon } from "../FilesystemUtil";
import { fs_node_icon, fs_path_url } from "../FilesystemUtil";
let dispatch = createEventDispatcher()
@@ -18,7 +18,7 @@ export const update = async () => {
dispatch("loading", true)
try {
let resp = await fetch(fs_file_url(state.root.id, state.base.path)+"?torrent_info")
let resp = await fetch(fs_path_url(state.base.path)+"?torrent_info")
if (resp.status >= 400) {
let json = await resp.json()
@@ -75,7 +75,7 @@ const copy_magnet = () => {
<h1>{state.base.name}</h1>
<IconBlock icon_href={fs_node_icon(state.root.id, state.base, 256, 256)}>
<IconBlock icon_href={fs_node_icon(state.base, 256, 256)}>
{#if status === "finished"}
Created by: {torrent.created_by}<br/>
Comment: {torrent.comment}<br/>

View File

@@ -1,6 +1,6 @@
<script>
import { onMount, createEventDispatcher, tick } from "svelte";
import { fs_file_url } from "../FilesystemUtil";
import { fs_path_url } from "../FilesystemUtil";
let dispatch = createEventDispatcher()
export let state
@@ -100,7 +100,7 @@ const fullscreen = () => {
on:play={() => playing = true }
on:ended={() => dispatch("next", {})}
>
<source src={fs_file_url(state.root.id, state.base.path)} type={state.base.file_type} />
<source src={fs_path_url(state.base.path)} type={state.base.file_type} />
</video>
{/if}
</div>

View File

@@ -4,7 +4,7 @@ import { formatDataVolume, formatDate } from "../../util/Formatting.svelte"
import ZipItem from "./ZipItem.svelte";
import IconBlock from "../../file_viewer/viewers/IconBlock.svelte";
import TextBlock from "../../file_viewer/viewers/TextBlock.svelte";
import { fs_file_url, fs_node_icon } from "../FilesystemUtil";
import { fs_node_icon, fs_path_url } from "../FilesystemUtil";
let dispatch = createEventDispatcher()
@@ -23,7 +23,7 @@ export const update = async () => {
dispatch("loading", true)
try {
let resp = await fetch(fs_file_url(state.root.id, state.base.path)+"?zip_info")
let resp = await fetch(fs_path_url(state.base.path)+"?zip_info")
if (resp.status >= 400) {
status = "parse_failed"
@@ -61,7 +61,7 @@ const recursive_size = (file) => {
<h1>{state.base.name}</h1>
<IconBlock icon_href={fs_node_icon(state.root.id, state.base, 256, 256)}>
<IconBlock icon_href={fs_node_icon(state.base, 256, 256)}>
Compressed size: {formatDataVolume(state.base.file_size, 3)}<br/>
Uncompressed size: {formatDataVolume(uncomp_size, 3)} (Ratio: {comp_ratio.toFixed(2)}x)<br/>
Uploaded on: {formatDate(state.base.created, true, true, true)}