Commit graph sonda/web
Author SHA1 Message Date
squidd
0b9d158f2b Merge pull request 'feat(web): admin area with libraries and scanning (F3a)' (#70) from feat/admin-libraries into main 2026-11-12 14:49:29 +01:00
tgiachi
d88710fd73 feat(web): the Admin area with libraries and scanning, and an Admin link for admins
The Admin link is shown only to an admin and /admin opens the libraries. Someone else who opens the address gets a notice and the server is not asked anything. README describes what the admin area covers so far.
2026-11-12 14:44:08 +01:00
tgiachi
3dd85fc230 feat(web): admin layout, library list, add form and scan panel
The admin frame shows its sections only to an admin and asks nothing of the server for anyone else. Libraries can be added, edited (only what changed is sent) and removed after a confirmation that says the music on disk is never touched; a scan can be started for one library or all, optionally reading every file again, and the panel follows it and shows the summary, with the files in unsupported formats standing out.
2026-11-12 14:42:54 +01:00
squidd
7b24f76c46 Merge pull request 'feat(auth): accounts are identified by an email address' (#69) from feat/email-login into main 2026-11-12 14:41:32 +01:00
tgiachi
96ad8b1f62 feat(auth): accounts are identified by an email address
Registration, login and the admin's create-user call take `email` instead of
`username`, and the user object returns `email`. The address is checked for its
shape (a plain address, no display name, at most 254 bytes), trimmed, lowercased
and unique. Sonda sends no mail and does not verify it.

- Migration 0018 renames the users column (and the PostgreSQL index); values are
  kept, so an account made before keeps its plain name and still logs in with it
  (login does not check the shape).
- Error code username_taken becomes email_taken; the JWT claim is now `email`,
  so access tokens issued before the upgrade are refused once and clients refresh.
- OpenAPI spec, README, the web login form (type email), strings (en, it) and
  the generated API types follow.

Closes #65
2026-11-12 14:40:33 +01:00
tgiachi
1f8498f6ea feat(web): hooks for libraries and scanning
List, add, rename or move and remove libraries, start a scan of one or all (reading every file again on request), and follow the scan by reading its status while it runs.
2026-11-12 14:40:22 +01:00
tgiachi
0527a12c87 feat(web): the Lidarr button on the artist page and on Discover cards
The artist page reads what Lidarr has first, so it also works for an artist the library has nothing of. A card does not ask Lidarr anything until an admin sends the artist.
2026-11-12 14:30:29 +01:00
tgiachi
67205ec2e1 feat(web): the Request on Lidarr button, for admins, with a confirmation first
Only an admin gets it. It reads what Lidarr has before showing itself (or, on a list card, not at all), asks before sending, sends one artist once, and explains every outcome in words, including a timeout that rereads the state. The API types are regenerated from the spec, which gained the Lidarr endpoints and providers since they were last built.
2026-11-12 14:29:46 +01:00
tgiachi
9dcb7637e7 feat(web): hooks to read and send an artist to Lidarr
Reading is a status, never an error. Sending is one POST for one artist; when it worked, or Lidarr did not answer in time, what Lidarr has is read again.
2026-11-12 14:28:17 +01:00
tgiachi
44dbc727aa fix(web): no photo lookups for artists you do not have, and stale suggestions after changes
A suggestion for an artist outside the library no longer asks for its photo, since that makes the server look the name up at the providers for every card. Changing a wish or a dismissal marks the kept suggestions old without asking Discover at once. Visible focus on the switch, the tabs and the chip buttons.
2026-11-12 14:17:05 +01:00
tgiachi
edbe212f46 fix(web): clear the artist box after choosing, wrap suggestion cards on phones
Found in a real browser: after choosing a starting artist the box kept its text and claimed nothing matched, the card's buttons squeezed the name on a phone, and the switch knob was almost invisible when off.
2026-11-12 14:15:51 +01:00
tgiachi
0198a6d10b fix(web): say what to do when Discover starts from a listening that is empty
Found against a real server: with the setting on and nothing played, the answer is empty with no seeds. The page now says to play something or pick an artist, instead of a plain 'no suggestions'.
2026-11-12 14:12:57 +01:00
tgiachi
88d3df9f61 feat(web): the Discover page with its three tabs, a sidebar link and a route
The tab is kept in the address (?tab=) and moves with the arrow keys; only the open tab asks the server for its list. README now describes Discover in the web app.
2026-11-12 14:11:27 +01:00
tgiachi
6d03b1b661 feat(web): the wishlist and the not-interested lists
Paged rows with remove, not interested and interested again. An artist links to its page only when it is in the library, since one kept alive only by a mark answers 404. The wishlist can hide the artists you already have.
2026-11-12 14:10:07 +01:00
tgiachi
60349153c0 feat(web): the Suggestions tab of Discover with seeds, taste and clear states
Nothing is asked of Discover until there is an artist the user picked or their listening is allowed. Covers a busy server (Retry-After countdown), Last.fm off or failing, cancelling a slow request when leaving, and no automatic retries. Also adds the starting-artist picker and a taste panel.
2026-11-12 14:09:24 +01:00
tgiachi
71b0b39a07 feat(web): a card for a Discover suggestion with its score explained
Shows the score in percent, the seeds it comes from, a part-by-part explanation (a missing genre is not a zero), and the wishlist and not-interested actions.
2026-11-12 14:06:49 +01:00
tgiachi
3cd0ef7150 feat(web): a switch in Settings for starting Discover from your listening
Turning it on shows a dialog that says the names of the most played artists go to Last.fm. Turning it off asks nothing, and a failed change leaves the switch as it was.
2026-11-12 14:05:49 +01:00
tgiachi
63ed483936 feat(web): data hooks for Discover, the wishlist, dismissed artists, taste and own settings
Suggestions are kept five minutes and cancelled when nobody looks. Wishlist and dismiss change the suggestions at once and go back if the call fails.
2026-11-12 14:04:16 +01:00
tgiachi
54b19d6d4f feat(web): lists in query values, request cancelling and Retry-After in the API client
A list value is sent once per item (seed=1&seed=2). A signal can cancel a request and a cancelled call rejects with AbortError, not as a lost connection. ApiError keeps Retry-After in seconds.
2026-11-12 14:03:11 +01:00
tgiachi
075e000fd8 feat(web): a button for browser full screen
- one button in the player bar and one in the full-screen player puts the whole page in full screen and takes it out
- it follows the browser: Esc and F11 flip it back, a refused request leaves the page as it was
- left out where the browser has no Fullscreen API (for example iPhone Safari)
- English and Italian labels
2026-11-12 12:28:15 +01:00
tgiachi
241c1efc5d feat(web): Neon theme
- colour in the surfaces too: deep indigo ground, saturated violet panels, electric yellow accent
- checked by the same contrast test as the other themes
- README lists six themes
2026-11-12 12:10:36 +01:00
tgiachi
0d5805fd37 feat(web): Dracula theme
- a livelier dark theme: violet ground, hot pink accent
- covered by the same contrast test as the others
- README lists five themes
2026-11-12 12:08:54 +01:00
tgiachi
d7bd2c75db style(web): squarer corners
- base radius from 10px to 4px; one value (--radius in src/index.css) sets every corner
- no fully round shapes any more: play button, search box, pills and artist photos are squares with small corners
2026-11-12 12:03:53 +01:00
tgiachi
80a26aeb4a fix(web): keep the player bar on screen, label the settings choices, compact menu on phones
- the player bar stays at the bottom on long pages (sticky sits on its wrapper, not on the bar)
- theme and language groups in Settings have a visible label
- on a phone the menu is a row of links instead of a tall card, and the privacy note is left out there
- the full-screen player is centred vertically
Found by running the app in a real browser against a real server.
2026-11-12 11:58:48 +01:00
tgiachi
9eb9341593 fix(web): renew the session in the background, work over plain HTTP, and do not carry a queue to the next sign-in
- the token is renewed in the background when under 3 minutes are left, so the stream URL of the next track is never built from an expired token
- a renewal adopts a session from another tab only when it differs from the one in memory
- listen keys no longer need crypto.randomUUID, which does not exist on pages opened over plain HTTP on a local network
- signing out, or closing the app, stops the music and empties the queue, and the play in progress is reported first
- a provider address that is not an http(s) address is shown as text, never as a link
2026-11-12 11:48:32 +01:00
tgiachi
e0c42dd5ac docs(web): how to run and build the web app
- README section for the web client: how to run it next to sondad, what it does today, the commands
- the greeting on Home is read once per visit (lint: no Date during render)
- checked against a real sondad: login, renewal and spent refresh tokens, media URLs with Range, listens, search, and the provider-off answers
2026-11-12 11:45:20 +01:00
tgiachi
005d0808e9 feat(web): settings for theme, language and password
- theme and language as radio groups, each theme with a preview of its colours, the choice remembered
- change password: 8 to 256 bytes checked before sending; a changed password signs this session out, as the server ends every session
- account name and role, and sign out
2026-11-12 11:41:14 +01:00
tgiachi
3a93c65574 feat(web): home page
- greeting by the hour, recently played songs from the listening history (each song once), shelves of albums and artists
- an empty history, an empty library and a song that is gone each get their own short message
- a shelf that cannot be loaded does not hide the others
2026-11-12 11:39:56 +01:00
tgiachi
77d60664bb feat(web): search
- search page with a 250 ms pause after typing, the text kept in the address, and at most 200 characters sent
- artists, albums and songs in three groups of six, each with a link to the full list
- accents and capitals are left to the server, which ignores them
- list hooks can take a smaller page size and stay switched off until there is something to ask
2026-11-12 11:38:10 +01:00
tgiachi
e2899c6647 feat(web): artists, albums and songs pages with provider data and attribution
- lists of artists, albums and songs, loaded 50 at a time, with the search text taken from the address
- album page and artist page; a click on a song plays the list from there
- artist page shows a Wikipedia text, similar artists and tags with their credits, and the photo credit
- providers that are off, unreachable or without an id give a short explanation, never an error page
- artists a provider named, with nothing to play, still have a page
2026-11-12 11:36:35 +01:00
tgiachi
20856f2ec6 feat(web): player bar and full-screen player
- bar at the bottom of every page with cover, artists, controls, seek and time
- full-screen player in a dialog: big cover, bar-style seek control, up next, focus kept inside, Escape closes
- Space plays and pauses unless the key belongs to a field, a button or a link
- songs list row, seek control and time formatting
- jumpTo in the queue store for a click on an upcoming track
2026-11-12 11:32:29 +01:00
tgiachi
4ab5f8ace9 feat(web): report listens, one event per play
- one event per play with its own idempotency key: complete, skip, or play when the page closes
- a failed send is retried with the same body and key after 1, 4 and 16 seconds; a 400 or 404 is final
- closing the page sends the open play and anything waiting for a retry with keepalive
- a hidden tab keeps playing, so only pagehide ends a play early
2026-11-12 11:28:50 +01:00
tgiachi
92d9c8ed78 feat(web): audio engine that survives token renewal
- drives the audio element from the player store: load, play, pause, seek, next on end
- a renewed access token swaps the stream URL and resumes at the same second, playing or paused
- reports start, listened time (in steps of at most two seconds) and finish for the listen reporter
- media keys and lock screen through the Media Session API
2026-11-12 11:26:54 +01:00
tgiachi
cffa8f1976 feat(web): player queue store
- queue with next, previous, seek, repeat (off, all, one), shuffle that keeps the original order, enqueue, play next and remove
- seek and restart requests are explicit, so the audio engine can follow them
2026-11-12 11:24:55 +01:00
tgiachi
3ffd07c546 feat(web): app shell, sidebar and routes
- sidebar with the current page marked, privacy note, and a main area that wraps on narrow screens
- routes for home, search, artists, albums, songs and settings, and a not-found page
2026-11-12 11:23:24 +01:00
tgiachi
1250fd4eac feat(web): catalog hooks, covers and artist photos with fallbacks
- paged lists for artists, albums and songs, 50 at a time, with search text and artist/album filters
- cover and artist photo that fall back to rings or an initial, and retry when the token is renewed
2026-11-12 11:22:16 +01:00
tgiachi
1c5b4a4fa0 feat(web): API client, session with cross-tab refresh, login screen
- fetch client with bearer token, one retry after a renewal, ApiError with the server code
- session kept in localStorage; renewal is single-flight in a tab and under a Web Lock across tabs, and a tab adopts a session another tab already renewed
- a refused refresh token signs out once; an unreachable server keeps the session
- mediaUrl and onTokenChange for audio and image URLs that carry the token
- sign-in and first-account screen, and a gate that shows the app only when signed in
2026-11-12 11:21:06 +01:00
tgiachi
7363b80ebd feat(web): English and Italian UI text
- i18next with en and it, language from the stored choice, then the browser, then English
- a test keeps both files on the same keys with no empty text
- API error codes map to error.<code>, with error.unknown as the fallback
2026-11-12 11:18:34 +01:00
tgiachi
abeef4e30f feat(web): four themes with a contrast test
- Sonda, Tokyo Night, Gruvbox dark and Gruvbox light as CSS variables with shadcn token names
- contrast test: text 4.5:1, accent and form outlines 3:1 in every theme
- Gruvbox dark muted text lightened to pass
- theme choice is stored in localStorage and survives it being blocked
2026-11-12 11:17:41 +01:00
tgiachi
f1da4b5aaf feat(web): scaffold the React app with Vite, Tailwind and shadcn/ui
- Vite, React 19 and TypeScript in web/, Vitest with jsdom and Testing Library
- Tailwind v4 and shadcn/ui, with Figtree and Fraunces bundled locally
- npm run gen:api builds src/api/schema.d.ts from the OpenAPI spec
- dev server proxies /api to sondad (SONDA_URL, default 127.0.0.1:8080)
- mockFetch test helper that refuses unmatched requests
2026-11-12 11:15:50 +01:00