feat(web): add /admin layout with role-gated load + sidebar
Hard route gate in admin/+layout.ts redirects non-admins to / before the layout (or any child) renders. AdminSidebar reads the active route from $app/state and applies a 12% accent-tinted bg + 2px forest-teal left strip on the active item. Overview landing shows pending-request count and Lidarr connected/unset, each linking to its sub-page. Shell nav exposes the Admin link only to is_admin users. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { createAdminRequestsQuery, createLidarrConfigQuery } from '$lib/api/admin';
|
||||
|
||||
const requestsStore = createAdminRequestsQuery('pending');
|
||||
const requests = $derived($requestsStore);
|
||||
|
||||
const configStore = createLidarrConfigQuery();
|
||||
const config = $derived($configStore);
|
||||
|
||||
const pendingCount = $derived(requests.data?.length ?? 0);
|
||||
const lidarrConnected = $derived(config.data?.enabled === true);
|
||||
</script>
|
||||
|
||||
<div class="space-y-6">
|
||||
<header>
|
||||
<h2 class="font-display text-2xl font-medium text-text-primary">Overview</h2>
|
||||
</header>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<a
|
||||
href="/admin/requests"
|
||||
class="block rounded-xl border border-border bg-surface p-5 transition-colors hover:bg-surface-hover"
|
||||
>
|
||||
<div class="text-sm text-text-secondary">Pending requests</div>
|
||||
<div class="font-display mt-1 text-3xl font-medium text-text-primary">{pendingCount}</div>
|
||||
</a>
|
||||
<a
|
||||
href="/admin/integrations"
|
||||
class="block rounded-xl border border-border bg-surface p-5 transition-colors hover:bg-surface-hover"
|
||||
>
|
||||
<div class="text-sm text-text-secondary">Lidarr</div>
|
||||
<div class="font-display mt-1 text-2xl font-medium text-text-primary">
|
||||
{lidarrConnected ? 'Connected' : 'Unset'}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user