feat(setup): add done button and integrate NFO scan into initialization
- Add /api/setup/unresolved/done endpoint to mark phase complete - NFO scan now runs after series sync during initialization - Middleware redirects to /login after setup complete (was /loading) - Done button allows skipping folder resolution with redirect to NFO scan phase
This commit is contained in:
@@ -13,18 +13,38 @@ The application uses a middleware-based redirect system to ensure users complete
|
||||
│ SETUP FLOW │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ /setup ──► /loading ──┬──► /setup/unresolved ──► /loading │
|
||||
│ │ │ │ │ │
|
||||
│ │ │ │ │ │
|
||||
│ ▼ ▼ ▼ ▼ │
|
||||
│ (first time) (WebSocket) (has folders) (all resolved) │
|
||||
│ │ │ │
|
||||
│ ▼ │ │
|
||||
│ /login ◄───────────────────┴──────────────────────┤
|
||||
│ /setup ──► /loading ──► /setup/unresolved ──► /loading ──► /login │
|
||||
│ │ │ │ │ │
|
||||
│ │ │ │ │ │
|
||||
│ ▼ ▼ ▼ ▼ │
|
||||
│ (first (Series Scan + (has folders) (all resolved) │
|
||||
│ time) NFO Scan) │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ ▼ │
|
||||
│ │ [Done button] ──► marks complete │
|
||||
│ │ │ │
|
||||
│ │ ▼ │
|
||||
│ │ /loading (NFO phase runs again) │
|
||||
│ │ │ │
|
||||
│ └────────┴─────────────────────────────────────┘
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**New Navigation Order:**
|
||||
1. `/setup` → Initial configuration
|
||||
2. `/loading` → Series scan + NFO scan
|
||||
3. `/setup/unresolved` → Resolve folders (if any)
|
||||
4. `/loading` → NFO scan runs again
|
||||
5. `/login` → Authentication
|
||||
|
||||
**Key Changes:**
|
||||
- After `/setup/unresolved`, the "Done" button marks the phase as complete
|
||||
- Revisiting `/setup/unresolved` after completion → redirects to `/loading`
|
||||
- `/loading` always goes to `/setup/unresolved` if unresolved folders exist
|
||||
- NFO scan runs as a separate phase after series sync during initialization
|
||||
|
||||
## Middleware: SetupRedirectMiddleware
|
||||
|
||||
**File:** `src/server/middleware/setup_redirect.py`
|
||||
@@ -49,9 +69,12 @@ The middleware intercepts all requests and redirects to `/setup` if:
|
||||
### Middleware Logic
|
||||
|
||||
1. **Setup incomplete** → Redirect to `/setup`
|
||||
2. **Setup complete, accessing `/setup`** → Redirect to `/loading`
|
||||
2. **Setup complete, accessing `/setup`** → Redirect to `/login`
|
||||
3. **Setup complete, accessing `/loading`** → Allow access (page handles its own redirect)
|
||||
4. **API requests during setup** → Return 503 with `setup_url`
|
||||
4. **Setup complete, accessing `/setup/unresolved`**:
|
||||
- If `unresolved_completed` flag is set → Redirect to `/loading`
|
||||
- Otherwise → Allow access
|
||||
5. **API requests during setup** → Return 503 with `setup_url`
|
||||
|
||||
## Pages
|
||||
|
||||
@@ -104,17 +127,25 @@ Allows manual resolution of folders that couldn't be auto-matched:
|
||||
- Provides search suggestions
|
||||
- Input field for entering provider key
|
||||
- Resolve/delete actions
|
||||
- **Done button** at top to complete the phase without resolving all folders
|
||||
|
||||
**Post-resolution flow:**
|
||||
```javascript
|
||||
function checkEmptyList() {
|
||||
if (listEl.children.length === 0) {
|
||||
// All folders resolved → return to loading
|
||||
setTimeout(() => { window.location.href = '/loading'; }, 2000);
|
||||
}
|
||||
// After clicking "Done" button
|
||||
async function handleDone() {
|
||||
// Call API to mark phase as complete
|
||||
await fetch('/api/setup/unresolved/done', { method: 'POST' });
|
||||
// Redirect to loading for final NFO scan
|
||||
window.location.href = '/loading';
|
||||
}
|
||||
```
|
||||
|
||||
**Done button behavior:**
|
||||
- Marks all remaining folders as handled
|
||||
- Sets `unresolved_completed` flag in config
|
||||
- Redirects to `/loading` to run final NFO scan
|
||||
- After completion, `/setup/unresolved` becomes inaccessible (redirects to `/loading`)
|
||||
|
||||
### 4. Login Page (`/login`)
|
||||
|
||||
**File:** `src/server/web/templates/login.html`
|
||||
@@ -132,6 +163,7 @@ Authentication page. After successful login → redirect to `/` (main app).
|
||||
| `POST` | `/api/setup/unresolved/{folder_name}/resolve` | Resolve with provider key |
|
||||
| `POST` | `/api/setup/unresolved/{folder_name}/search` | Re-search for matches |
|
||||
| `DELETE` | `/api/setup/unresolved/{folder_name}` | Remove folder from tracking |
|
||||
| `POST` | `/api/setup/unresolved/done` | Mark unresolved phase as complete |
|
||||
|
||||
### Auth API
|
||||
|
||||
|
||||
Reference in New Issue
Block a user