Add a little avatar cache, change page store to state
This commit is contained in:
parent
fd3f3f26af
commit
796066ce42
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PaginationMeta } from '$lib/types';
|
import type { PaginationMeta } from '$lib/types';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let { meta }: Props = $props();
|
let { meta }: Props = $props();
|
||||||
let pageNum = $derived(Number($page.url.searchParams.get('page')) || 1);
|
let pageNum = $derived(Number(page.url.searchParams.get('page')) || 1);
|
||||||
let firstPage = $derived(pageNum === 1);
|
let firstPage = $derived(pageNum === 1);
|
||||||
let lastPage = $derived(!meta.pageCount || pageNum === meta.pageCount);
|
let lastPage = $derived(!meta.pageCount || pageNum === meta.pageCount);
|
||||||
let pageButtons = $derived(Array.from({ length: meta.pageCount }, (_, i) => i + 1));
|
let pageButtons = $derived(Array.from({ length: meta.pageCount }, (_, i) => i + 1));
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<nav class="pager">
|
<nav class="pager">
|
||||||
<a
|
<a
|
||||||
class="page-button page-prev {firstPage ? 'disabled' : ''}"
|
class="page-button page-prev {firstPage ? 'disabled' : ''}"
|
||||||
href={`?${makePageUrl($page.url.searchParams, pageNum - 1)}`}
|
href={`?${makePageUrl(page.url.searchParams, pageNum - 1)}`}
|
||||||
tabindex={firstPage ? -1 : 0}
|
tabindex={firstPage ? -1 : 0}
|
||||||
aria-label={$t('common.previous')}><</a
|
aria-label={$t('common.previous')}><</a
|
||||||
>
|
>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
{@const active = buttonNumber === pageNum}
|
{@const active = buttonNumber === pageNum}
|
||||||
<a
|
<a
|
||||||
class="page-button page-link {active ? 'disabled' : ''}"
|
class="page-button page-link {active ? 'disabled' : ''}"
|
||||||
href={`?${makePageUrl($page.url.searchParams, buttonNumber)}`}
|
href={`?${makePageUrl(page.url.searchParams, buttonNumber)}`}
|
||||||
tabindex={active ? -1 : 0}
|
tabindex={active ? -1 : 0}
|
||||||
aria-label={`${$t('common.page')} ${buttonNumber}`}>{buttonNumber}</a
|
aria-label={`${$t('common.page')} ${buttonNumber}`}>{buttonNumber}</a
|
||||||
>
|
>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
<a
|
<a
|
||||||
class="page-button page-prev {lastPage ? 'disabled' : ''}"
|
class="page-button page-prev {lastPage ? 'disabled' : ''}"
|
||||||
tabindex={lastPage ? -1 : 0}
|
tabindex={lastPage ? -1 : 0}
|
||||||
href={`?${makePageUrl($page.url.searchParams, pageNum + 1)}`}
|
href={`?${makePageUrl(page.url.searchParams, pageNum + 1)}`}
|
||||||
aria-label={$t('common.next')}>></a
|
aria-label={$t('common.next')}>></a
|
||||||
>
|
>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { UserSession } from '$lib/types';
|
import type { UserSession } from '$lib/types';
|
||||||
import { hasPrivileges } from '$lib/utils';
|
import { hasPrivileges } from '$lib/utils';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href={link.href}
|
href={link.href}
|
||||||
class="sidebar-link{$page.url.pathname.startsWith(link.href) ? ' active' : ''}"
|
class="sidebar-link{page.url.pathname.startsWith(link.href) ? ' active' : ''}"
|
||||||
>{link.title}</a
|
>{link.title}</a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<script>
|
<script>
|
||||||
import { invalidateAll } from '$app/navigation';
|
import { invalidateAll } from '$app/navigation';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
import MainContainer from '$lib/components/container/MainContainer.svelte';
|
import MainContainer from '$lib/components/container/MainContainer.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<MainContainer>
|
<MainContainer>
|
||||||
<div class="centered">
|
<div class="centered">
|
||||||
<h1>{$page.status}</h1>
|
<h1>{page.status}</h1>
|
||||||
<p>{$page.error?.message}</p>
|
<p>{page.error?.message}</p>
|
||||||
{#if $page.status !== 404}
|
{#if page.status !== 404}
|
||||||
<Button onclick={() => invalidateAll()} variant="link">Go back</Button>
|
<Button onclick={() => invalidateAll()} variant="link">Go back</Button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,7 +8,8 @@ export async function GET({ params: { uuid } }) {
|
|||||||
return new Response(fallback, {
|
return new Response(fallback, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'image/png'
|
'Content-Type': 'image/png',
|
||||||
|
'Cache-Control': 'max-age=3600'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -17,7 +18,8 @@ export async function GET({ params: { uuid } }) {
|
|||||||
return new Response(readUpload, {
|
return new Response(readUpload, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': uploadFile.mimetype
|
'Content-Type': uploadFile.mimetype,
|
||||||
|
'Cache-Control': 'max-age=3600'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ export async function GET({ params: { uuid } }) {
|
|||||||
return new Response(fallback, {
|
return new Response(fallback, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'image/png'
|
'Content-Type': 'image/png',
|
||||||
|
'Cache-Control': 'max-age=3600'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -17,7 +18,8 @@ export async function GET({ params: { uuid } }) {
|
|||||||
return new Response(readUpload, {
|
return new Response(readUpload, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': uploadFile.mimetype
|
'Content-Type': uploadFile.mimetype,
|
||||||
|
'Cache-Control': 'max-age=3600'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
import ButtonRow from '$lib/components/container/ButtonRow.svelte';
|
import ButtonRow from '$lib/components/container/ButtonRow.svelte';
|
||||||
import TitleRow from '$lib/components/container/TitleRow.svelte';
|
import TitleRow from '$lib/components/container/TitleRow.svelte';
|
||||||
import ThemeButton from '$lib/components/ThemeButton.svelte';
|
import ThemeButton from '$lib/components/ThemeButton.svelte';
|
||||||
import { page } from '$app/stores';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: PageData;
|
data: PageData;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import { env } from '$env/dynamic/public';
|
import { env } from '$env/dynamic/public';
|
||||||
import Alert from '$lib/components/Alert.svelte';
|
import Alert from '$lib/components/Alert.svelte';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
@ -24,7 +24,7 @@
|
|||||||
let submitted = $state(false);
|
let submitted = $state(false);
|
||||||
let errors = $derived([...internalErrors, ...(form?.errors?.length ? form.errors : [])]);
|
let errors = $derived([...internalErrors, ...(form?.errors?.length ? form.errors : [])]);
|
||||||
let actionUrl = $derived(
|
let actionUrl = $derived(
|
||||||
data.setter ? `?/setPassword&token=${$page.url.searchParams.get('token')}` : '?/sendEmail'
|
data.setter ? `?/setPassword&token=${page.url.searchParams.get('token')}` : '?/sendEmail'
|
||||||
);
|
);
|
||||||
let pageTitle = $derived(data.setter ? 'setNewPassword' : 'resetPassword');
|
let pageTitle = $derived(data.setter ? 'setNewPassword' : 'resetPassword');
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
import { env } from '$env/dynamic/public';
|
import { env } from '$env/dynamic/public';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import Paginator from '$lib/components/Paginator.svelte';
|
import Paginator from '$lib/components/Paginator.svelte';
|
||||||
import FormControl from '$lib/components/form/FormControl.svelte';
|
import FormControl from '$lib/components/form/FormControl.svelte';
|
||||||
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<select
|
<select
|
||||||
name="actions"
|
name="actions"
|
||||||
id="actions"
|
id="actions"
|
||||||
value={$page.url.searchParams.getAll('actions')}
|
value={page.url.searchParams.getAll('actions')}
|
||||||
multiple
|
multiple
|
||||||
>
|
>
|
||||||
{#each data.actions as action}
|
{#each data.actions as action}
|
||||||
@ -44,11 +44,11 @@
|
|||||||
<ColumnView>
|
<ColumnView>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<label for="content">{$t('admin.audit.comment')}</label>
|
<label for="content">{$t('admin.audit.comment')}</label>
|
||||||
<input name="content" id="content" value={$page.url.searchParams.get('content')} />
|
<input name="content" id="content" value={page.url.searchParams.get('content')} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<label for="ip">{$t('admin.audit.ip')}</label>
|
<label for="ip">{$t('admin.audit.ip')}</label>
|
||||||
<input name="ip" id="ip" value={$page.url.searchParams.get('ip')} />
|
<input name="ip" id="ip" value={page.url.searchParams.get('ip')} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</ColumnView>
|
</ColumnView>
|
||||||
</SplitView>
|
</SplitView>
|
||||||
@ -56,7 +56,7 @@
|
|||||||
<SplitView>
|
<SplitView>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<label for="user">{$t('admin.audit.user')}</label>
|
<label for="user">{$t('admin.audit.user')}</label>
|
||||||
<input name="user" id="user" value={$page.url.searchParams.get('user')} />
|
<input name="user" id="user" value={page.url.searchParams.get('user')} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</SplitView>
|
</SplitView>
|
||||||
|
|
||||||
@ -66,7 +66,7 @@
|
|||||||
name="flagged"
|
name="flagged"
|
||||||
id="flagged"
|
id="flagged"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={!!$page.url.searchParams.get('flagged')}
|
checked={!!page.url.searchParams.get('flagged')}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
||||||
import { env } from '$env/dynamic/public';
|
import { env } from '$env/dynamic/public';
|
||||||
import FormControl from '$lib/components/form/FormControl.svelte';
|
import FormControl from '$lib/components/form/FormControl.svelte';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: PageData;
|
data: PageData;
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<label for="filter">{$t('common.filter')}</label>
|
<label for="filter">{$t('common.filter')}</label>
|
||||||
<input name="filter" value={$page.url.searchParams.get('filter')} />
|
<input name="filter" value={page.url.searchParams.get('filter')} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import ActionButton from '$lib/components/ActionButton.svelte';
|
import ActionButton from '$lib/components/ActionButton.svelte';
|
||||||
import type { ActionData, PageData } from './$types';
|
import type { ActionData, PageData } from './$types';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import { env } from '$env/dynamic/public';
|
import { env } from '$env/dynamic/public';
|
||||||
import { OAUTH2_MAX_REDIRECTS, OAUTH2_MAX_URLS } from '$lib/constants';
|
import { OAUTH2_MAX_REDIRECTS, OAUTH2_MAX_URLS } from '$lib/constants';
|
||||||
@ -456,7 +456,7 @@
|
|||||||
<b>{$t('admin.oauth2.revoked')}</b>
|
<b>{$t('admin.oauth2.revoked')}</b>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<a href={`${$page.url.pathname}/user/${user.uuid}`}>{$t('admin.oauth2.privileges.edit')}</a>
|
<a href={`${page.url.pathname}/user/${user.uuid}`}>{$t('admin.oauth2.privileges.edit')}</a>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<b>{$t('admin.oauth2.noAuthorizations')}</b>
|
<b>{$t('admin.oauth2.noAuthorizations')}</b>
|
||||||
@ -464,7 +464,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</ColumnView>
|
</ColumnView>
|
||||||
|
|
||||||
<AvatarModal show={showAvatarModal} url={$page.url.pathname} />
|
<AvatarModal show={showAvatarModal} url={page.url.pathname} />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
h2,
|
h2,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import { env } from '$env/dynamic/public';
|
import { env } from '$env/dynamic/public';
|
||||||
import FormControl from '$lib/components/form/FormControl.svelte';
|
import FormControl from '$lib/components/form/FormControl.svelte';
|
||||||
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
import ColumnView from '$lib/components/container/ColumnView.svelte';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/state';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: PageData;
|
data: PageData;
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<label for="filter">{$t('common.filter')}</label>
|
<label for="filter">{$t('common.filter')}</label>
|
||||||
<input name="filter" value={$page.url.searchParams.get('filter')} />
|
<input name="filter" value={page.url.searchParams.get('filter')} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user