Add Brili-style scheduled routines timeline view

Replaces the flat routine card list with a day-oriented timeline showing
scheduled routines at their time slots, with week strip navigation and
a live "now" indicator. Adds bulk schedules API endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 18:34:03 -06:00
parent bb01f0213f
commit 749f734aff
3 changed files with 330 additions and 102 deletions

View File

@@ -506,6 +506,34 @@ def register(app):
# ── Routine Scheduling ────────────────────────────────────────
@app.route("/api/routines/schedules", methods=["GET"])
def api_listAllSchedules():
"""Get all schedules for the user's routines with routine metadata."""
user_uuid = _auth(flask.request)
if not user_uuid:
return flask.jsonify({"error": "unauthorized"}), 401
routines = postgres.select("routines", where={"user_uuid": user_uuid})
if not routines:
return flask.jsonify([]), 200
result = []
for r in routines:
sched = postgres.select_one("routine_schedules", {"routine_id": r["id"]})
if not sched:
continue
steps = postgres.select("routine_steps", where={"routine_id": r["id"]})
total_duration = sum(s.get("duration_minutes") or 0 for s in steps)
result.append({
"routine_id": r["id"],
"routine_name": r.get("name", ""),
"routine_icon": r.get("icon", ""),
"days": sched.get("days", []),
"time": sched.get("time"),
"remind": sched.get("remind", True),
"total_duration_minutes": total_duration,
})
return flask.jsonify(result), 200
@app.route("/api/routines/<routine_id>/schedule", methods=["PUT"])
def api_setRoutineSchedule(routine_id):
"""Set when this routine should run. Body: {days: ["mon","tue",...], time: "08:00", remind: true}"""