Files
Showy/docs-vault/Settings Page.md
T

81 lines
2.2 KiB
Markdown

---
title: Settings Page
tags:
- feature
- settings
- maintenance
---
# Settings Page
## Overview
App configuration and maintenance tools at `/settings`. Contains two card sections.
## General Settings
Form using react-hook-form + zod validation.
| Field | Type | Description |
|---|---|---|
| TMDB API Key | Password input | Required for [[TMDB Integration]] |
| Backend Port | Number input | Port the backend server runs on (default 4000) |
Saved via `PUT /api/v1/settings`.
## Cleanup
Maintenance tools for cleaning up orphaned data. Uses backend maintenance endpoints.
### Orphan Files
Files that exist on disk but have **no matching database record**.
| Action | Button | Endpoint | Effect |
|---|---|---|---|
| Scan | `Scan` (outline) | `GET /maintenance/orphan-files` | Dry run — counts only |
| Delete | `Delete` (destructive) | `DELETE /maintenance/orphan-files` | Removes files from disk |
The Delete button only appears when the scan finds orphans.
### Orphan Media Records
Database records that point to **files that no longer exist on disk**.
| Action | Button | Endpoint | Effect |
|---|---|---|---|
| Scan | `Scan` (outline) | `GET /maintenance/orphan-media-records` | Dry run — counts only |
| Delete | `Delete` (destructive) | `DELETE /maintenance/orphan-media-records` | Removes DB records |
### Response Format
Both scan and delete return:
```json
{ "posters": 0, "logos": 0, "backdrops": 0, "stills": 0 }
```
Displayed as: "3 poster(s), 1 backdrop(s)" or "None found".
## Implementation Details
- State: `useState` for scan results (`OrphanResult | null`)
- Mutations: `useMutation` for scan and delete operations
- Loading: `Loader2` spinner on buttons during operations
- Conditional rendering: Delete button only shown when `hasOrphans(result) === true`
## Important Files
| File | Role |
|---|---|
| `react_frontend/src/pages/SettingsPage.tsx` | Page component |
| `react_frontend/src/api/maintenance.ts` | API client |
| `backend/controllers/maintenanceController.js` | Route handlers |
| `backend/services/maintenanceService.js` | Business logic |
## See Also
- [[API Reference#Maintenance]] — Endpoint details
- [[Media System]] — How media files are stored
- [[Env]] — Settings configuration