Added streaming up- and downloads, fixed file sizes and added a (not working) dashboard

This commit is contained in:
Mawoka
2023-05-29 16:24:38 +02:00
parent ef73234606
commit a8b59ce6f5
17 changed files with 414 additions and 147 deletions
+2
View File
@@ -42,6 +42,7 @@
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@unlazy/svelte": "^0.8.9",
"@uppy/compressor": "^1.0.2",
"@uppy/core": "^3.2.0",
"@uppy/dashboard": "^3.4.0",
@@ -89,6 +90,7 @@
"svelte-tippy": "^1.3.2",
"swiper": "^8.4.7",
"tailwindcss": "^3.3.1",
"thumbhash": "^0.1.1",
"tippy.js": "^6.3.7",
"tslib": "^2.5.0",
"typescript": "~5.0.4",
+56
View File
@@ -29,6 +29,7 @@ specifiers:
'@types/ua-parser-js': ^0.7.36
'@typescript-eslint/eslint-plugin': ^5.59.0
'@typescript-eslint/parser': ^5.59.0
'@unlazy/svelte': ^0.8.9
'@uppy/compressor': ^1.0.2
'@uppy/core': ^3.2.0
'@uppy/dashboard': ^3.4.0
@@ -77,6 +78,7 @@ specifiers:
svelte-tippy: ^1.3.2
swiper: ^8.4.7
tailwindcss: ^3.3.1
thumbhash: ^0.1.1
tippy.js: ^6.3.7
tslib: ^2.5.0
typescript: ~5.0.4
@@ -117,6 +119,7 @@ devDependencies:
'@types/ua-parser-js': 0.7.36
'@typescript-eslint/eslint-plugin': 5.59.0_wsbkzerfphvgr4lle7vmeh64yi
'@typescript-eslint/parser': 5.59.0_voubu7prgxjfsfbgx5d4sqnwiy
'@unlazy/svelte': 0.8.9_2a4gi7ewzykzc7boj45sshrguu
'@uppy/compressor': 1.0.2_@uppy+core@3.2.0
'@uppy/core': 3.2.0
'@uppy/dashboard': 3.4.0_@uppy+core@3.2.0
@@ -164,6 +167,7 @@ devDependencies:
svelte-tippy: 1.3.2
swiper: 8.4.7
tailwindcss: 3.3.1_postcss@8.4.22
thumbhash: 0.1.1
tippy.js: 6.3.7
tslib: 2.5.0
typescript: 5.0.4
@@ -1705,6 +1709,31 @@ packages:
eslint-visitor-keys: 3.4.0
dev: true
/@unlazy/core/0.8.9:
resolution:
{
integrity: sha512-DQ4WB/cuEWTknU/59uRwpSipvMAJzBDmRyaHDUc1RcXi0Z7/Vcl0EE7BpROxEynqd1EI+2oMWQaDLyXffUdUiA==
}
dependencies:
fast-blurhash: 1.1.2
thumbhash: 0.1.1
dev: true
/@unlazy/svelte/0.8.9_2a4gi7ewzykzc7boj45sshrguu:
resolution:
{
integrity: sha512-vgOYuOlknE6l/QhzZzpncsU8dMaTgLKGd7Xn4qwqTWAa3TF+6NRL7QedPJb2XBY8Th7yRQ79ZqeXaSDxWtL9zA==
}
peerDependencies:
svelte: ^3.54.0
dependencies:
svelte: 3.58.0
unlazy: 0.8.9_thumbhash@0.1.1
transitivePeerDependencies:
- fast-blurhash
- thumbhash
dev: true
/@uppy/companion-client/3.1.3:
resolution:
{
@@ -2982,6 +3011,13 @@ packages:
}
dev: true
/fast-blurhash/1.1.2:
resolution:
{
integrity: sha512-lJVOgYSlahqkRhrKumNx/SGB2F/qS0D1z7xjGYjb5EZJRtlzySGMniZjkQ9h9Rv8sPmM/V9orEgRiMwazDNH6A==
}
dev: true
/fast-deep-equal/3.1.3:
resolution:
{
@@ -5466,6 +5502,13 @@ packages:
any-promise: 1.3.0
dev: true
/thumbhash/0.1.1:
resolution:
{
integrity: sha512-kH5pKeIIBPQXAOni2AiY/Cu/NKdkFREdpH+TLdM0g6WA7RriCv0kPLgP731ady67MhTAqrVG/4mnEeibVuCJcg==
}
dev: true
/tiny-case/1.0.3:
resolution:
{
@@ -5628,6 +5671,19 @@ packages:
'@types/unist': 2.0.6
dev: true
/unlazy/0.8.9_thumbhash@0.1.1:
resolution:
{
integrity: sha512-lRCuXN20N1esqSQqtSVBLAw9GJz0lcBuOBs3UGGw7cFWHQlWJVZZ3OviwOl42f1CnVHjAON1rs2hIdJWgMAUyg==
}
peerDependencies:
fast-blurhash: ^1.1.2
thumbhash: ^0.1.1
dependencies:
'@unlazy/core': 0.8.9
thumbhash: 0.1.1
dev: true
/update-browserslist-db/1.0.11_browserslist@4.21.5:
resolution:
{
+36
View File
@@ -0,0 +1,36 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<script lang="ts">
import Spinner from '$lib/Spinner.svelte';
export let files: {
id: string;
uploaded_at: string;
mime_type?: string;
hash?: string;
size: number;
deleted_at?: string;
alt_text?: string;
filename?: string;
thumbhash?: string;
server?: string;
quizzes: { id: string }[];
quiztivities: { id: string }[];
}[];
const get_files = async () => {
const res = await fetch('/api/v1/storage/list');
files = await res.json();
};
if (!files) {
get_files();
}
</script>
{#if files}{:else}
<Spinner />
{/if}
@@ -0,0 +1,34 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<script lang="ts">
import type { PageData } from './$types';
// import FileDahboard from "$lib/files/dashboard.svelte"
// import { thumbHashToDataURL } from 'thumbhash';
export let data: PageData;
const files = data.files;
/* const base64ToBytes = (value: string) => {
const base64 = value.replace(/-/g, '+').replace(/_/g, '/');
const decodedData =
typeof Buffer !== 'undefined'
? Buffer.from(base64, 'base64')
: Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
return new Uint8Array(decodedData);
};*/
// let images_loaded = [];
</script>
<div class="w-full h-full">
<div class="grid grid-cols-2 w-full h-full gap-4">
{#each files as file, i}
<div class="w-full h-full flex" />
{/each}
</div>
</div>
@@ -0,0 +1,13 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import type { PageLoad } from './$types';
export const load = (async ({ fetch }) => {
const res = await fetch('/api/v1/storage/list');
if (res.ok) {
return { files: await res.json() };
}
}) satisfies PageLoad;