Enhanced setup and settings pages with full configuration

- Extended SetupRequest model to include all configuration fields
- Updated setup API endpoint to handle comprehensive configuration
- Created new setup.html with organized configuration sections
- Enhanced config modal in index.html with all settings
- Updated JavaScript modules to use unified config API
- Added backup configuration section
- Documented new features in features.md and instructions.md
This commit is contained in:
2026-01-17 18:01:15 +01:00
parent d676cb7dca
commit 4e29c4ed80
12 changed files with 1807 additions and 680 deletions

View File

@@ -8,32 +8,32 @@ The goal is to create a FastAPI-based web application that provides a modern int
## Architecture Principles
- **Single Responsibility**: Each file/class has one clear purpose
- **Dependency Injection**: Use FastAPI's dependency system
- **Clean Separation**: Web layer calls core logic, never the reverse
- **File Size Limit**: Maximum 500 lines per file
- **Type Hints**: Use comprehensive type annotations
- **Error Handling**: Proper exception handling and logging
- **Single Responsibility**: Each file/class has one clear purpose
- **Dependency Injection**: Use FastAPI's dependency system
- **Clean Separation**: Web layer calls core logic, never the reverse
- **File Size Limit**: Maximum 500 lines per file
- **Type Hints**: Use comprehensive type annotations
- **Error Handling**: Proper exception handling and logging
## Additional Implementation Guidelines
### Code Style and Standards
- **Type Hints**: Use comprehensive type annotations throughout all modules
- **Docstrings**: Follow PEP 257 for function and class documentation
- **Error Handling**: Implement custom exception classes with meaningful messages
- **Logging**: Use structured logging with appropriate log levels
- **Security**: Validate all inputs and sanitize outputs
- **Performance**: Use async/await patterns for I/O operations
- **Type Hints**: Use comprehensive type annotations throughout all modules
- **Docstrings**: Follow PEP 257 for function and class documentation
- **Error Handling**: Implement custom exception classes with meaningful messages
- **Logging**: Use structured logging with appropriate log levels
- **Security**: Validate all inputs and sanitize outputs
- **Performance**: Use async/await patterns for I/O operations
## 📞 Escalation
If you encounter:
- Architecture issues requiring design decisions
- Tests that conflict with documented requirements
- Breaking changes needed
- Unclear requirements or expectations
- Architecture issues requiring design decisions
- Tests that conflict with documented requirements
- Breaking changes needed
- Unclear requirements or expectations
**Document the issue and escalate rather than guessing.**
@@ -92,45 +92,77 @@ conda run -n AniWorld python -m uvicorn src.server.fastapi_app:app --host 127.0.
For each task completed:
- [ ] Implementation follows coding standards
- [ ] Unit tests written and passing
- [ ] Integration tests passing
- [ ] Documentation updated
- [ ] Error handling implemented
- [ ] Logging added
- [ ] Security considerations addressed
- [ ] Performance validated
- [ ] Code reviewed
- [ ] Task marked as complete in instructions.md
- [ ] Infrastructure.md updated and other docs
- [ ] Changes committed to git; keep your messages in git short and clear
- [ ] Take the next task
- [ ] Implementation follows coding standards
- [ ] Unit tests written and passing
- [ ] Integration tests passing
- [ ] Documentation updated
- [ ] Error handling implemented
- [ ] Logging added
- [ ] Security considerations addressed
- [ ] Performance validated
- [ ] Code reviewed
- [ ] Task marked as complete in instructions.md
- [ ] Infrastructure.md updated and other docs
- [ ] Changes committed to git; keep your messages in git short and clear
- [ ] Take the next task
---
## TODO List:
<!-- No pending issues -->
### ✅ Feature: Enhanced Setup and Settings Pages (COMPLETED)
## Recently Fixed Issues
1. **Setup Page Configuration**
- [x] Update setup page to allow configuration of the following settings:
- `name`: Application name (default: "Aniworld")
- `data_dir`: Data directory path (default: "data")
- `scheduler`:
- `enabled`: Enable/disable scheduler (default: true)
- `interval_minutes`: Scheduler interval in minutes (default: 60)
- `logging`:
- `level`: Log level (default: "INFO")
- `file`: Log file path (default: null)
- `max_bytes`: Max log file size in bytes (default: null)
- `backup_count`: Number of backup log files (default: 3)
- `backup`:
- `enabled`: Enable/disable backups (default: false)
- `path`: Backup directory path (default: "data/backups")
- `keep_days`: Days to keep backups (default: 30)
- `nfo`:
- `tmdb_api_key`: TMDB API key (default: null)
- `auto_create`: Auto-create NFO files (default: true)
- `update_on_scan`: Update NFO on scan (default: true)
- `download_poster`: Download poster images (default: true)
- `download_logo`: Download logo images (default: true)
- `download_fanart`: Download fanart images (default: true)
- `image_size`: Image size preference (default: "original")
- [x] Implement validation for all configuration fields
- [x] Add form UI with appropriate input types and validation feedback
- [x] Save configuration to config.json on setup completion
### 1. NFO API Endpoint Mismatch (Fixed: 2026-01-16)
2. **Settings Page Enhancement**
- [x] Display all configuration settings in settings page
- [x] Make all settings editable:
- General: `name`, `data_dir`
- Scheduler: `enabled`, `interval_minutes`
- Logging: `level`, `file`, `max_bytes`, `backup_count`
- Backup: `enabled`, `path`, `keep_days`
- NFO: `tmdb_api_key`, `auto_create`, `update_on_scan`, `download_poster`, `download_logo`, `download_fanart`, `image_size`
- Other: `master_password_hash` (allow password change), `anime_directory`
- [x] Implement save functionality with validation
- [x] Add success/error notifications for settings updates
- [x] Settings changes are applied immediately via API (some may require restart)
- [x] Add configuration section headers for better organization
- [x] Update JavaScript modules to handle all new configuration fields
**Issue**: Frontend JavaScript was calling incorrect NFO API endpoints causing 404 errors.
**Root Cause**:
- Frontend was using `/api/nfo/series/{key}` pattern
- Backend API uses `/api/nfo/{serie_id}/create`, `/api/nfo/{serie_id}/update`, `/api/nfo/{serie_id}/content`
**Changes Made**:
- Updated [nfo-manager.js](../src/server/web/static/js/index/nfo-manager.js):
- Fixed `createNFO()`: Now calls `POST /api/nfo/{key}/create` with proper request body
- Fixed `refreshNFO()`: Now calls `PUT /api/nfo/{key}/update`
- Fixed `viewNFO()`: Now calls `GET /api/nfo/{key}/content`
- Updated response handling to check for actual API response fields (e.g., `message`, `content`)
- Removed non-existent `getStatistics()` function
- Fixed `getSeriesWithoutNFO()` to use correct endpoint and response structure
**Status**: ✅ Fixed and tested
**Implementation Notes:**
- The setup page ([setup.html](../src/server/web/templates/setup.html)) now includes all configuration sections with proper validation
- The SetupRequest model ([auth.py](../src/server/models/auth.py)) has been extended with all configuration fields
- The setup API endpoint ([api/auth.py](../src/server/api/auth.py)) now saves all configuration values
- The config modal in [index.html](../src/server/web/templates/index.html) displays all settings with organized sections
- JavaScript modules ([main-config.js](../src/server/web/static/js/index/main-config.js), [scheduler-config.js](../src/server/web/static/js/index/scheduler-config.js), [logging-config.js](../src/server/web/static/js/index/logging-config.js), [nfo-config.js](../src/server/web/static/js/index/nfo-config.js)) have been updated to use the unified config API
- All configuration is saved through the `/api/config` endpoint using PUT requests
- Configuration validation is performed both client-side and server-side
---