diff --git a/frontend/src/lib/ui/AdvancedParameters.svelte b/frontend/src/lib/ui/AdvancedParameters.svelte new file mode 100644 index 0000000..4dceecf --- /dev/null +++ b/frontend/src/lib/ui/AdvancedParameters.svelte @@ -0,0 +1,47 @@ + + +
+ + ($status && v < $status?.max_views) || + $t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })} + /> +
+ +
+ + ($status && v < $status?.max_expiration) || + $t('home.errors.max', { values: { n: $status?.max_expiration ?? 0 } })} + /> +
+ + diff --git a/frontend/src/lib/ui/Loader.svelte b/frontend/src/lib/ui/Loader.svelte new file mode 100644 index 0000000..313485c --- /dev/null +++ b/frontend/src/lib/ui/Loader.svelte @@ -0,0 +1,41 @@ + + + + + + + + + + diff --git a/frontend/src/lib/views/Create.svelte b/frontend/src/lib/views/Create.svelte index 94a2e43..2130128 100644 --- a/frontend/src/lib/views/Create.svelte +++ b/frontend/src/lib/views/Create.svelte @@ -7,13 +7,14 @@ import { create, PayloadToLargeError } from '$lib/api' import { Crypto, Hex } from '$lib/crypto' import { status } from '$lib/stores/status' + import AdvancedParameters from '$lib/ui/AdvancedParameters.svelte' import Button from '$lib/ui/Button.svelte' import FileUpload from '$lib/ui/FileUpload.svelte' + import Loader from '$lib/ui/Loader.svelte' import MaxSize from '$lib/ui/MaxSize.svelte' import Result, { type NoteResult } from '$lib/ui/NoteResult.svelte' import Switch from '$lib/ui/Switch.svelte' import TextArea from '$lib/ui/TextArea.svelte' - import TextInput from '$lib/ui/TextInput.svelte' let note: Note = { contents: '', @@ -27,7 +28,7 @@ let isFile = false let timeExpiration = false let description = '' - let loading = false + let loading: string | null = null let error: string | null = null $: if (!advanced) { @@ -56,7 +57,7 @@ async function submit() { try { error = null - loading = true + loading = $t('common.encrypting') const password = Hex.encode(Crypto.getRandomBytes(32)) const key = await Crypto.getKeyFromString(password) @@ -75,6 +76,7 @@ if (timeExpiration) data.expiration = parseInt(note.expiration as any) else data.views = parseInt(note.views as any) + loading = $t('common.uploading') const response = await create(data) result = { password: password, @@ -90,7 +92,7 @@ error = $t('home.errors.note_error') } } finally { - loading = false + loading = null } } @@ -102,7 +104,7 @@ {@html $status?.theme_text || $t('home.intro')}

-
+
{#if isFile} {:else} @@ -129,7 +131,7 @@


{#if loading} - {$t('common.loading')} + {loading} {:else} {description} {/if} @@ -138,31 +140,7 @@ {#if advanced}


-
- - ($status && v < $status?.max_views) || - $t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })} - /> -
- -
- - ($status && v < $status?.max_expiration) || - $t('home.errors.max', { values: { n: $status?.max_expiration ?? 0 } })} - /> -
+
{/if}
@@ -184,15 +162,7 @@ flex: 1; } - .middle-switch { - margin: 0 1rem; - } - .error-text { margin-top: 0.5rem; } - - .fields { - display: flex; - } diff --git a/frontend/src/routes/note/[id].svelte b/frontend/src/routes/note/[id].svelte index 18e88ef..85426eb 100644 --- a/frontend/src/routes/note/[id].svelte +++ b/frontend/src/routes/note/[id].svelte @@ -16,6 +16,7 @@ import { get, info } from '$lib/api' import { Crypto } from '$lib/crypto' import Button from '$lib/ui/Button.svelte' + import Loader from '$lib/ui/Loader.svelte' import ShowNote, { type DecryptedNote } from '$lib/ui/ShowNote.svelte' export let id: string @@ -24,20 +25,20 @@ let note: DecryptedNote | null = null let exists = false - let loading = true + let loading: string | null = null let error: string | null = null onMount(async () => { // Check if note exists try { - loading = true + loading = $t('common.loading') password = window.location.hash.slice(1) await info(id) exists = true } catch { exists = false } finally { - loading = false + loading = null } }) @@ -47,8 +48,9 @@ async function show() { try { error = null - loading = true + loading = $t('common.downloading') const data = await get(id) + loading = $t('common.decrypting') const key = await Crypto.getKeyFromString(password) switch (data.meta.type) { case 'text': @@ -70,7 +72,7 @@ } catch { error = $t('show.errors.decryption_failed') } finally { - loading = false + loading = null } } @@ -97,5 +99,11 @@ {/if} {/if} {#if loading} -

{$t('common.loading')}

+

{loading}

{/if} + +