adding velocity control
This commit is contained in:
@@ -22,11 +22,11 @@ The app is intentionally small: one Go binary serves both the API and embedded f
|
||||
## Repository Organization
|
||||
|
||||
- `main.go`: backend entrypoint. Owns the HTTP server, embedded static file serving, environment-driven Transmission RPC client configuration, session-ID handshake, connection warning page, JSON helpers, and API routes.
|
||||
- `web/index.html`: SPA shell. Defines the header, stats pills, filter input, sort buttons, list container, empty state, error state, footer, and script/style links.
|
||||
- `web/index.html`: SPA shell. Defines the header, stats pills, alternative-speed controls, filter input, sort buttons, list container, empty state, error state, footer, and script/style links.
|
||||
- `web/icon.svg`: editable vector source for the app icon.
|
||||
- `web/icon.png`: reusable raster app icon used by the SPA header and browser tab.
|
||||
- `web/app.js`: frontend application logic. Owns state, polling, fetch helpers, formatting, torrent classification, sorting, keyed DOM reconciliation, pause/resume actions, and event wiring.
|
||||
- `web/styles.css`: all styling. Owns dark theme variables, layout, cards, badges, progress bars, action buttons, empty/error states, and responsive rules.
|
||||
- `web/app.js`: frontend application logic. Owns state, polling, fetch helpers, formatting, session-limit presentation and alternative-speed toggling, torrent classification, sorting, keyed DOM reconciliation, pause/resume actions, and event wiring.
|
||||
- `web/styles.css`: all styling. Owns dark theme variables, layout, cards, badges, progress bars, action buttons, alternative-speed controls, empty/error states, and responsive rules.
|
||||
- `go.mod`: Go module declaration.
|
||||
- `Dockerfile`: multi-stage production build.
|
||||
- `README.md`: public project documentation, configuration guide, and deployment instructions.
|
||||
@@ -38,13 +38,15 @@ The backend uses `net/http` with a single `http.ServeMux`. It exposes:
|
||||
|
||||
- `GET /api/torrents`: sends Transmission `torrent-get` with the required torrent fields and returns the RPC `arguments` JSON directly.
|
||||
- `GET /api/stats`: sends Transmission `session-stats` and returns the RPC `arguments` JSON directly.
|
||||
- `GET /api/session`: sends Transmission `session-get` for alternative-speed state, normal and alternative speed limits, and speed-unit metadata; returns the RPC `arguments` JSON directly.
|
||||
- `POST /api/session/alternative-speed`: validates an `{"enabled": boolean}` body and sends Transmission `session-set` to toggle alternative speeds.
|
||||
- `POST /api/torrents/{id}/pause`: validates a positive numeric torrent id and sends `torrent-stop`.
|
||||
- `POST /api/torrents/{id}/resume`: validates a positive numeric torrent id and sends queue-respecting `torrent-start`.
|
||||
- `/`: checks the Transmission connection and serves a warning page with the connection error when setup fails; otherwise serves embedded files from `web/`.
|
||||
|
||||
Transmission RPC calls must reuse the existing `Client.rpc` path so session-ID handling is consistent. The session ID is cached in `Client.sessionID` and guarded by `sync.Mutex`.
|
||||
|
||||
API errors return JSON with an `error` string. Invalid torrent action methods should return `405`; invalid ids should return `400`; unknown action paths should return `404`; Transmission failures should return `502`.
|
||||
API errors return JSON with an `error` string. Invalid torrent action methods should return `405`; invalid ids or malformed alternative-speed bodies should return `400`; unknown action paths should return `404`; Transmission failures should return `502`.
|
||||
|
||||
## Transmission RPC Model
|
||||
|
||||
@@ -67,9 +69,11 @@ The UI definition of "peers at 100%" is an absolute count of `peers[]` entries w
|
||||
|
||||
The UI availability value comes from Transmission's `availability` per-piece array. Render and sort it as a complete-copy estimate, treating `-1` entries as pieces available locally.
|
||||
|
||||
Alternative-speed controls use the effective profile: alternative caps when `alt-speed-enabled` is true, otherwise enabled normal caps. Positive caps are displayed in the header; zero or negative values are treated as unrestricted.
|
||||
|
||||
## Frontend Architecture
|
||||
|
||||
The frontend is a single page with module-level state in `web/app.js`. It polls on a user-selectable interval, defaults to 3 seconds, and fetches torrents and stats in parallel.
|
||||
The frontend is a single page with module-level state in `web/app.js`. It polls on a user-selectable interval, defaults to 3 seconds, and fetches torrents, stats, and session settings in parallel.
|
||||
|
||||
Important patterns:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user