diff --git a/api/router.py b/api/router.py index 9d353ea..9430e5e 100644 --- a/api/router.py +++ b/api/router.py @@ -98,7 +98,7 @@ async def setup_post(body: dict): @router.get("/status") async def get_status(user: dict = Depends(current_user)): - return {"status": state.status, "username": user["username"]} + return {"status": state.status, "username": user["username"], "is_admin": user.get("is_admin", False)} @router.post("/toggle") diff --git a/frontend/app.js b/frontend/app.js index d80a868..841b719 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -181,6 +181,14 @@ async function loadTranscripts() { if (data.username) { userChip.textContent = data.username; } + if (data.is_admin) { + const gearLink = document.createElement('a'); + gearLink.href = '/settings'; + gearLink.className = 'back-btn'; + gearLink.title = 'Einstellungen'; + gearLink.textContent = '\u2699'; + document.querySelector('.header-right').prepend(gearLink); + } connectWs(); loadTranscripts(); })(); diff --git a/frontend/index.html b/frontend/index.html index 46d1615..388f9d5 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -68,6 +68,13 @@ transition: border-color 0.15s, color 0.15s; } .logout-btn:hover { border-color: var(--red); color: var(--red); } + .back-btn { + font-size: .75rem; padding: 4px 10px; border-radius: 20px; + background: none; border: 1px solid var(--border); color: var(--muted); + cursor: pointer; font-family: inherit; text-decoration: none; + transition: border-color .15s, color .15s; + } + .back-btn:hover { border-color: var(--red); color: var(--red); } main { flex: 1; display: flex; diff --git a/tests/test_api.py b/tests/test_api.py index 761b85f..7b7a5a9 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -146,6 +146,20 @@ def test_audio_combined_forbidden_for_non_admin(): app.dependency_overrides.pop(current_user, None) +def test_status_includes_is_admin(): + from main import app + from api.router import current_user + app.dependency_overrides[current_user] = lambda: {"username": "u", "output_dir": "/tmp", "is_admin": True} + try: + from fastapi.testclient import TestClient + client = TestClient(app) + r = client.get("/status", headers={"Authorization": "Bearer fake"}) + assert r.status_code == 200 + assert r.json()["is_admin"] is True + finally: + app.dependency_overrides.pop(current_user, None) + + def test_put_config_deep_merges(tmp_path, monkeypatch): import config as cfg_mod monkeypatch.setattr(cfg_mod, "CONFIG_PATH", str(tmp_path / "config.toml"))