From 31078b181ad0eff928579c62ace67a43d185992d Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sun, 8 Feb 2026 18:25:43 +1100 Subject: [PATCH] Split up settings sub pages into templates loaded by htmx to reduce initial load --- app.py | 30 +- templates/partials/settings/activity.html | 14 + templates/partials/settings/exercises.html | 163 ++++++++++ templates/partials/settings/export.html | 48 +++ templates/partials/settings/people.html | 78 +++++ templates/settings.html | 342 ++------------------- 6 files changed, 357 insertions(+), 318 deletions(-) create mode 100644 templates/partials/settings/activity.html create mode 100644 templates/partials/settings/exercises.html create mode 100644 templates/partials/settings/export.html create mode 100644 templates/partials/settings/people.html diff --git a/app.py b/app.py index e317d91..3106027 100644 --- a/app.py +++ b/app.py @@ -227,7 +227,19 @@ def get_person_name(person_id): @ app.route("/settings") @ login_required def settings(): + if htmx: + return render_block(app.jinja_env, 'settings.html', 'content') + return render_template('settings.html') + +@ app.route("/settings/tab/people") +@ login_required +def settings_people(): people = db.get_people() + return render_template('partials/settings/people.html', people=people) + +@ app.route("/settings/tab/exercises") +@ login_required +def settings_exercises(): exercises = db.get_all_exercises() all_attributes = db.exercises.get_attributes_by_category() categories_list = db.exercises.get_all_attribute_categories() @@ -237,10 +249,20 @@ def settings(): for cat, attrs in all_attributes.items(): formatted_options[cat] = [{"id": a['attribute_id'], "attribute_id": a['attribute_id'], "name": a['name'], "category_id": a['category_id']} for a in attrs] - if htmx: - return render_block(app.jinja_env, "settings.html", "content", - people=people, exercises=exercises, all_attributes=formatted_options, categories_list=categories_list), 200, {"HX-Trigger": "updatedPeople"} - return render_template('settings.html', people=people, exercises=exercises, all_attributes=formatted_options, categories_list=categories_list) + return render_template('partials/settings/exercises.html', + exercises=exercises, + all_attributes=formatted_options, + categories_list=categories_list) + +@ app.route("/settings/tab/export") +@ login_required +def settings_export(): + return render_template('partials/settings/export.html') + +@ app.route("/settings/tab/activity") +@ login_required +def settings_activity(): + return render_template('partials/settings/activity.html') @app.route("/settings/activity_logs") diff --git a/templates/partials/settings/activity.html b/templates/partials/settings/activity.html new file mode 100644 index 0000000..0a87ac1 --- /dev/null +++ b/templates/partials/settings/activity.html @@ -0,0 +1,14 @@ +
+
+

Activity Logs

+

Review recent actions and administrative changes.

+
+
+
+
+
+

Loading activity history...

+
+
+
+
\ No newline at end of file diff --git a/templates/partials/settings/exercises.html b/templates/partials/settings/exercises.html new file mode 100644 index 0000000..41ad975 --- /dev/null +++ b/templates/partials/settings/exercises.html @@ -0,0 +1,163 @@ +
+
+

Exercise Configuration

+

Manage available exercises and their categories.

+
+ +
+
+
+
+ + + + + + + + + + {% for exercise in exercises %} + {{ render_partial('partials/exercise.html', exercise_id=exercise.exercise_id, + name=exercise.name, attributes=exercise.attributes)}} + {% endfor %} + +
+ Exercise Name + +
+
+ +
+ +
+ + + + + +
+
+
+
+
+
+
+ +
+
+

Add New Exercise

+

Create a new exercise with specific muscle groups and equipment. +

+
+ +
+ +
+
+ + +
+ +
+ {% for cat_name, options in all_attributes.items() %} +
+ + {{ render_partial('partials/custom_select.html', + name='attribute_ids', + options=options, + multiple=true, + search=true, + placeholder='Select ' ~ cat_name + )}} +
+ {% endfor %} +
+ +
+ +
+
+
+
+ + +
+
+

Manage Categories & Options

+

Add or edit muscle groups, equipment types, and other exercise + attributes.

+
+ +
+ {% for cat in categories_list %} + {% set options = all_attributes.get(cat.name, []) %} + {{ render_partial('partials/exercise/category_admin.html', category_id=cat.category_id, + name=cat.name, attributes=options) }} + {% endfor %} +
+ + +
+
+
+ + +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/templates/partials/settings/export.html b/templates/partials/settings/export.html new file mode 100644 index 0000000..1b715e9 --- /dev/null +++ b/templates/partials/settings/export.html @@ -0,0 +1,48 @@ +
+
+

Data & Portability

+

Export your data for backup or external analysis.

+
+ +
+ +
+
+
+ + + +
+

Workout History

+
+

Download all workout records, sets, and + performance data in CSV format.

+ + Download CSV + +
+ + +
+
+
+ + + +
+

Database Snapshot

+
+

Create a full SQL dump of your database including + schema and all records.

+ + Download SQL Script + +
+
+
\ No newline at end of file diff --git a/templates/partials/settings/people.html b/templates/partials/settings/people.html new file mode 100644 index 0000000..60cb817 --- /dev/null +++ b/templates/partials/settings/people.html @@ -0,0 +1,78 @@ +
+
+
+

User Management

+

Add, edit or remove people from the tracker.

+
+
+ +
+
+
+
+ + + + + + + + + {% for p in people %} + {{ render_partial('partials/person.html', person_id=p['PersonId'], name=p['Name'])}} + {% endfor %} + +
+ Name + +
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/templates/settings.html b/templates/settings.html index b8eb2d1..45bbb0d 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -13,7 +13,8 @@
-