feat: ProjectSource auto-fills active project from Manager

Added /api/active-project endpoint that reads current_project from
config. ProjectSource now hides the project_name widget and fetches
the active project automatically on create, load, and click.
Title shows "Source: <label> [<project>]" for at-a-glance status.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 12:07:37 +02:00
parent 2277e6e427
commit 410c80afc8
2 changed files with 76 additions and 28 deletions
+7 -1
View File
@@ -13,7 +13,7 @@ from fastapi.responses import FileResponse
from nicegui import app
from db import ProjectDB
from utils import load_json, KEY_BATCH_DATA, KEY_SEQUENCE_NUMBER
from utils import load_json, load_config, KEY_BATCH_DATA, KEY_SEQUENCE_NUMBER
logger = logging.getLogger(__name__)
@@ -27,6 +27,7 @@ def register_api_routes(db: ProjectDB) -> None:
_db = db
app.add_api_route("/api/projects", _list_projects, methods=["GET"])
app.add_api_route("/api/active-project", _get_active_project, methods=["GET"])
app.add_api_route("/api/projects/{name}/files", _list_files, methods=["GET"])
app.add_api_route("/api/projects/{name}/files/{file_name}/sequences", _list_sequences, methods=["GET"])
app.add_api_route("/api/projects/{name}/files/{file_name}/data", _get_data, methods=["GET"])
@@ -46,6 +47,11 @@ def _list_projects() -> dict[str, Any]:
return {"projects": [p["name"] for p in projects]}
def _get_active_project() -> dict[str, Any]:
config = load_config()
return {"project": config.get("current_project", "")}
def _list_files(name: str) -> dict[str, Any]:
db = _get_db()
files = db.list_project_files(name)