Skip to content

Library page: unified Albums + Artists view with three toggles

jedmund requested to merge jedmund/library-page into jedmund/quality-badge

Stacked on PR #40. The third of four PRs in the Library redesign: replaces the old List view at / with a single Library page that can render albums or artists, from the unsorted or sorted side, in grid or list view.

What changes

  • / is now the Library page. Four orthogonal toggles drive what's shown:
    • Source: Unsorted | Sorted (strict — no 'all')
    • Type: Albums | Artists
    • View: Grid | List
    • Search: client-side filter over the loaded set All four (except search) live in URL params, so refreshes and back/forward preserve state and views are shareable.
  • +page.server.ts SSR loader normalizes both albums (unsorted) and sorted_albums rows into a LibraryAlbumItem[]. Artists view reuses the extended getArtistIndex from earlier in this PR.
  • getArtistIndex now takes a thresholds parameter and returns per-source quality counts (green/yellow/red/gray) plus totalSizeBytes. Existing pendingCount/sortedCount fields preserved so the legacy /artists page still renders.
  • New components:
    • LibraryAlbumCard — grid card taking the normalized shape (handles sorted-side missing artwork via the existing placeholder)
    • AlbumGrid — responsive 280px grid wrapper
    • AlbumListRow + AlbumTable — eight-column list view (Artist · Album · Year · Quality · Codec · Bitrate · Sample rate · Size)
    • ArtistCard — grid card with name, count, and quality dots
    • ArtistListRow — table row equivalent
  • $lib/format.ts consolidates the formatBytes (and adds formatHz/formatBitrate/formatBitDepth) duplicated across batch/+page.svelte and FileList.svelte. Existing duplicates aren't removed in this PR — that's PR 4 cleanup.
  • Nav label changed from 'List' to 'Library'. The 'Artists' link stays as the working fallback for this PR.

Behavior carried over

  • Clicking an unsorted album opens AlbumOrganizePanel (existing flow via fetchAlbum + currentAlbum store).
  • Refresh icon triggers /api/scan and invalidateAll()s the loader.
  • Active scan banner with progress.

Behavior intentionally not in this PR

  • Sorted album clicks are no-ops. The slide-over panel becomes mode-aware (read-only for sorted) in PR 4.
  • Artist clicks navigate to /artist/[key], which 404s until PR 4. The legacy /artists route is kept as a working fallback.

Verification

  • pnpm run build passes.
  • Visit /. Default view: Unsorted + Albums + Grid (matches the old List page visually, plus quality dots from PR 2).
  • Toggle each of the six combinations:
    • Unsorted + Albums + Grid / List
    • Sorted + Albums + Grid / List (sorted side now populates after the PR 1 backfill scan)
    • Unsorted + Artists + Grid / List
    • Sorted + Artists + Grid / List
  • Each toggle updates URL params; refresh and back/forward preserve state.
  • Search filters artist+album within the current view.
  • Click an unsorted album → existing sort panel opens.
  • Click a sorted album → no-op (PR 4 will make the panel read-only-aware).
  • Click an artist → navigates to /artist/[key] which 404s in this PR.
  • Old /artists route still works.

Merge request reports

Loading