From c8b9591441fc02ee3628041c578021478407c5b5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 1 Sep 2026 15:10:52 +0200 Subject: [PATCH] UI --- plugins/trainingsplan/app.py | 11 +- plugins/trainingsplan/static/index.html | 850 ++++++++++++++++++++++++ 2 files changed, 858 insertions(+), 3 deletions(-) create mode 100644 plugins/trainingsplan/static/index.html diff --git a/plugins/trainingsplan/app.py b/plugins/trainingsplan/app.py index 5f1b1a3..b599e81 100644 --- a/plugins/trainingsplan/app.py +++ b/plugins/trainingsplan/app.py @@ -10,7 +10,7 @@ from copy import deepcopy from pathlib import Path from typing import Any, Callable -from flask import Flask, jsonify, request, send_file +from flask import Flask, Response, jsonify, request, send_file from schema_contract import default_config, normalize_training_config, stable_id, validate_training_config from storage import atomic_json_write, utc_now @@ -21,6 +21,7 @@ PLANS_DIR = DATA_DIR / "plans" ACTIVE_FILE = DATA_DIR / "active.txt" LEGACY_CONFIG = DATA_DIR / "config.json" BACKUPS_DIR = DATA_DIR / "backups" +STATIC_DIR = BASE_DIR / "static" PLANS_DIR.mkdir(parents=True, exist_ok=True) BACKUPS_DIR.mkdir(parents=True, exist_ok=True) @@ -160,6 +161,10 @@ def public_wrapper(wrapper: dict[str, Any], *, draft: bool = True) -> dict[str, def _save_draft(pid: str, wrapper: dict[str, Any], config: dict[str, Any]) -> dict[str, Any]: + meta = config.get("meta") if isinstance(config.get("meta"), dict) else {} + title = str(meta.get("title") or "").strip() + if title: + wrapper["name"] = title wrapper["draft"] = normalize_training_config(config, plan_id=wrapper["plan_id"]) wrapper["draft"]["meta"]["title"] = str(wrapper["name"]) wrapper["revision"] += 1 @@ -172,7 +177,7 @@ def _mutate_draft(pid: str, mutator: Callable[[dict[str, Any]], Any]) -> tuple[d wrapper = read_plan(pid) draft = deepcopy(wrapper["draft"]) result = mutator(draft) - if isinstance(result, str) and result in {"day", "exercise", "item", "used"}: + if result is None or result is False or (isinstance(result, str) and result in {"day", "exercise", "item", "used"}): return wrapper, result saved = _save_draft(pid, wrapper, draft) return saved, result @@ -201,7 +206,7 @@ ensure_seed() @app.route("/") def index(): - return jsonify({"name": "Trainingsplan-Backend", "status": "ok"}) + return Response((STATIC_DIR / "index.html").read_text(encoding="utf-8"), mimetype="text/html") @app.route("/api/plans", methods=["GET"]) diff --git a/plugins/trainingsplan/static/index.html b/plugins/trainingsplan/static/index.html new file mode 100644 index 0000000..c8a61aa --- /dev/null +++ b/plugins/trainingsplan/static/index.html @@ -0,0 +1,850 @@ + + + + + + Trainingsplan-Editor + + + +
+
+
TP
+
+

Trainingsplan-Editor

+
Lade...
+
+
+
+ + + + + + +
+
+ +
+ + +
+
+ + +
+
+ +
+ + + +