3.5 KiB
Executable File
3.5 KiB
Executable File
Technical Plan: Web Application Settings Mechanism
This plan outlines the implementation of a settings management system for the Superset Tools application, allowing users to configure multiple Superset environments and global application settings (like backup storage) via the web UI.
1. Backend Architecture
1.1 Data Models (Pydantic)
We will define models in backend/src/core/config_models.py:
from pydantic import BaseModel, Field
from typing import List, Optional
class Environment(BaseModel):
id: str
name: str
url: str
username: str
password: str # Will be masked in UI
is_default: bool = False
class GlobalSettings(BaseModel):
backup_path: str
default_environment_id: Optional[str] = None
class AppConfig(BaseModel):
environments: List[Environment] = []
settings: GlobalSettings
1.2 Configuration Manager
A new class ConfigManager in backend/src/core/config_manager.py will handle:
- Loading/saving
AppConfigtoconfig.json. - CRUD operations for environments.
- Updating global settings.
- Validating backup paths and Superset URLs.
- Enforcing system invariants (e.g., at least one environment configured).
1.3 API Endpoints
New router backend/src/api/routes/settings.py:
GET /settings: Retrieve all settings (masking passwords).PATCH /settings/global: Update global settings (backup path, etc.).GET /settings/environments: List all environments.POST /settings/environments: Add a new environment.PUT /settings/environments/{id}: Update an environment.DELETE /settings/environments/{id}: Remove an environment.POST /settings/environments/{id}/test: Test connection to a specific environment.
1.4 Integration
- Update
backend/src/dependencies.pyto provide a singletonConfigManager. - Refactor
superset_tool/utils/init_clients.pyto fetch environment details fromConfigManagerinstead of hardcoded values.
2. Frontend Implementation
2.1 Settings Page
- Create
frontend/src/pages/Settings.svelte. - Add a "Settings" link to the main navigation (likely in
App.svelte).
2.2 Components
- EnvironmentList: Displays a table/list of configured environments with Edit/Delete buttons.
- EnvironmentForm: A modal or inline form for adding/editing environments.
- GlobalSettingsForm: Form for editing the backup storage path.
2.3 API Integration
- Add functions to
frontend/src/lib/api.jsfor interacting with the new settings endpoints.
3. Workflow Diagram
graph TD
UI[Web UI - Settings Page] --> API[FastAPI Settings Router]
API --> CM[Config Manager]
CM --> JSON[(config.json)]
CM --> SS[Superset Instance] : Test Connection
Plugins[Plugins - Backup/Migration] --> CM : Get Env/Path
4. Implementation Steps
- Backend Core:
- Create
config_models.pyandconfig_manager.py. - Implement file-based persistence.
- Create
- Backend API:
- Implement
settings.pyrouter. - Register router in
app.py.
- Implement
- Frontend UI:
- Create
Settings.svelteand necessary components. - Implement API calls and state management.
- Create
- Refactoring:
- Update
init_clients.pyto use the new configuration system. - Ensure existing plugins (Backup, Migration) use the configured settings.
- Update
- Validation:
- Add path existence/write checks for backup storage.
- Add URL/Connection checks for Superset environments.