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:
@@ -29,8 +29,8 @@ optional_bearer = HTTPBearer(auto_error=False)
|
||||
async def setup_auth(req: SetupRequest):
|
||||
"""Initial setup endpoint to configure the master password.
|
||||
|
||||
This endpoint also initializes the configuration with default values
|
||||
and saves the anime directory and master password hash.
|
||||
This endpoint also initializes the configuration with all provided values
|
||||
and saves them to config.json.
|
||||
"""
|
||||
if auth_service.is_configured():
|
||||
raise HTTPException(
|
||||
@@ -44,26 +44,77 @@ async def setup_auth(req: SetupRequest):
|
||||
req.master_password
|
||||
)
|
||||
|
||||
# Initialize or update config with master password hash
|
||||
# and anime directory
|
||||
# Initialize or update config with all provided values
|
||||
config_service = get_config_service()
|
||||
try:
|
||||
config = config_service.load_config()
|
||||
except Exception:
|
||||
# If config doesn't exist, create default
|
||||
from src.server.models.config import (
|
||||
SchedulerConfig,
|
||||
LoggingConfig,
|
||||
BackupConfig,
|
||||
NFOConfig,
|
||||
)
|
||||
config = AppConfig()
|
||||
|
||||
# Update basic settings
|
||||
if req.name:
|
||||
config.name = req.name
|
||||
if req.data_dir:
|
||||
config.data_dir = req.data_dir
|
||||
|
||||
# Update scheduler configuration
|
||||
if req.scheduler_enabled is not None:
|
||||
config.scheduler.enabled = req.scheduler_enabled
|
||||
if req.scheduler_interval_minutes is not None:
|
||||
config.scheduler.interval_minutes = req.scheduler_interval_minutes
|
||||
|
||||
# Update logging configuration
|
||||
if req.logging_level:
|
||||
config.logging.level = req.logging_level.upper()
|
||||
if req.logging_file is not None:
|
||||
config.logging.file = req.logging_file
|
||||
if req.logging_max_bytes is not None:
|
||||
config.logging.max_bytes = req.logging_max_bytes
|
||||
if req.logging_backup_count is not None:
|
||||
config.logging.backup_count = req.logging_backup_count
|
||||
|
||||
# Update backup configuration
|
||||
if req.backup_enabled is not None:
|
||||
config.backup.enabled = req.backup_enabled
|
||||
if req.backup_path:
|
||||
config.backup.path = req.backup_path
|
||||
if req.backup_keep_days is not None:
|
||||
config.backup.keep_days = req.backup_keep_days
|
||||
|
||||
# Update NFO configuration
|
||||
if req.nfo_tmdb_api_key is not None:
|
||||
config.nfo.tmdb_api_key = req.nfo_tmdb_api_key
|
||||
if req.nfo_auto_create is not None:
|
||||
config.nfo.auto_create = req.nfo_auto_create
|
||||
if req.nfo_update_on_scan is not None:
|
||||
config.nfo.update_on_scan = req.nfo_update_on_scan
|
||||
if req.nfo_download_poster is not None:
|
||||
config.nfo.download_poster = req.nfo_download_poster
|
||||
if req.nfo_download_logo is not None:
|
||||
config.nfo.download_logo = req.nfo_download_logo
|
||||
if req.nfo_download_fanart is not None:
|
||||
config.nfo.download_fanart = req.nfo_download_fanart
|
||||
if req.nfo_image_size:
|
||||
config.nfo.image_size = req.nfo_image_size.lower()
|
||||
|
||||
# Store master password hash in config's other field
|
||||
config.other['master_password_hash'] = password_hash
|
||||
|
||||
# Store anime directory in config's other field if provided
|
||||
anime_directory = None
|
||||
if hasattr(req, 'anime_directory') and req.anime_directory:
|
||||
if req.anime_directory:
|
||||
anime_directory = req.anime_directory.strip()
|
||||
if anime_directory:
|
||||
config.other['anime_directory'] = anime_directory
|
||||
|
||||
# Save the config with the password hash and anime directory
|
||||
# Save the config with all updates
|
||||
config_service.save_config(config, create_backup=False)
|
||||
|
||||
# Sync series from data files to database if anime directory is set
|
||||
|
||||
Reference in New Issue
Block a user