feat: add user credentials management and health monitoring features
- Implemented CredentialsDialog for updating user credentials. - Created auth store with functions for managing authentication state. - Added HealthWidget to display server health status. - Introduced health monitoring functionality with polling. - Developed AppShell layout to manage authentication and loading states. - Added SettingsDialog for user preferences including theme and language. - Created utility functions for list management and data fetching. - Implemented dashboard view mode preferences. - Integrated search functionality for filtering lists. - Established theme management with local storage support. - Added utility functions for class name management. - Configured SvelteKit for static site generation with fallback. - Set up Vite for development with proxy support for API calls. - Created About and List detail pages with data fetching and display. - Added favicon and updated project configuration files.
This commit is contained in:
1 parent
a4a3eeb5cc
commit
6c1ea2da47
80 files changed
No files matched your search
@@ -0,0 +1,3 @@
|
||||
// Fully client-rendered SPA — the Go server only ever serves the static build plus
|
||||
// its JSON/API routes, so there is no server to render against.
|
||||
export const ssr = false;
|
||||
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import '../app.css';
|
||||
import '$lib/theme.svelte.js';
|
||||
import { QueryClientProvider } from '@tanstack/svelte-query';
|
||||
import { queryClient } from '$lib/query/queryClient.js';
|
||||
import AppShell from '$lib/features/layout/AppShell.svelte';
|
||||
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AppShell>
|
||||
{@render children()}
|
||||
</AppShell>
|
||||
</QueryClientProvider>
|
||||
@@ -0,0 +1,166 @@
|
||||
<script>
|
||||
import { goto } from '$app/navigation';
|
||||
import { resolve } from '$app/paths';
|
||||
import { ArrowDown, ArrowUp, LayoutGrid, List, Search, X } from '@lucide/svelte';
|
||||
import { createOverviewData } from '$lib/features/lists/listsData.svelte.js';
|
||||
import { searchState, filterListsBySearch } from '$lib/search.svelte.js';
|
||||
import { createDashboardViewMode } from '$lib/preferences/viewMode.svelte.js';
|
||||
import Button from '$lib/components/ui/button.svelte';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '$lib/components/ui/select';
|
||||
import Paginator from '$lib/components/ui/paginator.svelte';
|
||||
import ListsGrid from '$lib/components/lists/ListsGrid.svelte';
|
||||
import ListsTable from '$lib/components/lists/ListsTable.svelte';
|
||||
|
||||
const SORT_FIELDS = [
|
||||
{ field: 'name', label: 'Name' },
|
||||
{ field: 'created', label: 'Created' },
|
||||
{ field: 'updated', label: 'Updated' },
|
||||
];
|
||||
|
||||
// Passed as `Select`'s `items` prop so the trigger shows the right label immediately, even
|
||||
// before the dropdown has ever been opened - bits-ui can't rely on `Select.Item` having
|
||||
// mounted to the DOM yet to read its label back off of it.
|
||||
const sortItems = SORT_FIELDS.map((s) => ({ value: s.field, label: s.label }));
|
||||
|
||||
const overview = createOverviewData();
|
||||
const viewMode = createDashboardViewMode();
|
||||
|
||||
let sortField = $state('name');
|
||||
let sortDir = $state('asc');
|
||||
let page = $state(1);
|
||||
let pageSize = $state(24);
|
||||
|
||||
function sortLists(lists, field, dir) {
|
||||
const sorted = [...lists].sort((a, b) => {
|
||||
if (field === 'name') return a.name.localeCompare(b.name);
|
||||
if (field === 'created') return (a.createdAt ?? 0) - (b.createdAt ?? 0);
|
||||
return (a.effectiveUpdatedAt ?? a.updatedAt ?? 0) - (b.effectiveUpdatedAt ?? b.updatedAt ?? 0);
|
||||
});
|
||||
return dir === 'desc' ? sorted.reverse() : sorted;
|
||||
}
|
||||
|
||||
let searched = $derived(filterListsBySearch(overview.lists, searchState.query));
|
||||
let sorted = $derived(sortLists(searched, sortField, sortDir));
|
||||
let pageItems = $derived(sorted.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize));
|
||||
|
||||
$effect(() => {
|
||||
void searchState.query;
|
||||
void sortField;
|
||||
void sortDir;
|
||||
page = 1;
|
||||
});
|
||||
|
||||
function goToList(list) {
|
||||
void goto(resolve('/lists/[id]', { id: list.id }));
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex-1 p-4">
|
||||
<div class="mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<div class="rounded-lg border border-border bg-surface p-3">
|
||||
<div class="text-xs text-muted-fg">Lists</div>
|
||||
<div class="mt-1 text-lg font-semibold text-fg">{overview.stats.lists}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-border bg-surface p-3">
|
||||
<div class="text-xs text-muted-fg">Fields</div>
|
||||
<div class="mt-1 text-lg font-semibold text-fg">{overview.stats.fields}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-border bg-surface p-3">
|
||||
<div class="text-xs text-muted-fg">Items</div>
|
||||
<div class="mt-1 text-lg font-semibold text-fg">{overview.stats.items}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-border bg-surface p-3">
|
||||
<div class="text-xs text-muted-fg">Values</div>
|
||||
<div class="mt-1 text-lg font-semibold text-fg">{overview.stats.values}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if overview.isLoading}
|
||||
<div class="flex items-center gap-3 py-10 text-sm text-muted-fg">
|
||||
<span class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"></span>
|
||||
Loading lists…
|
||||
</div>
|
||||
{:else if overview.error}
|
||||
<p class="text-sm text-danger">{overview.error.message}</p>
|
||||
{:else}
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<div class="relative min-w-0 flex-1 basis-full sm:basis-auto">
|
||||
<Search class="pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-fg" />
|
||||
<input
|
||||
type="search"
|
||||
bind:value={searchState.query}
|
||||
placeholder="Search lists…"
|
||||
autocapitalize="none"
|
||||
class="h-9 w-full rounded-md border border-border bg-bg pl-8 pr-8 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
/>
|
||||
{#if searchState.query}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (searchState.query = '')}
|
||||
title="Clear search"
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2 text-muted-fg hover:text-fg"
|
||||
>
|
||||
<X class="size-4" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Select type="single" value={sortField} items={sortItems} onValueChange={(field) => (sortField = field)}>
|
||||
<SelectTrigger class="min-w-0 flex-1 sm:w-44 sm:flex-none">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{#each sortItems as item (item.value)}
|
||||
<SelectItem value={item.value} label={item.label}>{item.label}</SelectItem>
|
||||
{/each}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Toggle sort direction"
|
||||
onclick={() => (sortDir = sortDir === 'asc' ? 'desc' : 'asc')}
|
||||
>
|
||||
{#if sortDir === 'desc'}
|
||||
<ArrowDown class="size-4" />
|
||||
{:else}
|
||||
<ArrowUp class="size-4" />
|
||||
{/if}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={viewMode.mode === 'grid' ? 'Switch to list view' : 'Switch to grid view'}
|
||||
onclick={() => viewMode.setMode(viewMode.mode === 'grid' ? 'list' : 'grid')}
|
||||
>
|
||||
{#if viewMode.mode === 'grid'}
|
||||
<LayoutGrid class="size-4" />
|
||||
{:else}
|
||||
<List class="size-4" />
|
||||
{/if}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto rounded-lg border border-border bg-bg p-3">
|
||||
{#if viewMode.mode === 'list'}
|
||||
<ListsTable lists={pageItems} fields={overview.fields} items={overview.items} onSelect={goToList} />
|
||||
{:else}
|
||||
<ListsGrid lists={pageItems} fields={overview.fields} items={overview.items} onSelect={goToList} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Paginator
|
||||
{page}
|
||||
{pageSize}
|
||||
pageLength={pageItems.length}
|
||||
totalLength={sorted.length}
|
||||
onPaging={(e) => {
|
||||
page = e.page;
|
||||
pageSize = e.pageSize;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script>
|
||||
import { Table2 } from '@lucide/svelte';
|
||||
import TechStackSection from '$lib/features/about/TechStackSection.svelte';
|
||||
</script>
|
||||
|
||||
<main class="flex-1 overflow-y-auto p-5">
|
||||
<div class="mx-auto max-w-2xl">
|
||||
<div class="mb-4 flex items-center gap-3">
|
||||
<Table2 class="size-8 text-primary" />
|
||||
<div>
|
||||
<h1 class="text-xl font-semibold text-fg">CollabTable</h1>
|
||||
<p class="text-sm text-muted-fg">Collaborative list management server.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TechStackSection />
|
||||
</div>
|
||||
</main>
|
||||
@@ -0,0 +1,3 @@
|
||||
export const load = ({ params }) => {
|
||||
return { id: params.id };
|
||||
};
|
||||
@@ -0,0 +1,119 @@
|
||||
<script>
|
||||
import { goto } from '$app/navigation';
|
||||
import { resolve } from '$app/paths';
|
||||
import { ArrowLeft, LoaderCircle } from '@lucide/svelte';
|
||||
import Button from '$lib/components/ui/button.svelte';
|
||||
import Paginator from '$lib/components/ui/paginator.svelte';
|
||||
import { createOverviewData } from '$lib/features/lists/listsData.svelte.js';
|
||||
import { listFieldsFor, listItemsFor, itemValuesFor, valueFor, fmtDate } from '$lib/features/lists/listHelpers.js';
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
function goBack() {
|
||||
if (typeof window !== 'undefined' && window.history.length > 1) {
|
||||
window.history.back();
|
||||
} else {
|
||||
void goto(resolve('/'));
|
||||
}
|
||||
}
|
||||
|
||||
const overview = createOverviewData();
|
||||
|
||||
const list = $derived(overview.lists.find((l) => l.id === data.id));
|
||||
const listFields = $derived(listFieldsFor(overview.fields, data.id));
|
||||
const listItems = $derived(listItemsFor(overview.items, data.id));
|
||||
|
||||
let page = $state(1);
|
||||
let pageSize = $state(24);
|
||||
const pageItems = $derived(listItems.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize));
|
||||
</script>
|
||||
|
||||
<div class="p-4">
|
||||
<div class="mb-4 flex min-w-0 items-center gap-3">
|
||||
<Button type="button" variant="secondary" size="sm" class="shrink-0" onclick={goBack}>
|
||||
<ArrowLeft class="size-4" />
|
||||
Back
|
||||
</Button>
|
||||
{#if list}
|
||||
<h1 class="min-w-0 truncate text-lg font-semibold text-fg">{list.name}</h1>
|
||||
{#if list.isDeleted}
|
||||
<span class="shrink-0 rounded-full bg-danger/15 px-2 py-0.5 text-[11px] font-medium text-danger">Deleted</span>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if overview.isLoading}
|
||||
<div class="rounded-lg border border-border bg-bg p-4">
|
||||
<div class="flex flex-col items-center gap-3 py-12 text-center text-sm text-muted-fg">
|
||||
<LoaderCircle class="size-8 animate-spin text-primary" />
|
||||
Loading…
|
||||
</div>
|
||||
</div>
|
||||
{:else if !list}
|
||||
<div class="rounded-lg border border-border bg-bg p-4">
|
||||
<p class="py-8 text-center text-sm text-muted-fg">List not found.</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="rounded-lg border border-border bg-bg p-4">
|
||||
<div class="mb-2 text-xs text-muted-fg">
|
||||
Created {fmtDate(list.createdAt)} · Updated {fmtDate(list.effectiveUpdatedAt ?? list.updatedAt)}
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<div class="mb-1.5 text-sm font-medium text-fg">Fields ({listFields.length})</div>
|
||||
{#if listFields.length === 0}
|
||||
<p class="text-sm text-muted-fg">No fields</p>
|
||||
{:else}
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{#each listFields as f (f.id)}
|
||||
<span class="rounded-md bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary">
|
||||
{f.name} ({f.fieldType})
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="mb-1.5 text-sm font-medium text-fg">Items ({listItems.length})</div>
|
||||
{#if listItems.length === 0}
|
||||
<p class="text-sm text-muted-fg">No items</p>
|
||||
{:else}
|
||||
<div class="overflow-x-auto rounded-lg border border-border">
|
||||
<table class="min-w-max w-full text-left text-sm">
|
||||
<thead>
|
||||
<tr class="text-muted-fg">
|
||||
<th class="py-2 pl-3 font-medium">Item ID</th>
|
||||
{#each listFields as f (f.id)}
|
||||
<th class="py-2 font-medium">{f.name}</th>
|
||||
{/each}
|
||||
<th class="py-2 pr-3 font-medium">Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each pageItems as item (item.id)}
|
||||
{@const itemValues = itemValuesFor(overview.values, item.id)}
|
||||
<tr class="border-t border-border">
|
||||
<td class="py-2 pl-3 font-mono text-xs text-muted-fg">{item.id.slice(0, 8)}…</td>
|
||||
{#each listFields as f (f.id)}
|
||||
<td class="py-2 text-fg">{valueFor(itemValues, item.id, f.id) ?? '—'}</td>
|
||||
{/each}
|
||||
<td class="py-2 pr-3 text-muted-fg">{fmtDate(item.updatedAt)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<Paginator
|
||||
{page}
|
||||
{pageSize}
|
||||
pageLength={pageItems.length}
|
||||
totalLength={listItems.length}
|
||||
onPaging={(e) => {
|
||||
page = e.page;
|
||||
pageSize = e.pageSize;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in new issue
Block a user