Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75736dadec | ||
|
|
49e9c9c214 | ||
|
|
8d56c352fc | ||
|
|
00437a92ab | ||
|
|
24f60c0a6d | ||
|
|
fdaf4471da | ||
|
|
6e952f9277 | ||
|
|
952cb90973 | ||
|
|
ebea9946a7 | ||
|
|
bd694b30a6 | ||
|
|
9fb04af7df | ||
|
|
430a928df6 | ||
|
|
c63ec5f700 | ||
|
|
b7f2e2adbe | ||
|
|
bbc59457ac | ||
|
|
190c0dd7fa | ||
|
|
a4376d1cd8 | ||
|
|
a639d08037 | ||
|
|
630a3de88a | ||
|
|
6d0e2de66d | ||
|
|
1fa0edb3b5 | ||
|
|
ac31c5e014 | ||
|
|
422a117026 | ||
|
|
d51bfd3daa | ||
|
|
c2b2c71ccd | ||
|
|
7e8422cbd7 | ||
|
|
3f5b9b8b58 | ||
|
|
5bbea036c2 | ||
|
|
c762495b6f | ||
|
|
979e734bd9 | ||
|
|
79cb3e0100 | ||
|
|
9d22e7e8af | ||
|
|
f46c367c27 | ||
|
|
ac4c6760d7 | ||
|
|
5a6a140dfd | ||
|
|
931012c16b | ||
|
|
03f4b871a9 | ||
|
|
601fc80178 | ||
|
|
3ff2a1bf45 | ||
|
|
51aa57f304 | ||
|
|
ca4411f30f | ||
|
|
b551365fb5 | ||
|
|
272c123952 | ||
|
|
9387670a7b | ||
|
|
d4a8401a6a | ||
|
|
aaf88a6f12 | ||
|
|
b789c1bd44 | ||
|
|
5062aa8068 | ||
|
|
8a042589e7 | ||
|
|
3898b5ad45 | ||
|
|
9d15336144 |
No files matched your search
@@ -13,7 +13,8 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
echo "=== Deploying to DEVELOPMENT ==="
|
echo "=== Deploying to DEVELOPMENT ==="
|
||||||
cd /home/lars/docker/bodytrack-dev
|
cd /home/lars/docker/bodytrack-dev
|
||||||
git pull origin develop
|
git fetch origin develop
|
||||||
|
git reset --hard origin/develop
|
||||||
docker compose -f docker-compose.dev-env.yml build --no-cache
|
docker compose -f docker-compose.dev-env.yml build --no-cache
|
||||||
docker compose -f docker-compose.dev-env.yml up -d
|
docker compose -f docker-compose.dev-env.yml up -d
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
echo "=== Deploying to PRODUCTION ==="
|
echo "=== Deploying to PRODUCTION ==="
|
||||||
cd /home/lars/docker/bodytrack
|
cd /home/lars/docker/bodytrack
|
||||||
git pull origin main
|
# Arbeitskopie = exakt origin/main (vermeidet Abbruch bei lokalem package-lock o. ä.)
|
||||||
|
git fetch origin main
|
||||||
|
git reset --hard origin/main
|
||||||
docker compose -f docker-compose.yml build --no-cache
|
docker compose -f docker-compose.yml build --no-cache
|
||||||
docker compose -f docker-compose.yml up -d
|
docker compose -f docker-compose.yml up -d
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|||||||
+2
-1
@@ -64,4 +64,5 @@ tmp/
|
|||||||
|
|
||||||
# Cursor MCP mit Secrets (Example: .cursor/mcp.json.example)
|
# Cursor MCP mit Secrets (Example: .cursor/mcp.json.example)
|
||||||
.cursor/mcp.json
|
.cursor/mcp.json
|
||||||
.claude/settings.local.jsonfrontend/package-lock.json
|
.claude/settings.local.json
|
||||||
|
frontend/package-lock.json
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
> | Architektur-Regeln | `.claude/rules/ARCHITECTURE.md` |
|
> | Architektur-Regeln | `.claude/rules/ARCHITECTURE.md` |
|
||||||
> | Coding-Regeln | `.claude/rules/CODING_RULES.md` |
|
> | Coding-Regeln | `.claude/rules/CODING_RULES.md` |
|
||||||
> | Lessons Learned | `.claude/rules/LESSONS_LEARNED.md` |
|
> | Lessons Learned | `.claude/rules/LESSONS_LEARNED.md` |
|
||||||
|
> | **GUI / IA / Admin / Nav / PWA-Leiste** | **`docs/issues/GUI_IA_ADMIN_NAV_2026-04-05.md`** |
|
||||||
|
|
||||||
## Claude Code Verantwortlichkeiten
|
## Claude Code Verantwortlichkeiten
|
||||||
|
|
||||||
@@ -69,6 +70,8 @@ backend/
|
|||||||
frontend/src/
|
frontend/src/
|
||||||
├── App.jsx # Root, Auth-Gates, Navigation
|
├── App.jsx # Root, Auth-Gates, Navigation
|
||||||
├── app.css # CSS-Variablen + globale Styles
|
├── app.css # CSS-Variablen + globale Styles
|
||||||
|
├── config/ # appNav.js · adminNav.js (Single Source für Main/Admin-Nav)
|
||||||
|
├── layouts/ # AdminShell · RequireAdmin
|
||||||
├── context/ # AuthContext · ProfileContext
|
├── context/ # AuthContext · ProfileContext
|
||||||
├── pages/ # Alle Screens
|
├── pages/ # Alle Screens
|
||||||
└── utils/
|
└── utils/
|
||||||
@@ -90,6 +93,10 @@ frontend/src/
|
|||||||
**Branch:** develop
|
**Branch:** develop
|
||||||
**Nächster Schritt:** Frontend Chart Integration → Testing → Prod Deploy v0.9i
|
**Nächster Schritt:** Frontend Chart Integration → Testing → Prod Deploy v0.9i
|
||||||
|
|
||||||
|
### GUI / Informationsarchitektur (Abnahme dieser Iteration, 2026-04-05)
|
||||||
|
|
||||||
|
Admin-Bereich (`AdminShell`, Hub-Routen), Hauptnavigation inkl. **Ziele** (`config/appNav.js`), Einstellungen nur aktives Profil + E-Mail, KI-Analyse Ergebnis in rechter Spalte, **PWA** Bottom-Nav inkl. iOS Safe Area. Zentrale Agent-Doku: **`docs/issues/GUI_IA_ADMIN_NAV_2026-04-05.md`**. Responsive-Epic **Gitea #30:** Phasenplan `docs/issues/PHASE_PLAN_RESPONSIVE_UI.md` — **P7 Kern erledigt**, **P8** (Regression/Abnahme) ausstehend; Issue bewusst **nicht** geschlossen.
|
||||||
|
|
||||||
### Updates (28.03.2026 - Phase 0c Multi-Layer Architecture Complete) 🆕
|
### Updates (28.03.2026 - Phase 0c Multi-Layer Architecture Complete) 🆕
|
||||||
|
|
||||||
#### Phase 0c: Multi-Layer Data Architecture ✅ **COMPLETED**
|
#### Phase 0c: Multi-Layer Data Architecture ✅ **COMPLETED**
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
"""Derive lean_mass and fat_mass from weight_log + body_fat_pct for caliper entries."""
|
||||||
|
from datetime import date, datetime
|
||||||
|
from decimal import Decimal
|
||||||
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
from db import get_cursor, r2d
|
||||||
|
|
||||||
|
|
||||||
|
def as_date(d: Any) -> Optional[date]:
|
||||||
|
if d is None:
|
||||||
|
return None
|
||||||
|
if isinstance(d, datetime):
|
||||||
|
return d.date()
|
||||||
|
if isinstance(d, date):
|
||||||
|
return d
|
||||||
|
if isinstance(d, str) and len(d) >= 10:
|
||||||
|
return datetime.strptime(d[:10], "%Y-%m-%d").date()
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _floaty(x: Any) -> float:
|
||||||
|
if isinstance(x, Decimal):
|
||||||
|
return float(x)
|
||||||
|
return float(x)
|
||||||
|
|
||||||
|
|
||||||
|
def load_weight_rows(conn: Any, profile_id: str) -> List[Dict[str, Any]]:
|
||||||
|
cur = get_cursor(conn)
|
||||||
|
cur.execute(
|
||||||
|
"SELECT date, weight FROM weight_log WHERE profile_id=%s ORDER BY date",
|
||||||
|
(profile_id,),
|
||||||
|
)
|
||||||
|
return [r2d(r) for r in cur.fetchall()]
|
||||||
|
|
||||||
|
|
||||||
|
def nearest_weight_kg(weight_rows: List[Dict[str, Any]], caliper_date: Any) -> Optional[float]:
|
||||||
|
td = as_date(caliper_date)
|
||||||
|
if td is None or not weight_rows:
|
||||||
|
return None
|
||||||
|
best: Optional[float] = None
|
||||||
|
best_delta: Optional[int] = None
|
||||||
|
for row in weight_rows:
|
||||||
|
wd = as_date(row.get("date"))
|
||||||
|
if wd is None:
|
||||||
|
continue
|
||||||
|
wraw = row.get("weight")
|
||||||
|
if wraw is None:
|
||||||
|
continue
|
||||||
|
delta = abs((wd - td).days)
|
||||||
|
if best_delta is None or delta < best_delta:
|
||||||
|
best_delta = delta
|
||||||
|
best = _floaty(wraw)
|
||||||
|
return best
|
||||||
|
|
||||||
|
|
||||||
|
def nearest_weight_kg_from_map(wlog: Dict[Any, Any], target_date: Any) -> Optional[float]:
|
||||||
|
if not wlog:
|
||||||
|
return None
|
||||||
|
td = as_date(target_date)
|
||||||
|
if td is None:
|
||||||
|
return None
|
||||||
|
best_w: Optional[float] = None
|
||||||
|
best_delta: Optional[int] = None
|
||||||
|
for wd, wval in wlog.items():
|
||||||
|
if wval is None:
|
||||||
|
continue
|
||||||
|
wdate = as_date(wd)
|
||||||
|
if wdate is None:
|
||||||
|
continue
|
||||||
|
delta = abs((wdate - td).days)
|
||||||
|
if best_delta is None or delta < best_delta:
|
||||||
|
best_delta = delta
|
||||||
|
best_w = _floaty(wval)
|
||||||
|
return best_w
|
||||||
|
|
||||||
|
|
||||||
|
def compute_lean_fat_kg(weight_kg: float, body_fat_pct: float) -> Tuple[float, float]:
|
||||||
|
lean = round(weight_kg - (weight_kg * body_fat_pct / 100.0), 2)
|
||||||
|
fat = round(weight_kg * body_fat_pct / 100.0, 2)
|
||||||
|
return lean, fat
|
||||||
|
|
||||||
|
|
||||||
|
def fill_caliper_body_comp(d: Dict[str, Any], conn: Any, profile_id: str) -> None:
|
||||||
|
"""Mutate caliper API payload (model_dump) before INSERT/UPDATE."""
|
||||||
|
bf = d.get("body_fat_pct")
|
||||||
|
if bf is None:
|
||||||
|
return
|
||||||
|
if d.get("lean_mass") is not None and d.get("fat_mass") is not None:
|
||||||
|
return
|
||||||
|
rows = load_weight_rows(conn, profile_id)
|
||||||
|
w = nearest_weight_kg(rows, d.get("date"))
|
||||||
|
if w is None:
|
||||||
|
return
|
||||||
|
lean, fat = compute_lean_fat_kg(w, _floaty(bf))
|
||||||
|
d["lean_mass"] = lean
|
||||||
|
d["fat_mass"] = fat
|
||||||
|
|
||||||
|
|
||||||
|
def enrich_caliper_row_for_response(row: Dict[str, Any], weight_rows: List[Dict[str, Any]]) -> None:
|
||||||
|
"""Fill missing lean_mass / fat_mass for API responses (read path)."""
|
||||||
|
bf = row.get("body_fat_pct")
|
||||||
|
if bf is None:
|
||||||
|
return
|
||||||
|
if row.get("lean_mass") is not None and row.get("fat_mass") is not None:
|
||||||
|
return
|
||||||
|
w = nearest_weight_kg(weight_rows, row.get("date"))
|
||||||
|
if w is None:
|
||||||
|
return
|
||||||
|
lean, fat = compute_lean_fat_kg(w, _floaty(bf))
|
||||||
|
row["lean_mass"] = lean
|
||||||
|
row["fat_mass"] = fat
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- Migration 035: Backfill caliper lean_mass / fat_mass from nearest weight_log row
|
||||||
|
-- Date: 2026-04-06
|
||||||
|
|
||||||
|
UPDATE caliper_log c
|
||||||
|
SET
|
||||||
|
lean_mass = sub.lean_mass,
|
||||||
|
fat_mass = sub.fat_mass
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
c2.id,
|
||||||
|
round((wl.weight::numeric - (wl.weight::numeric * c2.body_fat_pct::numeric / 100.0))::numeric, 2) AS lean_mass,
|
||||||
|
round((wl.weight::numeric * c2.body_fat_pct::numeric / 100.0)::numeric, 2) AS fat_mass
|
||||||
|
FROM caliper_log c2
|
||||||
|
CROSS JOIN LATERAL (
|
||||||
|
SELECT w.weight
|
||||||
|
FROM weight_log w
|
||||||
|
WHERE w.profile_id = c2.profile_id
|
||||||
|
ORDER BY abs(w.date - c2.date) ASC
|
||||||
|
LIMIT 1
|
||||||
|
) wl
|
||||||
|
WHERE c2.body_fat_pct IS NOT NULL
|
||||||
|
AND (c2.lean_mass IS NULL OR c2.fat_mass IS NULL)
|
||||||
|
) sub
|
||||||
|
WHERE c.id = sub.id;
|
||||||
@@ -28,6 +28,7 @@ class ProfileUpdate(BaseModel):
|
|||||||
goal_weight: Optional[float] = None
|
goal_weight: Optional[float] = None
|
||||||
goal_bf_pct: Optional[float] = None
|
goal_bf_pct: Optional[float] = None
|
||||||
quality_filter_level: Optional[str] = None # Issue #31: Global quality filter
|
quality_filter_level: Optional[str] = None # Issue #31: Global quality filter
|
||||||
|
email: Optional[str] = None # Self-service; leer = entfernen; Änderung setzt Verifikation zurück
|
||||||
|
|
||||||
|
|
||||||
# ── Tracking Models ───────────────────────────────────────────────────────────
|
# ── Tracking Models ───────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from auth import require_auth, check_feature_access, increment_feature_usage
|
|||||||
from models import CaliperEntry
|
from models import CaliperEntry
|
||||||
from routers.profiles import get_pid
|
from routers.profiles import get_pid
|
||||||
from feature_logger import log_feature_usage
|
from feature_logger import log_feature_usage
|
||||||
|
from caliper_composition import enrich_caliper_row_for_response, fill_caliper_body_comp, load_weight_rows
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/caliper", tags=["caliper"])
|
router = APIRouter(prefix="/api/caliper", tags=["caliper"])
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -27,7 +28,11 @@ def list_caliper(limit: int=100, x_profile_id: Optional[str]=Header(default=None
|
|||||||
cur = get_cursor(conn)
|
cur = get_cursor(conn)
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"SELECT * FROM caliper_log WHERE profile_id=%s ORDER BY date DESC LIMIT %s", (pid,limit))
|
"SELECT * FROM caliper_log WHERE profile_id=%s ORDER BY date DESC LIMIT %s", (pid,limit))
|
||||||
return [r2d(r) for r in cur.fetchall()]
|
rows = [r2d(r) for r in cur.fetchall()]
|
||||||
|
weight_rows = load_weight_rows(conn, pid)
|
||||||
|
for row in rows:
|
||||||
|
enrich_caliper_row_for_response(row, weight_rows)
|
||||||
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@router.post("")
|
@router.post("")
|
||||||
@@ -55,6 +60,7 @@ def upsert_caliper(e: CaliperEntry, x_profile_id: Optional[str]=Header(default=N
|
|||||||
cur.execute("SELECT id FROM caliper_log WHERE profile_id=%s AND date=%s", (pid,e.date))
|
cur.execute("SELECT id FROM caliper_log WHERE profile_id=%s AND date=%s", (pid,e.date))
|
||||||
ex = cur.fetchone()
|
ex = cur.fetchone()
|
||||||
d = e.model_dump()
|
d = e.model_dump()
|
||||||
|
fill_caliper_body_comp(d, conn, pid)
|
||||||
is_new_entry = not ex
|
is_new_entry = not ex
|
||||||
|
|
||||||
if ex:
|
if ex:
|
||||||
@@ -86,6 +92,7 @@ def update_caliper(eid: str, e: CaliperEntry, x_profile_id: Optional[str]=Header
|
|||||||
pid = get_pid(x_profile_id)
|
pid = get_pid(x_profile_id)
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
d = e.model_dump()
|
d = e.model_dump()
|
||||||
|
fill_caliper_body_comp(d, conn, pid)
|
||||||
cur = get_cursor(conn)
|
cur = get_cursor(conn)
|
||||||
cur.execute(f"UPDATE caliper_log SET {', '.join(f'{k}=%s' for k in d)} WHERE id=%s AND profile_id=%s",
|
cur.execute(f"UPDATE caliper_log SET {', '.join(f'{k}=%s' for k in d)} WHERE id=%s AND profile_id=%s",
|
||||||
list(d.values())+[eid,pid])
|
list(d.values())+[eid,pid])
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from db import get_db, get_cursor, r2d
|
|||||||
from auth import require_auth, check_feature_access, increment_feature_usage
|
from auth import require_auth, check_feature_access, increment_feature_usage
|
||||||
from routers.profiles import get_pid
|
from routers.profiles import get_pid
|
||||||
from feature_logger import log_feature_usage
|
from feature_logger import log_feature_usage
|
||||||
|
from caliper_composition import enrich_caliper_row_for_response, load_weight_rows
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/export", tags=["export"])
|
router = APIRouter(prefix="/api/export", tags=["export"])
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -68,10 +69,21 @@ def export_csv(x_profile_id: Optional[str]=Header(default=None), session: dict=D
|
|||||||
details = f"Taille:{float(r['c_waist'])}cm Bauch:{float(r['c_belly'])}cm Hüfte:{float(r['c_hip'])}cm"
|
details = f"Taille:{float(r['c_waist'])}cm Bauch:{float(r['c_belly'])}cm Hüfte:{float(r['c_hip'])}cm"
|
||||||
writer.writerow(["Umfänge", r['date'], "", details])
|
writer.writerow(["Umfänge", r['date'], "", details])
|
||||||
|
|
||||||
# Caliper
|
# Caliper (Magermasse aus Gewicht + KF% nachziehen wenn in DB leer)
|
||||||
cur.execute("SELECT date, body_fat_pct, lean_mass FROM caliper_log WHERE profile_id=%s ORDER BY date", (pid,))
|
cur.execute(
|
||||||
for r in cur.fetchall():
|
"SELECT date, body_fat_pct, lean_mass, fat_mass FROM caliper_log WHERE profile_id=%s ORDER BY date",
|
||||||
writer.writerow(["Caliper", r['date'], f"{float(r['body_fat_pct'])}%", f"Magermasse:{float(r['lean_mass'])}kg"])
|
(pid,),
|
||||||
|
)
|
||||||
|
cal_rows = [r2d(r) for r in cur.fetchall()]
|
||||||
|
weight_rows = load_weight_rows(conn, pid)
|
||||||
|
for r in cal_rows:
|
||||||
|
enrich_caliper_row_for_response(r, weight_rows)
|
||||||
|
if r.get("body_fat_pct") is None:
|
||||||
|
continue
|
||||||
|
bf = float(r["body_fat_pct"])
|
||||||
|
lm = r.get("lean_mass")
|
||||||
|
details = f"Magermasse:{float(lm)}kg" if lm is not None else ""
|
||||||
|
writer.writerow(["Caliper", r["date"], f"{bf}%", details])
|
||||||
|
|
||||||
# Nutrition
|
# Nutrition
|
||||||
cur.execute("SELECT date, kcal, protein_g FROM nutrition_log WHERE profile_id=%s ORDER BY date", (pid,))
|
cur.execute("SELECT date, kcal, protein_g FROM nutrition_log WHERE profile_id=%s ORDER BY date", (pid,))
|
||||||
@@ -141,6 +153,10 @@ def export_json(x_profile_id: Optional[str]=Header(default=None), session: dict=
|
|||||||
cur.execute("SELECT * FROM ai_insights WHERE profile_id=%s ORDER BY created DESC", (pid,))
|
cur.execute("SELECT * FROM ai_insights WHERE profile_id=%s ORDER BY created DESC", (pid,))
|
||||||
data['insights'] = [r2d(r) for r in cur.fetchall()]
|
data['insights'] = [r2d(r) for r in cur.fetchall()]
|
||||||
|
|
||||||
|
w_rows = [{'date': x['date'], 'weight': x['weight']} for x in data.get('weight', [])]
|
||||||
|
for row in data.get('caliper', []):
|
||||||
|
enrich_caliper_row_for_response(row, w_rows)
|
||||||
|
|
||||||
def decimal_handler(obj):
|
def decimal_handler(obj):
|
||||||
if isinstance(obj, Decimal):
|
if isinstance(obj, Decimal):
|
||||||
return float(obj)
|
return float(obj)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from db import get_db, get_cursor, r2d
|
|||||||
from auth import require_auth, check_feature_access, increment_feature_usage
|
from auth import require_auth, check_feature_access, increment_feature_usage
|
||||||
from routers.profiles import get_pid
|
from routers.profiles import get_pid
|
||||||
from feature_logger import log_feature_usage
|
from feature_logger import log_feature_usage
|
||||||
|
from caliper_composition import compute_lean_fat_kg, nearest_weight_kg_from_map
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/nutrition", tags=["nutrition"])
|
router = APIRouter(prefix="/api/nutrition", tags=["nutrition"])
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -202,8 +203,12 @@ def nutrition_correlations(x_profile_id: Optional[str]=Header(default=None), ses
|
|||||||
if d in cal_by_date:
|
if d in cal_by_date:
|
||||||
lm = cal_by_date[d].get('lean_mass')
|
lm = cal_by_date[d].get('lean_mass')
|
||||||
bf = cal_by_date[d].get('body_fat_pct')
|
bf = cal_by_date[d].get('body_fat_pct')
|
||||||
row['lean_mass']=float(lm) if lm is not None else None
|
if bf is not None and lm is None:
|
||||||
row['body_fat_pct']=float(bf) if bf is not None else None
|
wkg = nearest_weight_kg_from_map(wlog, d)
|
||||||
|
if wkg is not None:
|
||||||
|
lm, _fat = compute_lean_fat_kg(wkg, float(bf))
|
||||||
|
row['lean_mass'] = float(lm) if lm is not None else None
|
||||||
|
row['body_fat_pct'] = float(bf) if bf is not None else None
|
||||||
result.append(row)
|
result.append(row)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -68,13 +68,62 @@ def get_profile(pid: str, session=Depends(require_auth)):
|
|||||||
|
|
||||||
@router.put("/profiles/{pid}")
|
@router.put("/profiles/{pid}")
|
||||||
def update_profile(pid: str, p: ProfileUpdate, session=Depends(require_auth)):
|
def update_profile(pid: str, p: ProfileUpdate, session=Depends(require_auth)):
|
||||||
"""Update profile by ID (admin)."""
|
"""Update profile by ID."""
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
data = {k:v for k,v in p.model_dump().items() if v is not None}
|
|
||||||
data['updated'] = datetime.now().isoformat()
|
|
||||||
cur = get_cursor(conn)
|
cur = get_cursor(conn)
|
||||||
cur.execute(f"UPDATE profiles SET {', '.join(f'{k}=%s' for k in data)} WHERE id=%s",
|
cur.execute("SELECT * FROM profiles WHERE id=%s", (pid,))
|
||||||
list(data.values())+[pid])
|
row = cur.fetchone()
|
||||||
|
if not row:
|
||||||
|
raise HTTPException(404, "Profil nicht gefunden")
|
||||||
|
rowd = r2d(row)
|
||||||
|
cur_email_norm = (rowd.get("email") or "").strip().lower()
|
||||||
|
|
||||||
|
patch = p.model_dump(exclude_unset=True)
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
if "email" in patch:
|
||||||
|
ev = patch["email"]
|
||||||
|
if ev is None or (isinstance(ev, str) and ev.strip() == ""):
|
||||||
|
if rowd.get("email") is not None:
|
||||||
|
data["email"] = None
|
||||||
|
data["email_verified"] = False
|
||||||
|
data["verification_token"] = None
|
||||||
|
data["verification_expires"] = None
|
||||||
|
else:
|
||||||
|
email_norm = ev.strip().lower()
|
||||||
|
if "@" not in email_norm or len(email_norm) < 5:
|
||||||
|
raise HTTPException(400, "Ungültige E-Mail-Adresse")
|
||||||
|
cur.execute(
|
||||||
|
"""
|
||||||
|
SELECT id FROM profiles
|
||||||
|
WHERE email IS NOT NULL AND lower(trim(email)) = %s AND id <> %s
|
||||||
|
""",
|
||||||
|
(email_norm, pid),
|
||||||
|
)
|
||||||
|
if cur.fetchone():
|
||||||
|
raise HTTPException(409, "E-Mail wird bereits verwendet")
|
||||||
|
data["email"] = email_norm
|
||||||
|
if email_norm != cur_email_norm:
|
||||||
|
data["email_verified"] = False
|
||||||
|
data["verification_token"] = None
|
||||||
|
data["verification_expires"] = None
|
||||||
|
|
||||||
|
nullable_keys = {"goal_weight", "goal_bf_pct", "dob"}
|
||||||
|
for k, v in patch.items():
|
||||||
|
if k == "email":
|
||||||
|
continue
|
||||||
|
if v is None and k in nullable_keys:
|
||||||
|
data[k] = None
|
||||||
|
elif v is not None:
|
||||||
|
data[k] = v
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
return get_profile(pid, session)
|
||||||
|
|
||||||
|
data["updated"] = datetime.now().isoformat()
|
||||||
|
cols = ", ".join(f"{k}=%s" for k in data)
|
||||||
|
vals = list(data.values()) + [pid]
|
||||||
|
cur.execute(f"UPDATE profiles SET {cols} WHERE id=%s", vals)
|
||||||
return get_profile(pid, session)
|
return get_profile(pid, session)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+199
-80
@@ -9,7 +9,8 @@ Endpoints:
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, date
|
||||||
|
from decimal import Decimal, InvalidOperation
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
@@ -19,6 +20,174 @@ from db import get_db, get_cursor
|
|||||||
|
|
||||||
router = APIRouter(prefix="/api/sleep", tags=["sleep"])
|
router = APIRouter(prefix="/api/sleep", tags=["sleep"])
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_row_keys(row: dict) -> dict:
|
||||||
|
return {(k or "").strip(): (v.strip() if isinstance(v, str) else v) for k, v in row.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def _safe_float(value) -> float | None:
|
||||||
|
if value is None or value == "":
|
||||||
|
return None
|
||||||
|
if isinstance(value, (int, float)):
|
||||||
|
return float(value)
|
||||||
|
if isinstance(value, Decimal):
|
||||||
|
return float(value)
|
||||||
|
try:
|
||||||
|
s = str(value).strip().replace(",", ".")
|
||||||
|
return float(s)
|
||||||
|
except (ValueError, InvalidOperation):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_apple_sleep_datetime(value: str) -> datetime:
|
||||||
|
raw = (value or "").strip()
|
||||||
|
if not raw:
|
||||||
|
raise ValueError("empty datetime")
|
||||||
|
fmts = (
|
||||||
|
"%Y-%m-%d %H:%M:%S %z",
|
||||||
|
"%d.%m.%y %H:%M:%S",
|
||||||
|
"%d.%m.%Y %H:%M:%S",
|
||||||
|
"%Y-%m-%d %H:%M:%S",
|
||||||
|
)
|
||||||
|
last_err = None
|
||||||
|
for fmt in fmts:
|
||||||
|
try:
|
||||||
|
return datetime.strptime(raw, fmt)
|
||||||
|
except ValueError as e:
|
||||||
|
last_err = e
|
||||||
|
raise ValueError(f"Unbekanntes Datumsformat: {raw!r}") from last_err
|
||||||
|
|
||||||
|
|
||||||
|
def _hr_to_minutes(hours: float | None) -> int:
|
||||||
|
if hours is None:
|
||||||
|
return 0
|
||||||
|
return int(round(float(hours) * 60))
|
||||||
|
|
||||||
|
|
||||||
|
def _detect_apple_sleep_csv_format(fieldnames: list[str] | None) -> Literal["segments", "summary"]:
|
||||||
|
if not fieldnames:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="CSV enthält keine Spaltenüberschriften.",
|
||||||
|
)
|
||||||
|
fn = {(f or "").strip() for f in fieldnames}
|
||||||
|
if {"Start", "End", "Duration (hr)", "Value"}.issubset(fn):
|
||||||
|
return "segments"
|
||||||
|
if "Start" in fn and "End" in fn and "Total Sleep (hr)" in fn:
|
||||||
|
return "summary"
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail=(
|
||||||
|
"Unbekanntes Apple-Health-Schlaf-CSV. "
|
||||||
|
"Erwartet wird entweder der Segment-Export (Spalten Start, End, Duration (hr), Value) "
|
||||||
|
"oder die Schlafanalyse mit Nacht-Zusammenfassung (u. a. Total Sleep (hr), Core/Light, Deep, REM)."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _build_nights_from_apple_summary(reader: csv.DictReader) -> dict[date, dict]:
|
||||||
|
nights_dict: dict[date, dict] = {}
|
||||||
|
for raw in reader:
|
||||||
|
row = _strip_row_keys(raw)
|
||||||
|
start_s = row.get("Start") or ""
|
||||||
|
end_s = row.get("End") or ""
|
||||||
|
if not start_s or not end_s:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
start_dt = _parse_apple_sleep_datetime(start_s)
|
||||||
|
end_dt = _parse_apple_sleep_datetime(end_s)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
dt_key = (row.get("Date/Time") or row.get("Datum/Uhrzeit") or "").strip()
|
||||||
|
if dt_key:
|
||||||
|
try:
|
||||||
|
wake_d = datetime.strptime(dt_key[:10], "%Y-%m-%d").date()
|
||||||
|
except ValueError:
|
||||||
|
wake_d = end_dt.date()
|
||||||
|
else:
|
||||||
|
wake_d = end_dt.date()
|
||||||
|
|
||||||
|
core_hr = _safe_float(row.get("Core (hr)"))
|
||||||
|
if core_hr is None:
|
||||||
|
core_hr = _safe_float(row.get("Light (hr)")) or 0.0
|
||||||
|
deep_min = _hr_to_minutes(_safe_float(row.get("Deep (hr)")))
|
||||||
|
rem_min = _hr_to_minutes(_safe_float(row.get("REM (hr)")))
|
||||||
|
light_min = _hr_to_minutes(core_hr)
|
||||||
|
awake_min = _hr_to_minutes(_safe_float(row.get("Awake (hr)")))
|
||||||
|
nights_dict[wake_d] = {
|
||||||
|
"bedtime": start_dt,
|
||||||
|
"wake_time": end_dt,
|
||||||
|
"segments": [],
|
||||||
|
"deep_minutes": deep_min,
|
||||||
|
"rem_minutes": rem_min,
|
||||||
|
"light_minutes": light_min,
|
||||||
|
"awake_minutes": awake_min,
|
||||||
|
}
|
||||||
|
return nights_dict
|
||||||
|
|
||||||
|
|
||||||
|
def _build_nights_from_apple_segments(reader: csv.DictReader, phase_map: dict) -> dict[date, dict]:
|
||||||
|
segments = []
|
||||||
|
for raw in reader:
|
||||||
|
row = _strip_row_keys(raw)
|
||||||
|
phase_key = (row.get("Value") or "").strip()
|
||||||
|
phase_en = phase_map.get(phase_key)
|
||||||
|
if phase_en is None:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
start_dt = _parse_apple_sleep_datetime(row.get("Start") or "")
|
||||||
|
end_dt = _parse_apple_sleep_datetime(row.get("End") or "")
|
||||||
|
duration_hr = _safe_float(row.get("Duration (hr)"))
|
||||||
|
if duration_hr is None:
|
||||||
|
continue
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
continue
|
||||||
|
duration_min = int(duration_hr * 60)
|
||||||
|
segments.append({
|
||||||
|
"start": start_dt,
|
||||||
|
"end": end_dt,
|
||||||
|
"duration_min": duration_min,
|
||||||
|
"phase": phase_en,
|
||||||
|
})
|
||||||
|
|
||||||
|
segments.sort(key=lambda s: s["start"])
|
||||||
|
nights = []
|
||||||
|
current_night = None
|
||||||
|
|
||||||
|
for seg in segments:
|
||||||
|
if current_night is None or (seg["start"] - current_night["wake_time"]).total_seconds() > 7200:
|
||||||
|
current_night = {
|
||||||
|
"bedtime": seg["start"],
|
||||||
|
"wake_time": seg["end"],
|
||||||
|
"segments": [],
|
||||||
|
"deep_minutes": 0,
|
||||||
|
"rem_minutes": 0,
|
||||||
|
"light_minutes": 0,
|
||||||
|
"awake_minutes": 0,
|
||||||
|
}
|
||||||
|
nights.append(current_night)
|
||||||
|
|
||||||
|
current_night["segments"].append(seg)
|
||||||
|
current_night["wake_time"] = max(current_night["wake_time"], seg["end"])
|
||||||
|
current_night["bedtime"] = min(current_night["bedtime"], seg["start"])
|
||||||
|
|
||||||
|
if seg["phase"] == "deep":
|
||||||
|
current_night["deep_minutes"] += seg["duration_min"]
|
||||||
|
elif seg["phase"] == "rem":
|
||||||
|
current_night["rem_minutes"] += seg["duration_min"]
|
||||||
|
elif seg["phase"] == "light":
|
||||||
|
current_night["light_minutes"] += seg["duration_min"]
|
||||||
|
elif seg["phase"] == "awake":
|
||||||
|
current_night["awake_minutes"] += seg["duration_min"]
|
||||||
|
|
||||||
|
nights_dict: dict[date, dict] = {}
|
||||||
|
for night in nights:
|
||||||
|
wake_date = night["wake_time"].date()
|
||||||
|
nights_dict[wake_date] = night
|
||||||
|
return nights_dict
|
||||||
|
|
||||||
|
|
||||||
# ── Models ────────────────────────────────────────────────────────────────────
|
# ── Models ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
class SleepCreate(BaseModel):
|
class SleepCreate(BaseModel):
|
||||||
@@ -460,96 +629,46 @@ async def import_apple_health_sleep(
|
|||||||
"""
|
"""
|
||||||
Import sleep data from Apple Health CSV export.
|
Import sleep data from Apple Health CSV export.
|
||||||
|
|
||||||
Expected CSV format:
|
Supports:
|
||||||
Start,End,Duration (hr),Value,Source
|
- Segment-Export: Start, End, Duration (hr), Value (Kern/Tief/REM/Wach oder Core/Deep/…)
|
||||||
2026-03-14 22:44:23,2026-03-14 23:00:19,0.266,Kern,Apple Watch
|
- Schlafanalyse (Nacht-Zusammenfassung): Date/Time, Start, End, Total Sleep (hr),
|
||||||
|
Core/Light (hr), Deep (hr), REM (hr), Awake (hr), …
|
||||||
|
|
||||||
- Aggregates segments by night (wake date)
|
- Aggregates segments by night (wake date) where applicable
|
||||||
- Maps German phase names: Kern→light, REM→rem, Tief→deep, Wach→awake
|
- Stores Roh-Segmente in JSONB (bei Zusammenfassung oft leer)
|
||||||
- Stores raw segments in JSONB
|
- Überschreibt keine manuellen Einträge (source='manual')
|
||||||
- Does NOT overwrite manual entries (source='manual')
|
|
||||||
"""
|
"""
|
||||||
pid = session['profile_id']
|
pid = session['profile_id']
|
||||||
|
|
||||||
# Read CSV
|
|
||||||
content = await file.read()
|
content = await file.read()
|
||||||
csv_text = content.decode('utf-8-sig') # Handle BOM
|
csv_text = content.decode('utf-8-sig')
|
||||||
reader = csv.DictReader(io.StringIO(csv_text))
|
reader = csv.DictReader(io.StringIO(csv_text))
|
||||||
|
fmt = _detect_apple_sleep_csv_format(reader.fieldnames)
|
||||||
|
|
||||||
# Phase mapping (German → English)
|
|
||||||
phase_map = {
|
phase_map = {
|
||||||
'Kern': 'light',
|
"Kern": "light",
|
||||||
'REM': 'rem',
|
"Core": "light",
|
||||||
'Tief': 'deep',
|
"Light": "light",
|
||||||
'Wach': 'awake',
|
"REM": "rem",
|
||||||
'Schlafend': None # Ignore initial sleep entry
|
"Tief": "deep",
|
||||||
|
"Deep": "deep",
|
||||||
|
"Wach": "awake",
|
||||||
|
"Awake": "awake",
|
||||||
|
"Schlafend": None,
|
||||||
|
"Asleep": None,
|
||||||
|
"In Bed": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse segments
|
if fmt == "summary":
|
||||||
segments = []
|
nights_dict = _build_nights_from_apple_summary(reader)
|
||||||
for row in reader:
|
else:
|
||||||
phase_de = row['Value'].strip()
|
nights_dict = _build_nights_from_apple_segments(reader, phase_map)
|
||||||
phase_en = phase_map.get(phase_de)
|
|
||||||
|
|
||||||
if phase_en is None: # Skip "Schlafend"
|
if not nights_dict:
|
||||||
continue
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
start_dt = datetime.strptime(row['Start'], '%Y-%m-%d %H:%M:%S')
|
detail="Keine importierbaren Schlafzeilen gefunden (prüfe Start/Ende und Format).",
|
||||||
end_dt = datetime.strptime(row['End'], '%Y-%m-%d %H:%M:%S')
|
)
|
||||||
duration_hr = float(row['Duration (hr)'])
|
|
||||||
duration_min = int(duration_hr * 60)
|
|
||||||
|
|
||||||
segments.append({
|
|
||||||
'start': start_dt,
|
|
||||||
'end': end_dt,
|
|
||||||
'duration_min': duration_min,
|
|
||||||
'phase': phase_en
|
|
||||||
})
|
|
||||||
|
|
||||||
# Sort segments chronologically
|
|
||||||
segments.sort(key=lambda s: s['start'])
|
|
||||||
|
|
||||||
# Group segments into nights (gap-based)
|
|
||||||
# If gap between segments > 2 hours → new night
|
|
||||||
nights = []
|
|
||||||
current_night = None
|
|
||||||
|
|
||||||
for seg in segments:
|
|
||||||
# Start new night if:
|
|
||||||
# 1. First segment
|
|
||||||
# 2. Gap > 2 hours since last segment
|
|
||||||
if current_night is None or (seg['start'] - current_night['wake_time']).total_seconds() > 7200:
|
|
||||||
current_night = {
|
|
||||||
'bedtime': seg['start'],
|
|
||||||
'wake_time': seg['end'],
|
|
||||||
'segments': [],
|
|
||||||
'deep_minutes': 0,
|
|
||||||
'rem_minutes': 0,
|
|
||||||
'light_minutes': 0,
|
|
||||||
'awake_minutes': 0
|
|
||||||
}
|
|
||||||
nights.append(current_night)
|
|
||||||
|
|
||||||
# Add segment to current night
|
|
||||||
current_night['segments'].append(seg)
|
|
||||||
current_night['wake_time'] = max(current_night['wake_time'], seg['end'])
|
|
||||||
current_night['bedtime'] = min(current_night['bedtime'], seg['start'])
|
|
||||||
|
|
||||||
# Sum phases
|
|
||||||
if seg['phase'] == 'deep':
|
|
||||||
current_night['deep_minutes'] += seg['duration_min']
|
|
||||||
elif seg['phase'] == 'rem':
|
|
||||||
current_night['rem_minutes'] += seg['duration_min']
|
|
||||||
elif seg['phase'] == 'light':
|
|
||||||
current_night['light_minutes'] += seg['duration_min']
|
|
||||||
elif seg['phase'] == 'awake':
|
|
||||||
current_night['awake_minutes'] += seg['duration_min']
|
|
||||||
|
|
||||||
# Convert nights list to dict with wake_date as key
|
|
||||||
nights_dict = {}
|
|
||||||
for night in nights:
|
|
||||||
wake_date = night['wake_time'].date() # Date when you woke up
|
|
||||||
nights_dict[wake_date] = night
|
|
||||||
|
|
||||||
# Insert nights
|
# Insert nights
|
||||||
imported = 0
|
imported = 0
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
# GUI, Informationsarchitektur, Admin & Navigation (Abnahme 2026-04-05)
|
||||||
|
|
||||||
|
> **Zweck:** Einheitliche Referenz für Menschen und Code-Agents (Cursor, Claude Code, …).
|
||||||
|
> **Gitea:** Teilaspekte zu [#30 Responsive UI](http://192.168.2.144:3000/Lars/mitai-jinkendo/issues/30); Admin-Layout kein separates Issue.
|
||||||
|
> **Branch-Realität:** Umsetzung auf `develop`, Deploy nach `main` wie üblich.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Kurzüberblick
|
||||||
|
|
||||||
|
| Thema | Kern |
|
||||||
|
|-------|------|
|
||||||
|
| **Admin** | Eigener Bereich mit Shell wie KI-Analyse: Gruppen-Chips (mobil) / Sidebar (Desktop), Hub `/admin/g/:groupId`, Route-Guard `RequireAdmin` |
|
||||||
|
| **Ziele** | Eigener Hauptnav-Punkt `/goals`; nicht mehr primär unter Analyse; Dashboard + Einstellungen als Sekundär-Einstiege |
|
||||||
|
| **Einstellungen / Profil** | Nur **aktives** Profil inline; E-Mail-Self-Service; neue Profile nur **Admin → Benutzerverwaltung** |
|
||||||
|
| **KI-Analyse** | Neue Ergebnis-Karte im **rechten** Spalt der `analysis-split`, damit Kategorie-Nav nicht verdrängt wird |
|
||||||
|
| **PWA / iPhone** | Bottom-Nav: Safe Area auf **`.bottom-nav`**, kein Clipping durch `overflow-y` + `safe-area` auf Items |
|
||||||
|
| **Deploy Prod** | Workflow: `git fetch` + `git reset --hard origin/<branch>` statt `pull` bei schmutziger `package-lock` |
|
||||||
|
| **#14 Icon Picker** | Erledigt (`EmojiIconPicker`); Gitea geschlossen |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Dateien (Single Source of Truth im Code)
|
||||||
|
|
||||||
|
| Bereich | Pfade |
|
||||||
|
|---------|--------|
|
||||||
|
| Hauptnavigation | `frontend/src/config/appNav.js` (`getMainNavItems`) |
|
||||||
|
| Active-State Bottom + Sidebar | `frontend/src/App.jsx` (`navItemActive`), `frontend/src/components/DesktopSidebar.jsx` |
|
||||||
|
| Admin Shell & Routing | `frontend/src/layouts/AdminShell.jsx`, `frontend/src/layouts/RequireAdmin.jsx`, `frontend/src/config/adminNav.js` (`ADMIN_GROUPS`, Hubs) |
|
||||||
|
| Admin-Seiten | `frontend/src/pages/AdminHomePage.jsx`, `AdminGroupHubPage.jsx`, `AdminUsersPage.jsx`, `AdminSystemPage.jsx`, … |
|
||||||
|
| Einstellungen Profil | `frontend/src/pages/SettingsPage.jsx`, `.settings-page__field` in `app.css` |
|
||||||
|
| KI-Analyse Layout | `frontend/src/pages/Analysis.jsx` + `.analysis-split*` in `app.css` |
|
||||||
|
| Admin-Zugriff verweigert | `frontend/src/pages/Dashboard.jsx` (`adminDenied` State aus `location.state`) |
|
||||||
|
| Bottom-Nav / Safe Area | `frontend/src/app.css` (`--nav-h`, `--nav-pad-top`, `.bottom-nav`, `.app-main` padding-bottom) |
|
||||||
|
| Deploy | `.gitea/workflows/deploy-prod.yml`, `deploy-dev.yml` |
|
||||||
|
| Backend Profil E-Mail | `backend/models.py` (`ProfileUpdate.email`), `backend/routers/profiles.py` (`update_profile` + Eindeutigkeit / Verifikation) |
|
||||||
|
| .gitignore Fix | `frontend/package-lock.json` eigene Zeile (war mit `settings.local` verklebt) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Navigation: Reihenfolge (Mobile & Desktop)
|
||||||
|
|
||||||
|
Übersicht → Erfassen → Verlauf → **Ziele** → Analyse → Einstellungen → **[Admin]**
|
||||||
|
|
||||||
|
- **Ziele:** `NavLink` mit `end: true` (exakt `/goals`).
|
||||||
|
- **Admin:** nur wenn `session.role === 'admin'`; Highlight bei `pathname.startsWith('/admin')`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Admin-Bereich (IA)
|
||||||
|
|
||||||
|
1. **Shell** nutzt dieselben UI-Klassen wie die Analyse: `.analysis-split`, `.analysis-split__nav-wrap`, `.analysis-split__main`.
|
||||||
|
2. **Nur Gruppen** in der Shell-Nav (inkl. Zähler pro Gruppe).
|
||||||
|
3. Konkrete Seiten: Karten auf **`/admin/g/:groupId`** (z. B. `features`, `prompts`, `system`).
|
||||||
|
4. **KI-Prompts** eigene Gruppe; **Basiseinstellungen** = SMTP + Placeholder-Export (`/admin/system`).
|
||||||
|
5. Kein Admin-Block mehr in den **Einstellungen** (nur Admin-Hinweis-Link zu Benutzerverwaltung).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Backend-Hinweis Profil
|
||||||
|
|
||||||
|
`PUT /api/profile` akzeptiert `email`; Änderung setzt `email_verified` u. a. zurück (siehe `profiles.py`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Gitea / Issues (manuell oder `scripts/gitea/gitea_api.py`)
|
||||||
|
|
||||||
|
| Issue | Empfehlung |
|
||||||
|
|-------|------------|
|
||||||
|
| **#30** | Offen lassen oder TEILWEISE: Desktop-Sidebar existiert; ergänzt um Admin-Shell, scrollable Bottom-Nav, iOS Safe-Area. Kommentar mit Link **auf dieses Dokument**. |
|
||||||
|
| **#14** | Bereits geschlossen (Icon-Picker). |
|
||||||
|
| **Kein eigenes Admin-IA-Issue** | Optional: Sub-Issue „Admin Shell P7“ schließen oder mit #30 verknüpfen. |
|
||||||
|
|
||||||
|
Schließe **kein** großes #30 ohne Abnahme „volle Responsive-Spec“ – diese Session liefert nur einen **abgegrenzten** GUI-Stand.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Checks für Folge-Agents
|
||||||
|
|
||||||
|
1. `frontend`: `npm run build`
|
||||||
|
2. Admin-Route als Nicht-Admin: Redirect `/`, Dashboard-Hinweis
|
||||||
|
3. iPhone PWA: Bottom-Nav nicht beschnitten; Content nicht hinter Home-Indicator
|
||||||
|
4. `develop` → nach Abnahme `main` + Deploy (siehe aktualisierte Workflows)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Changelog-Kurz
|
||||||
|
|
||||||
|
- Admin: Shell, Hub-Routen, `RequireAdmin`, entfernt aus Settings.
|
||||||
|
- Ziele: `appNav`, Dashboard, Settings, Analyse nur noch Hinweis-Link.
|
||||||
|
- Settings: Mein Profil, E-Mail, keine Profilliste.
|
||||||
|
- Analyse: `newResult` in `analysis-split__main`.
|
||||||
|
- CSS: Bottom-Nav scroll + Safe Area + `--nav-pad-top`.
|
||||||
|
- Deploy: `reset --hard` auf Runner-Arbeitskopie.
|
||||||
|
- Review-Liste: #14 erledigt (siehe `REVIEW_OPEN_ISSUES_2026-04-04.md`).
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
> **Gitea:** [#30 – Responsive UI](http://192.168.2.144:3000/Lars/mitai-jinkendo/issues/30)
|
> **Gitea:** [#30 – Responsive UI](http://192.168.2.144:3000/Lars/mitai-jinkendo/issues/30)
|
||||||
> **Spec:** `.claude/docs/functional/RESPONSIVE_UI.md`
|
> **Spec:** `.claude/docs/functional/RESPONSIVE_UI.md`
|
||||||
> **Breakpoint:** `<1024px` = Mobile (Bottom-Nav, bestehendes Verhalten), `≥1024px` = Desktop (Sidebar 220px)
|
> **Breakpoint:** `<1024px` = Mobile (Bottom-Nav, bestehendes Verhalten), `≥1024px` = Desktop (Sidebar 220px)
|
||||||
> **Letzte Plan-Aktualisierung:** 2026-04-04
|
> **Letzte Plan-Aktualisierung:** 2026-04-05 (P7 Admin-Shell umgesetzt; Doku `GUI_IA_ADMIN_NAV_2026-04-05.md`; P8 ausstehend)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
| Phase | Titel | Status | Datum / Notiz |
|
| Phase | Titel | Status | Datum / Notiz |
|
||||||
|-------|--------|--------|----------------|
|
|-------|--------|--------|----------------|
|
||||||
| P0 | Vorbereitung & Baseline | ☐ pending | |
|
| P0 | Vorbereitung & Baseline | ☑ erledigt | Spec `RESPONSIVE_UI.md` bereinigt |
|
||||||
| P1 | App-Shell: Sidebar + Breakpoint + gemeinsame Navigation | ☐ pending | |
|
| P1 | App-Shell: Sidebar + Breakpoint + gemeinsame Navigation | ☑ erledigt | `DesktopSidebar`, `config/appNav.js`, Admin `/admin/*`-Highlight |
|
||||||
| P2 | Globales Layout & Content-Bereich (CSS) | ☐ pending | |
|
| P2 | Globales Layout & Content-Bereich (CSS) | ☑ erledigt | Desktop: Header aus, Content max 1200px; Mobile unverändert Bottom-Nav |
|
||||||
| P3 | Dashboard (Desktop-Grid) | ☐ pending | |
|
| P3 | Dashboard (Desktop-Grid) | ☑ erledigt | 4-spaltige Kennzahlen; Begrüßung; Ernährung/Aktivität 2-spaltig |
|
||||||
| P4 | Verlauf (Tabs links / Content rechts) | ☐ pending | |
|
| P4 | Verlauf (Tabs links / Content rechts) | ☑ erledigt | `History.jsx` + `.history-*` in `app.css`; Tab-State bei `location.state.tab` |
|
||||||
| P5 | Analyse (Prompts links / Ergebnis rechts) | ☐ pending | |
|
| P5 | Analyse (Prompts links / Ergebnis rechts) | ☑ erledigt | `Analysis.jsx` + `.analysis-split*` in `app.css` |
|
||||||
| P6 | Erfassung / Capture & Formularseiten | ☐ pending | |
|
| P6 | Erfassung / Capture & Formularseiten | ☑ erledigt | `.capture-page` + `--capture-content-max` (eine Desktop-Breite); CaptureShell-Navigation |
|
||||||
| P7 | Admin & restliche Vollbreiten-Seiten | ☐ pending | |
|
| P7 | Admin & restliche Vollbreiten-Seiten | ☑ erledigt (Kern) | **2026-04-05:** `AdminShell` + Hub-Routen + `adminNav`; Tabellen/„volle Breite“ weiter iterativ laut Spec §5.5 |
|
||||||
| P8 | Abschluss, Regression, Spec-Pflege | ☐ pending | |
|
| P8 | Abschluss, Regression, Spec-Pflege | ☐ pending | |
|
||||||
|
|
||||||
**Status-Legende:** `☐ pending` · `◐ in Arbeit` · `☑ erledigt` · `⏸ blockiert`
|
**Status-Legende:** `☐ pending` · `◐ in Arbeit` · `☑ erledigt` · `⏸ blockiert`
|
||||||
@@ -202,6 +202,8 @@ Spec **§5.4**: Desktop Formulare **zentriert**, **max-width ~600px** im Content
|
|||||||
|
|
||||||
## Phase P7 – Admin & übrige Seiten
|
## Phase P7 – Admin & übrige Seiten
|
||||||
|
|
||||||
|
**Stand 2026-04-05:** Admin nutzt **dedizierte Shell** mit Gruppen-Navigation und Hubs (`AdminShell`, `adminNav.js`, `RequireAdmin`) — IA- und Routing-Grundlage erledigt. Tabellen „mehr Breite“ / feinere Layout-Tuning gemäß §5.5 können weiterlaufen ohne Shell-Refactor. Doku: `GUI_IA_ADMIN_NAV_2026-04-05.md`.
|
||||||
|
|
||||||
### Ziel
|
### Ziel
|
||||||
Spec **§5.5**: Admin-Tabellen nutzen auf Desktop **mehr Breite**; Mobile weiterhin horizontales Scrollen wo nötig.
|
Spec **§5.5**: Admin-Tabellen nutzen auf Desktop **mehr Breite**; Mobile weiterhin horizontales Scrollen wo nötig.
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
|
|
||||||
| # | Titel (gekürzt) | Vorschlag | Notiz |
|
| # | Titel (gekürzt) | Vorschlag | Notiz |
|
||||||
|---|-----------------|-----------|--------|
|
|---|-----------------|-----------|--------|
|
||||||
| 14 | Icon Picker Trainingstypen | OFFEN | Nur Freitext-Feld `icon` |
|
| 14 | Icon Picker Trainingstypen | **ERLEDIGT** | `EmojiIconPicker` in `AdminTrainingTypesPage.jsx`; Gitea #14 geschlossen (2026-04) |
|
||||||
| 15 | Quality-Filter KI & Charts | TEILWEISE | Registry/Charts Confidence, kein durchgängiges Produkt |
|
| 15 | Quality-Filter KI & Charts | TEILWEISE | Registry/Charts Confidence, kein durchgängiges Produkt |
|
||||||
| 21 | Universeller CSV-Parser + Mapping | OFFEN | Modul-spezifische Parser |
|
| 21 | Universeller CSV-Parser + Mapping | OFFEN | Modul-spezifische Parser |
|
||||||
| 25 | Ziele-System Goals | DONE? | GoalsPage, Router, Focus Areas |
|
| 25 | Ziele-System Goals | DONE? | GoalsPage, Router, Focus Areas |
|
||||||
| 26 | Charts erweitern | TEILWEISE | Phase-0c API + History/NutritionCharts |
|
| 26 | Charts erweitern | TEILWEISE | Phase-0c API + History/NutritionCharts |
|
||||||
| 27 | Korrelationen & Insights | TEILWEISE | C-Charts + offene Data-Layer-TODOs |
|
| 27 | Korrelationen & Insights | TEILWEISE | C-Charts + offene Data-Layer-TODOs |
|
||||||
| 29 | Abilities-Matrix UI | TEILWEISE | Admin/ProfileBuilder, UX offen |
|
| 29 | Abilities-Matrix UI | TEILWEISE | Admin/ProfileBuilder, UX offen |
|
||||||
| 30 | Responsive UI Sidebar | OFFEN | Weiterhin Bottom-Nav-fokussiert |
|
| 30 | Responsive UI Sidebar | **TEILWEISE** | P1–P6 + **P7 Admin-Shell** + iOS Bottom-Nav Safe-Area; SSoT-Doku: **`GUI_IA_ADMIN_NAV_2026-04-05.md`**; #30 bleibt offen bis P8/Abnahme |
|
||||||
| 32 | Version-System (inkl. ehem. #33) | OFFEN | Gitea: Body/Titel 2026-04-04 aktualisiert; Runner/Build-Git bewusst später |
|
| 32 | Version-System (inkl. ehem. #33) | OFFEN | Gitea: Body/Titel 2026-04-04 aktualisiert; Runner/Build-Git bewusst später |
|
||||||
| 33 | — | GESCHLOSSEN | In #32 konsolidiert (superseded) |
|
| 33 | — | GESCHLOSSEN | In #32 konsolidiert (superseded) |
|
||||||
| 34 | External Volumes Doku | PRÜFEN | Gegen Compose abgleichen |
|
| 34 | External Volumes Doku | PRÜFEN | Gegen Compose abgleichen |
|
||||||
@@ -48,14 +48,11 @@
|
|||||||
|
|
||||||
## Details je Issue (älteste zuerst)
|
## Details je Issue (älteste zuerst)
|
||||||
|
|
||||||
### #14 – [FEAT-001] Icon Picker für Trainingstypen
|
### #14 – [FEAT-001] Icon Picker für Trainingstypen — **ERLEDIGT**
|
||||||
|
|
||||||
**Code-Stand:** `AdminTrainingTypesPage.jsx` nutzt ein **Textfeld** `icon` (frei, z. B. Emoji). Kein dedizierter Icon-Picker (Palette, Vorschau, Kategorien).
|
**Code-Stand:** `AdminTrainingTypesPage.jsx` nutzt **`EmojiIconPicker`** (`frontend/src/components/EmojiIconPicker.jsx`) für Neu- und Bearbeiten-Dialoge; Wert bleibt String in `training_types.icon`.
|
||||||
|
|
||||||
**Vorschlag:** `OFFEN` – Issue beibehalten; optional präzisieren: „Emoji-Picker oder vordefinierte Icon-Liste statt Freitext“.
|
**Gitea:** Issue **#14 geschlossen** (Kommentar + Close, Stand 2026-04).
|
||||||
|
|
||||||
**Kommentar-Entwurf für Gitea:**
|
|
||||||
> Stand Backend/Frontend: `icon` wird als String in `training_types` gespeichert, Eingabe ist Freitext. Icon-Picker-UX steht noch aus.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -115,11 +112,11 @@
|
|||||||
|
|
||||||
### #30 – [FEAT] Responsive UI – Desktop Sidebar + 2-spaltig
|
### #30 – [FEAT] Responsive UI – Desktop Sidebar + 2-spaltig
|
||||||
|
|
||||||
**Code-Stand:** Weiterhin stark **Mobile-first** (z. B. `bottom-nav` in `App.jsx`); keine ausgebaute Desktop-Sidebar wie im klassischen Admin-Dashboard.
|
**Code-Stand (2026-04-05):** **Desktop-Sidebar** (`DesktopSidebar`, `config/appNav.js`) und **Mobile Bottom-Nav** mit horizontalem Scroll + **Safe Area** (`app.css`); **Admin** eigener Bereich **`AdminShell`** mit Gruppen-Hub wie Analyse (`adminNav.js`, `/admin/g/:groupId`, `RequireAdmin`). Siehe **`docs/issues/GUI_IA_ADMIN_NAV_2026-04-05.md`** (Dateipfade, IA, Deploy-Hinweis).
|
||||||
|
|
||||||
**Umsetzungsplan:** `docs/issues/PHASE_PLAN_RESPONSIVE_UI.md` (Phasen P0–P8, Abnahmekriterien & Tests, Fortschrittstabelle).
|
**Umsetzungsplan:** `docs/issues/PHASE_PLAN_RESPONSIVE_UI.md` (Phasen P0–P8). **P7** Kern umgesetzt; **P8** (Regression, finale Abnahme) stehen noch aus – Issue **nicht** schließen ohne P8-Checkliste.
|
||||||
|
|
||||||
**Vorschlag:** `OFFEN`.
|
**Vorschlag:** `TEILWEISE` – Gitea-Kommentar mit Link auf die GUI-Doku; Titel/Beschreibung optional um „Admin-Shell / Ziele-Nav / iOS PWA-Leiste“ ergänzen.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
# Umsetzungsplan: Sportspezifisch auswertbare Trainingsprofile
|
||||||
|
|
||||||
|
**Status:** Konzept für fachliche Abstimmung / Konzeptagent
|
||||||
|
**Datum:** 2026-04-05
|
||||||
|
**Bezug:** Fachliches Teilkonzept „Sportspezifisch auswertbare Trainingsprofile“ (User-Entwurf)
|
||||||
|
**Hinweis:** Keine Implementierung ohne Freigabe der unter [Offene Fragen](#offene-fragen-für-den-fachlichen-konzeptagenten) gekläerten Punkte.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Kurzfazit: Machbarkeit
|
||||||
|
|
||||||
|
**Fachlich und technisch grundsätzlich machbar** als gestaffelte Erweiterung auf dem bestehenden System:
|
||||||
|
|
||||||
|
- `training_types.profile` (JSONB)
|
||||||
|
- `TrainingProfileEvaluator` (`backend/profile_evaluator.py`)
|
||||||
|
- Persistenz: `activity_log.evaluation`, `quality_label`, `overall_score`
|
||||||
|
|
||||||
|
**Engpass:** Viele im Teilkonzept genannten Kriterien (z. B. Muskelgruppen, Nähe zum muskulären Versagen, detaillierte Zonenzeiten) **lassen sich aus der aktuellen `activity_log`-Datenbasis nicht zuverlässig ableiten**. Dafür braucht es zusätzliche Erfassung, Importfelder oder explizite „niedrige Evidenz / unbekannt“-Markierung in Metriken und KI-Kontext (Placeholder-Registry, Erklärbarkeit).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Ist-Analyse (Abhängigkeiten)
|
||||||
|
|
||||||
|
### 2.1 Daten & Konfiguration
|
||||||
|
|
||||||
|
| Baustein | Rolle |
|
||||||
|
|---------|--------|
|
||||||
|
| `training_types` | `category`, `subcategory`, `name_*`, optional `abilities` (JSONB), `profile` (JSONB) |
|
||||||
|
| `activity_type_mappings` | Import/manuelles Mapping `activity_type` → `training_type_id` (unverändert lassen) |
|
||||||
|
| `training_parameters` | Registry messbarer Parameter für Regeln (`source_field` → `activity_log`) |
|
||||||
|
| `activity_log` | u. a. `training_type_id`, `evaluation`, `quality_label`, `overall_score` |
|
||||||
|
|
||||||
|
### 2.2 Bewertung heute
|
||||||
|
|
||||||
|
- Der Evaluator läuft über mehrere **rule_sets** (Minimumanforderungen, Zonen, Effekte, Periodisierung, KPI, Safety).
|
||||||
|
- **Ein** zusammengefasster `overall_score` und **ein** `quality_label` (`excellent` | `good` | `acceptable` | `poor`).
|
||||||
|
- **Relevanz, intrinsische Qualität, Zielbezug, Platzierung** sind im Ergebnis **nicht formal getrennt**; Periodisierung/Performance sind teils **MVP/vereinfacht**.
|
||||||
|
|
||||||
|
### 2.3 Downstream (nicht brechen)
|
||||||
|
|
||||||
|
- **Issue #31 / Quality Filter:** `profiles.quality_filter_level`, `quality_filter.py` (SQL-Fragmente nach `quality_label`)
|
||||||
|
- **Frontend:** Badges in Aktivitäts-UI, History-Hinweise
|
||||||
|
- **Data Layer / Charts:** u. a. `calculate_quality_sessions_pct`, `activity_score`, Korrelationen
|
||||||
|
- **Placeholder Registry:** u. a. `quality_sessions_pct` (bekannte Semantik-/Label-Diskrepanz, siehe unten)
|
||||||
|
|
||||||
|
### 2.4 Bekannte technische Inkonsistenz (Bestand)
|
||||||
|
|
||||||
|
`calculate_quality_sessions_pct` filtert u. a. auf `quality_label IN (..., 'very_good', ...)`, der `TrainingProfileEvaluator` setzt **`very_good` nicht**. Das sollte **vor oder zusammen mit** größeren Profil-Erweiterungen bereinigt werden, damit neue Dimensionen nicht auf wackeliger Basis validiert werden.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Umsetzungsprinzipien (Kompatibilität)
|
||||||
|
|
||||||
|
1. **Kein Big-Bang:** Consumer erwarten weiterhin sinnvolle `quality_label` / `overall_score`, es sei denn, es gibt eine **versionierte Cutover-Strategie**.
|
||||||
|
2. **Additive JSON-Struktur** in `evaluation` (z. B. mehrdimensionale Teilergebnisse), ohne bestehende Schlüssel willkürlich zu entfernen.
|
||||||
|
3. **Legacy-Vertrag festlegen:** z. B. `overall_score` = **primär intrinsische** Qualität (oder explizit „Legacy-Komposit“ mit `schema_version`).
|
||||||
|
4. **`training_types` bleibt Single Source** für Typ + Profil; Mapping-Import-Logik nicht „mitziehen“, außer es ist fachlich nötig.
|
||||||
|
5. **Neue Coach-Metriken:** über Placeholder Registry, mit Evidence-Tags; keine doppelte Wahrheit neben der Registry.
|
||||||
|
6. **KI:** `ai_context` / `interpretation_boundary` im Profil ausbaubar machen (was erlaubt/verboten ist, bei Datenlücken).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Phasenplan
|
||||||
|
|
||||||
|
### Phase 0 – Begriffe, Verträge, Bestandsaufnahme
|
||||||
|
|
||||||
|
- Glossar: Relevanz, intrinsische Qualität, Zielbeitrag, Platzierung, Belastung, sportspezifische Qualität → **Mapping auf bestehende `rule_sets`**.
|
||||||
|
- Vollständige Liste: wer liest `quality_label` / `evaluation` / `overall_score` (APIs, SQL, Frontend).
|
||||||
|
- Align: `very_good` vs. Evaluator-Labels; optional: Rolle von `acceptable` in „Qualitätssessions“ vs. globalem Filter **fachlich** klären.
|
||||||
|
|
||||||
|
### Phase 1 – Metamodell im Profil-JSON
|
||||||
|
|
||||||
|
- Erweiterung `training_types.profile`: z. B. `sport_logic`, `dimensions_config`, `goal_linkage`, `load_character`, `recovery_character`, `interference`, `ai_interpretation`.
|
||||||
|
- Evaluator liefert **Teilscores + Begründungen** pro Dimension; **Legacy-Felder** ableitbar und dokumentiert.
|
||||||
|
|
||||||
|
### Phase 2 – Zielbezug
|
||||||
|
|
||||||
|
- Input: aktive Ziele, `goal_mode`, Focus-Gewichte (`user_focus_area_weights`).
|
||||||
|
- Ausgabe: eigene Dimension **`goal_fit`**, ohne intrinsische Bewertung zu überschreiben.
|
||||||
|
|
||||||
|
### Phase 3 – Wochenkontext / Platzierung / Interferenz
|
||||||
|
|
||||||
|
- Kontext in `load_evaluation_context` erweitern (Reihenfolge, Vortag, Ruhetage, optional Vitals/Schlaf).
|
||||||
|
- Regeln schrittweise; False-Positive-Risiko beachten.
|
||||||
|
|
||||||
|
### Phase 4 – Sportspezifische Templates
|
||||||
|
|
||||||
|
- Profilvorlagen pro `sport_logic` (analog `profile_templates.py`), unterschiedliche Parameter und Schwellen.
|
||||||
|
- `confidence` / `data_sufficiency` pro Dimension.
|
||||||
|
|
||||||
|
### Phase 5 – Coach-Metriken & Placeholder
|
||||||
|
|
||||||
|
- Neue Platzhalter nur bei klarer Semantik; ggf. `quality_sessions_pct` **umschreiben** oder durch neuen Key ersetzen + Deprecation-Plan.
|
||||||
|
|
||||||
|
### Phase 6 – Frontend / Admin
|
||||||
|
|
||||||
|
- Dimensionen sichtbar machen; Badges können vorerst Legacy-Score anzeigen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Risiken (Kurz)
|
||||||
|
|
||||||
|
| Risiko | Maßnahme |
|
||||||
|
|--------|----------|
|
||||||
|
| Bedeutung von `quality_label` wechselt still | `evaluation.schema_version`, dokumentierter Vertrag, ggf. separates `intrinsic_quality_label` nach Cutover |
|
||||||
|
| Charts/Scores springen | Shadow-Vergleich, gestuftes Rollout |
|
||||||
|
| KI übertreibt bei Datenlücken | `ai_interpretation` + Metadata-Evidence |
|
||||||
|
| Registry-Drift | Alle neuen Kennzahlen registrieren |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Offene Fragen für den fachlichen Konzeptagenten
|
||||||
|
|
||||||
|
Die folgenden Blöcke sind bewusst als Markdown-Codeblöcke formatiert, damit sie **unverändert** in Prompts oder Tickets übernommen werden können.
|
||||||
|
|
||||||
|
### Block A – Priorität & Konflikte zwischen Dimensionen
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Wenn sich Dimensionen widersprechen (z. B. intrinsische Qualität „hoch“, Zielpassung „niedrig“, Platzierung „problematisch“):
|
||||||
|
|
||||||
|
1. Welche Dimension soll für die **primäre Nutzer-/Coach-Aussage** in der UI führend sein?
|
||||||
|
2. Gibt es eine **feste Prioritätsreihenfolge** (z. B. Sicherheit > Platzierung > Zielpassung > intrinsische Qualität) oder ist sie kontextabhängig?
|
||||||
|
3. Soll es eine **explizite „Gesamt-Coach-Empfehlung“** geben, die aus den Dimensionen kombiniert wird, oder nur parallele Teilurteile ohne Gesamtnote?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block B – Minimaldatensatz & Sportlogiken
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Pro Trainingsfamilie / „sport_logic“ (Kraft, Cardio, Schnellkraft, Kampfsport, Mobility, Erholung aktiv, Geist & Meditation):
|
||||||
|
|
||||||
|
1. Welche **messbaren Felder** sind minimal nötig, damit eine sportspezifische Bewertung **fachlich vertretbar** ist (nicht nur „nice to have“)?
|
||||||
|
2. Welche Aussagen dürfen **ohne** diese Felder **nicht** getroffen werden (nur „unbekannt“ / Confidence niedrig)?
|
||||||
|
3. Sollen fehlende Daten die **intrinsische** Bewertung hart begrenzen (Cap), oder nur **Zusatzdimensionen** betreffen?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block C – Einzeltraining vs. Wochenkontext
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Platzierung / Kontextqualität:
|
||||||
|
|
||||||
|
1. Darf schlechte Platzierung die **sichtbare Einheit-Qualität** numerisch senken, oder nur **Flags/Hinweise** erzeugen?
|
||||||
|
2. Welche zeitliche Auflösung ist Pflicht: nur **Datum** oder auch **start_time** / Reihenfolge am Tag?
|
||||||
|
3. Wie gehen wir mit **unvollständiger Historie** um (Importlücken, manuell gelöschte Einträge)?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block D – Ziele & Multi-Ziel
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Zielbezug (goal_fit):
|
||||||
|
|
||||||
|
1. Bewertung strikt gegen **ein Primärziel**, oder gewichtet gegen **alle aktiven Ziele**?
|
||||||
|
2. Wie werden **Focus Areas** vs. **konkrete Goals** priorisiert, wenn sie sich widersprechen?
|
||||||
|
3. Soll „behindert das Ziel“ (Teilkonzept) ein **eigener Score** oder nur eine **kategorische** Aussage sein?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block E – KI & Haftung / Grenzen
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
KI-Interpretationsrahmen (pro Profil oder global):
|
||||||
|
|
||||||
|
1. Welche Formulierungen sind **verboten** (medizinische Diagnosen, absolute Leistungsversprechen, …)?
|
||||||
|
2. Muss jede KI-gestützte Aussage einen **Evidenz-Hinweis** tragen („basierend auf Dauer/HF“, „Muskelgruppen nicht erfasst“)?
|
||||||
|
3. Soll der Nutzer **opt-in** für interpretative Texte jenseits der Regeln haben?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block F – Legacy-Metriken & Filter
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Bestehende Kennzahlen:
|
||||||
|
|
||||||
|
1. Soll `quality_label` / `overall_score` dauerhaft **nur intrinsisch** bedeuten, oder ein **Komposit** aus mehreren Dimensionen?
|
||||||
|
2. Wie sollen `quality_sessions_pct` und der globale **Quality Filter** künftig mit mehrdimensionalen Urteilen umgehen (nur intrinsisch filtern vs. Kombination)?
|
||||||
|
3. Ist `acceptable` fachlich eine „Qualitätssession“ oder nur „formal ok“?
|
||||||
|
```
|
||||||
|
|
||||||
|
### Block G – Abnahme / Akzeptanz
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Abnahme:
|
||||||
|
|
||||||
|
1. Welche **messbaren** Abnahmekriterien gelten pro Phase (z. B. % konsistent bewerteter Sessions, keine Regression bei Filter-Charts)?
|
||||||
|
2. Wer **fachlich** sign-off: Rolle „Domain Owner“ vs. Entwicklung?
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Anhang: Referenz im Repository
|
||||||
|
|
||||||
|
| Thema | Pfad (orientierend) |
|
||||||
|
|-------|---------------------|
|
||||||
|
| Evaluator | `backend/profile_evaluator.py` |
|
||||||
|
| Regeln | `backend/rule_engine.py` |
|
||||||
|
| Auswertung + Kontext | `backend/evaluation_helper.py` |
|
||||||
|
| Profile JSON / Migration | `backend/migrations/014_training_profiles.sql`, Templates `backend/profile_templates.py` |
|
||||||
|
| Quality Filter | `backend/quality_filter.py` |
|
||||||
|
| Aktivitäts-API inkl. Eval | `backend/routers/activity.py` |
|
||||||
|
| Quality-Sessions-Metrik | `backend/data_layer/activity_metrics.py` (`calculate_quality_sessions_pct`) |
|
||||||
|
| Placeholder Registry | `backend/placeholder_registrations/activity_metrics.py` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Ende des Dokuments.*
|
||||||
+121
-71
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { BrowserRouter, Routes, Route, NavLink, useNavigate } from 'react-router-dom'
|
import { BrowserRouter, Routes, Route, NavLink, useLocation } from 'react-router-dom'
|
||||||
import { LayoutDashboard, PlusSquare, TrendingUp, BarChart2, Settings, LogOut } from 'lucide-react'
|
import { LogOut } from 'lucide-react'
|
||||||
import { ProfileProvider, useProfile } from './context/ProfileContext'
|
import { ProfileProvider, useProfile } from './context/ProfileContext'
|
||||||
import { AuthProvider, useAuth } from './context/AuthContext'
|
import { AuthProvider, useAuth } from './context/AuthContext'
|
||||||
import { setProfileId } from './utils/api'
|
import { setProfileId } from './utils/api'
|
||||||
@@ -11,6 +11,7 @@ import LoginScreen from './pages/LoginScreen'
|
|||||||
import Register from './pages/Register'
|
import Register from './pages/Register'
|
||||||
import Verify from './pages/Verify'
|
import Verify from './pages/Verify'
|
||||||
import Dashboard from './pages/Dashboard'
|
import Dashboard from './pages/Dashboard'
|
||||||
|
import CaptureShell from './layouts/CaptureShell'
|
||||||
import CaptureHub from './pages/CaptureHub'
|
import CaptureHub from './pages/CaptureHub'
|
||||||
import WeightScreen from './pages/WeightScreen'
|
import WeightScreen from './pages/WeightScreen'
|
||||||
import CircumScreen from './pages/CircumScreen'
|
import CircumScreen from './pages/CircumScreen'
|
||||||
@@ -33,6 +34,12 @@ import AdminTrainingProfiles from './pages/AdminTrainingProfiles'
|
|||||||
import AdminPromptsPage from './pages/AdminPromptsPage'
|
import AdminPromptsPage from './pages/AdminPromptsPage'
|
||||||
import AdminGoalTypesPage from './pages/AdminGoalTypesPage'
|
import AdminGoalTypesPage from './pages/AdminGoalTypesPage'
|
||||||
import AdminFocusAreasPage from './pages/AdminFocusAreasPage'
|
import AdminFocusAreasPage from './pages/AdminFocusAreasPage'
|
||||||
|
import AdminHomePage from './pages/AdminHomePage'
|
||||||
|
import AdminUsersPage from './pages/AdminUsersPage'
|
||||||
|
import AdminSystemPage from './pages/AdminSystemPage'
|
||||||
|
import AdminGroupHubPage from './pages/AdminGroupHubPage'
|
||||||
|
import RequireAdmin from './layouts/RequireAdmin'
|
||||||
|
import AdminShell from './layouts/AdminShell'
|
||||||
import SubscriptionPage from './pages/SubscriptionPage'
|
import SubscriptionPage from './pages/SubscriptionPage'
|
||||||
import SleepPage from './pages/SleepPage'
|
import SleepPage from './pages/SleepPage'
|
||||||
import RestDaysPage from './pages/RestDaysPage'
|
import RestDaysPage from './pages/RestDaysPage'
|
||||||
@@ -40,21 +47,34 @@ import VitalsPage from './pages/VitalsPage'
|
|||||||
import GoalsPage from './pages/GoalsPage'
|
import GoalsPage from './pages/GoalsPage'
|
||||||
import CustomGoalsPage from './pages/CustomGoalsPage'
|
import CustomGoalsPage from './pages/CustomGoalsPage'
|
||||||
import WorkflowEditorPage from './pages/WorkflowEditorPage'
|
import WorkflowEditorPage from './pages/WorkflowEditorPage'
|
||||||
|
import DesktopSidebar from './components/DesktopSidebar'
|
||||||
|
import { getMainNavItems } from './config/appNav'
|
||||||
|
import { isCaptureSectionPath } from './config/captureNav'
|
||||||
import './app.css'
|
import './app.css'
|
||||||
|
|
||||||
function Nav() {
|
function navItemActive(pathname, item, routerIsActive) {
|
||||||
const links = [
|
if (item.to.startsWith('/admin')) return pathname.startsWith('/admin')
|
||||||
{ to:'/', icon:<LayoutDashboard size={20}/>, label:'Übersicht' },
|
if (item.to === '/capture' && isCaptureSectionPath(pathname)) return true
|
||||||
{ to:'/capture', icon:<PlusSquare size={20}/>, label:'Erfassen' },
|
return routerIsActive
|
||||||
{ to:'/history', icon:<TrendingUp size={20}/>, label:'Verlauf' },
|
}
|
||||||
{ to:'/analysis', icon:<BarChart2 size={20}/>, label:'Analyse' },
|
|
||||||
{ to:'/settings', icon:<Settings size={20}/>, label:'Einst.' },
|
function Nav({ isAdmin }) {
|
||||||
]
|
const items = getMainNavItems(isAdmin)
|
||||||
|
const loc = useLocation()
|
||||||
return (
|
return (
|
||||||
<nav className="bottom-nav">
|
<nav className="bottom-nav">
|
||||||
{links.map(l=>(
|
{items.map((item) => (
|
||||||
<NavLink key={l.to} to={l.to} end={l.to==='/'} className={({isActive})=>'nav-item'+(isActive?' active':'')}>
|
<NavLink
|
||||||
{l.icon}<span>{l.label}</span>
|
key={item.to}
|
||||||
|
to={item.to}
|
||||||
|
end={!!item.end}
|
||||||
|
className={({ isActive }) =>
|
||||||
|
'nav-item' +
|
||||||
|
(navItemActive(loc.pathname, item, isActive) ? ' active' : '')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<item.Icon size={20} strokeWidth={2} />
|
||||||
|
<span>{item.shortLabel || item.label}</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
@@ -62,9 +82,8 @@ function Nav() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AppShell() {
|
function AppShell() {
|
||||||
const { session, loading: authLoading, needsSetup, logout } = useAuth()
|
const { session, loading: authLoading, needsSetup, logout, isAdmin } = useAuth()
|
||||||
const { activeProfile, loading: profileLoading } = useProfile()
|
const { activeProfile, loading: profileLoading } = useProfile()
|
||||||
const nav = useNavigate()
|
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
if (confirm('Wirklich abmelden?')) {
|
if (confirm('Wirklich abmelden?')) {
|
||||||
@@ -136,70 +155,101 @@ function AppShell() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<header className="app-header">
|
<DesktopSidebar
|
||||||
<span className="app-logo">Mitai Jinkendo</span>
|
isAdmin={isAdmin}
|
||||||
<div style={{display:'flex', gap:12, alignItems:'center'}}>
|
activeProfile={activeProfile}
|
||||||
<button
|
sessionProfile={session?.profile}
|
||||||
onClick={handleLogout}
|
onLogout={handleLogout}
|
||||||
title="Abmelden"
|
/>
|
||||||
style={{
|
<div className="app-shell__column">
|
||||||
background:'none',
|
<header className="app-header app-header--mobile">
|
||||||
border:'none',
|
<span className="app-logo">Mitai Jinkendo</span>
|
||||||
cursor:'pointer',
|
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
||||||
padding:6,
|
<button
|
||||||
display:'flex',
|
type="button"
|
||||||
alignItems:'center',
|
onClick={handleLogout}
|
||||||
color:'var(--text2)',
|
title="Abmelden"
|
||||||
transition:'color 0.15s'
|
style={{
|
||||||
}}
|
background: 'none',
|
||||||
onMouseEnter={e => e.currentTarget.style.color = '#D85A30'}
|
border: 'none',
|
||||||
onMouseLeave={e => e.currentTarget.style.color = 'var(--text2)'}
|
cursor: 'pointer',
|
||||||
>
|
padding: 6,
|
||||||
<LogOut size={18}/>
|
display: 'flex',
|
||||||
</button>
|
alignItems: 'center',
|
||||||
<NavLink to="/settings" style={{textDecoration:'none'}}>
|
color: 'var(--text2)',
|
||||||
{activeProfile
|
transition: 'color 0.15s'
|
||||||
? <Avatar profile={activeProfile} size={30}/>
|
}}
|
||||||
: <div style={{width:30,height:30,borderRadius:'50%',background:'var(--accent)'}}/>
|
onMouseEnter={(e) => {
|
||||||
}
|
e.currentTarget.style.color = '#D85A30'
|
||||||
</NavLink>
|
}}
|
||||||
</div>
|
onMouseLeave={(e) => {
|
||||||
</header>
|
e.currentTarget.style.color = 'var(--text2)'
|
||||||
<main className="app-main">
|
}}
|
||||||
|
>
|
||||||
|
<LogOut size={18} />
|
||||||
|
</button>
|
||||||
|
<NavLink to="/settings" style={{ textDecoration: 'none' }}>
|
||||||
|
{activeProfile ? (
|
||||||
|
<Avatar profile={activeProfile} size={30} />
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
borderRadius: '50%',
|
||||||
|
background: 'var(--accent)'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main className="app-main">
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Dashboard/>}/>
|
<Route path="/" element={<Dashboard/>}/>
|
||||||
<Route path="/capture" element={<CaptureHub/>}/>
|
<Route element={<CaptureShell />}>
|
||||||
<Route path="/wizard" element={<MeasureWizard/>}/>
|
<Route path="/capture" element={<CaptureHub />} />
|
||||||
<Route path="/weight" element={<WeightScreen/>}/>
|
<Route path="/wizard" element={<MeasureWizard />} />
|
||||||
<Route path="/circum" element={<CircumScreen/>}/>
|
<Route path="/weight" element={<WeightScreen />} />
|
||||||
<Route path="/caliper" element={<CaliperScreen/>}/>
|
<Route path="/circum" element={<CircumScreen />} />
|
||||||
|
<Route path="/caliper" element={<CaliperScreen />} />
|
||||||
|
<Route path="/sleep" element={<SleepPage />} />
|
||||||
|
<Route path="/rest-days" element={<RestDaysPage />} />
|
||||||
|
<Route path="/vitals" element={<VitalsPage />} />
|
||||||
|
<Route path="/custom-goals" element={<CustomGoalsPage />} />
|
||||||
|
<Route path="/nutrition" element={<NutritionPage />} />
|
||||||
|
<Route path="/activity" element={<ActivityPage />} />
|
||||||
|
<Route path="/guide" element={<GuidePage />} />
|
||||||
|
</Route>
|
||||||
<Route path="/history" element={<History/>}/>
|
<Route path="/history" element={<History/>}/>
|
||||||
<Route path="/sleep" element={<SleepPage/>}/>
|
|
||||||
<Route path="/rest-days" element={<RestDaysPage/>}/>
|
|
||||||
<Route path="/vitals" element={<VitalsPage/>}/>
|
|
||||||
<Route path="/goals" element={<GoalsPage/>}/>
|
<Route path="/goals" element={<GoalsPage/>}/>
|
||||||
<Route path="/custom-goals" element={<CustomGoalsPage/>}/>
|
|
||||||
<Route path="/nutrition" element={<NutritionPage/>}/>
|
|
||||||
<Route path="/activity" element={<ActivityPage/>}/>
|
|
||||||
<Route path="/analysis" element={<Analysis/>}/>
|
<Route path="/analysis" element={<Analysis/>}/>
|
||||||
<Route path="/settings" element={<SettingsPage/>}/>
|
<Route path="/settings" element={<SettingsPage/>}/>
|
||||||
<Route path="/guide" element={<GuidePage/>}/>
|
<Route element={<RequireAdmin />}>
|
||||||
<Route path="/admin/tier-limits" element={<AdminTierLimitsPage/>}/>
|
<Route path="admin" element={<AdminShell />}>
|
||||||
<Route path="/admin/features" element={<AdminFeaturesPage/>}/>
|
<Route index element={<AdminHomePage />} />
|
||||||
<Route path="/admin/tiers" element={<AdminTiersPage/>}/>
|
<Route path="g/:groupId" element={<AdminGroupHubPage />} />
|
||||||
<Route path="/admin/coupons" element={<AdminCouponsPage/>}/>
|
<Route path="users" element={<AdminUsersPage />} />
|
||||||
<Route path="/admin/user-restrictions" element={<AdminUserRestrictionsPage/>}/>
|
<Route path="system" element={<AdminSystemPage />} />
|
||||||
<Route path="/admin/training-types" element={<AdminTrainingTypesPage/>}/>
|
<Route path="tier-limits" element={<AdminTierLimitsPage/>}/>
|
||||||
<Route path="/admin/activity-mappings" element={<AdminActivityMappingsPage/>}/>
|
<Route path="features" element={<AdminFeaturesPage/>}/>
|
||||||
<Route path="/admin/training-profiles" element={<AdminTrainingProfiles/>}/>
|
<Route path="tiers" element={<AdminTiersPage/>}/>
|
||||||
<Route path="/admin/prompts" element={<AdminPromptsPage/>}/>
|
<Route path="coupons" element={<AdminCouponsPage/>}/>
|
||||||
<Route path="/admin/goal-types" element={<AdminGoalTypesPage/>}/>
|
<Route path="user-restrictions" element={<AdminUserRestrictionsPage/>}/>
|
||||||
<Route path="/admin/focus-areas" element={<AdminFocusAreasPage/>}/>
|
<Route path="training-types" element={<AdminTrainingTypesPage/>}/>
|
||||||
|
<Route path="activity-mappings" element={<AdminActivityMappingsPage/>}/>
|
||||||
|
<Route path="training-profiles" element={<AdminTrainingProfiles/>}/>
|
||||||
|
<Route path="prompts" element={<AdminPromptsPage/>}/>
|
||||||
|
<Route path="goal-types" element={<AdminGoalTypesPage/>}/>
|
||||||
|
<Route path="focus-areas" element={<AdminFocusAreasPage/>}/>
|
||||||
|
</Route>
|
||||||
|
</Route>
|
||||||
<Route path="/workflow-editor/:id" element={<WorkflowEditorPage/>}/>
|
<Route path="/workflow-editor/:id" element={<WorkflowEditorPage/>}/>
|
||||||
<Route path="/subscription" element={<SubscriptionPage/>}/>
|
<Route path="/subscription" element={<SubscriptionPage/>}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
<Nav/>
|
</div>
|
||||||
|
<Nav isAdmin={isAdmin} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+780
-18
@@ -12,9 +12,12 @@
|
|||||||
--accent-dark: #0a5c43;
|
--accent-dark: #0a5c43;
|
||||||
--danger: #D85A30;
|
--danger: #D85A30;
|
||||||
--warn: #EF9F27;
|
--warn: #EF9F27;
|
||||||
--nav-h: 64px;
|
/* Höhe der eigentlichen Tab-Zeile (ohne Abstand/Home-Indicator) */
|
||||||
|
--nav-h: 56px;
|
||||||
|
--nav-pad-top: 8px;
|
||||||
--header-h: 52px;
|
--header-h: 52px;
|
||||||
--font: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
--font: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
||||||
|
--capture-content-max: 800px;
|
||||||
}
|
}
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
@@ -35,20 +38,61 @@ body { font-family: var(--font); background: var(--bg); color: var(--text1); -we
|
|||||||
position: sticky; top: 0; z-index: 10;
|
position: sticky; top: 0; z-index: 10;
|
||||||
}
|
}
|
||||||
.app-logo { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
|
.app-logo { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
|
||||||
.app-main { flex: 1; overflow-y: auto; padding: 16px 16px calc(var(--nav-h) + 16px); }
|
/* unten: Tab-Leiste + Abstand nach oben zur Leiste + Home-Indicator (iPhone) */
|
||||||
|
.app-main {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 16px 16px calc(var(--nav-h) + var(--nav-pad-top) + env(safe-area-inset-bottom, 0px) + 20px);
|
||||||
|
}
|
||||||
|
|
||||||
.bottom-nav {
|
.bottom-nav {
|
||||||
position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
|
position: fixed;
|
||||||
width: 100%; max-width: 600px;
|
bottom: 0;
|
||||||
height: var(--nav-h); display: flex; align-items: stretch;
|
left: 50%;
|
||||||
background: var(--surface); border-top: 1px solid var(--border);
|
transform: translateX(-50%);
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: var(--surface);
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: visible;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 2px;
|
||||||
|
padding: var(--nav-pad-top) 6px env(safe-area-inset-bottom, 0px);
|
||||||
|
min-height: calc(var(--nav-h) + var(--nav-pad-top) + env(safe-area-inset-bottom, 0px));
|
||||||
|
height: auto;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.bottom-nav::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
.nav-item {
|
.nav-item {
|
||||||
flex: 1; display: flex; flex-direction: column; align-items: center;
|
flex: 0 0 auto;
|
||||||
justify-content: center; gap: 3px; color: var(--text3);
|
min-width: 56px;
|
||||||
text-decoration: none; font-size: 10px; font-weight: 500;
|
max-width: 96px;
|
||||||
transition: color 0.15s; padding-bottom: env(safe-area-inset-bottom, 0);
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 3px;
|
||||||
|
color: var(--text3);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: color 0.15s;
|
||||||
|
padding: 2px 4px 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.nav-item span {
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1.15;
|
||||||
|
text-align: center;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
.nav-item.active { color: var(--accent); }
|
.nav-item.active { color: var(--accent); }
|
||||||
.nav-item svg { flex-shrink: 0; }
|
.nav-item svg { flex-shrink: 0; }
|
||||||
@@ -86,6 +130,32 @@ body { font-family: var(--font); background: var(--bg); color: var(--text1); -we
|
|||||||
}
|
}
|
||||||
.form-input:focus { outline: none; border-color: var(--accent); }
|
.form-input:focus { outline: none; border-color: var(--accent); }
|
||||||
.form-unit { font-size: 12px; color: var(--text3); width: 24px; }
|
.form-unit { font-size: 12px; color: var(--text3); width: 24px; }
|
||||||
|
|
||||||
|
/* Einstellungen Profil: Label als Überschrift oben, volle Breite, linksbündig */
|
||||||
|
.settings-page__field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.settings-page__field-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text1);
|
||||||
|
text-align: left;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
.settings-page__field .form-input {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
text-align: left;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
.form-select {
|
.form-select {
|
||||||
font-family: var(--font); font-size: 13px; color: var(--text1);
|
font-family: var(--font); font-size: 13px; color: var(--text1);
|
||||||
background: var(--surface2); border: 1.5px solid var(--border2);
|
background: var(--surface2); border: 1.5px solid var(--border2);
|
||||||
@@ -125,6 +195,380 @@ body { font-family: var(--font); background: var(--bg); color: var(--text1); -we
|
|||||||
/* Section */
|
/* Section */
|
||||||
.section-gap { margin-bottom: 16px; }
|
.section-gap { margin-bottom: 16px; }
|
||||||
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
|
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
|
||||||
|
|
||||||
|
/* Verlauf: Mobile Tabs horizontale Leiste, Desktop vertikal links (P4 / RESPONSIVE_UI §5.2) */
|
||||||
|
.history-page__title {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-page__layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tabs {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tabs__scroller {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 6px;
|
||||||
|
overflow-x: auto;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tabs__scroller::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tab-btn {
|
||||||
|
white-space: nowrap;
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 7px 14px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1.5px solid var(--border2);
|
||||||
|
background: var(--surface);
|
||||||
|
color: var(--text2);
|
||||||
|
font-family: var(--font);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tab-btn:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--text1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tab-btn.history-tab-btn--active {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--accent);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tab-btn.history-tab-btn--active:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.history-page__layout {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tabs {
|
||||||
|
flex: 0 0 260px;
|
||||||
|
max-width: 280px;
|
||||||
|
position: sticky;
|
||||||
|
top: 16px;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tabs__scroller {
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-x: visible;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc(100vh - 120px);
|
||||||
|
padding-bottom: 0;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-tab-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
border-radius: 10px;
|
||||||
|
white-space: normal;
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 10px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* KI-Analyse (P5): Mobile Prompt-Leiste oben / horizontal, Desktop links ~300px (RESPONSIVE_UI §5.3) */
|
||||||
|
.analysis-page__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.analysis-page__header > div:first-child {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 6px;
|
||||||
|
overflow-x: auto;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1.5px solid var(--border2);
|
||||||
|
background: var(--surface);
|
||||||
|
color: var(--text2);
|
||||||
|
font-family: var(--font);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--text1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item--active {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--accent);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item--active:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item--active .muted {
|
||||||
|
color: rgba(255, 255, 255, 0.88) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-cat-count {
|
||||||
|
margin-left: 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 500;
|
||||||
|
opacity: 0.92;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item--active .analysis-split__nav-cat-count {
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.analysis-split__nav-item {
|
||||||
|
text-decoration: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.analysis-split {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-wrap {
|
||||||
|
flex: 0 0 300px;
|
||||||
|
max-width: 320px;
|
||||||
|
position: sticky;
|
||||||
|
top: 16px;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav {
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-x: visible;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc(100vh - 140px);
|
||||||
|
padding-bottom: 0;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__nav-item {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-start;
|
||||||
|
text-align: left;
|
||||||
|
border-radius: 10px;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.analysis-split__main {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erfassung: eine einheitliche Inhaltsbreite (Desktop), zentriert; mobil volle Breite */
|
||||||
|
.capture-page {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.capture-page {
|
||||||
|
max-width: var(--capture-content-max);
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erfassung: Sub-Navigation (Mobil = Chips, Desktop = linke Spalte) */
|
||||||
|
.capture-shell {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 6px;
|
||||||
|
overflow-x: auto;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 7px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1.5px solid var(--border2);
|
||||||
|
background: var(--surface);
|
||||||
|
color: var(--text2);
|
||||||
|
font-family: var(--font);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--text1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item--active {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--accent);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item--active:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item--highlight:not(.capture-shell__nav-item--active) {
|
||||||
|
border-color: #7f77dd88;
|
||||||
|
background: #7f77dd14;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-icon {
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-label {
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.capture-shell__layout {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-wrap {
|
||||||
|
flex: 0 0 260px;
|
||||||
|
max-width: 280px;
|
||||||
|
position: sticky;
|
||||||
|
top: 16px;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav {
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-x: visible;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc(100vh - 140px);
|
||||||
|
padding-bottom: 0;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__nav-item {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-start;
|
||||||
|
border-radius: 10px;
|
||||||
|
white-space: normal;
|
||||||
|
padding: 9px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.capture-shell__main {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Admin: Split-Layout wie .analysis-split (nur Gruppen in der Nav) */
|
||||||
|
.admin-shell {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-page {
|
||||||
|
max-width: var(--capture-content-max);
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.muted { color: var(--text3); font-size: 13px; }
|
.muted { color: var(--text3); font-size: 13px; }
|
||||||
.empty-state { text-align: center; padding: 48px 16px; color: var(--text3); }
|
.empty-state { text-align: center; padding: 48px 16px; color: var(--text3); }
|
||||||
.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 6px; }
|
.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 6px; }
|
||||||
@@ -147,14 +591,332 @@ body { font-family: var(--font); background: var(--bg); color: var(--text1); -we
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 6-item nav - smaller labels */
|
|
||||||
.nav-item span { font-size: 11px; }
|
|
||||||
|
|
||||||
/* 7-item nav scrollable */
|
|
||||||
.bottom-nav { overflow-x: auto; }
|
|
||||||
.nav-item span { font-size: 11px; }
|
|
||||||
.nav-item { min-width: 60px; }
|
|
||||||
|
|
||||||
/* Header with profile avatar */
|
/* Header with profile avatar */
|
||||||
.app-header { display:flex; align-items:center; justify-content:space-between; }
|
.app-header { display:flex; align-items:center; justify-content:space-between; }
|
||||||
.app-header a { display:flex; }
|
.app-header a { display:flex; }
|
||||||
|
|
||||||
|
/* ── Responsive shell: Desktop sidebar (≥1024px) — spec RESPONSIVE_UI.md ───── */
|
||||||
|
.app-shell__column {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar {
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 220px;
|
||||||
|
height: 100vh;
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 30;
|
||||||
|
background: var(--surface);
|
||||||
|
border-right: 1px solid var(--border);
|
||||||
|
padding: 16px 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__brand {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 0 16px 20px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__logo {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 3px solid var(--accent);
|
||||||
|
flex-shrink: 0;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__title {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--accent);
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 0 0 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px 16px 10px 13px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--text2);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
border-radius: 0 8px 8px 0;
|
||||||
|
transition: background 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__link:hover {
|
||||||
|
background: var(--surface2);
|
||||||
|
color: var(--text1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__link.desktop-sidebar__link--active {
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: var(--accent);
|
||||||
|
border-left-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__footer {
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
padding: 16px 12px 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__user {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__user-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__user-name {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text1);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__user-tier {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text3);
|
||||||
|
text-transform: lowercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__logout {
|
||||||
|
flex-shrink: 0;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--text3);
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar__logout:hover {
|
||||||
|
color: var(--danger);
|
||||||
|
background: rgba(216, 90, 48, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1023px) {
|
||||||
|
.app-shell {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.app-shell {
|
||||||
|
display: block;
|
||||||
|
max-width: none;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desktop-sidebar {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-shell__column {
|
||||||
|
margin-left: 220px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-header--mobile {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-nav {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-main {
|
||||||
|
padding: 24px 32px 32px;
|
||||||
|
padding-bottom: max(32px, env(safe-area-inset-bottom, 0px));
|
||||||
|
max-width: 1200px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dashboard (P3): Begrüßung + Kennzahlen-Zeile */
|
||||||
|
.dashboard-greeting {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-greeting__meta {
|
||||||
|
margin-top: 0 !important;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Dashboard layout (Mobile baseline + Desktop im Block oben teilweise) ─ */
|
||||||
|
|
||||||
|
.dashboard-page {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-greeting {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dashboard-Raster (KPI, Nebeneinander-Kacheln): 2 / 4 Spalten.
|
||||||
|
* StatCard, DashboardTile: span via --tile-sm / --tile-lg (JS clamp).
|
||||||
|
*/
|
||||||
|
.dashboard-stat-grid,
|
||||||
|
.dashboard-tile-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-stat-grid--mobile-4col,
|
||||||
|
.dashboard-tile-grid--mobile-4col {
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-stat-card {
|
||||||
|
background: var(--surface);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 12px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
transition: border-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-stat-card,
|
||||||
|
.dashboard-tile {
|
||||||
|
min-width: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
grid-column: span var(--tile-sm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.dashboard-stat-card,
|
||||||
|
.dashboard-tile {
|
||||||
|
grid-column: span var(--tile-lg, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Dashboard-Abschnitte (Überschrift + Trennlinie) ─ */
|
||||||
|
.dashboard-section {
|
||||||
|
margin-bottom: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__headline {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text3);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__description {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text3);
|
||||||
|
margin: 4px 0 0 0;
|
||||||
|
line-height: 1.35;
|
||||||
|
max-width: 640px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-section__actions {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-pill-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ernährung/Aktivität: Raster wie KPI; Kacheln per DashboardTile steuerbar */
|
||||||
|
.dashboard-summary-row.dashboard-tile-grid {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-erholung-grid .dashboard-tile > .card,
|
||||||
|
.dashboard-summary-row .dashboard-tile > .card {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.dashboard-stat-grid,
|
||||||
|
.dashboard-tile-grid {
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Abschnitt mit optionalem Kopf (Titel, Beschreibung, Aktionen) und unterem Rand zur optischen Trennung.
|
||||||
|
*/
|
||||||
|
export default function DashboardSection({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
headerRight,
|
||||||
|
children,
|
||||||
|
className = '',
|
||||||
|
bodyClassName = ''
|
||||||
|
}) {
|
||||||
|
const showHeader = title || description || headerRight
|
||||||
|
return (
|
||||||
|
<section className={`dashboard-section ${className}`.trim()}>
|
||||||
|
{showHeader && (
|
||||||
|
<header className="dashboard-section__header">
|
||||||
|
<div className="dashboard-section__headline">
|
||||||
|
{title ? <h2 className="dashboard-section__title">{title}</h2> : null}
|
||||||
|
{description ? (
|
||||||
|
<p className="dashboard-section__description">{description}</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
{headerRight ? (
|
||||||
|
<div className="dashboard-section__actions">{headerRight}</div>
|
||||||
|
) : null}
|
||||||
|
</header>
|
||||||
|
)}
|
||||||
|
<div className={`dashboard-section__body ${bodyClassName}`.trim()}>{children}</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import {
|
||||||
|
clampTileSpan,
|
||||||
|
DASHBOARD_TILE_GRID_COLS
|
||||||
|
} from '../utils/dashboardLayout'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kachel im Raster `.dashboard-tile-grid` / `.dashboard-stat-grid`.
|
||||||
|
* Standard: volle Zeile (Mobile 2/2, Desktop 4/4). Anpassbar via spanMobile / spanDesktop.
|
||||||
|
*/
|
||||||
|
export default function DashboardTile({
|
||||||
|
children,
|
||||||
|
spanMobile = DASHBOARD_TILE_GRID_COLS.mobile,
|
||||||
|
spanDesktop = DASHBOARD_TILE_GRID_COLS.desktop,
|
||||||
|
className = ''
|
||||||
|
}) {
|
||||||
|
const sm = clampTileSpan(spanMobile, DASHBOARD_TILE_GRID_COLS.mobile)
|
||||||
|
const lg = clampTileSpan(spanDesktop, DASHBOARD_TILE_GRID_COLS.desktop)
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`dashboard-tile ${className}`.trim()}
|
||||||
|
style={{
|
||||||
|
'--tile-sm': String(sm),
|
||||||
|
'--tile-lg': String(lg)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { NavLink, useLocation } from 'react-router-dom'
|
||||||
|
import { LogOut } from 'lucide-react'
|
||||||
|
import { Avatar } from '../pages/ProfileSelect'
|
||||||
|
import { getMainNavItems } from '../config/appNav'
|
||||||
|
import { isCaptureSectionPath } from '../config/captureNav'
|
||||||
|
|
||||||
|
function sidebarLinkActive(pathname, item, routerIsActive) {
|
||||||
|
if (item.to.startsWith('/admin')) return pathname.startsWith('/admin')
|
||||||
|
if (item.to === '/capture' && isCaptureSectionPath(pathname)) return true
|
||||||
|
return routerIsActive
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Desktop-Sidebar (≥1024px) — Sichtbarkeit via CSS (.desktop-sidebar).
|
||||||
|
*/
|
||||||
|
export default function DesktopSidebar({
|
||||||
|
isAdmin,
|
||||||
|
activeProfile,
|
||||||
|
sessionProfile,
|
||||||
|
onLogout
|
||||||
|
}) {
|
||||||
|
const loc = useLocation()
|
||||||
|
const items = getMainNavItems(isAdmin)
|
||||||
|
const tier = (activeProfile && activeProfile.tier) || sessionProfile?.tier || ''
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside className="desktop-sidebar" aria-label="Hauptnavigation">
|
||||||
|
<div className="desktop-sidebar__brand">
|
||||||
|
<div className="desktop-sidebar__logo" aria-hidden />
|
||||||
|
<div className="desktop-sidebar__title">Mitai Jinkendo</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav className="desktop-sidebar__nav">
|
||||||
|
{items.map((item) => (
|
||||||
|
<NavLink
|
||||||
|
key={item.to}
|
||||||
|
to={item.to}
|
||||||
|
end={!!item.end}
|
||||||
|
className={({ isActive }) =>
|
||||||
|
'desktop-sidebar__link' +
|
||||||
|
(sidebarLinkActive(loc.pathname, item, isActive)
|
||||||
|
? ' desktop-sidebar__link--active'
|
||||||
|
: '')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<item.Icon size={20} strokeWidth={2} />
|
||||||
|
<span>{item.label}</span>
|
||||||
|
</NavLink>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="desktop-sidebar__footer">
|
||||||
|
<NavLink to="/settings" className="desktop-sidebar__user">
|
||||||
|
{activeProfile ? (
|
||||||
|
<Avatar profile={activeProfile} size={32} />
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
borderRadius: '50%',
|
||||||
|
background: 'var(--accent)'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className="desktop-sidebar__user-text">
|
||||||
|
<span className="desktop-sidebar__user-name">
|
||||||
|
{activeProfile?.name || 'Profil'}
|
||||||
|
</span>
|
||||||
|
{tier ? (
|
||||||
|
<span className="desktop-sidebar__user-tier">{tier}</span>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</NavLink>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="desktop-sidebar__logout"
|
||||||
|
onClick={onLogout}
|
||||||
|
title="Abmelden"
|
||||||
|
>
|
||||||
|
<LogOut size={18} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
|
||||||
|
export default function EmailSettings() {
|
||||||
|
const [status, setStatus] = useState(null)
|
||||||
|
const [testTo, setTestTo] = useState('')
|
||||||
|
const [testing, setTesting] = useState(false)
|
||||||
|
const [testMsg, setTestMsg] = useState(null)
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
const token = localStorage.getItem('bodytrack_token')||''
|
||||||
|
fetch('/api/admin/email/status',{headers:{'X-Auth-Token':token}})
|
||||||
|
.then(r=>r.json()).then(setStatus)
|
||||||
|
},[])
|
||||||
|
|
||||||
|
const sendTest = async () => {
|
||||||
|
if (!testTo) return
|
||||||
|
setTesting(true); setTestMsg(null)
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem('bodytrack_token')||''
|
||||||
|
const r = await fetch('/api/admin/email/test',{
|
||||||
|
method:'POST',headers:{'Content-Type':'application/json','X-Auth-Token':token},
|
||||||
|
body:JSON.stringify({to:testTo})
|
||||||
|
})
|
||||||
|
if(!r.ok) throw new Error((await r.json()).detail)
|
||||||
|
setTestMsg('✓ Test-E-Mail gesendet!')
|
||||||
|
} catch(e){ setTestMsg('✗ Fehler: '+e.message) }
|
||||||
|
finally{ setTesting(false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card section-gap" style={{marginTop:0}}>
|
||||||
|
<div style={{fontWeight:700,fontSize:14,marginBottom:10,display:'flex',alignItems:'center',gap:6}}>
|
||||||
|
📧 E-Mail Konfiguration (SMTP)
|
||||||
|
</div>
|
||||||
|
{!status ? <div className="spinner" style={{width:16,height:16}}/> : (
|
||||||
|
<>
|
||||||
|
<div style={{padding:'8px 12px',borderRadius:8,marginBottom:12,
|
||||||
|
background:status.configured?'var(--accent-light)':'var(--warn-bg)',
|
||||||
|
fontSize:12,color:status.configured?'var(--accent-dark)':'var(--warn-text)'}}>
|
||||||
|
{status.configured
|
||||||
|
? <>✓ Konfiguriert: <strong>{status.smtp_user}</strong> via {status.smtp_host}</>
|
||||||
|
: <>⚠️ Nicht konfiguriert. SMTP-Einstellungen in der <code>.env</code> Datei setzen.</>}
|
||||||
|
</div>
|
||||||
|
{status.configured && (
|
||||||
|
<>
|
||||||
|
<div style={{fontSize:11,color:'var(--text3)',marginBottom:10,lineHeight:1.5}}>
|
||||||
|
<strong>App-URL:</strong> {status.app_url}<br/>
|
||||||
|
<span style={{fontSize:10}}>Für korrekte Links in E-Mails (z.B. Recovery-Links). In .env als APP_URL setzen.</span>
|
||||||
|
</div>
|
||||||
|
<div style={{display:'flex',gap:8}}>
|
||||||
|
<input type="email" className="form-input" placeholder="test@beispiel.de"
|
||||||
|
value={testTo} onChange={e=>setTestTo(e.target.value)} style={{flex:1}}/>
|
||||||
|
<button className="btn btn-secondary" onClick={sendTest} disabled={testing}>
|
||||||
|
{testing?'…':'Test'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{testMsg && <div style={{fontSize:12,marginTop:6,
|
||||||
|
color:testMsg.startsWith('✓')?'var(--accent)':'#D85A30'}}>{testMsg}</div>}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!status.configured && (
|
||||||
|
<div style={{fontSize:11,color:'var(--text3)',lineHeight:1.6}}>
|
||||||
|
Füge folgende Zeilen zur <code>.env</code> Datei hinzu:<br/>
|
||||||
|
<code style={{background:'var(--surface2)',padding:'6px 8px',borderRadius:4,
|
||||||
|
display:'block',marginTop:6,fontSize:11}}>
|
||||||
|
SMTP_HOST=smtp.gmail.com<br/>
|
||||||
|
SMTP_PORT=587<br/>
|
||||||
|
SMTP_USER=deine@gmail.com<br/>
|
||||||
|
SMTP_PASS=dein_app_passwort<br/>
|
||||||
|
APP_URL=http://192.168.2.49:3002
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
/**
|
||||||
|
* Admin: Nur Gruppen in der Shell-Navigation; konkrete Seiten wählt man auf der Hub-Seite (/admin/g/:id).
|
||||||
|
* @typedef {{ to: string, label: string, description?: string }} AdminGroupItem
|
||||||
|
* @typedef {{ id: string, label: string, description: string, items: AdminGroupItem[] }} AdminGroup
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {AdminGroup[]} */
|
||||||
|
export const ADMIN_GROUPS = [
|
||||||
|
{
|
||||||
|
id: 'users',
|
||||||
|
label: 'Benutzerverwaltung',
|
||||||
|
description: 'Profile anlegen, Rollen setzen und Recovery-E-Mails pflegen.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/users',
|
||||||
|
label: 'Profile & Rollen',
|
||||||
|
description: 'Neue Profile, Admin-Rolle, PIN und E-Mail pro Nutzer.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'features',
|
||||||
|
label: 'Features',
|
||||||
|
description: 'Feature-Registry, Kontingente und individuelle Overrides.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/features',
|
||||||
|
label: 'Feature-Registry',
|
||||||
|
description: 'Features definieren und Kategorien zuordnen.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: '/admin/tier-limits',
|
||||||
|
label: 'Tier-Limits',
|
||||||
|
description: 'Limit-Matrix pro Tier bearbeiten.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: '/admin/user-restrictions',
|
||||||
|
label: 'User-Overrides',
|
||||||
|
description: 'Individuelle Feature-Limits setzen.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'subscription',
|
||||||
|
label: 'Subscription',
|
||||||
|
description: 'Tiers und Gutscheine für das Freemium-System.',
|
||||||
|
items: [
|
||||||
|
{ to: '/admin/tiers', label: 'Tiers', description: 'Abo-Stufen und Zuordnung.' },
|
||||||
|
{ to: '/admin/coupons', label: 'Coupons', description: 'Gutscheincodes verwalten.' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'training',
|
||||||
|
label: 'Trainingstypen',
|
||||||
|
description: 'Trainingstypen, Mappings und Trainings-Profile.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/training-types',
|
||||||
|
label: 'Trainingstypen',
|
||||||
|
description: 'Kategorien und Typen verwalten.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: '/admin/activity-mappings',
|
||||||
|
label: 'Activity-Mappings',
|
||||||
|
description: 'Lernendes Zuordnungssystem (Sprache / Apple Health).',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: '/admin/training-profiles',
|
||||||
|
label: 'Trainings-Profile',
|
||||||
|
description: 'Training-Type-Profile (#15).',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'goals',
|
||||||
|
label: 'Ziele & Fokus',
|
||||||
|
description: 'Ziel-Typen und Focus Areas.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/goal-types',
|
||||||
|
label: 'Ziel-Typen',
|
||||||
|
description: 'Custom Goal Types mit oder ohne Datenquelle.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: '/admin/focus-areas',
|
||||||
|
label: 'Focus Areas',
|
||||||
|
description: 'Dynamische Fokusbereiche und Kategorien.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'prompts',
|
||||||
|
label: 'KI-Prompts',
|
||||||
|
description: 'Pipeline- und Basis-Prompts für die KI-Analyse.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/prompts',
|
||||||
|
label: 'KI-Prompts verwalten',
|
||||||
|
description: 'Prompts bearbeiten, Stages, Test & Export.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'system',
|
||||||
|
label: 'Basiseinstellungen',
|
||||||
|
description: 'System-E-Mail und Platzhalter-Metadaten.',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
to: '/admin/system',
|
||||||
|
label: 'SMTP & Metadaten-Export',
|
||||||
|
description: 'SMTP-Status, Test-Mail und Placeholder-Katalog (JSON/ZIP).',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export function adminGroupHubPath(groupId) {
|
||||||
|
return `/admin/g/${groupId}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shell-Navigation: Übersicht + eine Zeile/Spalte pro Gruppe (ohne Einzelseiten).
|
||||||
|
* @typedef {{ id: string, label: string, to: string, end?: boolean }} AdminShellNavEntry
|
||||||
|
* @returns {AdminShellNavEntry[]}
|
||||||
|
*/
|
||||||
|
export function getAdminShellNavEntries() {
|
||||||
|
return [
|
||||||
|
{ id: 'overview', label: 'Übersicht', to: '/admin', end: true },
|
||||||
|
...ADMIN_GROUPS.map((g) => ({
|
||||||
|
id: g.id,
|
||||||
|
label: g.label,
|
||||||
|
to: adminGroupHubPath(g.id),
|
||||||
|
end: false,
|
||||||
|
})),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Aktiver Shell-Eintrag inkl. Leaf-Routen der Gruppe (z. B. /admin/features → Gruppe „Features“). */
|
||||||
|
export function adminShellEntryIsActive(pathname, entry) {
|
||||||
|
if (entry.id === 'overview') {
|
||||||
|
return pathname === '/admin'
|
||||||
|
}
|
||||||
|
const group = ADMIN_GROUPS.find((x) => x.id === entry.id)
|
||||||
|
if (!group) return false
|
||||||
|
if (pathname === adminGroupHubPath(group.id)) return true
|
||||||
|
return group.items.some((it) => pathname === it.to)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Anzahl Unterseiten für Chip-Badge (wie KI-Analyse). */
|
||||||
|
export function adminShellEntryItemCount(entry) {
|
||||||
|
if (entry.id === 'overview') return 0
|
||||||
|
const g = ADMIN_GROUPS.find((x) => x.id === entry.id)
|
||||||
|
return g ? g.items.length : 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import {
|
||||||
|
LayoutDashboard,
|
||||||
|
PlusSquare,
|
||||||
|
TrendingUp,
|
||||||
|
Target,
|
||||||
|
BarChart2,
|
||||||
|
Settings,
|
||||||
|
Shield
|
||||||
|
} from 'lucide-react'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Quelle für Hauptnavigation (Bottom-Nav + Desktop-Sidebar).
|
||||||
|
* @typedef {{ to: string, label: string, shortLabel?: string, end?: boolean, Icon: import('react').ForwardRefExoticComponent }} AppNavItem
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @returns {Omit<AppNavItem, 'Icon'>[]} */
|
||||||
|
function baseItems() {
|
||||||
|
return [
|
||||||
|
{ to: '/', label: 'Übersicht', end: true },
|
||||||
|
{ to: '/capture', label: 'Erfassen' },
|
||||||
|
{ to: '/history', label: 'Verlauf' },
|
||||||
|
{ to: '/goals', label: 'Ziele', shortLabel: 'Ziele', end: true },
|
||||||
|
{ to: '/analysis', label: 'Analyse' },
|
||||||
|
{ to: '/settings', label: 'Einstellungen', shortLabel: 'Einst.' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param {boolean} isAdmin */
|
||||||
|
export function getMainNavItems(isAdmin) {
|
||||||
|
const icons = [
|
||||||
|
LayoutDashboard,
|
||||||
|
PlusSquare,
|
||||||
|
TrendingUp,
|
||||||
|
Target,
|
||||||
|
BarChart2,
|
||||||
|
Settings
|
||||||
|
]
|
||||||
|
const raw = baseItems().map((item, i) => ({
|
||||||
|
...item,
|
||||||
|
Icon: icons[i]
|
||||||
|
}))
|
||||||
|
if (isAdmin) {
|
||||||
|
raw.push({ to: '/admin', label: 'Admin', end: false, Icon: Shield })
|
||||||
|
}
|
||||||
|
return raw
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* Erfassungs-Routen: Kachel-Hub + Sub-Navigation (Chip / Seitenleiste).
|
||||||
|
* Pfade müssen mit den Routes in App.jsx unter CaptureShell übereinstimmen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const CAPTURE_HUB_TILES = [
|
||||||
|
{
|
||||||
|
icon: '⚖️',
|
||||||
|
label: 'Gewicht',
|
||||||
|
sub: 'Tägliche Gewichtseingabe',
|
||||||
|
to: '/weight',
|
||||||
|
color: '#378ADD',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🪄',
|
||||||
|
label: 'Assistent',
|
||||||
|
sub: 'Schritt-für-Schritt Messung (Umfänge & Caliper)',
|
||||||
|
to: '/wizard',
|
||||||
|
color: '#7F77DD',
|
||||||
|
highlight: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '📏',
|
||||||
|
label: 'Umfänge',
|
||||||
|
sub: 'Hals, Brust, Taille, Bauch, Hüfte, Oberschenkel, Wade, Arm',
|
||||||
|
to: '/circum',
|
||||||
|
color: '#1D9E75',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '📐',
|
||||||
|
label: 'Caliper',
|
||||||
|
sub: 'Körperfett per Hautfaltenmessung',
|
||||||
|
to: '/caliper',
|
||||||
|
color: '#D85A30',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🍽️',
|
||||||
|
label: 'Ernährung',
|
||||||
|
sub: 'FDDB CSV importieren',
|
||||||
|
to: '/nutrition',
|
||||||
|
color: '#EF9F27',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🏋️',
|
||||||
|
label: 'Aktivität',
|
||||||
|
sub: 'Training manuell oder Apple Health importieren',
|
||||||
|
to: '/activity',
|
||||||
|
color: '#D4537E',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🌙',
|
||||||
|
label: 'Schlaf',
|
||||||
|
sub: 'Schlafdaten erfassen oder Apple Health importieren',
|
||||||
|
to: '/sleep',
|
||||||
|
color: '#7B68EE',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🛌',
|
||||||
|
label: 'Ruhetage',
|
||||||
|
sub: 'Kraft-, Cardio-, oder Entspannungs-Ruhetag erfassen',
|
||||||
|
to: '/rest-days',
|
||||||
|
color: '#9B59B6',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '❤️',
|
||||||
|
label: 'Vitalwerte',
|
||||||
|
sub: 'Ruhepuls und HRV morgens erfassen',
|
||||||
|
to: '/vitals',
|
||||||
|
color: '#E74C3C',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '🎯',
|
||||||
|
label: 'Eigene Ziele',
|
||||||
|
sub: 'Fortschritte für individuelle Ziele erfassen',
|
||||||
|
to: '/custom-goals',
|
||||||
|
color: '#1D9E75',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: '📖',
|
||||||
|
label: 'Messanleitung',
|
||||||
|
sub: 'Wie und wo genau messen?',
|
||||||
|
to: '/guide',
|
||||||
|
color: '#888780',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
/** Erster Eintrag: zurück zur Kachel-Übersicht */
|
||||||
|
const OVERVIEW_ENTRY = {
|
||||||
|
icon: '📋',
|
||||||
|
label: 'Übersicht',
|
||||||
|
sub: 'Alle Erfassungsarten',
|
||||||
|
to: '/capture',
|
||||||
|
color: 'var(--accent)',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reihenfolge für Chip- / Seitenleiste (inkl. Übersicht) */
|
||||||
|
export const CAPTURE_SHELL_NAV_ITEMS = [OVERVIEW_ENTRY, ...CAPTURE_HUB_TILES]
|
||||||
|
|
||||||
|
export const CAPTURE_SECTION_PATHS = CAPTURE_SHELL_NAV_ITEMS.map((e) => e.to)
|
||||||
|
|
||||||
|
export function isCaptureSectionPath(pathname) {
|
||||||
|
return CAPTURE_SECTION_PATHS.includes(pathname)
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Outlet, NavLink, useLocation } from 'react-router-dom'
|
||||||
|
import {
|
||||||
|
getAdminShellNavEntries,
|
||||||
|
adminShellEntryIsActive,
|
||||||
|
adminShellEntryItemCount,
|
||||||
|
} from '../config/adminNav'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wie KI-Analyse: nur Gruppen-Chips (mobil) bzw. Seitenleiste (desktop);
|
||||||
|
* konkrete Admin-Seiten über Hub unter /admin/g/:groupId.
|
||||||
|
*/
|
||||||
|
export default function AdminShell() {
|
||||||
|
const loc = useLocation()
|
||||||
|
const entries = getAdminShellNavEntries()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="admin-shell">
|
||||||
|
<div className="analysis-split">
|
||||||
|
<div className="analysis-split__nav-wrap">
|
||||||
|
<nav className="analysis-split__nav" aria-label="Adminbereich">
|
||||||
|
{entries.map((entry) => {
|
||||||
|
const active = adminShellEntryIsActive(loc.pathname, entry)
|
||||||
|
const count = adminShellEntryItemCount(entry)
|
||||||
|
return (
|
||||||
|
<NavLink
|
||||||
|
key={entry.id}
|
||||||
|
to={entry.to}
|
||||||
|
end={!!entry.end}
|
||||||
|
className={() =>
|
||||||
|
'analysis-split__nav-item' +
|
||||||
|
(active ? ' analysis-split__nav-item--active' : '')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{entry.label}
|
||||||
|
{count > 0 && (
|
||||||
|
<span className="analysis-split__nav-cat-count">({count})</span>
|
||||||
|
)}
|
||||||
|
</NavLink>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<div className="analysis-split__main">
|
||||||
|
<div className="admin-page">
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Outlet, NavLink } from 'react-router-dom'
|
||||||
|
import { CAPTURE_SHELL_NAV_ITEMS } from '../config/captureNav'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erfassung: Mobil Chip-Leiste, Desktop linke Spalte – Wechsel zwischen Masken ohne Hub.
|
||||||
|
*/
|
||||||
|
export default function CaptureShell() {
|
||||||
|
return (
|
||||||
|
<div className="capture-shell">
|
||||||
|
<div className="capture-shell__layout">
|
||||||
|
<nav className="capture-shell__nav-wrap" aria-label="Erfassungsbereiche">
|
||||||
|
<div className="capture-shell__nav">
|
||||||
|
{CAPTURE_SHELL_NAV_ITEMS.map((e) => (
|
||||||
|
<NavLink
|
||||||
|
key={e.to}
|
||||||
|
to={e.to}
|
||||||
|
end={e.to === '/capture'}
|
||||||
|
className={({ isActive }) =>
|
||||||
|
'capture-shell__nav-item' +
|
||||||
|
(isActive ? ' capture-shell__nav-item--active' : '') +
|
||||||
|
(e.highlight ? ' capture-shell__nav-item--highlight' : '')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span className="capture-shell__nav-icon" aria-hidden>{e.icon}</span>
|
||||||
|
<span className="capture-shell__nav-label">{e.label}</span>
|
||||||
|
</NavLink>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div className="capture-shell__main">
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Navigate, Outlet, useLocation } from 'react-router-dom'
|
||||||
|
import { useAuth } from '../context/AuthContext'
|
||||||
|
|
||||||
|
export default function RequireAdmin() {
|
||||||
|
const { isAdmin } = useAuth()
|
||||||
|
const loc = useLocation()
|
||||||
|
if (!isAdmin) {
|
||||||
|
return <Navigate to="/" replace state={{ from: loc.pathname, adminDenied: true }} />
|
||||||
|
}
|
||||||
|
return <Outlet />
|
||||||
|
}
|
||||||
@@ -254,7 +254,7 @@ export default function ActivityPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Aktivität</h1>
|
<h1 className="page-title">Aktivität</h1>
|
||||||
|
|
||||||
<div className="tabs" style={{overflowX:'auto',flexWrap:'nowrap'}}>
|
<div className="tabs" style={{overflowX:'auto',flexWrap:'nowrap'}}>
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { useParams, Navigate, Link } from 'react-router-dom'
|
||||||
|
import { ADMIN_GROUPS } from '../config/adminNav'
|
||||||
|
|
||||||
|
export default function AdminGroupHubPage() {
|
||||||
|
const { groupId } = useParams()
|
||||||
|
const group = ADMIN_GROUPS.find((g) => g.id === groupId)
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
return <Navigate to="/admin" replace />
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2 className="page-title" style={{ margin: '0 0 8px', fontSize: 18 }}>
|
||||||
|
{group.label}
|
||||||
|
</h2>
|
||||||
|
<p style={{ fontSize: 13, color: 'var(--text2)', marginBottom: 18, lineHeight: 1.6 }}>
|
||||||
|
{group.description}
|
||||||
|
</p>
|
||||||
|
<p style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 12 }}>
|
||||||
|
Bereich wählen · {group.items.length}{' '}
|
||||||
|
{group.items.length === 1 ? 'Seite' : 'Seiten'}
|
||||||
|
</p>
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||||
|
{group.items.map((item) => (
|
||||||
|
<Link
|
||||||
|
key={item.to}
|
||||||
|
to={item.to}
|
||||||
|
className="card section-gap"
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
textDecoration: 'none',
|
||||||
|
color: 'inherit',
|
||||||
|
borderColor: 'var(--accent)',
|
||||||
|
borderWidth: 2,
|
||||||
|
display: 'block',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontWeight: 700, fontSize: 15, color: 'var(--accent)', marginBottom: 4 }}>
|
||||||
|
{item.label}
|
||||||
|
</div>
|
||||||
|
{item.description && (
|
||||||
|
<div style={{ fontSize: 12, color: 'var(--text2)', lineHeight: 1.5 }}>
|
||||||
|
{item.description}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div style={{ marginTop: 20 }}>
|
||||||
|
<Link to="/admin" className="btn btn-secondary" style={{ fontSize: 13 }}>
|
||||||
|
← Zur Übersicht
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import { Shield } from 'lucide-react'
|
||||||
|
import { ADMIN_GROUPS, adminGroupHubPath } from '../config/adminNav'
|
||||||
|
|
||||||
|
export default function AdminHomePage() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}>
|
||||||
|
<Shield size={20} color="var(--accent)" />
|
||||||
|
<h1 className="page-title" style={{ margin: 0 }}>Adminbereich</h1>
|
||||||
|
</div>
|
||||||
|
<p style={{ fontSize: 13, color: 'var(--text2)', marginBottom: 18, lineHeight: 1.6 }}>
|
||||||
|
Wähle links oder oben eine <strong>Gruppe</strong>. Die einzelnen Verwaltungsseiten erreichst du auf der
|
||||||
|
folgenden Gruppenseite – wie bei der KI-Analyse (Kategorie → Detail).
|
||||||
|
</p>
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||||
|
{ADMIN_GROUPS.map((group) => (
|
||||||
|
<Link
|
||||||
|
key={group.id}
|
||||||
|
to={adminGroupHubPath(group.id)}
|
||||||
|
className="card section-gap"
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
textDecoration: 'none',
|
||||||
|
color: 'inherit',
|
||||||
|
display: 'block',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontWeight: 700, fontSize: 15, marginBottom: 6 }}>{group.label}</div>
|
||||||
|
<div style={{ fontSize: 12, color: 'var(--text2)', lineHeight: 1.5 }}>
|
||||||
|
{group.description}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 11, color: 'var(--text3)', marginTop: 8 }}>
|
||||||
|
{group.items.length} {group.items.length === 1 ? 'Bereich' : 'Bereiche'}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { Settings } from 'lucide-react'
|
||||||
|
import EmailSettings from '../components/EmailSettings'
|
||||||
|
import { api } from '../utils/api'
|
||||||
|
|
||||||
|
export default function AdminSystemPage() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div style={{display:'flex',alignItems:'center',gap:8,marginBottom:16}}>
|
||||||
|
<Settings size={18} color="var(--accent)"/>
|
||||||
|
<h2 style={{fontSize:17,fontWeight:700,margin:0}}>Basiseinstellungen</h2>
|
||||||
|
</div>
|
||||||
|
<p style={{fontSize:13,color:'var(--text2)',marginBottom:16,lineHeight:1.6}}>
|
||||||
|
SMTP für System-E-Mails und Export der Placeholder-Metadaten für Dokumentation und Compliance.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<EmailSettings />
|
||||||
|
|
||||||
|
<div className="card section-gap" style={{marginTop:16}}>
|
||||||
|
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
||||||
|
<Settings size={16} color="var(--accent)"/> Placeholder-Metadaten (Export)
|
||||||
|
</div>
|
||||||
|
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
||||||
|
Vollständige Metadaten aller registrierten Platzhalter (JSON/ZIP für Katalog und Reports).
|
||||||
|
</div>
|
||||||
|
<div style={{display:'grid',gap:8}}>
|
||||||
|
<button type="button" className="btn btn-secondary btn-full"
|
||||||
|
onClick={async()=>{
|
||||||
|
try {
|
||||||
|
const data = await api.exportPlaceholdersExtendedJson()
|
||||||
|
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'})
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = url
|
||||||
|
a.download = `placeholder-metadata-extended-${new Date().toISOString().split('T')[0]}.json`
|
||||||
|
a.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch(e) {
|
||||||
|
alert('Fehler beim Export: '+e.message)
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
📄 Complete JSON exportieren
|
||||||
|
</button>
|
||||||
|
<button type="button" className="btn btn-secondary btn-full"
|
||||||
|
onClick={()=>{
|
||||||
|
try {
|
||||||
|
const token = localStorage.getItem('bodytrack_token')
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = `/api/prompts/placeholders/export-catalog-zip?token=${token}`
|
||||||
|
a.download = `placeholder-catalog-${new Date().toISOString().split('T')[0]}.zip`
|
||||||
|
a.click()
|
||||||
|
} catch(e) {
|
||||||
|
alert('Fehler beim Export: '+e.message)
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
📦 Complete ZIP (JSON + Markdown + Reports)
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div style={{fontSize:11,color:'var(--text3)',marginTop:8,lineHeight:1.5}}>
|
||||||
|
<strong>JSON:</strong> Maschinenlesbare Metadaten ·{' '}
|
||||||
|
<strong>ZIP:</strong> Katalog, Gap Report, Export Spec
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { Plus, Trash2, Pencil, Check, X, Shield, Key, Settings } from 'lucide-react'
|
import { Plus, Trash2, Pencil, Check, X, Shield, Key } from 'lucide-react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
import { api } from '../utils/api'
|
import { api } from '../utils/api'
|
||||||
@@ -17,23 +17,6 @@ function Avatar({ profile, size=36 }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Toggle({ value, onChange, label, disabled=false }) {
|
|
||||||
return (
|
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',
|
|
||||||
padding:'8px 0',borderBottom:'1px solid var(--border)'}}>
|
|
||||||
<span style={{fontSize:13,color:disabled?'var(--text3)':'var(--text1)'}}>{label}</span>
|
|
||||||
<div onClick={()=>!disabled&&onChange(!value)}
|
|
||||||
style={{width:40,height:22,borderRadius:11,background:value?'var(--accent)':'var(--border)',
|
|
||||||
position:'relative',cursor:disabled?'not-allowed':'pointer',transition:'background 0.2s',
|
|
||||||
opacity:disabled?0.5:1}}>
|
|
||||||
<div style={{position:'absolute',top:2,left:value?18:2,width:18,height:18,
|
|
||||||
borderRadius:'50%',background:'white',transition:'left 0.2s',
|
|
||||||
boxShadow:'0 1px 3px rgba(0,0,0,0.2)'}}/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function NewProfileForm({ onSave, onCancel }) {
|
function NewProfileForm({ onSave, onCancel }) {
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
name:'', pin:'', email:'', avatar_color:COLORS[0],
|
name:'', pin:'', email:'', avatar_color:COLORS[0],
|
||||||
@@ -210,7 +193,6 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
|||||||
|
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
||||||
{/* Permissions */}
|
|
||||||
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8}}>BERECHTIGUNGEN</div>
|
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8}}>BERECHTIGUNGEN</div>
|
||||||
|
|
||||||
<div style={{marginBottom:8}}>
|
<div style={{marginBottom:8}}>
|
||||||
@@ -231,7 +213,6 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Feature-Overrides */}
|
|
||||||
<div style={{marginBottom:12,padding:10,background:'var(--accent-light)',borderRadius:6,fontSize:12}}>
|
<div style={{marginBottom:12,padding:10,background:'var(--accent-light)',borderRadius:6,fontSize:12}}>
|
||||||
<strong>Feature-Limits:</strong> Nutze die neue{' '}
|
<strong>Feature-Limits:</strong> Nutze die neue{' '}
|
||||||
<Link to="/admin/user-restrictions" style={{color:'var(--accent-dark)',fontWeight:600}}>
|
<Link to="/admin/user-restrictions" style={{color:'var(--accent-dark)',fontWeight:600}}>
|
||||||
@@ -240,13 +221,11 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
|||||||
Seite um individuelle Limits zu setzen.
|
Seite um individuelle Limits zu setzen.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Email */}
|
|
||||||
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
||||||
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:6}}>E-MAIL (für Recovery & Zusammenfassungen)</div>
|
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:6}}>E-MAIL (für Recovery & Zusammenfassungen)</div>
|
||||||
<EmailEditor profileId={profile.id} currentEmail={profile.email} onSaved={onRefresh}/>
|
<EmailEditor profileId={profile.id} currentEmail={profile.email} onSaved={onRefresh}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* PIN change */}
|
|
||||||
<div style={{marginTop:14,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
<div style={{marginTop:14,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
||||||
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8,display:'flex',alignItems:'center',gap:4}}>
|
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8,display:'flex',alignItems:'center',gap:4}}>
|
||||||
<Key size={12}/> PIN / PASSWORT ÄNDERN
|
<Key size={12}/> PIN / PASSWORT ÄNDERN
|
||||||
@@ -264,84 +243,7 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function EmailSettings() {
|
export default function AdminUsersPage() {
|
||||||
const [status, setStatus] = useState(null)
|
|
||||||
const [testTo, setTestTo] = useState('')
|
|
||||||
const [testing, setTesting] = useState(false)
|
|
||||||
const [testMsg, setTestMsg] = useState(null)
|
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
const token = localStorage.getItem('bodytrack_token')||''
|
|
||||||
fetch('/api/admin/email/status',{headers:{'X-Auth-Token':token}})
|
|
||||||
.then(r=>r.json()).then(setStatus)
|
|
||||||
},[])
|
|
||||||
|
|
||||||
const sendTest = async () => {
|
|
||||||
if (!testTo) return
|
|
||||||
setTesting(true); setTestMsg(null)
|
|
||||||
try {
|
|
||||||
const token = localStorage.getItem('bodytrack_token')||''
|
|
||||||
const r = await fetch('/api/admin/email/test',{
|
|
||||||
method:'POST',headers:{'Content-Type':'application/json','X-Auth-Token':token},
|
|
||||||
body:JSON.stringify({to:testTo})
|
|
||||||
})
|
|
||||||
if(!r.ok) throw new Error((await r.json()).detail)
|
|
||||||
setTestMsg('✓ Test-E-Mail gesendet!')
|
|
||||||
} catch(e){ setTestMsg('✗ Fehler: '+e.message) }
|
|
||||||
finally{ setTesting(false) }
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:10,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
📧 E-Mail Konfiguration
|
|
||||||
</div>
|
|
||||||
{!status ? <div className="spinner" style={{width:16,height:16}}/> : (
|
|
||||||
<>
|
|
||||||
<div style={{padding:'8px 12px',borderRadius:8,marginBottom:12,
|
|
||||||
background:status.configured?'var(--accent-light)':'var(--warn-bg)',
|
|
||||||
fontSize:12,color:status.configured?'var(--accent-dark)':'var(--warn-text)'}}>
|
|
||||||
{status.configured
|
|
||||||
? <>✓ Konfiguriert: <strong>{status.smtp_user}</strong> via {status.smtp_host}</>
|
|
||||||
: <>⚠️ Nicht konfiguriert. SMTP-Einstellungen in der <code>.env</code> Datei setzen.</>}
|
|
||||||
</div>
|
|
||||||
{status.configured && (
|
|
||||||
<>
|
|
||||||
<div style={{fontSize:11,color:'var(--text3)',marginBottom:10,lineHeight:1.5}}>
|
|
||||||
<strong>App-URL:</strong> {status.app_url}<br/>
|
|
||||||
<span style={{fontSize:10}}>Für korrekte Links in E-Mails (z.B. Recovery-Links). In .env als APP_URL setzen.</span>
|
|
||||||
</div>
|
|
||||||
<div style={{display:'flex',gap:8}}>
|
|
||||||
<input type="email" className="form-input" placeholder="test@beispiel.de"
|
|
||||||
value={testTo} onChange={e=>setTestTo(e.target.value)} style={{flex:1}}/>
|
|
||||||
<button className="btn btn-secondary" onClick={sendTest} disabled={testing}>
|
|
||||||
{testing?'…':'Test'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{testMsg && <div style={{fontSize:12,marginTop:6,
|
|
||||||
color:testMsg.startsWith('✓')?'var(--accent)':'#D85A30'}}>{testMsg}</div>}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{!status.configured && (
|
|
||||||
<div style={{fontSize:11,color:'var(--text3)',lineHeight:1.6}}>
|
|
||||||
Füge folgende Zeilen zur <code>.env</code> Datei hinzu:<br/>
|
|
||||||
<code style={{background:'var(--surface2)',padding:'6px 8px',borderRadius:4,
|
|
||||||
display:'block',marginTop:6,fontSize:11}}>
|
|
||||||
SMTP_HOST=smtp.gmail.com<br/>
|
|
||||||
SMTP_PORT=587<br/>
|
|
||||||
SMTP_USER=deine@gmail.com<br/>
|
|
||||||
SMTP_PASS=dein_app_passwort<br/>
|
|
||||||
APP_URL=http://192.168.2.49:3002
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AdminPanel() {
|
|
||||||
const { session } = useAuth()
|
const { session } = useAuth()
|
||||||
const [profiles, setProfiles] = useState([])
|
const [profiles, setProfiles] = useState([])
|
||||||
const [creating, setCreating] = useState(false)
|
const [creating, setCreating] = useState(false)
|
||||||
@@ -367,7 +269,7 @@ export default function AdminPanel() {
|
|||||||
|
|
||||||
<div style={{padding:'10px 12px',background:'var(--accent-light)',borderRadius:8,
|
<div style={{padding:'10px 12px',background:'var(--accent-light)',borderRadius:8,
|
||||||
fontSize:12,color:'var(--accent-dark)',marginBottom:16,lineHeight:1.5}}>
|
fontSize:12,color:'var(--accent-dark)',marginBottom:16,lineHeight:1.5}}>
|
||||||
👑 Du bist Admin. Hier kannst du Profile verwalten, Berechtigungen setzen und KI-Limits konfigurieren.
|
👑 Profile anlegen, Rollen setzen und Recovery-E-Mail pro Nutzer pflegen. Feature-Limits über „User-Overrides“ in der Seitenleiste.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{creating && (
|
{creating && (
|
||||||
@@ -384,171 +286,6 @@ export default function AdminPanel() {
|
|||||||
<Plus size={14}/> Neues Profil anlegen
|
<Plus size={14}/> Neues Profil anlegen
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Email Settings */}
|
|
||||||
<EmailSettings/>
|
|
||||||
|
|
||||||
{/* v9c Subscription Management */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> Subscription-System (v9c)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Verwalte Tiers, Features und Limits für das neue Freemium-System.
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<Link to="/admin/tiers">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🎯 Tiers verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/features">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🔧 Feature-Registry verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/tier-limits">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
📊 Tier Limits Matrix bearbeiten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/coupons">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🎟️ Coupons verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/user-restrictions">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
👤 User Feature-Overrides
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* v9d Training Types Management */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> Trainingstypen (v9d)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Verwalte Trainingstypen, Kategorien und Activity-Mappings (lernendes System).
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<Link to="/admin/training-types">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🏋️ Trainingstypen verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/activity-mappings">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🔗 Activity-Mappings (lernendes System)
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
<Link to="/admin/training-profiles">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
⭐ Training Type Profiles (#15)
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* KI-Prompts Section */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> KI-Prompts (v9f)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Verwalte AI-Prompts mit KI-Unterstützung: Generiere, optimiere und organisiere Prompts.
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<Link to="/admin/prompts">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🤖 KI-Prompts verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Goal Types Section */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> Ziel-Typen (v9e)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Verwalte Goal-Type-Definitionen: Erstelle custom goal types mit oder ohne automatische Datenquelle.
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<Link to="/admin/goal-types">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🎯 Ziel-Typen verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Focus Areas Section */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> Focus Areas (v9g)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Verwalte Focus Area Definitionen: Dynamisches, erweiterbares System mit 26+ Bereichen über 7 Kategorien.
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<Link to="/admin/focus-areas">
|
|
||||||
<button className="btn btn-secondary btn-full">
|
|
||||||
🎯 Focus Areas verwalten
|
|
||||||
</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Placeholder Metadata Export Section */}
|
|
||||||
<div className="card section-gap" style={{marginTop:16}}>
|
|
||||||
<div style={{fontWeight:700,fontSize:14,marginBottom:12,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Settings size={16} color="var(--accent)"/> Placeholder Metadata Export (v1.0)
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:12,lineHeight:1.5}}>
|
|
||||||
Exportiere vollständige Metadaten aller 116 Placeholders. Normative Compliance v1.0.0.
|
|
||||||
</div>
|
|
||||||
<div style={{display:'grid',gap:8}}>
|
|
||||||
<button className="btn btn-secondary btn-full"
|
|
||||||
onClick={async()=>{
|
|
||||||
try {
|
|
||||||
const data = await api.exportPlaceholdersExtendedJson()
|
|
||||||
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'})
|
|
||||||
const url = window.URL.createObjectURL(blob)
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = url
|
|
||||||
a.download = `placeholder-metadata-extended-${new Date().toISOString().split('T')[0]}.json`
|
|
||||||
a.click()
|
|
||||||
window.URL.revokeObjectURL(url)
|
|
||||||
} catch(e) {
|
|
||||||
alert('Fehler beim Export: '+e.message)
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
📄 Complete JSON exportieren
|
|
||||||
</button>
|
|
||||||
<button className="btn btn-secondary btn-full"
|
|
||||||
onClick={async()=>{
|
|
||||||
try {
|
|
||||||
const token = localStorage.getItem('bodytrack_token')
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = `/api/prompts/placeholders/export-catalog-zip?token=${token}`
|
|
||||||
a.download = `placeholder-catalog-${new Date().toISOString().split('T')[0]}.zip`
|
|
||||||
a.click()
|
|
||||||
} catch(e) {
|
|
||||||
alert('Fehler beim Export: '+e.message)
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
📦 Complete ZIP (JSON + Markdown + Reports)
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:11,color:'var(--text3)',marginTop:8,lineHeight:1.5}}>
|
|
||||||
<strong>JSON:</strong> Maschinenlesbare Metadaten aller Placeholders<br/>
|
|
||||||
<strong>ZIP:</strong> Katalog (JSON + MD), Gap Report, Export Spec (4 Dateien)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+231
-82
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect, useMemo } from 'react'
|
||||||
import { Brain, Trash2, ChevronDown, ChevronUp, Target } from 'lucide-react'
|
import { Brain, Trash2, ChevronDown, ChevronUp } from 'lucide-react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { api } from '../utils/api'
|
import { api } from '../utils/api'
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
import Markdown from '../utils/Markdown'
|
import Markdown from '../utils/Markdown'
|
||||||
@@ -14,6 +14,58 @@ const SLUG_LABELS = {
|
|||||||
pipeline: '🔬 Mehrstufige Gesamtanalyse'
|
pipeline: '🔬 Mehrstufige Gesamtanalyse'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** DB `ai_prompts.category` – Reihenfolge der Gruppen in der Analyse-Navigation */
|
||||||
|
const ANALYSIS_CATEGORY_ORDER = ['körper', 'ernährung', 'training', 'schlaf', 'vitalwerte', 'ziele', 'ganzheitlich']
|
||||||
|
|
||||||
|
const ANALYSIS_CATEGORY_LABELS = {
|
||||||
|
körper: 'Körper',
|
||||||
|
ernährung: 'Ernährung',
|
||||||
|
training: 'Training',
|
||||||
|
schlaf: 'Schlaf',
|
||||||
|
vitalwerte: 'Vitalwerte',
|
||||||
|
ziele: 'Ziele',
|
||||||
|
ganzheitlich: 'Ganzheitlich',
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortAnalysisCategoryKeys(keys) {
|
||||||
|
return [...keys].sort((a, b) => {
|
||||||
|
const na = String(a).toLowerCase()
|
||||||
|
const nb = String(b).toLowerCase()
|
||||||
|
const ia = ANALYSIS_CATEGORY_ORDER.indexOf(na)
|
||||||
|
const ib = ANALYSIS_CATEGORY_ORDER.indexOf(nb)
|
||||||
|
if (ia === -1 && ib === -1) return String(a).localeCompare(String(b), 'de')
|
||||||
|
if (ia === -1) return 1
|
||||||
|
if (ib === -1) return -1
|
||||||
|
return ia - ib
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function analysisCategoryLabel(key) {
|
||||||
|
const k = String(key).toLowerCase()
|
||||||
|
return ANALYSIS_CATEGORY_LABELS[k] || String(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pipeline-Prompts nach `category` gruppieren (Backend-Feld), innerhalb Gruppe nach sort_order */
|
||||||
|
function buildPipelineGroups(pipelinePrompts) {
|
||||||
|
const m = new Map()
|
||||||
|
for (const p of pipelinePrompts) {
|
||||||
|
const raw =
|
||||||
|
p.category != null && String(p.category).trim() !== ''
|
||||||
|
? String(p.category).trim()
|
||||||
|
: 'ganzheitlich'
|
||||||
|
if (!m.has(raw)) m.set(raw, [])
|
||||||
|
m.get(raw).push(p)
|
||||||
|
}
|
||||||
|
for (const arr of m.values()) {
|
||||||
|
arr.sort((a, b) => (Number(a.sort_order) || 0) - (Number(b.sort_order) || 0))
|
||||||
|
}
|
||||||
|
return sortAnalysisCategoryKeys([...m.keys()]).map(cat => ({
|
||||||
|
categoryKey: cat,
|
||||||
|
label: analysisCategoryLabel(cat),
|
||||||
|
prompts: m.get(cat),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
function InsightCard({ ins, onDelete, defaultOpen=false, prompts=[] }) {
|
function InsightCard({ ins, onDelete, defaultOpen=false, prompts=[] }) {
|
||||||
const [open, setOpen] = useState(defaultOpen)
|
const [open, setOpen] = useState(defaultOpen)
|
||||||
|
|
||||||
@@ -278,7 +330,6 @@ function InsightCard({ ins, onDelete, defaultOpen=false, prompts=[] }) {
|
|||||||
|
|
||||||
export default function Analysis() {
|
export default function Analysis() {
|
||||||
const { canUseAI } = useAuth()
|
const { canUseAI } = useAuth()
|
||||||
const navigate = useNavigate()
|
|
||||||
const [prompts, setPrompts] = useState([])
|
const [prompts, setPrompts] = useState([])
|
||||||
const [allInsights, setAllInsights] = useState([])
|
const [allInsights, setAllInsights] = useState([])
|
||||||
const [loading, setLoading] = useState(null)
|
const [loading, setLoading] = useState(null)
|
||||||
@@ -286,6 +337,9 @@ export default function Analysis() {
|
|||||||
const [tab, setTab] = useState('run')
|
const [tab, setTab] = useState('run')
|
||||||
const [newResult, setNewResult] = useState(null)
|
const [newResult, setNewResult] = useState(null)
|
||||||
const [aiUsage, setAiUsage] = useState(null)
|
const [aiUsage, setAiUsage] = useState(null)
|
||||||
|
/** Kategorie-Schlüssel aus `buildPipelineGroups` (Navigation); Detail = alle Pipelines dieser Kategorie */
|
||||||
|
const [activeCategoryKey, setActiveCategoryKey] = useState(null)
|
||||||
|
const [historyScopePick, setHistoryScopePick] = useState(null)
|
||||||
|
|
||||||
const loadAll = async () => {
|
const loadAll = async () => {
|
||||||
const [p, i] = await Promise.all([
|
const [p, i] = await Promise.all([
|
||||||
@@ -305,6 +359,25 @@ export default function Analysis() {
|
|||||||
}).catch(err => console.error('Failed to load usage:', err))
|
}).catch(err => console.error('Failed to load usage:', err))
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const list = prompts.filter(p => p.active && p.type === 'pipeline')
|
||||||
|
setActiveCategoryKey(prev => {
|
||||||
|
if (!list.length) return null
|
||||||
|
const groups = buildPipelineGroups(list)
|
||||||
|
const keys = groups.map(g => g.categoryKey)
|
||||||
|
if (prev && keys.includes(prev)) return prev
|
||||||
|
return groups[0]?.categoryKey ?? null
|
||||||
|
})
|
||||||
|
}, [prompts])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!newResult?.scope) return
|
||||||
|
const list = prompts.filter(p => p.active && p.type === 'pipeline')
|
||||||
|
const groups = buildPipelineGroups(list)
|
||||||
|
const g = groups.find(gg => gg.prompts.some(p => p.slug === newResult.scope))
|
||||||
|
if (g) setActiveCategoryKey(g.categoryKey)
|
||||||
|
}, [newResult?.scope, prompts])
|
||||||
|
|
||||||
const runPrompt = async (slug) => {
|
const runPrompt = async (slug) => {
|
||||||
setLoading(slug); setError(null); setNewResult(null)
|
setLoading(slug); setError(null); setNewResult(null)
|
||||||
try {
|
try {
|
||||||
@@ -383,25 +456,36 @@ export default function Analysis() {
|
|||||||
grouped[key].push(ins)
|
grouped[key].push(ins)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Show only active pipeline-type prompts
|
// Show only active pipeline-type prompts (und nach DB-Kategorie gruppiert)
|
||||||
const pipelinePrompts = prompts.filter(p => p.active && p.type === 'pipeline')
|
const { pipelinePrompts, pipelineGroups } = useMemo(() => {
|
||||||
|
const list = prompts.filter(p => p.active && p.type === 'pipeline')
|
||||||
|
return { pipelinePrompts: list, pipelineGroups: buildPipelineGroups(list) }
|
||||||
|
}, [prompts])
|
||||||
|
|
||||||
|
const historyScopeKeys = Object.keys(grouped).sort((a, b) => a.localeCompare(b))
|
||||||
|
const activeHistoryScope =
|
||||||
|
historyScopeKeys.length === 0
|
||||||
|
? null
|
||||||
|
: historyScopeKeys.includes(historyScopePick)
|
||||||
|
? historyScopePick
|
||||||
|
: historyScopeKeys[0]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="analysis-page">
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
<div className="analysis-page__header">
|
||||||
<h1 className="page-title" style={{ margin: 0 }}>KI-Analyse</h1>
|
<div>
|
||||||
<button
|
<h1 className="page-title" style={{ margin: 0 }}>KI-Analyse</h1>
|
||||||
className="btn btn-secondary"
|
<p style={{ fontSize: 12, color: 'var(--text3)', margin: '8px 0 0', lineHeight: 1.5, maxWidth: 520 }}>
|
||||||
onClick={() => navigate('/goals')}
|
Ziele und Fokusbereiche steuern den Kontext der Auswertungen –{' '}
|
||||||
style={{ fontSize: 13, padding: '6px 12px' }}
|
<Link to="/goals" style={{ color: 'var(--accent)', fontWeight: 600 }}>unter „Ziele“ konfigurieren</Link>
|
||||||
>
|
{' '}(auch über die untere Navigation).
|
||||||
<Target size={14} /> Ziele
|
</p>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tabs">
|
<div className="tabs">
|
||||||
<button className={'tab'+(tab==='run'?' active':'')} onClick={()=>setTab('run')}>Analysen starten</button>
|
<button type="button" className={'tab'+(tab==='run'?' active':'')} onClick={()=>setTab('run')}>Analysen starten</button>
|
||||||
<button className={'tab'+(tab==='history'?' active':'')} onClick={()=>setTab('history')}>
|
<button type="button" className={'tab'+(tab==='history'?' active':'')} onClick={()=>setTab('history')}>
|
||||||
Verlauf
|
Verlauf
|
||||||
{allInsights.length>0 && <span style={{marginLeft:4,fontSize:10,background:'var(--accent)',
|
{allInsights.length>0 && <span style={{marginLeft:4,fontSize:10,background:'var(--accent)',
|
||||||
color:'white',padding:'1px 5px',borderRadius:8}}>{allInsights.length}</span>}
|
color:'white',padding:'1px 5px',borderRadius:8}}>{allInsights.length}</span>}
|
||||||
@@ -422,8 +506,8 @@ export default function Analysis() {
|
|||||||
{/* ── Analysen starten ── */}
|
{/* ── Analysen starten ── */}
|
||||||
{tab==='run' && (
|
{tab==='run' && (
|
||||||
<div>
|
<div>
|
||||||
{/* Fresh result shown immediately */}
|
{/* Fallback: Ergebnis oben nur wenn keine Pipeline-Split-Ansicht (z. B. keine Prompts) */}
|
||||||
{newResult && (
|
{newResult && !(canUseAI && pipelinePrompts.length > 0) && (
|
||||||
<div style={{marginBottom:16}}>
|
<div style={{marginBottom:16}}>
|
||||||
<div style={{fontSize:12,fontWeight:600,color:'var(--accent)',marginBottom:8}}>
|
<div style={{fontSize:12,fontWeight:600,color:'var(--accent)',marginBottom:8}}>
|
||||||
✅ Neue Analyse erstellt:
|
✅ Neue Analyse erstellt:
|
||||||
@@ -452,64 +536,114 @@ export default function Analysis() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{canUseAI && pipelinePrompts.length > 0 && (
|
{canUseAI && pipelinePrompts.length > 0 && (
|
||||||
<p style={{fontSize:13,color:'var(--text2)',marginBottom:14,lineHeight:1.6}}>
|
<>
|
||||||
Wähle eine mehrstufige KI-Analyse:
|
<p style={{fontSize:13,color:'var(--text2)',marginBottom:14,lineHeight:1.6}}>
|
||||||
</p>
|
Zuerst die <strong>Kategorie</strong> wählen (Chip-Leiste bzw. Seitenleiste). Alle Pipeline-Analysen
|
||||||
)}
|
dieser Kategorie erscheinen im Detailbereich (rechts auf Desktop, darunter auf Mobil).
|
||||||
|
Kategorien kommen aus dem Feld „Kategorie“ beim jeweiligen Prompt im Admin.
|
||||||
{pipelinePrompts.map(p => {
|
</p>
|
||||||
const existing = allInsights.find(i=>i.scope===p.slug)
|
<div className="analysis-split">
|
||||||
return (
|
<div className="analysis-split__nav-wrap">
|
||||||
<div key={p.id} className="card" style={{marginBottom:16,borderColor:'var(--accent)',borderWidth:2}}>
|
<nav className="analysis-split__nav" aria-label="KI-Analyse-Kategorien">
|
||||||
<div style={{display:'flex',alignItems:'flex-start',gap:12}}>
|
{pipelineGroups.map(({ categoryKey, label, prompts: inGroup }) => (
|
||||||
<div style={{flex:1}}>
|
<button
|
||||||
<div className="badge-container-right" style={{fontWeight:700,fontSize:15,color:'var(--accent)'}}>
|
key={categoryKey}
|
||||||
<span>{p.display_name || SLUG_LABELS[p.slug] || p.name}</span>
|
type="button"
|
||||||
{aiUsage && <UsageBadge {...aiUsage} />}
|
className={
|
||||||
</div>
|
'analysis-split__nav-item' +
|
||||||
{p.description && (
|
(activeCategoryKey === categoryKey ? ' analysis-split__nav-item--active' : '')
|
||||||
<div style={{fontSize:12,color:'var(--text2)',marginTop:3,lineHeight:1.5}}>
|
}
|
||||||
{p.description}
|
onClick={() => setActiveCategoryKey(categoryKey)}
|
||||||
</div>
|
aria-current={activeCategoryKey === categoryKey ? 'page' : undefined}
|
||||||
)}
|
>
|
||||||
{existing && (
|
{label}
|
||||||
<div style={{fontSize:11,color:'var(--text3)',marginTop:3}}>
|
<span className="analysis-split__nav-cat-count">({inGroup.length})</span>
|
||||||
Letzte Analyse: {dayjs(existing.created).format('DD.MM.YYYY, HH:mm')}
|
</button>
|
||||||
</div>
|
))}
|
||||||
)}
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div className="analysis-split__main">
|
||||||
title={aiUsage && !aiUsage.allowed ? `Limit erreicht (${aiUsage.used}/${aiUsage.limit}). Kontaktiere den Admin oder warte bis zum nächsten Reset.` : ''}
|
{newResult && (
|
||||||
style={{display:'inline-block'}}
|
<div style={{ marginBottom: 20 }}>
|
||||||
>
|
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--accent)', marginBottom: 8 }}>
|
||||||
<button
|
✅ Neue Analyse erstellt:
|
||||||
className="btn btn-primary"
|
</div>
|
||||||
style={{flexShrink:0,minWidth:100, cursor: (aiUsage && !aiUsage.allowed) ? 'not-allowed' : 'pointer'}}
|
<InsightCard
|
||||||
onClick={()=>runPrompt(p.slug)}
|
ins={{ ...newResult, created: new Date().toISOString() }}
|
||||||
disabled={!!loading||!canUseAI||(aiUsage && !aiUsage.allowed)}
|
onDelete={deleteInsight}
|
||||||
>
|
defaultOpen={true}
|
||||||
{loading===p.slug
|
prompts={prompts}
|
||||||
? <><div className="spinner" style={{width:13,height:13}}/> Läuft…</>
|
/>
|
||||||
: (aiUsage && !aiUsage.allowed) ? '🔒 Limit'
|
</div>
|
||||||
: <><Brain size={13}/> Starten</>}
|
)}
|
||||||
</button>
|
{activeCategoryKey && (() => {
|
||||||
</div>
|
const group = pipelineGroups.find(g => g.categoryKey === activeCategoryKey)
|
||||||
|
if (!group?.prompts?.length) return null
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 12 }}>
|
||||||
|
{group.label} · {group.prompts.length} {group.prompts.length === 1 ? 'Analyse' : 'Analysen'}
|
||||||
|
</div>
|
||||||
|
{group.prompts.map(p => {
|
||||||
|
const existing = allInsights.find(i => i.scope === p.slug)
|
||||||
|
return (
|
||||||
|
<div key={p.id} className="card" style={{marginBottom:16,borderColor:'var(--accent)',borderWidth:2}}>
|
||||||
|
<div style={{display:'flex',alignItems:'flex-start',gap:12,flexWrap:'wrap'}}>
|
||||||
|
<div style={{flex:1,minWidth:0}}>
|
||||||
|
<div className="badge-container-right" style={{fontWeight:700,fontSize:15,color:'var(--accent)'}}>
|
||||||
|
<span>{p.display_name || SLUG_LABELS[p.slug] || p.name}</span>
|
||||||
|
{aiUsage && <UsageBadge {...aiUsage} />}
|
||||||
|
</div>
|
||||||
|
{p.description && (
|
||||||
|
<div style={{fontSize:12,color:'var(--text2)',marginTop:3,lineHeight:1.5}}>
|
||||||
|
{p.description}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{existing && (
|
||||||
|
<div style={{fontSize:11,color:'var(--text3)',marginTop:3}}>
|
||||||
|
Letzte Analyse: {dayjs(existing.created).format('DD.MM.YYYY, HH:mm')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
title={aiUsage && !aiUsage.allowed ? `Limit erreicht (${aiUsage.used}/${aiUsage.limit}). Kontaktiere den Admin oder warte bis zum nächsten Reset.` : ''}
|
||||||
|
style={{display:'inline-block'}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-primary"
|
||||||
|
style={{flexShrink:0,minWidth:100, cursor: (aiUsage && !aiUsage.allowed) ? 'not-allowed' : 'pointer'}}
|
||||||
|
onClick={() => runPrompt(p.slug)}
|
||||||
|
disabled={!!loading||!canUseAI||(aiUsage && !aiUsage.allowed)}
|
||||||
|
>
|
||||||
|
{loading===p.slug
|
||||||
|
? <><div className="spinner" style={{width:13,height:13}}/> Läuft…</>
|
||||||
|
: (aiUsage && !aiUsage.allowed) ? '🔒 Limit'
|
||||||
|
: <><Brain size={13}/> Starten</>}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{existing && newResult?.id !== existing.id && (
|
||||||
|
<div style={{marginTop:8,borderTop:'1px solid var(--border)',paddingTop:8}}>
|
||||||
|
<InsightCard ins={existing} onDelete={deleteInsight} defaultOpen={false} prompts={prompts}/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
})()}
|
||||||
</div>
|
</div>
|
||||||
{/* Show existing result collapsed */}
|
|
||||||
{existing && newResult?.id !== existing.id && (
|
|
||||||
<div style={{marginTop:8,borderTop:'1px solid var(--border)',paddingTop:8}}>
|
|
||||||
<InsightCard ins={existing} onDelete={deleteInsight} defaultOpen={false} prompts={prompts}/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
</>
|
||||||
})}
|
)}
|
||||||
|
|
||||||
{canUseAI && pipelinePrompts.length === 0 && (
|
{canUseAI && pipelinePrompts.length === 0 && (
|
||||||
<div className="empty-state">
|
<div className="empty-state">
|
||||||
<p>Keine aktiven Pipeline-Prompts verfügbar.</p>
|
<p>Keine aktiven Pipeline-Prompts verfügbar.</p>
|
||||||
<p style={{fontSize:12,color:'var(--text3)',marginTop:8}}>
|
<p style={{fontSize:12,color:'var(--text3)',marginTop:8}}>
|
||||||
Erstelle Pipeline-Prompts im Admin-Bereich (Einstellungen → Admin → KI-Prompts).
|
Erstelle Pipeline-Prompts im Admin-Bereich unter Admin → KI-Prompts.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -519,18 +653,33 @@ export default function Analysis() {
|
|||||||
{/* ── Verlauf gruppiert ── */}
|
{/* ── Verlauf gruppiert ── */}
|
||||||
{tab==='history' && (
|
{tab==='history' && (
|
||||||
<div>
|
<div>
|
||||||
{allInsights.length===0
|
{allInsights.length===0 ? (
|
||||||
? <div className="empty-state"><h3>Noch keine Analysen</h3></div>
|
<div className="empty-state"><h3>Noch keine Analysen</h3></div>
|
||||||
: Object.entries(grouped).map(([scope, ins]) => (
|
) : (
|
||||||
<div key={scope} style={{marginBottom:20}}>
|
<div className="analysis-split">
|
||||||
<div style={{fontSize:13,fontWeight:700,color:'var(--text3)',
|
<div className="analysis-split__nav-wrap">
|
||||||
textTransform:'uppercase',letterSpacing:'0.05em',marginBottom:8}}>
|
<nav className="analysis-split__nav" aria-label="Gespeicherte Analysen">
|
||||||
{prompts.find(p => p.slug === scope)?.display_name || SLUG_LABELS[scope] || scope} ({ins.length})
|
{historyScopeKeys.map(scope => (
|
||||||
</div>
|
<button
|
||||||
{ins.map(i => <InsightCard key={i.id} ins={i} onDelete={deleteInsight} prompts={prompts}/>)}
|
key={scope}
|
||||||
|
type="button"
|
||||||
|
className={'analysis-split__nav-item' + (activeHistoryScope === scope ? ' analysis-split__nav-item--active' : '')}
|
||||||
|
onClick={() => setHistoryScopePick(scope)}
|
||||||
|
aria-current={activeHistoryScope === scope ? 'page' : undefined}
|
||||||
|
>
|
||||||
|
{prompts.find(pr => pr.slug === scope)?.display_name || SLUG_LABELS[scope] || scope}
|
||||||
|
<span className="muted" style={{ fontSize: 12 }}> ({grouped[scope].length})</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
))
|
<div className="analysis-split__main">
|
||||||
}
|
{activeHistoryScope && grouped[activeHistoryScope]?.map(i => (
|
||||||
|
<InsightCard key={i.id} ins={i} onDelete={deleteInsight} prompts={prompts}/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ function emptyForm() {
|
|||||||
function CaliperForm({ form, setForm, profile, onSave, onCancel, saveLabel='Speichern', saving=false, error=null, usage=null }) {
|
function CaliperForm({ form, setForm, profile, onSave, onCancel, saveLabel='Speichern', saving=false, error=null, usage=null }) {
|
||||||
const sex = profile?.sex||'m'
|
const sex = profile?.sex||'m'
|
||||||
const age = profile?.dob ? Math.floor((Date.now()-new Date(profile.dob))/(365.25*24*3600*1000)) : 30
|
const age = profile?.dob ? Math.floor((Date.now()-new Date(profile.dob))/(365.25*24*3600*1000)) : 30
|
||||||
const weight = form.weight || 80
|
|
||||||
const sfPoints = METHOD_POINTS[form.sf_method]?.[sex] || []
|
const sfPoints = METHOD_POINTS[form.sf_method]?.[sex] || []
|
||||||
const sfVals = {}
|
const sfVals = {}
|
||||||
sfPoints.forEach(k=>{ const v=form[`sf_${k}`]; if(v!==''&&v!=null) sfVals[k]=parseFloat(v) })
|
sfPoints.forEach(k=>{ const v=form[`sf_${k}`]; if(v!==''&&v!=null) sfVals[k]=parseFloat(v) })
|
||||||
@@ -79,7 +78,7 @@ function CaliperForm({ form, setForm, profile, onSave, onCancel, saveLabel='Spei
|
|||||||
<button
|
<button
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
style={{width:'100%', cursor: (usage && !usage.allowed) ? 'not-allowed' : 'pointer'}}
|
style={{width:'100%', cursor: (usage && !usage.allowed) ? 'not-allowed' : 'pointer'}}
|
||||||
onClick={()=>onSave(bfPct, sex)}
|
onClick={()=>onSave(bfPct)}
|
||||||
disabled={saving || (usage && !usage.allowed)}
|
disabled={saving || (usage && !usage.allowed)}
|
||||||
>
|
>
|
||||||
{(usage && !usage.allowed) ? '🔒 Limit erreicht' : saveLabel}
|
{(usage && !usage.allowed) ? '🔒 Limit erreicht' : saveLabel}
|
||||||
@@ -117,22 +116,19 @@ export default function CaliperScreen() {
|
|||||||
loadUsage()
|
loadUsage()
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
const buildPayload = (f, bfPct, sex) => {
|
const buildPayload = (f, bfPct) => {
|
||||||
const weight = profile?.weight || null
|
|
||||||
const payload = { date: f.date, sf_method: f.sf_method, notes: f.notes }
|
const payload = { date: f.date, sf_method: f.sf_method, notes: f.notes }
|
||||||
Object.entries(f).forEach(([k,v])=>{ if(k.startsWith('sf_')&&v!==''&&v!=null) payload[k]=parseFloat(v) })
|
Object.entries(f).forEach(([k,v])=>{ if(k.startsWith('sf_')&&v!==''&&v!=null) payload[k]=parseFloat(v) })
|
||||||
if(bfPct!=null) {
|
if (bfPct != null) payload.body_fat_pct = bfPct
|
||||||
payload.body_fat_pct = bfPct
|
// lean_mass / fat_mass: Backend leitet aus nächstem weight_log zum Messdatum ab
|
||||||
// get latest weight from profile or skip lean/fat
|
|
||||||
}
|
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSave = async (bfPct, sex) => {
|
const handleSave = async (bfPct) => {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
setError(null)
|
setError(null)
|
||||||
try {
|
try {
|
||||||
const payload = buildPayload(form, bfPct, sex)
|
const payload = buildPayload(form, bfPct)
|
||||||
await api.upsertCaliper(payload)
|
await api.upsertCaliper(payload)
|
||||||
setSaved(true)
|
setSaved(true)
|
||||||
await load()
|
await load()
|
||||||
@@ -148,8 +144,8 @@ export default function CaliperScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdate = async (bfPct, sex) => {
|
const handleUpdate = async (bfPct) => {
|
||||||
const payload = buildPayload(editing, bfPct, sex)
|
const payload = buildPayload(editing, bfPct)
|
||||||
await api.updateCaliper(editing.id, payload)
|
await api.updateCaliper(editing.id, payload)
|
||||||
setEditing(null); await load()
|
setEditing(null); await load()
|
||||||
}
|
}
|
||||||
@@ -160,7 +156,7 @@ export default function CaliperScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:16}}>
|
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:16}}>
|
||||||
<h1 className="page-title" style={{margin:0}}>Caliper</h1>
|
<h1 className="page-title" style={{margin:0}}>Caliper</h1>
|
||||||
<button className="btn btn-secondary" style={{fontSize:12,padding:'6px 10px'}} onClick={()=>nav('/guide')}>
|
<button className="btn btn-secondary" style={{fontSize:12,padding:'6px 10px'}} onClick={()=>nav('/guide')}>
|
||||||
|
|||||||
@@ -1,94 +1,14 @@
|
|||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { ChevronRight } from 'lucide-react'
|
import { ChevronRight } from 'lucide-react'
|
||||||
|
import { CAPTURE_HUB_TILES } from '../config/captureNav'
|
||||||
const ENTRIES = [
|
|
||||||
{
|
|
||||||
icon: '⚖️',
|
|
||||||
label: 'Gewicht',
|
|
||||||
sub: 'Tägliche Gewichtseingabe',
|
|
||||||
to: '/weight',
|
|
||||||
color: '#378ADD',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🪄',
|
|
||||||
label: 'Assistent',
|
|
||||||
sub: 'Schritt-für-Schritt Messung (Umfänge & Caliper)',
|
|
||||||
to: '/wizard',
|
|
||||||
color: '#7F77DD',
|
|
||||||
highlight: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '📏',
|
|
||||||
label: 'Umfänge',
|
|
||||||
sub: 'Hals, Brust, Taille, Bauch, Hüfte, Oberschenkel, Wade, Arm',
|
|
||||||
to: '/circum',
|
|
||||||
color: '#1D9E75',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '📐',
|
|
||||||
label: 'Caliper',
|
|
||||||
sub: 'Körperfett per Hautfaltenmessung',
|
|
||||||
to: '/caliper',
|
|
||||||
color: '#D85A30',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🍽️',
|
|
||||||
label: 'Ernährung',
|
|
||||||
sub: 'FDDB CSV importieren',
|
|
||||||
to: '/nutrition',
|
|
||||||
color: '#EF9F27',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🏋️',
|
|
||||||
label: 'Aktivität',
|
|
||||||
sub: 'Training manuell oder Apple Health importieren',
|
|
||||||
to: '/activity',
|
|
||||||
color: '#D4537E',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🌙',
|
|
||||||
label: 'Schlaf',
|
|
||||||
sub: 'Schlafdaten erfassen oder Apple Health importieren',
|
|
||||||
to: '/sleep',
|
|
||||||
color: '#7B68EE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🛌',
|
|
||||||
label: 'Ruhetage',
|
|
||||||
sub: 'Kraft-, Cardio-, oder Entspannungs-Ruhetag erfassen',
|
|
||||||
to: '/rest-days',
|
|
||||||
color: '#9B59B6',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '❤️',
|
|
||||||
label: 'Vitalwerte',
|
|
||||||
sub: 'Ruhepuls und HRV morgens erfassen',
|
|
||||||
to: '/vitals',
|
|
||||||
color: '#E74C3C',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '🎯',
|
|
||||||
label: 'Eigene Ziele',
|
|
||||||
sub: 'Fortschritte für individuelle Ziele erfassen',
|
|
||||||
to: '/custom-goals',
|
|
||||||
color: '#1D9E75',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: '📖',
|
|
||||||
label: 'Messanleitung',
|
|
||||||
sub: 'Wie und wo genau messen?',
|
|
||||||
to: '/guide',
|
|
||||||
color: '#888780',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export default function CaptureHub() {
|
export default function CaptureHub() {
|
||||||
const nav = useNavigate()
|
const nav = useNavigate()
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Erfassen</h1>
|
<h1 className="page-title">Erfassen</h1>
|
||||||
<div style={{display:'flex',flexDirection:'column',gap:10}}>
|
<div style={{display:'flex',flexDirection:'column',gap:10}}>
|
||||||
{ENTRIES.map(e => (
|
{CAPTURE_HUB_TILES.map(e => (
|
||||||
<button key={e.to} onClick={()=>nav(e.to)}
|
<button key={e.to} onClick={()=>nav(e.to)}
|
||||||
style={{
|
style={{
|
||||||
display:'flex', alignItems:'center', gap:14,
|
display:'flex', alignItems:'center', gap:14,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export default function CircumScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:16}}>
|
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:16}}>
|
||||||
<h1 className="page-title" style={{margin:0}}>Umfänge</h1>
|
<h1 className="page-title" style={{margin:0}}>Umfänge</h1>
|
||||||
<button className="btn btn-secondary" style={{fontSize:12,padding:'6px 10px'}} onClick={()=>nav('/guide')}>
|
<button className="btn btn-secondary" style={{fontSize:12,padding:'6px 10px'}} onClick={()=>nav('/guide')}>
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export default function CustomGoalsPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ paddingBottom: 80 }}>
|
<div className="capture-page" style={{ paddingBottom: 80 }}>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div style={{
|
<div style={{
|
||||||
background: 'linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%)',
|
background: 'linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%)',
|
||||||
|
|||||||
+270
-157
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect, useRef } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate, useLocation } from 'react-router-dom'
|
||||||
import { Check, ChevronRight, Brain } from 'lucide-react'
|
import { Check, Brain } from 'lucide-react'
|
||||||
import {
|
import {
|
||||||
LineChart, Line, XAxis, YAxis, Tooltip,
|
LineChart, Line, XAxis, YAxis, Tooltip,
|
||||||
ResponsiveContainer, CartesianGrid
|
ResponsiveContainer, CartesianGrid
|
||||||
@@ -13,10 +13,17 @@ import EmailVerificationBanner from '../components/EmailVerificationBanner'
|
|||||||
import TrainingTypeDistribution from '../components/TrainingTypeDistribution'
|
import TrainingTypeDistribution from '../components/TrainingTypeDistribution'
|
||||||
import SleepWidget from '../components/SleepWidget'
|
import SleepWidget from '../components/SleepWidget'
|
||||||
import RestDaysWidget from '../components/RestDaysWidget'
|
import RestDaysWidget from '../components/RestDaysWidget'
|
||||||
import { getInterpretation, getStatusColor, getStatusBg } from '../utils/interpret'
|
|
||||||
import Markdown from '../utils/Markdown'
|
import Markdown from '../utils/Markdown'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
|
import DashboardSection from '../components/DashboardSection'
|
||||||
|
import DashboardTile from '../components/DashboardTile'
|
||||||
|
import {
|
||||||
|
clampTileSpan,
|
||||||
|
DASHBOARD_TILE_GRID_COLS,
|
||||||
|
dashboardStatGridClassName,
|
||||||
|
dashboardTileGridClassName
|
||||||
|
} from '../utils/dashboardLayout'
|
||||||
dayjs.locale('de')
|
dayjs.locale('de')
|
||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||||
@@ -144,15 +151,37 @@ function Pill({ label, value, status, sub }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Stat Card ─────────────────────────────────────────────────────────────────
|
// ── Stat Card ─────────────────────────────────────────────────────────────────
|
||||||
function StatCard({ icon, label, value, unit, delta, deltaGoodWhenNeg=false, sub, onClick, color }) {
|
/**
|
||||||
|
* KPI-Kachel im Dashboard-Raster (`dashboard-stat-grid` / `dashboard-tile-grid`).
|
||||||
|
* @param {number} [spanMobile=1] Spaltenbreite unter 1024px (max. = Raster-Spalten mobile)
|
||||||
|
* @param {number} [spanDesktop=1] Spaltenbreite ≥1024px (max. 4)
|
||||||
|
*/
|
||||||
|
function StatCard({
|
||||||
|
icon,
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
unit,
|
||||||
|
delta,
|
||||||
|
deltaGoodWhenNeg = false,
|
||||||
|
sub,
|
||||||
|
onClick,
|
||||||
|
color,
|
||||||
|
spanMobile = 1,
|
||||||
|
spanDesktop = 1
|
||||||
|
}) {
|
||||||
const deltaColor = delta==null ? null
|
const deltaColor = delta==null ? null
|
||||||
: (deltaGoodWhenNeg ? delta<0 : delta>0) ? 'var(--accent)' : 'var(--warn)'
|
: (deltaGoodWhenNeg ? delta<0 : delta>0) ? 'var(--accent)' : 'var(--warn)'
|
||||||
|
const sm = clampTileSpan(spanMobile, DASHBOARD_TILE_GRID_COLS.mobile)
|
||||||
|
const lg = clampTileSpan(spanDesktop, DASHBOARD_TILE_GRID_COLS.desktop)
|
||||||
return (
|
return (
|
||||||
<div onClick={onClick} style={{
|
<div
|
||||||
flex:1, minWidth:80, background:'var(--surface)', borderRadius:12,
|
className="dashboard-stat-card"
|
||||||
padding:'12px 10px', cursor:onClick?'pointer':'default',
|
onClick={onClick}
|
||||||
border:'1px solid var(--border)', transition:'border-color 0.15s',
|
style={{
|
||||||
}}
|
cursor: onClick ? 'pointer' : 'default',
|
||||||
|
'--tile-sm': String(sm),
|
||||||
|
'--tile-lg': String(lg)
|
||||||
|
}}
|
||||||
onMouseEnter={e=>onClick&&(e.currentTarget.style.borderColor='var(--accent)')}
|
onMouseEnter={e=>onClick&&(e.currentTarget.style.borderColor='var(--accent)')}
|
||||||
onMouseLeave={e=>onClick&&(e.currentTarget.style.borderColor='var(--border)')}>
|
onMouseLeave={e=>onClick&&(e.currentTarget.style.borderColor='var(--border)')}>
|
||||||
<div style={{fontSize:18,marginBottom:4}}>{icon}</div>
|
<div style={{fontSize:18,marginBottom:4}}>{icon}</div>
|
||||||
@@ -223,8 +252,12 @@ function ComboChart({ weights, nutrition }) {
|
|||||||
// ── Main Dashboard ────────────────────────────────────────────────────────────
|
// ── Main Dashboard ────────────────────────────────────────────────────────────
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const nav = useNavigate()
|
const nav = useNavigate()
|
||||||
|
const location = useLocation()
|
||||||
const { activeProfile } = useProfile()
|
const { activeProfile } = useProfile()
|
||||||
|
|
||||||
|
const [adminDeniedHint, setAdminDeniedHint] = useState(false)
|
||||||
|
const [goalsCount, setGoalsCount] = useState(null)
|
||||||
|
|
||||||
const [stats, setStats] = useState(null)
|
const [stats, setStats] = useState(null)
|
||||||
const [weights, setWeights] = useState([])
|
const [weights, setWeights] = useState([])
|
||||||
const [calipers, setCalipers] = useState([])
|
const [calipers, setCalipers] = useState([])
|
||||||
@@ -261,7 +294,6 @@ export default function Dashboard() {
|
|||||||
const runPipeline = async () => {
|
const runPipeline = async () => {
|
||||||
setPipelineLoading(true); setPipelineError(null)
|
setPipelineLoading(true); setPipelineError(null)
|
||||||
try {
|
try {
|
||||||
const pid = localStorage.getItem('mitai-jinkendo_active_profile')||''
|
|
||||||
await api.insightPipeline()
|
await api.insightPipeline()
|
||||||
await load()
|
await load()
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -269,12 +301,22 @@ export default function Dashboard() {
|
|||||||
} finally { setPipelineLoading(false) }
|
} finally { setPipelineLoading(false) }
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{ load() },[])
|
||||||
console.log('[Dashboard] Component mounted, loading data...')
|
|
||||||
load()
|
|
||||||
},[])
|
|
||||||
|
|
||||||
console.log('[Dashboard] Rendering, loading=', loading, 'activeProfile=', activeProfile?.name)
|
useEffect(() => {
|
||||||
|
if (!location.state?.adminDenied) return
|
||||||
|
setAdminDeniedHint(true)
|
||||||
|
nav('.', { replace: true, state: null })
|
||||||
|
const clear = window.setTimeout(() => setAdminDeniedHint(false), 8000)
|
||||||
|
return () => window.clearTimeout(clear)
|
||||||
|
}, [location.state, nav])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!activeProfile?.id) return
|
||||||
|
api.listGoals()
|
||||||
|
.then((list) => setGoalsCount(Array.isArray(list) ? list.length : 0))
|
||||||
|
.catch(() => setGoalsCount(null))
|
||||||
|
}, [activeProfile?.id])
|
||||||
|
|
||||||
if (loading) return <div className="empty-state"><div className="spinner"/></div>
|
if (loading) return <div className="empty-state"><div className="spinner"/></div>
|
||||||
|
|
||||||
@@ -318,16 +360,38 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
const hasAnyData = latestW||latestCal||nutrition.length>0
|
const hasAnyData = latestW||latestCal||nutrition.length>0
|
||||||
|
|
||||||
console.log('[Dashboard] hasAnyData=', hasAnyData, 'latestW=', !!latestW, 'latestCal=', !!latestCal, 'nutrition.length=', nutrition.length)
|
const showNutrSummary = !!(avgKcal || avgProtein)
|
||||||
|
const showActSummary = actKcal != null
|
||||||
|
const summaryBoth = showNutrSummary && showActSummary
|
||||||
|
const summarySpanM = summaryBoth ? 1 : 2
|
||||||
|
const summarySpanD = summaryBoth ? 2 : 4
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="dashboard-page">
|
||||||
|
{adminDeniedHint && (
|
||||||
|
<div
|
||||||
|
role="alert"
|
||||||
|
style={{
|
||||||
|
marginBottom: 14,
|
||||||
|
padding: '12px 14px',
|
||||||
|
borderRadius: 10,
|
||||||
|
background: '#FCEBEB',
|
||||||
|
border: '1px solid #D85A3033',
|
||||||
|
fontSize: 13,
|
||||||
|
color: '#D85A30',
|
||||||
|
lineHeight: 1.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<strong>Kein Admin-Zugriff.</strong> Dieser Bereich ist nur für Konten mit Administrator-Rolle.
|
||||||
|
Du wurdest zur Übersicht weitergeleitet.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{/* Header greeting */}
|
{/* Header greeting */}
|
||||||
<div style={{marginBottom:16}}>
|
<div className="dashboard-greeting">
|
||||||
<h1 style={{fontSize:22,fontWeight:800,margin:0,color:'var(--text1)'}}>
|
<h1 style={{fontSize:22,fontWeight:800,margin:0,color:'var(--text1)'}}>
|
||||||
Hallo, {activeProfile?.name||'Nutzer'} 👋
|
Hallo, {activeProfile?.name||'Nutzer'} 👋
|
||||||
</h1>
|
</h1>
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginTop:2}}>
|
<div className="dashboard-greeting__meta" style={{fontSize:12,color:'var(--text3)',marginTop:2}}>
|
||||||
{dayjs().format('dddd, DD. MMMM YYYY')}
|
{dayjs().format('dddd, DD. MMMM YYYY')}
|
||||||
{latestW && ` · Letztes Update ${dayjs(latestW.date).format('DD.MM.')}`}
|
{latestW && ` · Letztes Update ${dayjs(latestW.date).format('DD.MM.')}`}
|
||||||
</div>
|
</div>
|
||||||
@@ -350,46 +414,54 @@ export default function Dashboard() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{hasAnyData && <>
|
{hasAnyData && <>
|
||||||
{/* Quick weight entry */}
|
<DashboardSection
|
||||||
<div className="card section-gap">
|
title="Gewicht heute"
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:10}}>
|
description="Tageswert erfassen – Grundlage für Trends und Ziele."
|
||||||
<div style={{fontWeight:600,fontSize:14}}>⚖️ Gewicht heute</div>
|
headerRight={
|
||||||
<button style={{background:'none',border:'none',fontSize:12,color:'var(--accent)',cursor:'pointer'}}
|
<button type="button" className="btn btn-secondary"
|
||||||
onClick={()=>nav('/weight')}>
|
style={{ fontSize: 12, padding: '6px 12px' }}
|
||||||
|
onClick={() => nav('/weight')}>
|
||||||
Alle Einträge →
|
Alle Einträge →
|
||||||
</button>
|
</button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="card section-gap">
|
||||||
|
<QuickWeight onSaved={load}/>
|
||||||
</div>
|
</div>
|
||||||
<QuickWeight onSaved={load}/>
|
</DashboardSection>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Key metrics */}
|
<DashboardSection
|
||||||
<div style={{display:'flex',gap:8,marginBottom:16,flexWrap:'wrap'}}>
|
title="Kennzahlen"
|
||||||
<StatCard icon="⚖️" label="Gewicht" value={latestW?.weight??'–'} unit="kg"
|
description="Aktuelle Messwerte und Ernährungs-Schnitt (7 Tage)."
|
||||||
delta={wDelta} deltaGoodWhenNeg={true}
|
>
|
||||||
sub={latestW ? dayjs(latestW.date).format('DD.MM.') : '–'}
|
<div className={dashboardStatGridClassName(DASHBOARD_TILE_GRID_COLS.mobile)}>
|
||||||
onClick={()=>nav('/history')} color="#378ADD"/>
|
<StatCard icon="⚖️" label="Gewicht" value={latestW?.weight??'–'} unit="kg"
|
||||||
{latestCal?.body_fat_pct && <StatCard icon="🫧" label="Körperfett" value={latestCal.body_fat_pct} unit="%"
|
delta={wDelta} deltaGoodWhenNeg={true}
|
||||||
delta={bfDelta} deltaGoodWhenNeg={true}
|
sub={latestW ? dayjs(latestW.date).format('DD.MM.') : '–'}
|
||||||
sub={bfCat?.label}
|
onClick={()=>nav('/history')} color="#378ADD"/>
|
||||||
onClick={()=>nav('/history',{state:{tab:'body'}})} color={bfCat?.color}/>}
|
{latestCal?.body_fat_pct && <StatCard icon="🫧" label="Körperfett" value={latestCal.body_fat_pct} unit="%"
|
||||||
{latestCal?.lean_mass && <StatCard icon="💪" label="Magermasse" value={latestCal.lean_mass} unit="kg"
|
delta={bfDelta} deltaGoodWhenNeg={true}
|
||||||
sub={latestCal.date ? dayjs(latestCal.date).format('DD.MM.') : '–'}
|
sub={bfCat?.label}
|
||||||
onClick={()=>nav('/history',{state:{tab:'body'}})}/>}
|
onClick={()=>nav('/history',{state:{tab:'body'}})} color={bfCat?.color}/>}
|
||||||
{avgKcal && <StatCard icon="🍽️" label="Ø Kalorien" value={avgKcal} unit="kcal"
|
{latestCal?.lean_mass && <StatCard icon="💪" label="Magermasse" value={latestCal.lean_mass} unit="kg"
|
||||||
sub="letzte 7 Tage" onClick={()=>nav('/history',{state:{tab:'nutrition'}})} color="#EF9F27"/>}
|
sub={latestCal.date ? dayjs(latestCal.date).format('DD.MM.') : '–'}
|
||||||
</div>
|
onClick={()=>nav('/history',{state:{tab:'body'}})}/>}
|
||||||
|
{avgKcal && <StatCard icon="🍽️" label="Ø Kalorien" value={avgKcal} unit="kcal"
|
||||||
{/* Status pills */}
|
sub="letzte 7 Tage" onClick={()=>nav('/history',{state:{tab:'nutrition'}})} color="#EF9F27"/>}
|
||||||
{pills.length > 0 && (
|
|
||||||
<div style={{display:'flex',gap:6,flexWrap:'wrap',marginBottom:16}}>
|
|
||||||
{pills.map((p,i)=><Pill key={i} {...p}/>)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
{pills.length > 0 && (
|
||||||
|
<div className="dashboard-pill-row">
|
||||||
|
{pills.map((p,i)=><Pill key={i} {...p}/>)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</DashboardSection>
|
||||||
|
|
||||||
{/* Goals progress */}
|
|
||||||
{(activeProfile?.goal_weight||activeProfile?.goal_bf_pct) && latestW && (
|
{(activeProfile?.goal_weight||activeProfile?.goal_bf_pct) && latestW && (
|
||||||
<div className="card section-gap" style={{marginBottom:16}}>
|
<DashboardSection
|
||||||
<div style={{fontWeight:600,fontSize:13,marginBottom:10}}>🎯 Ziele</div>
|
title="Profil-Ziele"
|
||||||
|
description="Fortschritt zu den Zielwerten in deinem Profil."
|
||||||
|
>
|
||||||
|
<div className="card section-gap">
|
||||||
{activeProfile?.goal_weight && latestW && (()=>{
|
{activeProfile?.goal_weight && latestW && (()=>{
|
||||||
const start = Math.max(...weights.map(w=>w.weight))
|
const start = Math.max(...weights.map(w=>w.weight))
|
||||||
const curr = latestW.weight
|
const curr = latestW.weight
|
||||||
@@ -430,134 +502,175 @@ export default function Dashboard() {
|
|||||||
)
|
)
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
|
</DashboardSection>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Combined chart */}
|
|
||||||
{(weights.length>2||nutrition.length>2) && (
|
{(weights.length>2||nutrition.length>2) && (
|
||||||
<div className="card section-gap" style={{marginBottom:16}}>
|
<DashboardSection
|
||||||
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',marginBottom:8}}>
|
title="Trends"
|
||||||
<div style={{fontWeight:600,fontSize:13}}>📊 Kalorien + Gewicht (30 Tage)</div>
|
description="Kalorien und Gewicht der letzten 30 Tage."
|
||||||
<button style={{background:'none',border:'none',fontSize:12,color:'var(--accent)',cursor:'pointer'}}
|
headerRight={
|
||||||
|
<button type="button" className="btn btn-secondary" style={{ fontSize: 12, padding: '6px 12px' }}
|
||||||
onClick={()=>nav('/history',{state:{tab:'body'}})}>
|
onClick={()=>nav('/history',{state:{tab:'body'}})}>
|
||||||
Details →
|
Details →
|
||||||
</button>
|
</button>
|
||||||
</div>
|
}
|
||||||
<ComboChart weights={weights} nutrition={nutrition}/>
|
>
|
||||||
<div style={{display:'flex',gap:16,justifyContent:'center',marginTop:6,fontSize:10,color:'var(--text3)'}}>
|
<DashboardTile>
|
||||||
<span><span style={{display:'inline-block',width:12,height:2,background:'#EF9F27',verticalAlign:'middle',marginRight:3}}/>Ø Kalorien</span>
|
<div className="card section-gap">
|
||||||
<span><span style={{display:'inline-block',width:12,height:2,background:'#378ADD',verticalAlign:'middle',marginRight:3}}/>Gewicht</span>
|
<ComboChart weights={weights} nutrition={nutrition}/>
|
||||||
</div>
|
<div style={{display:'flex',gap:16,justifyContent:'center',marginTop:6,fontSize:10,color:'var(--text3)'}}>
|
||||||
</div>
|
<span><span style={{display:'inline-block',width:12,height:2,background:'#EF9F27',verticalAlign:'middle',marginRight:3}}/>Ø Kalorien</span>
|
||||||
|
<span><span style={{display:'inline-block',width:12,height:2,background:'#378ADD',verticalAlign:'middle',marginRight:3}}/>Gewicht</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DashboardTile>
|
||||||
|
</DashboardSection>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Activity + Nutrition summary row */}
|
{(showNutrSummary || showActSummary) && (
|
||||||
<div style={{display:'flex',gap:8,marginBottom:16}}>
|
<DashboardSection
|
||||||
{(avgKcal||avgProtein) && (
|
title="Ernährung & Aktivität"
|
||||||
<div className="card" style={{flex:1,cursor:'pointer'}} onClick={()=>nav('/history',{state:{tab:'nutrition'}})}>
|
description="Kurzüberblick; volle Verläufe unter Historie."
|
||||||
<div style={{fontWeight:600,fontSize:12,marginBottom:8,color:'var(--text3)'}}>🍽️ ERNÄHRUNG (Ø 7T)</div>
|
>
|
||||||
{avgKcal && <div style={{fontSize:16,fontWeight:700,color:'#EF9F27'}}>{avgKcal} kcal</div>}
|
<div className={`dashboard-summary-row ${dashboardTileGridClassName(DASHBOARD_TILE_GRID_COLS.mobile)}`}>
|
||||||
{avgProtein && <div style={{fontSize:13,fontWeight:600,
|
{showNutrSummary && (
|
||||||
color:proteinOk?'var(--accent)':'var(--warn)'}}>
|
<DashboardTile spanMobile={summarySpanM} spanDesktop={summarySpanD}>
|
||||||
{avgProtein}g Protein {proteinOk?'✓':'⚠️'}
|
<div className="card" style={{ cursor: 'pointer', height: '100%' }} onClick={()=>nav('/history',{state:{tab:'nutrition'}})}>
|
||||||
</div>}
|
<div style={{fontWeight:600,fontSize:12,marginBottom:8,color:'var(--text3)'}}>🍽️ ERNÄHRUNG (Ø 7T)</div>
|
||||||
<div style={{fontSize:10,color:'var(--text3)',marginTop:4}}>→ Verlauf Ernährung</div>
|
{avgKcal && <div style={{fontSize:16,fontWeight:700,color:'#EF9F27'}}>{avgKcal} kcal</div>}
|
||||||
|
{avgProtein && <div style={{fontSize:13,fontWeight:600,
|
||||||
|
color:proteinOk?'var(--accent)':'var(--warn)'}}>
|
||||||
|
{avgProtein}g Protein {proteinOk?'✓':'⚠️'}
|
||||||
|
</div>}
|
||||||
|
<div style={{fontSize:10,color:'var(--text3)',marginTop:4}}>→ Verlauf Ernährung</div>
|
||||||
|
</div>
|
||||||
|
</DashboardTile>
|
||||||
|
)}
|
||||||
|
{showActSummary && (
|
||||||
|
<DashboardTile spanMobile={summarySpanM} spanDesktop={summarySpanD}>
|
||||||
|
<div className="card" style={{ cursor: 'pointer', height: '100%' }} onClick={()=>nav('/history',{state:{tab:'activity'}})}>
|
||||||
|
<div style={{fontWeight:600,fontSize:12,marginBottom:8,color:'var(--text3)'}}>🏋️ AKTIVITÄT (7T)</div>
|
||||||
|
<div style={{fontSize:16,fontWeight:700,color:'#EF9F27'}}>{actKcal} kcal</div>
|
||||||
|
<div style={{fontSize:13,color:'var(--text2)'}}>{recentAct.length} Trainings</div>
|
||||||
|
<div style={{fontSize:10,color:'var(--text3)',marginTop:4}}>→ Verlauf Aktivität</div>
|
||||||
|
</div>
|
||||||
|
</DashboardTile>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</DashboardSection>
|
||||||
{actKcal!=null && (
|
)}
|
||||||
<div className="card" style={{flex:1,cursor:'pointer'}} onClick={()=>nav('/history',{state:{tab:'activity'}})}>
|
|
||||||
<div style={{fontWeight:600,fontSize:12,marginBottom:8,color:'var(--text3)'}}>🏋️ AKTIVITÄT (7T)</div>
|
|
||||||
<div style={{fontSize:16,fontWeight:700,color:'#EF9F27'}}>{actKcal} kcal</div>
|
|
||||||
<div style={{fontSize:13,color:'var(--text2)'}}>{recentAct.length} Trainings</div>
|
|
||||||
<div style={{fontSize:10,color:'var(--text3)',marginTop:4}}>→ Verlauf Aktivität</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Sleep Widget */}
|
<DashboardSection
|
||||||
<div style={{marginBottom:16}}>
|
title="Erholung"
|
||||||
<SleepWidget/>
|
description="Schlaf und Ruhetage im Überblick."
|
||||||
</div>
|
>
|
||||||
|
<div className={`dashboard-erholung-grid ${dashboardTileGridClassName(DASHBOARD_TILE_GRID_COLS.mobile)}`}>
|
||||||
|
<DashboardTile spanMobile={1} spanDesktop={2}>
|
||||||
|
<SleepWidget/>
|
||||||
|
</DashboardTile>
|
||||||
|
<DashboardTile spanMobile={1} spanDesktop={2}>
|
||||||
|
<RestDaysWidget/>
|
||||||
|
</DashboardTile>
|
||||||
|
</div>
|
||||||
|
</DashboardSection>
|
||||||
|
|
||||||
{/* Rest Days Widget */}
|
|
||||||
<div style={{marginBottom:16}}>
|
|
||||||
<RestDaysWidget/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Training Type Distribution */}
|
|
||||||
{activities.length > 0 && (
|
{activities.length > 0 && (
|
||||||
<div className="card section-gap" style={{marginBottom:16}}>
|
<DashboardSection
|
||||||
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',marginBottom:12}}>
|
title="Training"
|
||||||
<div style={{fontWeight:600,fontSize:13}}>🏋️ Trainingstyp-Verteilung</div>
|
description="Verteilung der Trainingstypen (28 Tage)."
|
||||||
<button style={{background:'none',border:'none',fontSize:12,color:'var(--accent)',cursor:'pointer'}}
|
headerRight={
|
||||||
|
<button type="button" className="btn btn-secondary" style={{ fontSize: 12, padding: '6px 12px' }}
|
||||||
onClick={()=>nav('/activity')}>
|
onClick={()=>nav('/activity')}>
|
||||||
Details →
|
Details →
|
||||||
</button>
|
</button>
|
||||||
</div>
|
}
|
||||||
<TrainingTypeDistribution days={28} />
|
>
|
||||||
</div>
|
<DashboardTile>
|
||||||
|
<div className="card section-gap">
|
||||||
|
<TrainingTypeDistribution days={28} />
|
||||||
|
</div>
|
||||||
|
</DashboardTile>
|
||||||
|
</DashboardSection>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Goals Preview */}
|
<DashboardSection
|
||||||
<div className="card section-gap" style={{marginBottom:16,cursor:'pointer'}}
|
title="Ziele & Fokus"
|
||||||
onClick={()=>nav('/goals')}>
|
description="Strategische Ziele und Schwerpunkte – eigener Menüpunkt „Ziele“, Kontext für KI und Dashboard."
|
||||||
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',marginBottom:12}}>
|
headerRight={
|
||||||
<div style={{fontWeight:600,fontSize:13}}>🎯 Ziele</div>
|
<button type="button" className="btn btn-secondary" style={{ fontSize: 12, padding: '6px 12px' }}
|
||||||
<button style={{background:'none',border:'none',fontSize:12,color:'var(--accent)',cursor:'pointer'}}
|
onClick={(e)=>{ e.stopPropagation(); nav('/goals') }}>
|
||||||
onClick={(e)=>{e.stopPropagation();nav('/goals')}}>
|
Ziele bearbeiten →
|
||||||
Verwalten →
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
}
|
||||||
<div style={{fontSize:12,color:'var(--text2)',padding:'8px 0'}}>
|
>
|
||||||
Definiere deine Trainingsmodus und konkrete Ziele für bessere KI-Analysen
|
<DashboardTile>
|
||||||
</div>
|
<div className="card section-gap" style={{ cursor: 'pointer' }} onClick={()=>nav('/goals')}>
|
||||||
</div>
|
{goalsCount != null && (
|
||||||
|
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text1)', marginBottom: 8 }}>
|
||||||
|
{goalsCount === 0
|
||||||
|
? 'Noch keine Ziele angelegt.'
|
||||||
|
: `${goalsCount} ${goalsCount === 1 ? 'Ziel' : 'Ziele'} im System.`}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div style={{ fontSize: 12, color: 'var(--text2)', padding: goalsCount != null ? '0 0 8px' : '8px 0' }}>
|
||||||
|
Hier pflegst du Focus Areas, Meilensteine und Fortschritt – unabhängig von der KI-Analyse-Seite.
|
||||||
|
Tippen zum Öffnen oder unten in der Navigation <strong>Ziele</strong> wählen.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DashboardTile>
|
||||||
|
</DashboardSection>
|
||||||
|
|
||||||
{/* Latest AI insight */}
|
<DashboardSection
|
||||||
<div className="card section-gap">
|
title="KI-Auswertung"
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:8}}>
|
description="Mehrstufige Pipeline und letzte Zusammenfassung."
|
||||||
<div style={{fontWeight:600,fontSize:13}}>🤖 KI-Auswertung</div>
|
headerRight={
|
||||||
<button className="btn btn-secondary" style={{fontSize:11,padding:'4px 10px'}}
|
<button type="button" className="btn btn-secondary" style={{ fontSize: 11, padding: '4px 10px' }}
|
||||||
onClick={()=>nav('/analysis')}>
|
onClick={()=>nav('/analysis')}>
|
||||||
<Brain size={11}/> Analysen →
|
<Brain size={11}/> Analysen →
|
||||||
</button>
|
</button>
|
||||||
</div>
|
}
|
||||||
{/* Pipeline trigger */}
|
>
|
||||||
<button className="btn btn-primary btn-full" style={{marginBottom:10}}
|
<DashboardTile>
|
||||||
onClick={runPipeline} disabled={pipelineLoading}>
|
<div className="card section-gap">
|
||||||
{pipelineLoading
|
<button type="button" className="btn btn-primary btn-full" style={{marginBottom:10}}
|
||||||
? <><div className="spinner" style={{width:13,height:13}}/> Analyse läuft… (3 Stufen)</>
|
onClick={runPipeline} disabled={pipelineLoading}>
|
||||||
: <><Brain size={13}/> 🔬 Mehrstufige Analyse starten</>}
|
{pipelineLoading
|
||||||
</button>
|
? <><div className="spinner" style={{width:13,height:13}}/> Analyse läuft… (3 Stufen)</>
|
||||||
{pipelineError && <div style={{fontSize:12,color:'#D85A30',marginBottom:8}}>{pipelineError}</div>}
|
: <><Brain size={13}/> 🔬 Mehrstufige Analyse starten</>}
|
||||||
|
</button>
|
||||||
|
{pipelineError && <div style={{fontSize:12,color:'#D85A30',marginBottom:8}}>{pipelineError}</div>}
|
||||||
|
|
||||||
{latestInsight ? (
|
{latestInsight ? (
|
||||||
<>
|
<>
|
||||||
<div style={{fontSize:11,color:'var(--text3)',marginBottom:6}}>
|
<div style={{fontSize:11,color:'var(--text3)',marginBottom:6}}>
|
||||||
Letzte Analyse: {dayjs(latestInsight.created).format('DD. MMMM YYYY, HH:mm')}
|
Letzte Analyse: {dayjs(latestInsight.created).format('DD. MMMM YYYY, HH:mm')}
|
||||||
</div>
|
</div>
|
||||||
<div style={{maxHeight: showInsight?'none':120, overflow:'hidden', position:'relative'}}>
|
<div style={{maxHeight: showInsight?'none':120, overflow:'hidden', position:'relative'}}>
|
||||||
<Markdown text={latestInsight.content}/>
|
<Markdown text={latestInsight.content}/>
|
||||||
{!showInsight && (
|
{!showInsight && (
|
||||||
<div style={{position:'absolute',bottom:0,left:0,right:0,height:40,
|
<div style={{position:'absolute',bottom:0,left:0,right:0,height:40,
|
||||||
background:'linear-gradient(transparent,var(--surface))'}}/>
|
background:'linear-gradient(transparent,var(--surface))'}}/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<button style={{background:'none',border:'none',cursor:'pointer',
|
<button type="button" style={{background:'none',border:'none',cursor:'pointer',
|
||||||
fontSize:12,color:'var(--accent)',marginTop:6,padding:0}}
|
fontSize:12,color:'var(--accent)',marginTop:6,padding:0}}
|
||||||
onClick={()=>setShowInsight(s=>!s)}>
|
onClick={()=>setShowInsight(s=>!s)}>
|
||||||
{showInsight?'▲ Weniger anzeigen':'▼ Vollständig anzeigen'}
|
{showInsight?'▲ Weniger anzeigen':'▼ Vollständig anzeigen'}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div style={{fontSize:13,color:'var(--text3)',padding:'8px 0'}}>
|
<div style={{fontSize:13,color:'var(--text3)',padding:'8px 0'}}>
|
||||||
Noch keine KI-Auswertung vorhanden.
|
Noch keine KI-Auswertung vorhanden.
|
||||||
<button className="btn btn-primary" style={{marginTop:8,display:'block',fontSize:12}}
|
<button type="button" className="btn btn-primary" style={{marginTop:8,display:'block',fontSize:12}}
|
||||||
onClick={()=>nav('/analysis')}>
|
onClick={()=>nav('/analysis')}>
|
||||||
Erste Analyse erstellen
|
Erste Analyse erstellen
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</DashboardTile>
|
||||||
</div>
|
</DashboardSection>
|
||||||
</>}
|
</>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default function GuidePage() {
|
|||||||
const methodPoints = CALIPER_METHODS[caliperMethod]?.points_m || []
|
const methodPoints = CALIPER_METHODS[caliperMethod]?.points_m || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Messanleitung</h1>
|
<h1 className="page-title">Messanleitung</h1>
|
||||||
|
|
||||||
<div className="tabs">
|
<div className="tabs">
|
||||||
|
|||||||
@@ -985,6 +985,11 @@ export default function History() {
|
|||||||
|
|
||||||
useEffect(()=>{ loadAll() },[])
|
useEffect(()=>{ loadAll() },[])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const t = location.state?.tab
|
||||||
|
if (t && TABS.some(x => x.id === t)) setTab(t)
|
||||||
|
}, [location.state?.tab])
|
||||||
|
|
||||||
const requestInsight = async (slug) => {
|
const requestInsight = async (slug) => {
|
||||||
setLoadingSlug(slug)
|
setLoadingSlug(slug)
|
||||||
try {
|
try {
|
||||||
@@ -1007,27 +1012,33 @@ export default function History() {
|
|||||||
const sp={insights,onRequest:requestInsight,loadingSlug,filterActiveSlugs}
|
const sp={insights,onRequest:requestInsight,loadingSlug,filterActiveSlugs}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="history-page">
|
||||||
<h1 className="page-title">Verlauf & Auswertung</h1>
|
<h1 className="page-title history-page__title">Verlauf & Auswertung</h1>
|
||||||
<div style={{display:'flex',gap:6,overflowX:'auto',paddingBottom:6,marginBottom:16,
|
<div className="history-page__layout">
|
||||||
msOverflowStyle:'none',scrollbarWidth:'none'}}>
|
<nav className="history-tabs" aria-label="Verlauf-Kategorien">
|
||||||
{TABS.map(t=>(
|
<div className="history-tabs__scroller">
|
||||||
<button key={t.id} onClick={()=>setTab(t.id)}
|
{TABS.map(t => (
|
||||||
style={{whiteSpace:'nowrap',padding:'7px 14px',borderRadius:20,flexShrink:0,
|
<button
|
||||||
border:`1.5px solid ${tab===t.id?'var(--accent)':'var(--border2)'}`,
|
key={t.id}
|
||||||
background:tab===t.id?'var(--accent)':'var(--surface)',
|
type="button"
|
||||||
color:tab===t.id?'white':'var(--text2)',
|
className={`history-tab-btn${tab === t.id ? ' history-tab-btn--active' : ''}`}
|
||||||
fontFamily:'var(--font)',fontSize:13,fontWeight:500,cursor:'pointer'}}>
|
onClick={() => setTab(t.id)}
|
||||||
{t.label}
|
aria-current={tab === t.id ? 'page' : undefined}
|
||||||
</button>
|
>
|
||||||
))}
|
{t.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div className="history-content">
|
||||||
|
{tab==='body' && <BodySection weights={weights} calipers={calipers} circs={circs} profile={profile} {...sp}/>}
|
||||||
|
{tab==='nutrition' && <NutritionSection nutrition={nutrition} weights={weights} profile={profile} {...sp}/>}
|
||||||
|
{tab==='activity' && <ActivitySection activities={activities} globalQualityLevel={activeProfile?.quality_filter_level} {...sp}/>}
|
||||||
|
{tab==='recovery' && <RecoverySection {...sp}/>}
|
||||||
|
{tab==='correlation' && <CorrelationSection corrData={corrData} profile={profile} {...sp}/>}
|
||||||
|
{tab==='photos' && <PhotoGrid/>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{tab==='body' && <BodySection weights={weights} calipers={calipers} circs={circs} profile={profile} {...sp}/>}
|
|
||||||
{tab==='nutrition' && <NutritionSection nutrition={nutrition} weights={weights} profile={profile} {...sp}/>}
|
|
||||||
{tab==='activity' && <ActivitySection activities={activities} globalQualityLevel={activeProfile?.quality_filter_level} {...sp}/>}
|
|
||||||
{tab==='recovery' && <RecoverySection {...sp}/>}
|
|
||||||
{tab==='correlation' && <CorrelationSection corrData={corrData} profile={profile} {...sp}/>}
|
|
||||||
{tab==='photos' && <PhotoGrid/>}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ export default function MeasureWizard() {
|
|||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
return (
|
return (
|
||||||
<div style={{display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',
|
<div className="capture-page" style={{display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',
|
||||||
minHeight:'60vh',gap:16,textAlign:'center'}}>
|
minHeight:'60vh',gap:16,textAlign:'center'}}>
|
||||||
<div style={{fontSize:48}}>✅</div>
|
<div style={{fontSize:48}}>✅</div>
|
||||||
<h2 style={{fontSize:20,fontWeight:700}}>Gespeichert!</h2>
|
<h2 style={{fontSize:20,fontWeight:700}}>Gespeichert!</h2>
|
||||||
@@ -361,11 +361,19 @@ export default function MeasureWizard() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'circum') return <CircumWizard onDone={()=>setDone(true)} onCancel={()=>setMode(null)}/>
|
if (mode === 'circum') return (
|
||||||
if (mode === 'caliper') return <CaliperWizard onDone={()=>setDone(true)} onCancel={()=>setMode(null)} profile={profile}/>
|
<div className="capture-page">
|
||||||
|
<CircumWizard onDone={()=>setDone(true)} onCancel={()=>setMode(null)}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
if (mode === 'caliper') return (
|
||||||
|
<div className="capture-page">
|
||||||
|
<CaliperWizard onDone={()=>setDone(true)} onCancel={()=>setMode(null)} profile={profile}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Assistent</h1>
|
<h1 className="page-title">Assistent</h1>
|
||||||
<p style={{fontSize:13,color:'var(--text2)',marginBottom:20,lineHeight:1.6}}>
|
<p style={{fontSize:13,color:'var(--text2)',marginBottom:20,lineHeight:1.6}}>
|
||||||
Der Assistent führt dich Schritt für Schritt durch die Messung – mit Anleitung für jeden Messpunkt.
|
Der Assistent führt dich Schritt für Schritt durch die Messung – mit Anleitung für jeden Messpunkt.
|
||||||
|
|||||||
@@ -802,7 +802,7 @@ export default function NutritionPage() {
|
|||||||
useEffect(() => { load() }, [])
|
useEffect(() => { load() }, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Ernährung</h1>
|
<h1 className="page-title">Ernährung</h1>
|
||||||
|
|
||||||
{/* Input Method Tabs */}
|
{/* Input Method Tabs */}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export default function RestDaysPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Ruhetage</h1>
|
<h1 className="page-title">Ruhetage</h1>
|
||||||
|
|
||||||
{/* Toast Notification */}
|
{/* Toast Notification */}
|
||||||
|
|||||||
+288
-200
@@ -1,103 +1,24 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { Save, Download, Upload, Trash2, Plus, Check, Pencil, X, LogOut, Shield, Key, BarChart3 } from 'lucide-react'
|
import { Save, Download, Upload, Check, LogOut, Key, BarChart3, Target } from 'lucide-react'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
import { useProfile } from '../context/ProfileContext'
|
import { useProfile } from '../context/ProfileContext'
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
import { Avatar } from './ProfileSelect'
|
import { Avatar } from './ProfileSelect'
|
||||||
import { api } from '../utils/api'
|
import { api } from '../utils/api'
|
||||||
import AdminPanel from './AdminPanel'
|
|
||||||
import FeatureUsageOverview from '../components/FeatureUsageOverview'
|
import FeatureUsageOverview from '../components/FeatureUsageOverview'
|
||||||
import UsageBadge from '../components/UsageBadge'
|
import UsageBadge from '../components/UsageBadge'
|
||||||
|
|
||||||
const COLORS = ['#1D9E75','#378ADD','#D85A30','#EF9F27','#7F77DD','#D4537E','#639922','#888780']
|
const COLORS = ['#1D9E75','#378ADD','#D85A30','#EF9F27','#7F77DD','#D4537E','#639922','#888780']
|
||||||
|
|
||||||
function ProfileForm({ profile, onSave, onCancel, title }) {
|
function dobInputValue(dob) {
|
||||||
const [form, setForm] = useState({
|
if (!dob) return ''
|
||||||
name: profile?.name || '',
|
const s = String(dob)
|
||||||
sex: profile?.sex || 'm',
|
return s.length >= 10 ? s.slice(0, 10) : s
|
||||||
dob: profile?.dob || '',
|
|
||||||
height: profile?.height || '',
|
|
||||||
goal_weight: profile?.goal_weight || '',
|
|
||||||
goal_bf_pct: profile?.goal_bf_pct || '',
|
|
||||||
avatar_color: profile?.avatar_color || COLORS[0],
|
|
||||||
})
|
|
||||||
const set = (k,v) => setForm(f=>({...f,[k]:v}))
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{background:'var(--surface2)',borderRadius:10,padding:14,marginTop:8,
|
|
||||||
border:'1.5px solid var(--accent)'}}>
|
|
||||||
{title && <div style={{fontWeight:600,fontSize:14,marginBottom:12,color:'var(--accent)'}}>{title}</div>}
|
|
||||||
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Name</label>
|
|
||||||
<input type="text" className="form-input" value={form.name}
|
|
||||||
onChange={e=>set('name',e.target.value)} autoFocus/>
|
|
||||||
<span className="form-unit"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{marginBottom:12}}>
|
|
||||||
<div style={{fontSize:12,color:'var(--text3)',marginBottom:8}}>Avatar-Farbe</div>
|
|
||||||
<div style={{display:'flex',gap:8,alignItems:'center'}}>
|
|
||||||
<Avatar profile={{...form}} size={36}/>
|
|
||||||
<div style={{display:'flex',gap:6,flexWrap:'wrap'}}>
|
|
||||||
{COLORS.map(c=>(
|
|
||||||
<div key={c} onClick={()=>set('avatar_color',c)}
|
|
||||||
style={{width:26,height:26,borderRadius:'50%',background:c,cursor:'pointer',
|
|
||||||
border:`3px solid ${form.avatar_color===c?'white':'transparent'}`,
|
|
||||||
boxShadow:form.avatar_color===c?`0 0 0 2px ${c}`:'none'}}/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Geschlecht</label>
|
|
||||||
<select className="form-select" value={form.sex} onChange={e=>set('sex',e.target.value)}>
|
|
||||||
<option value="m">Männlich</option>
|
|
||||||
<option value="f">Weiblich</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Geburtsdatum</label>
|
|
||||||
<input type="date" className="form-input" style={{width:140}} value={form.dob||''}
|
|
||||||
onChange={e=>set('dob',e.target.value)}/>
|
|
||||||
<span className="form-unit"/>
|
|
||||||
</div>
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Größe</label>
|
|
||||||
<input type="number" className="form-input" min={100} max={250} value={form.height||''}
|
|
||||||
onChange={e=>set('height',e.target.value)}/>
|
|
||||||
<span className="form-unit">cm</span>
|
|
||||||
</div>
|
|
||||||
<div style={{fontSize:11,fontWeight:600,color:'var(--text3)',textTransform:'uppercase',
|
|
||||||
letterSpacing:'0.04em',margin:'10px 0 6px'}}>Ziele (optional)</div>
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Zielgewicht</label>
|
|
||||||
<input type="number" className="form-input" min={30} max={300} step={0.1}
|
|
||||||
value={form.goal_weight||''} onChange={e=>set('goal_weight',e.target.value)} placeholder="–"/>
|
|
||||||
<span className="form-unit">kg</span>
|
|
||||||
</div>
|
|
||||||
<div className="form-row">
|
|
||||||
<label className="form-label">Ziel-KF%</label>
|
|
||||||
<input type="number" className="form-input" min={3} max={50} step={0.1}
|
|
||||||
value={form.goal_bf_pct||''} onChange={e=>set('goal_bf_pct',e.target.value)} placeholder="–"/>
|
|
||||||
<span className="form-unit">%</span>
|
|
||||||
</div>
|
|
||||||
<div style={{display:'flex',gap:8,marginTop:12}}>
|
|
||||||
<button className="btn btn-primary" style={{flex:1}} onClick={()=>onSave(form)}>
|
|
||||||
<Save size={13}/> Speichern
|
|
||||||
</button>
|
|
||||||
<button className="btn btn-secondary" style={{flex:1}} onClick={onCancel}>
|
|
||||||
<X size={13}/> Abbrechen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const { profiles, activeProfile, setActiveProfile, refreshProfiles } = useProfile()
|
const { profiles, activeProfile, setActiveProfile, refreshProfiles } = useProfile()
|
||||||
const { logout, isAdmin, canExport } = useAuth()
|
const { logout, canExport, isAdmin } = useAuth()
|
||||||
const [adminOpen, setAdminOpen] = useState(false)
|
|
||||||
const [pinOpen, setPinOpen] = useState(false)
|
const [pinOpen, setPinOpen] = useState(false)
|
||||||
const [newPin, setNewPin] = useState('')
|
const [newPin, setNewPin] = useState('')
|
||||||
const [pinMsg, setPinMsg] = useState(null)
|
const [pinMsg, setPinMsg] = useState(null)
|
||||||
@@ -131,8 +52,19 @@ export default function SettingsPage() {
|
|||||||
setTimeout(()=>setPinMsg(null), 2000)
|
setTimeout(()=>setPinMsg(null), 2000)
|
||||||
} catch(e) { setPinMsg('Fehler beim Speichern') }
|
} catch(e) { setPinMsg('Fehler beim Speichern') }
|
||||||
}
|
}
|
||||||
// editingId: string ID of profile being edited, or 'new' for new profile, or null
|
const [form, setForm] = useState({
|
||||||
const [editingId, setEditingId] = useState(null)
|
name: '',
|
||||||
|
email: '',
|
||||||
|
sex: 'm',
|
||||||
|
dob: '',
|
||||||
|
height: '',
|
||||||
|
goal_weight: '',
|
||||||
|
goal_bf_pct: '',
|
||||||
|
avatar_color: COLORS[0],
|
||||||
|
})
|
||||||
|
const setF = (k, v) => setForm((f) => ({ ...f, [k]: v }))
|
||||||
|
|
||||||
|
const [profileErr, setProfileErr] = useState(null)
|
||||||
const [saved, setSaved] = useState(false)
|
const [saved, setSaved] = useState(false)
|
||||||
const [importing, setImporting] = useState(false)
|
const [importing, setImporting] = useState(false)
|
||||||
const [importMsg, setImportMsg] = useState(null)
|
const [importMsg, setImportMsg] = useState(null)
|
||||||
@@ -202,53 +134,78 @@ export default function SettingsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!activeProfile) return
|
||||||
|
const sexRaw = activeProfile.sex || 'm'
|
||||||
|
setForm({
|
||||||
|
name: activeProfile.name || '',
|
||||||
|
email: activeProfile.email || '',
|
||||||
|
sex: sexRaw === 'f' ? 'w' : sexRaw,
|
||||||
|
dob: dobInputValue(activeProfile.dob),
|
||||||
|
height: activeProfile.height != null ? String(activeProfile.height) : '',
|
||||||
|
goal_weight: activeProfile.goal_weight != null ? String(activeProfile.goal_weight) : '',
|
||||||
|
goal_bf_pct: activeProfile.goal_bf_pct != null ? String(activeProfile.goal_bf_pct) : '',
|
||||||
|
avatar_color: activeProfile.avatar_color || COLORS[0],
|
||||||
|
})
|
||||||
|
setProfileErr(null)
|
||||||
|
}, [activeProfile?.id])
|
||||||
|
|
||||||
const handleQualityFilterChange = async (level) => {
|
const handleQualityFilterChange = async (level) => {
|
||||||
// Issue #31: Update global quality filter
|
|
||||||
await api.updateActiveProfile({ quality_filter_level: level })
|
await api.updateActiveProfile({ quality_filter_level: level })
|
||||||
await refreshProfiles()
|
await refreshProfiles()
|
||||||
const updated = profiles.find(p => p.id === activeProfile?.id)
|
const updated = profiles.find(p => p.id === activeProfile?.id)
|
||||||
if (updated) setActiveProfile({...updated, quality_filter_level: level})
|
if (updated) setActiveProfile({ ...updated, quality_filter_level: level })
|
||||||
setSaved(true)
|
setSaved(true)
|
||||||
setTimeout(() => setSaved(false), 2000)
|
setTimeout(() => setSaved(false), 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSave = async (form, profileId) => {
|
const handleSaveMyProfile = async () => {
|
||||||
const data = {}
|
if (!activeProfile) return
|
||||||
if (form.name) data.name = form.name
|
const name = form.name.trim()
|
||||||
if (form.sex) data.sex = form.sex
|
if (!name) {
|
||||||
if (form.dob) data.dob = form.dob
|
setProfileErr('Bitte einen Namen eingeben.')
|
||||||
if (form.height) data.height = parseFloat(form.height)
|
return
|
||||||
if (form.avatar_color) data.avatar_color = form.avatar_color
|
}
|
||||||
if (form.goal_weight) data.goal_weight = parseFloat(form.goal_weight)
|
const h = parseFloat(form.height)
|
||||||
if (form.goal_bf_pct) data.goal_bf_pct = parseFloat(form.goal_bf_pct)
|
if (!form.height || Number.isNaN(h) || h < 100 || h > 250) {
|
||||||
|
setProfileErr('Bitte eine gültige Größe (100–250 cm) eingeben.')
|
||||||
if (profileId === 'new') {
|
return
|
||||||
const p = await api.createProfile({ ...data, name: form.name || 'Neues Profil' })
|
}
|
||||||
await refreshProfiles()
|
let goal_weight = null
|
||||||
// Don't auto-switch – just close the form
|
if (form.goal_weight !== '') {
|
||||||
} else {
|
goal_weight = parseFloat(form.goal_weight)
|
||||||
await api.updateProfile(profileId, data)
|
if (Number.isNaN(goal_weight)) {
|
||||||
await refreshProfiles()
|
setProfileErr('Zielgewicht: bitte eine gültige Zahl eingeben oder leer lassen.')
|
||||||
// If editing active profile, update it
|
return
|
||||||
if (profileId === activeProfile?.id) {
|
|
||||||
const updated = profiles.find(p => p.id === profileId)
|
|
||||||
if (updated) setActiveProfile({...updated, ...data})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setEditingId(null)
|
let goal_bf_pct = null
|
||||||
setSaved(true)
|
if (form.goal_bf_pct !== '') {
|
||||||
setTimeout(() => setSaved(false), 2000)
|
goal_bf_pct = parseFloat(form.goal_bf_pct)
|
||||||
}
|
if (Number.isNaN(goal_bf_pct)) {
|
||||||
|
setProfileErr('Ziel-KF%: bitte eine gültige Zahl eingeben oder leer lassen.')
|
||||||
const handleDelete = async (id) => {
|
return
|
||||||
if (!confirm('Profil und ALLE zugehörigen Daten unwiderruflich löschen?')) return
|
}
|
||||||
await api.deleteProfile(id)
|
}
|
||||||
await refreshProfiles()
|
setProfileErr(null)
|
||||||
if (activeProfile?.id === id) {
|
try {
|
||||||
const remaining = profiles.filter(p => p.id !== id)
|
const payload = {
|
||||||
if (remaining.length) setActiveProfile(remaining[0])
|
name,
|
||||||
|
sex: form.sex,
|
||||||
|
dob: form.dob ? form.dob : null,
|
||||||
|
height: h,
|
||||||
|
avatar_color: form.avatar_color,
|
||||||
|
goal_weight,
|
||||||
|
goal_bf_pct,
|
||||||
|
email: form.email.trim() === '' ? null : form.email.trim(),
|
||||||
|
}
|
||||||
|
await api.updateActiveProfile(payload)
|
||||||
|
await refreshProfiles()
|
||||||
|
setSaved(true)
|
||||||
|
setTimeout(() => setSaved(false), 2000)
|
||||||
|
} catch (e) {
|
||||||
|
setProfileErr(e.message || 'Speichern fehlgeschlagen')
|
||||||
}
|
}
|
||||||
setEditingId(null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleExportPlaceholders = async () => {
|
const handleExportPlaceholders = async () => {
|
||||||
@@ -272,69 +229,216 @@ export default function SettingsPage() {
|
|||||||
<div>
|
<div>
|
||||||
<h1 className="page-title">Einstellungen</h1>
|
<h1 className="page-title">Einstellungen</h1>
|
||||||
|
|
||||||
{/* Profile list */}
|
{/* Aktives Profil (nur eigenes Profil; weitere Profile nur im Admin) */}
|
||||||
<div className="card section-gap">
|
<div className="card section-gap">
|
||||||
<div className="card-title">Profile ({profiles.length})</div>
|
<div className="card-title" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
||||||
|
<Avatar profile={{ ...form, name: form.name || '?' }} size={40} />
|
||||||
{profiles.map(p => (
|
Mein Profil
|
||||||
<div key={p.id}>
|
</div>
|
||||||
<div style={{display:'flex',alignItems:'center',gap:10,padding:'10px 0',
|
<p style={{ fontSize: 13, color: 'var(--text2)', marginBottom: 14, lineHeight: 1.6 }}>
|
||||||
borderBottom:'1px solid var(--border)'}}>
|
Hier bearbeitest du nur das <strong>aktive Profil</strong>. Zum Anlegen weiterer Profile oder zum
|
||||||
<Avatar profile={p} size={40}/>
|
Verwalten anderer Nutzer nutzt du den Admin-Bereich (Zugriff nur als Administrator).
|
||||||
<div style={{flex:1}}>
|
</p>
|
||||||
<div style={{fontSize:14,fontWeight:600}}>{p.name}</div>
|
{isAdmin && (
|
||||||
<div style={{fontSize:11,color:'var(--text3)'}}>
|
<div
|
||||||
{p.sex==='m'?'Männlich':'Weiblich'}
|
style={{
|
||||||
{p.height ? ` · ${p.height} cm` : ''}
|
fontSize: 12,
|
||||||
{p.goal_weight ? ` · Ziel: ${p.goal_weight} kg` : ''}
|
color: 'var(--accent-dark)',
|
||||||
</div>
|
background: 'var(--accent-light)',
|
||||||
</div>
|
padding: '10px 12px',
|
||||||
<div style={{display:'flex',gap:6,alignItems:'center'}}>
|
borderRadius: 8,
|
||||||
{activeProfile?.id === p.id
|
marginBottom: 14,
|
||||||
? <span style={{fontSize:11,color:'var(--accent)',fontWeight:600,padding:'3px 8px',
|
lineHeight: 1.5,
|
||||||
background:'var(--accent-light)',borderRadius:6}}>Aktiv</span>
|
}}
|
||||||
: <button className="btn btn-secondary" style={{padding:'4px 10px',fontSize:12}}
|
>
|
||||||
onClick={handleLogout}>
|
Admin:{' '}
|
||||||
Nutzer wechseln
|
<Link to="/admin/g/users" style={{ fontWeight: 600, color: 'var(--accent-dark)' }}>
|
||||||
</button>
|
Benutzerverwaltung
|
||||||
}
|
</Link>
|
||||||
<button className="btn btn-secondary" style={{padding:'4px 8px'}}
|
|
||||||
onClick={()=>setEditingId(editingId===p.id ? null : p.id)}>
|
|
||||||
<Pencil size={12}/>
|
|
||||||
</button>
|
|
||||||
{profiles.length > 1 && (
|
|
||||||
<button className="btn btn-danger" style={{padding:'4px 8px'}}
|
|
||||||
onClick={()=>handleDelete(p.id)}>
|
|
||||||
<Trash2 size={12}/>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Edit form – only shown for THIS profile */}
|
|
||||||
{editingId === p.id && (
|
|
||||||
<ProfileForm
|
|
||||||
profile={p}
|
|
||||||
onSave={(form) => handleSave(form, p.id)}
|
|
||||||
onCancel={() => setEditingId(null)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
|
||||||
|
|
||||||
{/* New profile */}
|
|
||||||
{editingId === 'new' ? (
|
|
||||||
<ProfileForm
|
|
||||||
title="Neues Profil"
|
|
||||||
onSave={(form) => handleSave(form, 'new')}
|
|
||||||
onCancel={() => setEditingId(null)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<button className="btn btn-secondary btn-full" style={{marginTop:12}}
|
|
||||||
onClick={() => setEditingId('new')}>
|
|
||||||
<Plus size={14}/> Neues Profil anlegen
|
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<div className="settings-page__field">
|
||||||
|
<label className="settings-page__field-label" htmlFor="settings-profile-name">
|
||||||
|
Name
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="settings-profile-name"
|
||||||
|
type="text"
|
||||||
|
className="form-input"
|
||||||
|
value={form.name}
|
||||||
|
onChange={(e) => setF('name', e.target.value)}
|
||||||
|
autoComplete="name"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="settings-page__field">
|
||||||
|
<label className="settings-page__field-label" htmlFor="settings-profile-email">
|
||||||
|
E-Mail
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="settings-profile-email"
|
||||||
|
type="email"
|
||||||
|
className="form-input"
|
||||||
|
placeholder="für Login, Recovery & Zusammenfassungen"
|
||||||
|
value={form.email}
|
||||||
|
onChange={(e) => setF('email', e.target.value)}
|
||||||
|
autoComplete="email"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{activeProfile?.email && activeProfile?.email_verified === false && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: 12,
|
||||||
|
color: 'var(--warn-text)',
|
||||||
|
background: 'var(--warn-bg)',
|
||||||
|
padding: '8px 10px',
|
||||||
|
borderRadius: 8,
|
||||||
|
marginBottom: 12,
|
||||||
|
lineHeight: 1.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Diese E-Mail ist noch nicht bestätigt. Nach einer Änderung der Adresse ist ggf. erneut eine
|
||||||
|
Bestätigung nötig.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div style={{ marginBottom: 12 }}>
|
||||||
|
<div style={{ fontSize: 12, color: 'var(--text3)', marginBottom: 8 }}>Avatar-Farbe</div>
|
||||||
|
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||||
|
<Avatar profile={{ ...form, name: form.name || '?' }} size={36} />
|
||||||
|
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
|
||||||
|
{COLORS.map((c) => (
|
||||||
|
<div
|
||||||
|
key={c}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onClick={() => setF('avatar_color', c)}
|
||||||
|
onKeyDown={(e) => e.key === 'Enter' && setF('avatar_color', c)}
|
||||||
|
style={{
|
||||||
|
width: 26,
|
||||||
|
height: 26,
|
||||||
|
borderRadius: '50%',
|
||||||
|
background: c,
|
||||||
|
cursor: 'pointer',
|
||||||
|
border: `3px solid ${form.avatar_color === c ? 'white' : 'transparent'}`,
|
||||||
|
boxShadow: form.avatar_color === c ? `0 0 0 2px ${c}` : 'none',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-label">Geschlecht</label>
|
||||||
|
<select className="form-select" value={form.sex} onChange={(e) => setF('sex', e.target.value)}>
|
||||||
|
<option value="m">Männlich</option>
|
||||||
|
<option value="w">Weiblich</option>
|
||||||
|
<option value="d">Divers</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-label">Geburtsdatum</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
className="form-input"
|
||||||
|
style={{ width: 'auto', minWidth: 140 }}
|
||||||
|
value={form.dob}
|
||||||
|
onChange={(e) => setF('dob', e.target.value)}
|
||||||
|
/>
|
||||||
|
<span className="form-unit" />
|
||||||
|
</div>
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-label">Größe</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-input"
|
||||||
|
min={100}
|
||||||
|
max={250}
|
||||||
|
value={form.height}
|
||||||
|
onChange={(e) => setF('height', e.target.value)}
|
||||||
|
/>
|
||||||
|
<span className="form-unit">cm</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: 600,
|
||||||
|
color: 'var(--text3)',
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: '0.04em',
|
||||||
|
margin: '14px 0 6px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Ziele (optional, Legacy)
|
||||||
|
</div>
|
||||||
|
<p style={{ fontSize: 12, color: 'var(--text3)', marginBottom: 10, lineHeight: 1.5 }}>
|
||||||
|
Diese Felder bleiben vorerst erhalten; strategische Ziele verwaltest du unter{' '}
|
||||||
|
<Link to="/goals">Analyse → Ziele</Link>.
|
||||||
|
</p>
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-label">Zielgewicht</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-input"
|
||||||
|
min={30}
|
||||||
|
max={300}
|
||||||
|
step={0.1}
|
||||||
|
value={form.goal_weight}
|
||||||
|
onChange={(e) => setF('goal_weight', e.target.value)}
|
||||||
|
placeholder="–"
|
||||||
|
/>
|
||||||
|
<span className="form-unit">kg</span>
|
||||||
|
</div>
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-label">Ziel-KF%</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-input"
|
||||||
|
min={3}
|
||||||
|
max={50}
|
||||||
|
step={0.1}
|
||||||
|
value={form.goal_bf_pct}
|
||||||
|
onChange={(e) => setF('goal_bf_pct', e.target.value)}
|
||||||
|
placeholder="–"
|
||||||
|
/>
|
||||||
|
<span className="form-unit">%</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{profileErr && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: 13,
|
||||||
|
color: '#D85A30',
|
||||||
|
background: '#FCEBEB',
|
||||||
|
padding: '10px 12px',
|
||||||
|
borderRadius: 8,
|
||||||
|
marginBottom: 12,
|
||||||
|
lineHeight: 1.4,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{profileErr}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<button type="button" className="btn btn-primary btn-full" style={{ marginTop: 8 }} onClick={handleSaveMyProfile}>
|
||||||
|
<Save size={14} /> Profil speichern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="card section-gap">
|
||||||
|
<div className="card-title" style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<Target size={15} color="var(--accent)" /> Strategische Ziele
|
||||||
|
</div>
|
||||||
|
<p style={{ fontSize: 13, color: 'var(--text2)', marginBottom: 12, lineHeight: 1.6 }}>
|
||||||
|
Konkrete Ziele, Focus Areas und Fortschritt – eigener Bereich{' '}
|
||||||
|
<strong>Ziele</strong> in der Navigation (nicht in der KI-Analyse).
|
||||||
|
</p>
|
||||||
|
<Link to="/goals" className="btn btn-secondary btn-full" style={{ textAlign: 'center', textDecoration: 'none', boxSizing: 'border-box' }}>
|
||||||
|
Zu den Zielen
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Auth actions */}
|
{/* Auth actions */}
|
||||||
@@ -375,22 +479,6 @@ export default function SettingsPage() {
|
|||||||
<FeatureUsageOverview />
|
<FeatureUsageOverview />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Admin Panel */}
|
|
||||||
{isAdmin && (
|
|
||||||
<div className="card section-gap">
|
|
||||||
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between'}}>
|
|
||||||
<div className="card-title" style={{margin:0,display:'flex',alignItems:'center',gap:6}}>
|
|
||||||
<Shield size={15} color="var(--accent)"/> Admin
|
|
||||||
</div>
|
|
||||||
<button className="btn btn-secondary" style={{fontSize:12}}
|
|
||||||
onClick={()=>setAdminOpen(o=>!o)}>
|
|
||||||
{adminOpen?'Schließen':'Öffnen'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{adminOpen && <div style={{marginTop:12}}><AdminPanel/></div>}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Export */}
|
{/* Export */}
|
||||||
<div className="card section-gap">
|
<div className="card section-gap">
|
||||||
<div className="card-title">Daten exportieren</div>
|
<div className="card-title">Daten exportieren</div>
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export default function SleepPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: '16px 16px 80px' }}>
|
<div className="capture-page" style={{ padding: '16px 16px 80px' }}>
|
||||||
{/* Toast Notification */}
|
{/* Toast Notification */}
|
||||||
{toast && (
|
{toast && (
|
||||||
<div style={{
|
<div style={{
|
||||||
|
|||||||
@@ -1064,7 +1064,7 @@ export default function VitalsPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Vitalwerte</h1>
|
<h1 className="page-title">Vitalwerte</h1>
|
||||||
|
|
||||||
<div className="tabs" style={{ overflowX: 'auto', flexWrap: 'nowrap' }}>
|
<div className="tabs" style={{ overflowX: 'auto', flexWrap: 'nowrap' }}>
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default function WeightScreen() {
|
|||||||
const avgAll = weights.length ? Math.round(weights.reduce((a,b)=>a+b,0)/weights.length*10)/10 : null
|
const avgAll = weights.length ? Math.round(weights.reduce((a,b)=>a+b,0)/weights.length*10)/10 : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="capture-page">
|
||||||
<h1 className="page-title">Gewicht</h1>
|
<h1 className="page-title">Gewicht</h1>
|
||||||
|
|
||||||
{/* Eingabe */}
|
{/* Eingabe */}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Gemeinsames Raster für Dashboard-Kacheln (Mobile 2 / Desktop 4 Spalten).
|
||||||
|
* Optional Mobile 4: mobile auf 4 setzen + Klasse dashboard-tile-grid--mobile-4col.
|
||||||
|
*/
|
||||||
|
export const DASHBOARD_TILE_GRID_COLS = { mobile: 2, desktop: 4 }
|
||||||
|
|
||||||
|
/** @param {number} span @param {number} maxCols */
|
||||||
|
export function clampTileSpan(span, maxCols) {
|
||||||
|
const n = Number(span)
|
||||||
|
if (!Number.isFinite(n)) return 1
|
||||||
|
return Math.min(maxCols, Math.max(1, Math.round(n)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param {number} [mobileCols] 2 oder 4 */
|
||||||
|
export function dashboardTileGridClassName(mobileCols = DASHBOARD_TILE_GRID_COLS.mobile) {
|
||||||
|
let c = 'dashboard-tile-grid'
|
||||||
|
if (mobileCols === 4) c += ' dashboard-tile-grid--mobile-4col'
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
/** KPI-Raster: dieselben Regeln wie `dashboard-tile-grid`, plus Legacy-Klasse `dashboard-stat-grid`. */
|
||||||
|
export function dashboardStatGridClassName(mobileCols = DASHBOARD_TILE_GRID_COLS.mobile) {
|
||||||
|
let c = 'dashboard-stat-grid dashboard-tile-grid'
|
||||||
|
if (mobileCols === 4) c += ' dashboard-stat-grid--mobile-4col dashboard-tile-grid--mobile-4col'
|
||||||
|
return c
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ python scripts/gitea/gitea_api.py issues create --title "Fix: …" --body-file p
|
|||||||
|
|
||||||
# Kommentar
|
# Kommentar
|
||||||
python scripts/gitea/gitea_api.py issues comment 42 --body "…"
|
python scripts/gitea/gitea_api.py issues comment 42 --body "…"
|
||||||
|
python scripts/gitea/gitea_api.py issues comment 42 --body-file path/to/comment.md
|
||||||
|
|
||||||
# Schließen / wieder öffnen
|
# Schließen / wieder öffnen
|
||||||
python scripts/gitea/gitea_api.py issues close 42
|
python scripts/gitea/gitea_api.py issues close 42
|
||||||
|
|||||||
@@ -71,8 +71,14 @@ def cmd_issues_create(args: argparse.Namespace, base: str, token: str, owner: st
|
|||||||
|
|
||||||
|
|
||||||
def cmd_issues_comment(args: argparse.Namespace, base: str, token: str, owner: str, repo: str) -> None:
|
def cmd_issues_comment(args: argparse.Namespace, base: str, token: str, owner: str, repo: str) -> None:
|
||||||
|
body = args.body or ""
|
||||||
|
if getattr(args, "body_file", None):
|
||||||
|
body = Path(args.body_file).read_text(encoding="utf-8")
|
||||||
|
if not body.strip():
|
||||||
|
sys.stderr.write("issues comment: --body oder --body-file mit Inhalt erforderlich\n")
|
||||||
|
sys.exit(2)
|
||||||
status, payload = issues_comment(
|
status, payload = issues_comment(
|
||||||
base, token, owner, repo, args.number, args.body
|
base, token, owner, repo, args.number, body
|
||||||
)
|
)
|
||||||
print(json.dumps(payload, indent=2, ensure_ascii=False))
|
print(json.dumps(payload, indent=2, ensure_ascii=False))
|
||||||
if status >= 400:
|
if status >= 400:
|
||||||
@@ -149,7 +155,8 @@ def main() -> None:
|
|||||||
|
|
||||||
p_co = i_sub.add_parser("comment", help="Add comment")
|
p_co = i_sub.add_parser("comment", help="Add comment")
|
||||||
p_co.add_argument("number", type=int)
|
p_co.add_argument("number", type=int)
|
||||||
p_co.add_argument("--body", required=True)
|
p_co.add_argument("--body", default="")
|
||||||
|
p_co.add_argument("--body-file", help="Kommentar aus Datei (UTF-8); überschreibt --body wenn gesetzt")
|
||||||
p_co.set_defaults(_handler=cmd_issues_comment)
|
p_co.set_defaults(_handler=cmd_issues_comment)
|
||||||
|
|
||||||
p_cl = i_sub.add_parser("close", help="Close issue")
|
p_cl = i_sub.add_parser("close", help="Close issue")
|
||||||
|
|||||||
Reference in new issue
Block a user