2024-07-31 10:29:46 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { enhance } from "$app/forms";
|
2024-08-02 15:33:18 +02:00
|
|
|
import Modal from "$lib/components/Modal.svelte";
|
2024-08-02 16:36:21 +02:00
|
|
|
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
2024-09-07 14:28:23 +02:00
|
|
|
import LoadingSpinner from "$lib/components/LoadingSpinner.svelte";
|
2024-08-05 14:38:44 +02:00
|
|
|
import type { ActionData, PageServerData } from "./$types";
|
2024-09-27 16:59:29 +02:00
|
|
|
import { enhanceForm } from "$lib/utils";
|
|
|
|
|
import { sending } from "$lib/runes.svelte";
|
2024-07-31 10:29:46 +02:00
|
|
|
|
2024-08-20 19:17:05 +02:00
|
|
|
const { data, form }: { data: PageServerData; form: ActionData } = $props();
|
2024-07-31 10:29:46 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-08-02 16:36:21 +02:00
|
|
|
<SuccessOrError success={form?.success} message={form?.message} />
|
2024-08-01 18:09:35 +02:00
|
|
|
|
2024-09-27 16:59:29 +02:00
|
|
|
{#if sending.value}
|
2024-09-07 14:28:23 +02:00
|
|
|
<LoadingSpinner />
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-08-24 21:43:15 +02:00
|
|
|
<section id="overview">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#overview">Overview</a>
|
|
|
|
|
</h2>
|
2024-07-31 10:29:46 +02:00
|
|
|
|
2024-08-03 13:49:41 +02:00
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<strong>Id:</strong>
|
|
|
|
|
{data.user.id}
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<strong>Username:</strong>
|
|
|
|
|
{data.user.username}
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2024-07-31 10:29:46 +02:00
|
|
|
</section>
|
|
|
|
|
|
2024-10-17 16:53:31 +02:00
|
|
|
{#if (data.storageSizes.data ?? []).length > 0}
|
2024-10-08 21:20:44 +02:00
|
|
|
<section id="storage">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#storage">Storage</a>
|
|
|
|
|
</h2>
|
|
|
|
|
<ul class="unpadded storage-grid">
|
|
|
|
|
{#each data.storageSizes.data as { website_title, storage_size_bytes, max_storage_bytes, max_storage_pretty, diff_storage_pretty }}
|
|
|
|
|
<li>
|
|
|
|
|
<strong>{website_title}</strong>
|
|
|
|
|
<label>
|
|
|
|
|
{max_storage_pretty} total — {diff_storage_pretty} free<br />
|
|
|
|
|
<meter
|
|
|
|
|
value={storage_size_bytes}
|
|
|
|
|
min="0"
|
|
|
|
|
max={max_storage_bytes}
|
|
|
|
|
high={max_storage_bytes * 0.75}
|
|
|
|
|
></meter>
|
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
{/each}
|
|
|
|
|
</ul>
|
|
|
|
|
</section>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-08-24 21:43:15 +02:00
|
|
|
<section id="logout">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#logout">Logout</a>
|
|
|
|
|
</h2>
|
2024-07-31 10:29:46 +02:00
|
|
|
|
2024-09-27 16:59:29 +02:00
|
|
|
<form method="POST" action="?/logout" use:enhance={enhanceForm()}>
|
2024-07-31 10:29:46 +02:00
|
|
|
<button type="submit">Logout</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
|
|
|
|
|
2024-08-24 21:43:15 +02:00
|
|
|
<section id="delete-account">
|
|
|
|
|
<h2>
|
|
|
|
|
<a href="#delete-account">Delete account</a>
|
|
|
|
|
</h2>
|
2024-07-31 10:29:46 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<Modal id="delete-account" text="Delete account">
|
|
|
|
|
<h3>Delete account</h3>
|
2024-07-31 10:29:46 +02:00
|
|
|
|
2024-08-02 15:33:18 +02:00
|
|
|
<p>
|
|
|
|
|
<strong>Caution!</strong>
|
|
|
|
|
Deleting your account will irretrievably erase all data.
|
|
|
|
|
</p>
|
|
|
|
|
|
2024-09-27 16:59:29 +02:00
|
|
|
<form method="POST" action="?/deleteAccount" use:enhance={enhanceForm({ closeModal: true })}>
|
2024-08-02 15:33:18 +02:00
|
|
|
<label>
|
|
|
|
|
Password:
|
|
|
|
|
<input type="password" name="password" required />
|
|
|
|
|
</label>
|
|
|
|
|
|
2024-08-03 18:07:27 +02:00
|
|
|
<button type="submit">Delete account</button>
|
2024-08-02 15:33:18 +02:00
|
|
|
</form>
|
|
|
|
|
</Modal>
|
2024-07-31 10:29:46 +02:00
|
|
|
</section>
|
2024-09-27 19:31:43 +02:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
form[action="?/logout"] > button {
|
|
|
|
|
max-inline-size: fit-content;
|
|
|
|
|
}
|
2024-10-08 21:20:44 +02:00
|
|
|
|
|
|
|
|
.storage-grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, 35ch), 1fr));
|
|
|
|
|
row-gap: var(--space-s);
|
|
|
|
|
column-gap: var(--space-m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.storage-grid > li {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--space-3xs);
|
|
|
|
|
}
|
2024-09-27 19:31:43 +02:00
|
|
|
</style>
|