Add Svelte web client and service worker
Mobile-first PWA: groups via key-in-fragment links, encrypted outbox and sync over SSE, all split modes, currencies with ECB rate prefill, photos, comments, history and rewind, stats, recurring expenses, CSV and backup, EN/CS, dark/light theme, Web Push decrypted in the service worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
This commit is contained in:
parent
f67add3660
commit
8fbbb4933e
53 changed files with 4558 additions and 37 deletions
40
apps/web/src/components/Restore.svelte
Normal file
40
apps/web/src/components/Restore.svelte
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<script lang="ts">
|
||||
import { restoreBackup } from '../lib/backup.ts';
|
||||
import { router } from '../lib/router.svelte.ts';
|
||||
import { t } from '../lib/settings.svelte.ts';
|
||||
import { ui } from '../lib/ui.svelte.ts';
|
||||
import Icon from './Icon.svelte';
|
||||
|
||||
let busy = $state(false);
|
||||
let error = $state('');
|
||||
|
||||
async function pick(e: Event) {
|
||||
const file = (e.target as HTMLInputElement).files?.[0];
|
||||
if (!file) return;
|
||||
busy = true;
|
||||
error = '';
|
||||
try {
|
||||
const { id, existed } = await restoreBackup(await file.text());
|
||||
if (existed) ui.show(t('restore_exists'), 4000);
|
||||
router.go(`/g/${id}`, { replace: true });
|
||||
} catch (err) {
|
||||
error = (err as Error).message === 'bad file' ? t('restore_bad_file') : t('error_generic', { msg: (err as Error).message });
|
||||
} finally {
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="topbar">
|
||||
<button class="icon-btn" onclick={() => router.back('/')} aria-label={t('back')}><Icon name="back" /></button>
|
||||
<h1>{t('restore_title')}</h1>
|
||||
</header>
|
||||
|
||||
<main class="page stack">
|
||||
<label class="field">
|
||||
{t('restore_pick')}
|
||||
<input type="file" accept="application/json,.json" onchange={pick} disabled={busy} />
|
||||
</label>
|
||||
{#if busy}<p class="muted">{t('restoring')}</p>{/if}
|
||||
{#if error}<p class="neg" role="alert">{error}</p>{/if}
|
||||
</main>
|
||||
Loading…
Add table
Add a link
Reference in a new issue