Admin requests: paginated API & UI overhaul

Add a paginated Admin Requests API and fully refactor the admin requests UI to support filtering, sorting, pagination, and URL state.

- New API: src/app/api/admin/requests/route.ts implements paginated, searchable, filterable, and sortable request listing with proper relation includes and pagination metadata.
- Frontend: RecentRequestsTable rewritten to fetch via SWR (authenticatedFetcher), read/write URL query params, debounce search, support status/user filters, sortable columns, page size selector, and full pagination UI; added loading/error states and toast feedback for actions.
- Admin page updated to use Suspense and the new RecentRequestsTable (component now fetches its own data).
- Settings: deprecated single download-client PUT route now maps updates into the new multi-client format (download_clients JSON), logs deprecation, and invalidates download client manager; settings GET now reads multi-client config for backward compatibility.
- Processors: monitor-download and retry-failed-imports updated to use the download-client-manager and new PathMappingConfig shape for path mapping logic.
- Minor API/schema updates: request-with-torrent schema extended (indexerId, infoUrl, protocol) and setup complete no longer writes legacy path keys.
- Tests updated to reflect API and processor changes.

This change centralizes request management on the server, modernizes the UI for large datasets, and migrates download client settings toward a multi-client configuration while keeping backward compatibility.
This commit is contained in:
kikootwo
2026-02-02 10:24:09 -05:00
parent 2cda6decbe
commit aefc9ef667
15 changed files with 1258 additions and 361 deletions
+21 -2
View File
@@ -9,7 +9,7 @@ Comprehensive overview of system metrics, active requests, download monitoring,
- **Metrics:** Total requests, active downloads, completed/failed requests, total users, system health
- **Requests Awaiting Approval:** Grid of requests pending admin approval (approve/deny buttons, auto-refresh)
- **Active Downloads:** Real-time table with title, progress, speed, ETA
- **Recent Requests:** Last 50 with status and timestamps
- **Request Management:** Full-featured table with filtering, sorting, pagination
- **Quick Actions:** Links to settings, users, scheduled jobs, system logs
## Data Sources
@@ -25,8 +25,15 @@ Comprehensive overview of system metrics, active requests, download monitoring,
**GET /api/admin/downloads/active**
- Request ID, title, progress %, speed, ETA, user
**GET /api/admin/requests/recent**
**GET /api/admin/requests** (Paginated)
- Query params: `page`, `pageSize` (10|25|50|100), `search`, `status`, `userId`, `sortBy`, `sortOrder`
- Returns: `requests[]`, `total`, `page`, `pageSize`, `totalPages`
- Sorting: createdAt (default), completedAt, title, user, status
- Filtering: by status, by user, text search (title/author)
**GET /api/admin/requests/recent** (Legacy)
- Request ID, title, user, status, created/completed dates
- Limited to 50 entries, no filtering
**GET /api/admin/requests/pending-approval**
- Requests with status 'awaiting_approval', includes audiobook + user details
@@ -54,6 +61,18 @@ Comprehensive overview of system metrics, active requests, download monitoring,
- Returns: Job logs with request/audiobook/user details, pagination info
- Filters: status (all/pending/active/completed/failed/delayed/stuck), type (all job types)
## Request Management Features
- **Filter Bar:**
- Text search (title/author, 300ms debounce)
- Status dropdown (all statuses)
- User dropdown (all users)
- Clear filters button
- **Sortable Columns:** Click headers to sort by title, user, status, requested, completed
- **Pagination:** Page navigation, page size selector (10/25/50/100), results count
- **URL State:** Filters/sort/page stored in URL query params (shareable, bookmarkable)
- **Actions:** Delete, cancel, manual search, fetch ebook (via dropdown)
## Features
- Auto-refresh every 10 seconds (SWR)