Compare commits
4 Commits
78f4a53c49
...
9e20976591
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e20976591 | ||
|
|
8b276804b9 | ||
|
|
5d2f3986bd | ||
|
|
d03581bff4 |
60
app.py
60
app.py
@@ -1,7 +1,7 @@
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
import os
|
import os
|
||||||
from flask import Flask, abort, render_template, redirect, request, url_for
|
from flask import Flask, abort, render_template, redirect, request, url_for
|
||||||
from flask_login import LoginManager, login_required
|
from flask_login import LoginManager, login_required, current_user
|
||||||
import jinja_partials
|
import jinja_partials
|
||||||
from jinja2_fragments import render_block
|
from jinja2_fragments import render_block
|
||||||
from decorators import (validate_person, validate_topset, validate_workout,
|
from decorators import (validate_person, validate_topset, validate_workout,
|
||||||
@@ -200,27 +200,57 @@ def get_person_name(person_id):
|
|||||||
@ app.route("/exercise", methods=['POST'])
|
@ app.route("/exercise", methods=['POST'])
|
||||||
def create_exercise():
|
def create_exercise():
|
||||||
name = request.form.get("name")
|
name = request.form.get("name")
|
||||||
new_exercise_id = db.create_exercise(name)
|
attribute_ids = request.form.getlist('attribute_ids')
|
||||||
return render_template('partials/exercise.html', exercise_id=new_exercise_id, name=name)
|
exercise = db.create_exercise(name, attribute_ids)
|
||||||
|
return render_template('partials/exercise.html',
|
||||||
|
exercise_id=exercise['exercise_id'],
|
||||||
|
name=exercise['name'],
|
||||||
|
attributes=exercise['attributes'])
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/exercise/<int:exercise_id>", methods=['GET'])
|
@ app.route("/exercise/<int:exercise_id>", methods=['GET'])
|
||||||
def get_exercise(exercise_id):
|
def get_exercise(exercise_id):
|
||||||
exercise = db.get_exercise(exercise_id)
|
exercise = db.get_exercise(exercise_id)
|
||||||
return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise.name)
|
return render_template('partials/exercise.html',
|
||||||
|
exercise_id=exercise_id,
|
||||||
|
name=exercise['name'],
|
||||||
|
attributes=exercise['attributes'])
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/exercise/<int:exercise_id>/edit_form", methods=['GET'])
|
@ app.route("/exercise/<int:exercise_id>/edit_form", methods=['GET'])
|
||||||
def get_exercise_edit_form(exercise_id):
|
def get_exercise_edit_form(exercise_id):
|
||||||
exercise = db.get_exercise(exercise_id)
|
exercise = db.get_exercise(exercise_id)
|
||||||
return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise['name'], is_edit=True)
|
all_attributes = db.exercises.get_attributes_by_category()
|
||||||
|
|
||||||
|
# Format options for custom_select
|
||||||
|
formatted_options = {}
|
||||||
|
ex_attr_ids = [a['attribute_id'] for a in exercise['attributes']]
|
||||||
|
for cat, attrs in all_attributes.items():
|
||||||
|
formatted_options[cat] = [
|
||||||
|
{
|
||||||
|
"id": a['attribute_id'],
|
||||||
|
"name": a['name'],
|
||||||
|
"selected": a['attribute_id'] in ex_attr_ids
|
||||||
|
} for a in attrs
|
||||||
|
]
|
||||||
|
|
||||||
|
return render_template('partials/exercise.html',
|
||||||
|
exercise_id=exercise_id,
|
||||||
|
name=exercise['name'],
|
||||||
|
attributes=exercise['attributes'],
|
||||||
|
all_attributes=formatted_options,
|
||||||
|
is_edit=True)
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/exercise/<int:exercise_id>/update", methods=['PUT'])
|
@ app.route("/exercise/<int:exercise_id>/update", methods=['PUT'])
|
||||||
def update_exercise(exercise_id):
|
def update_exercise(exercise_id):
|
||||||
new_name = request.form.get('name')
|
new_name = request.form.get('name')
|
||||||
db.update_exercise(exercise_id, new_name)
|
attribute_ids = request.form.getlist('attribute_ids')
|
||||||
return render_template('partials/exercise.html', exercise_id=exercise_id, name=new_name)
|
exercise = db.update_exercise(exercise_id, new_name, attribute_ids)
|
||||||
|
return render_template('partials/exercise.html',
|
||||||
|
exercise_id=exercise_id,
|
||||||
|
name=exercise['name'],
|
||||||
|
attributes=exercise['attributes'])
|
||||||
|
|
||||||
|
|
||||||
""" @ app.route("/exercise/<int:exercise_id>/delete", methods=['DELETE'])
|
""" @ app.route("/exercise/<int:exercise_id>/delete", methods=['DELETE'])
|
||||||
@@ -230,12 +260,24 @@ def delete_exercise(exercise_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/settings")
|
@ app.route("/settings")
|
||||||
|
@ login_required
|
||||||
def settings():
|
def settings():
|
||||||
|
# check if user is admin
|
||||||
|
if current_user.id != 1007:
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
people = db.get_people()
|
people = db.get_people()
|
||||||
exercises = db.get_all_exercises()
|
exercises = db.get_all_exercises()
|
||||||
|
all_attributes = db.exercises.get_attributes_by_category()
|
||||||
|
|
||||||
|
# Format options for custom_select
|
||||||
|
formatted_options = {}
|
||||||
|
for cat, attrs in all_attributes.items():
|
||||||
|
formatted_options[cat] = [{"id": a['attribute_id'], "name": a['name']} for a in attrs]
|
||||||
|
|
||||||
if htmx:
|
if htmx:
|
||||||
return render_block(app.jinja_env, "settings.html", "content", people=people, exercises=exercises), 200, {"HX-Trigger": "updatedPeople"}
|
return render_block(app.jinja_env, "settings.html", "content",
|
||||||
return render_template('settings.html', people=people, exercises=exercises)
|
people=people, exercises=exercises, all_attributes=formatted_options), 200, {"HX-Trigger": "updatedPeople"}
|
||||||
|
return render_template('settings.html', people=people, exercises=exercises, all_attributes=formatted_options)
|
||||||
|
|
||||||
|
|
||||||
# Routes moved to routes/tags.py blueprint
|
# Routes moved to routes/tags.py blueprint
|
||||||
|
|||||||
19
db.py
19
db.py
@@ -66,22 +66,17 @@ class DataBase():
|
|||||||
|
|
||||||
|
|
||||||
def get_exercise(self, exercise_id):
|
def get_exercise(self, exercise_id):
|
||||||
exercise = self.execute(
|
return self.exercises.get_exercise(exercise_id)
|
||||||
'SELECT exercise_id, name FROM exercise WHERE exercise_id=%s LIMIT 1', [exercise_id], one=True)
|
|
||||||
return exercise
|
|
||||||
|
|
||||||
def create_exercise(self, name):
|
def create_exercise(self, name, attribute_ids=None):
|
||||||
new_exercise = self.execute('INSERT INTO exercise (name) VALUES (%s) RETURNING exercise_id AS "ExerciseId"',
|
return self.exercises.add_exercise(name, attribute_ids)
|
||||||
[name], commit=True, one=True)
|
|
||||||
return new_exercise['ExerciseId']
|
|
||||||
|
|
||||||
def delete_exercise(self, exercise_id):
|
def delete_exercise(self, exercise_id):
|
||||||
self.execute('DELETE FROM exercise WHERE exercise_id=%s', [
|
self.execute('DELETE FROM exercise WHERE exercise_id=%s', [
|
||||||
exercise_id], commit=True)
|
exercise_id], commit=True)
|
||||||
|
|
||||||
def update_exercise(self, exercise_id, name):
|
def update_exercise(self, exercise_id, name, attribute_ids=None):
|
||||||
self.execute('UPDATE Exercise SET Name=%s WHERE exercise_id=%s', [
|
return self.exercises.update_exercise(exercise_id, name, attribute_ids)
|
||||||
name, exercise_id], commit=True)
|
|
||||||
|
|
||||||
def get_people(self):
|
def get_people(self):
|
||||||
people = self.execute(
|
people = self.execute(
|
||||||
@@ -382,9 +377,7 @@ class DataBase():
|
|||||||
return (topset.get('repetitions'), topset.get('weight'), topset['exercise_name'])
|
return (topset.get('repetitions'), topset.get('weight'), topset['exercise_name'])
|
||||||
|
|
||||||
def get_all_exercises(self):
|
def get_all_exercises(self):
|
||||||
exercises = self.execute(
|
return self.exercises.get("")
|
||||||
'SELECT exercise_id, name FROM exercise')
|
|
||||||
return exercises
|
|
||||||
|
|
||||||
def get_exercise_progress_for_user(self, person_id, exercise_id, min_date=None, max_date=None, epoch='all', degree=1):
|
def get_exercise_progress_for_user(self, person_id, exercise_id, min_date=None, max_date=None, epoch='all', degree=1):
|
||||||
today = datetime.now()
|
today = datetime.now()
|
||||||
|
|||||||
@@ -5,25 +5,119 @@ class Exercises:
|
|||||||
def get(self, query):
|
def get(self, query):
|
||||||
# Add wildcards to the query
|
# Add wildcards to the query
|
||||||
search_query = f"%{query}%"
|
search_query = f"%{query}%"
|
||||||
|
# We need to fetch exercises with their attributes.
|
||||||
|
# Since an exercise can have many attributes, we'll fetch basic info first or use a join.
|
||||||
|
# But wait, the settings page just lists names. We can fetch attributes separately for each row or do a group_concat-like join.
|
||||||
|
# However, for the settings list, we want to show the tags.
|
||||||
|
|
||||||
|
# Let's use a simpler approach: fetch exercises and then for each one (or via a single join) get attributes.
|
||||||
exercises = self.execute("SELECT exercise_id, name FROM exercise WHERE LOWER(name) LIKE LOWER(%s) ORDER BY name ASC;", [search_query])
|
exercises = self.execute("SELECT exercise_id, name FROM exercise WHERE LOWER(name) LIKE LOWER(%s) ORDER BY name ASC;", [search_query])
|
||||||
|
|
||||||
|
for ex in exercises:
|
||||||
|
ex['attributes'] = self.get_exercise_attributes(ex['exercise_id'])
|
||||||
|
|
||||||
return exercises
|
return exercises
|
||||||
|
|
||||||
def get_exercise(self, exercise_id):
|
def get_exercise(self, exercise_id):
|
||||||
exercise = self.execute("SELECT exercise_id, name FROM exercise WHERE exercise_id=%s;", [exercise_id], one=True)
|
exercise = self.execute("SELECT exercise_id, name FROM exercise WHERE exercise_id=%s;", [exercise_id], one=True)
|
||||||
|
if exercise:
|
||||||
|
exercise['attributes'] = self.get_exercise_attributes(exercise_id)
|
||||||
return exercise
|
return exercise
|
||||||
|
|
||||||
def update_exercise_name(self, exercise_id, updated_name):
|
def get_exercise_attributes(self, exercise_id):
|
||||||
self.execute("UPDATE exercise SET name = %s WHERE exercise_id = %s;", [updated_name, exercise_id], commit=True)
|
query = """
|
||||||
updated_exercise = self.get_exercise(exercise_id)
|
SELECT cat.name as category_name, attr.attribute_id, attr.name as attribute_name
|
||||||
return updated_exercise
|
FROM exercise_to_attribute eta
|
||||||
|
JOIN exercise_attribute attr ON eta.attribute_id = attr.attribute_id
|
||||||
|
JOIN exercise_attribute_category cat ON attr.category_id = cat.category_id
|
||||||
|
WHERE eta.exercise_id = %s
|
||||||
|
ORDER BY cat.name, attr.name
|
||||||
|
"""
|
||||||
|
return self.execute(query, [exercise_id])
|
||||||
|
|
||||||
|
def get_all_attribute_categories(self):
|
||||||
|
return self.execute("SELECT category_id, name FROM exercise_attribute_category ORDER BY name")
|
||||||
|
|
||||||
|
def get_attributes_by_category(self):
|
||||||
|
# Returns a dict: { category_name: [ {id, name}, ... ] }
|
||||||
|
categories = self.get_all_attribute_categories()
|
||||||
|
all_attrs = self.execute("SELECT attribute_id, name, category_id FROM exercise_attribute ORDER BY name")
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
for cat in categories:
|
||||||
|
result[cat['name']] = [a for a in all_attrs if a['category_id'] == cat['category_id']]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def update_exercise(self, exercise_id, name, attribute_ids=None):
|
||||||
|
self.execute("UPDATE exercise SET name = %s WHERE exercise_id = %s;", [name, exercise_id], commit=True)
|
||||||
|
|
||||||
|
# Update attributes: simple delete and re-insert for now
|
||||||
|
self.execute("DELETE FROM exercise_to_attribute WHERE exercise_id = %s", [exercise_id], commit=True)
|
||||||
|
|
||||||
|
if attribute_ids:
|
||||||
|
for attr_id in attribute_ids:
|
||||||
|
if attr_id:
|
||||||
|
self.execute("INSERT INTO exercise_to_attribute (exercise_id, attribute_id) VALUES (%s, %s)",
|
||||||
|
[exercise_id, attr_id], commit=True)
|
||||||
|
|
||||||
|
return self.get_exercise(exercise_id)
|
||||||
|
|
||||||
def delete_exercise(self, exercise_id):
|
def delete_exercise(self, exercise_id):
|
||||||
self.execute('DELETE FROM exercise WHERE exercise_id=%s', [
|
self.execute('DELETE FROM exercise WHERE exercise_id=%s', [
|
||||||
exercise_id], commit=True)
|
exercise_id], commit=True)
|
||||||
|
|
||||||
def add_exercise(self, name):
|
def add_exercise(self, name, attribute_ids=None):
|
||||||
result = self.execute('INSERT INTO exercise (name) VALUES (%s) RETURNING exercise_id', [name], commit=True, one=True)
|
result = self.execute('INSERT INTO exercise (name) VALUES (%s) RETURNING exercise_id', [name], commit=True, one=True)
|
||||||
exercise_id = result['exercise_id']
|
exercise_id = result['exercise_id']
|
||||||
new_exercise = self.get_exercise(exercise_id)
|
|
||||||
return new_exercise
|
if attribute_ids:
|
||||||
|
for attr_id in attribute_ids:
|
||||||
|
if attr_id:
|
||||||
|
self.execute("INSERT INTO exercise_to_attribute (exercise_id, attribute_id) VALUES (%s, %s)",
|
||||||
|
[exercise_id, attr_id], commit=True)
|
||||||
|
|
||||||
|
return self.get_exercise(exercise_id)
|
||||||
|
|
||||||
|
def get_workout_attribute_distribution(self, workout_id, category_name):
|
||||||
|
query = """
|
||||||
|
SELECT attr.name as attribute_name, COUNT(*) as count
|
||||||
|
FROM topset t
|
||||||
|
JOIN exercise e ON t.exercise_id = e.exercise_id
|
||||||
|
JOIN exercise_to_attribute eta ON e.exercise_id = eta.exercise_id
|
||||||
|
JOIN exercise_attribute attr ON eta.attribute_id = attr.attribute_id
|
||||||
|
JOIN exercise_attribute_category cat ON attr.category_id = cat.category_id
|
||||||
|
WHERE t.workout_id = %s AND cat.name = %s
|
||||||
|
GROUP BY attr.name
|
||||||
|
ORDER BY count DESC
|
||||||
|
"""
|
||||||
|
distribution = self.execute(query, [workout_id, category_name])
|
||||||
|
|
||||||
|
# Calculate percentages and SVG parameters
|
||||||
|
total_counts = sum(item['count'] for item in distribution)
|
||||||
|
accumulated_percentage = 0
|
||||||
|
|
||||||
|
# Color palette for segments
|
||||||
|
colors = [
|
||||||
|
"#3b82f6", # blue-500
|
||||||
|
"#06b6d4", # cyan-500
|
||||||
|
"#8b5cf6", # violet-500
|
||||||
|
"#ec4899", # pink-500
|
||||||
|
"#f59e0b", # amber-500
|
||||||
|
"#10b981", # emerald-500
|
||||||
|
"#6366f1", # indigo-500
|
||||||
|
"#f43f5e", # rose-500
|
||||||
|
"#84cc16", # lime-500
|
||||||
|
"#0ea5e9", # sky-500
|
||||||
|
]
|
||||||
|
|
||||||
|
if total_counts > 0:
|
||||||
|
for i, item in enumerate(distribution):
|
||||||
|
percentage = (item['count'] / total_counts) * 100
|
||||||
|
item['percentage'] = round(percentage)
|
||||||
|
item['dasharray'] = f"{percentage} 100"
|
||||||
|
item['dashoffset'] = -accumulated_percentage
|
||||||
|
item['color'] = colors[i % len(colors)]
|
||||||
|
accumulated_percentage += percentage
|
||||||
|
|
||||||
|
return distribution
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,11 @@ def _get_workout_view_model(person_id, workout_id):
|
|||||||
# Sort tags alphabetically by name for consistent display
|
# Sort tags alphabetically by name for consistent display
|
||||||
workout_data["tags"].sort(key=lambda x: x.get('tag_name', ''))
|
workout_data["tags"].sort(key=lambda x: x.get('tag_name', ''))
|
||||||
|
|
||||||
|
# Add multi-category breakdowns
|
||||||
|
workout_data["muscle_distribution"] = db.exercises.get_workout_attribute_distribution(workout_id, 'Muscle Group')
|
||||||
|
workout_data["equipment_distribution"] = db.exercises.get_workout_attribute_distribution(workout_id, 'Machine vs Free Weight')
|
||||||
|
workout_data["movement_distribution"] = db.exercises.get_workout_attribute_distribution(workout_id, 'Compound vs Isolation')
|
||||||
|
|
||||||
return workout_data
|
return workout_data
|
||||||
|
|
||||||
|
|
||||||
@@ -179,6 +184,16 @@ def get_workout_start_date(person_id, workout_id):
|
|||||||
start_date = workout.get('start_date') if workout else None
|
start_date = workout.get('start_date') if workout else None
|
||||||
return render_template('partials/start_date.html', person_id=person_id, workout_id=workout_id, start_date=start_date)
|
return render_template('partials/start_date.html', person_id=person_id, workout_id=workout_id, start_date=start_date)
|
||||||
|
|
||||||
|
@workout_bp.route("/person/<int:person_id>/workout/<int:workout_id>/distribution", methods=['GET'])
|
||||||
|
def get_workout_distribution(person_id, workout_id):
|
||||||
|
category = request.args.get('category', 'Muscle Group')
|
||||||
|
distribution = db.exercises.get_workout_attribute_distribution(workout_id, category)
|
||||||
|
return render_template('partials/workout_breakdown.html',
|
||||||
|
person_id=person_id,
|
||||||
|
workout_id=workout_id,
|
||||||
|
distribution=distribution,
|
||||||
|
category_name=category)
|
||||||
|
|
||||||
@workout_bp.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>/achievements", methods=['GET'])
|
@workout_bp.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>/achievements", methods=['GET'])
|
||||||
@validate_topset
|
@validate_topset
|
||||||
def get_topset_achievements(person_id, workout_id, topset_id):
|
def get_topset_achievements(person_id, workout_id, topset_id):
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 227 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900 w-1/5">
|
||||||
{% if is_edit|default(false, true) == false %}
|
{% if is_edit|default(false, true) == false %}
|
||||||
{{ name }}
|
{{ name }}
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -8,7 +8,35 @@
|
|||||||
type="text" name="name" value="{{ name }}">
|
type="text" name="name" value="{{ name }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900 float-right">
|
<td class="p-4 text-sm text-gray-900 w-3/5">
|
||||||
|
{% if is_edit|default(false, true) == false %}
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
{% for attr in attributes %}
|
||||||
|
<span
|
||||||
|
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800"
|
||||||
|
title="{{ attr.category_name }}">
|
||||||
|
{{ attr.attribute_name }}
|
||||||
|
</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
{% for cat_name, options in all_attributes.items() %}
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-gray-500 uppercase mb-1">{{ cat_name }}</label>
|
||||||
|
{{ render_partial('partials/custom_select.html',
|
||||||
|
name='attribute_ids',
|
||||||
|
options=options,
|
||||||
|
multiple=true,
|
||||||
|
search=true,
|
||||||
|
placeholder='Select ' ~ cat_name
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900 w-1/5 float-right">
|
||||||
{% if is_edit|default(false, true) == false %}
|
{% if is_edit|default(false, true) == false %}
|
||||||
<button
|
<button
|
||||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||||
|
|||||||
64
templates/partials/workout_breakdown.html
Normal file
64
templates/partials/workout_breakdown.html
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{% set distribution = distribution or muscle_distribution %}
|
||||||
|
{% set category_name = category_name or 'Muscle Group' %}
|
||||||
|
{% set breakdown_id = category_name.lower().replace(' ', '-') %}
|
||||||
|
|
||||||
|
{% if distribution %}
|
||||||
|
<div class="px-4 py-3 bg-white relative" id="{{ breakdown_id }}-breakdown"
|
||||||
|
hx-get="{{ url_for('workout.get_workout_distribution', person_id=person_id, workout_id=workout_id, category=category_name) }}"
|
||||||
|
hx-trigger="topsetAdded from:body" hx-swap="outerHTML">
|
||||||
|
|
||||||
|
<!-- Shared Popover Container (managed by Hyperscript) -->
|
||||||
|
<div id="popover-{{ breakdown_id }}"
|
||||||
|
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-30 hidden bg-white border border-gray-200 shadow-2xl rounded-xl p-4 min-w-[200px] animate-in fade-in zoom-in duration-200"
|
||||||
|
_="on click from elsewhere add .hidden to me">
|
||||||
|
<div id="content-{{ breakdown_id }}"></div>
|
||||||
|
<button class="absolute top-2 right-2 text-gray-400 hover:text-gray-600"
|
||||||
|
_="on click add .hidden to #popover-{{ breakdown_id }}">
|
||||||
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<h4 class="text-[9px] font-black text-gray-400 uppercase tracking-[0.25em]">{{ category_name }} Distribution
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sleek Performance Bar -->
|
||||||
|
<div class="w-full h-8 flex overflow-hidden rounded-lg bg-gray-100 shadow-inner p-0.5 cursor-pointer">
|
||||||
|
{% for item in distribution %}
|
||||||
|
<div class="h-full transition-all duration-700 ease-in-out flex items-center justify-center relative group first:rounded-l-md last:rounded-r-md"
|
||||||
|
style="width: {{ item.percentage }}%; background-color: {{ item.color }};" _="on click
|
||||||
|
halt the event
|
||||||
|
put '<div class=\'flex flex-col gap-1\'>
|
||||||
|
<div class=\'flex items-center gap-2\'>
|
||||||
|
<div class=\'w-3 h-3 rounded-full\' style=\'background-color: {{ item.color }}\'></div>
|
||||||
|
<span class=\'font-black text-sm uppercase\'>{{ item.attribute_name }}</span>
|
||||||
|
</div>
|
||||||
|
<div class=\'text-2xl font-black text-gray-900\'>{{ item.percentage }}%</div>
|
||||||
|
<div class=\'text-[10px] font-bold text-gray-400 uppercase tracking-wider\'>{{ item.count }} Sets Targeted</div>
|
||||||
|
</div>' into #content-{{ breakdown_id }}
|
||||||
|
remove .hidden from #popover-{{ breakdown_id }}"
|
||||||
|
title="{{ item.attribute_name }}: {{ item.percentage }}%">
|
||||||
|
|
||||||
|
<!-- Labels (Name & Percentage grouped and centered) -->
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-center gap-1.5 leading-none text-white pointer-events-none px-1 overflow-hidden">
|
||||||
|
{% if item.percentage > 18 %}
|
||||||
|
<span class="text-[9px] font-black uppercase tracking-tighter truncate drop-shadow-sm">{{
|
||||||
|
item.attribute_name }}</span>
|
||||||
|
<span class="text-[9px] font-bold opacity-90 whitespace-nowrap drop-shadow-sm">{{ item.percentage
|
||||||
|
}}%</span>
|
||||||
|
{% elif item.percentage > 8 %}
|
||||||
|
<span class="text-[9px] font-black drop-shadow-sm">{{ item.percentage }}%</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Enhanced Hover State -->
|
||||||
|
<div class="absolute inset-0 bg-white/15 opacity-0 group-hover:opacity-100 transition-opacity"></div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
@@ -107,11 +107,15 @@
|
|||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/4">
|
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/5">
|
||||||
Name
|
Name
|
||||||
</th>
|
</th>
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-3/4">
|
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-3/5">
|
||||||
|
Attributes
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-1/5">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div
|
<div
|
||||||
class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
hx-swap="outerHTML swap:0.5s">
|
hx-swap="outerHTML swap:0.5s">
|
||||||
{% for exercise in exercises %}
|
{% for exercise in exercises %}
|
||||||
{{ render_partial('partials/exercise.html', exercise_id=exercise.exercise_id,
|
{{ render_partial('partials/exercise.html', exercise_id=exercise.exercise_id,
|
||||||
name=exercise.name)}}
|
name=exercise.name, attributes=exercise.attributes)}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -155,12 +159,27 @@
|
|||||||
then reset() me">
|
then reset() me">
|
||||||
<div class="flex flex-wrap -mx-3 mb-2">
|
<div class="flex flex-wrap -mx-3 mb-2">
|
||||||
<div class="grow px-3">
|
<div class="grow px-3">
|
||||||
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-city">
|
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">
|
||||||
New exercise
|
New exercise
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
|
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500 mb-4"
|
||||||
type="text" name="name">
|
type="text" name="name" placeholder="Exercise Name">
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||||
|
{% for cat_name, options in all_attributes.items() %}
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-gray-500 uppercase mb-1">{{ cat_name }}</label>
|
||||||
|
{{ render_partial('partials/custom_select.html',
|
||||||
|
name='attribute_ids',
|
||||||
|
options=options,
|
||||||
|
multiple=true,
|
||||||
|
search=true,
|
||||||
|
placeholder='Select ' ~ cat_name
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row pt-6 px-3 w-36">
|
<div class="flex flex-row pt-6 px-3 w-36">
|
||||||
|
|||||||
@@ -45,63 +45,61 @@
|
|||||||
<div class='p-0 md:p-4 m-0 md:m-2'>
|
<div class='p-0 md:p-4 m-0 md:m-2'>
|
||||||
<div class="relative w-full h-full">
|
<div class="relative w-full h-full">
|
||||||
<!-- Modal content -->
|
<!-- Modal content -->
|
||||||
<div class="relative bg-white rounded-lg shadow">
|
<div class="relative bg-white rounded-lg shadow overflow-hidden">
|
||||||
<!-- Modal header -->
|
<!-- Modal header -->
|
||||||
<div class="flex items-start justify-between p-2 md:p-4 border-0 md:border-b rounded-t">
|
<div class="p-4 md:p-6 border-b relative">
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full pr-8">
|
||||||
<div class="flex items-center justify-between">
|
<h3 class="text-2xl font-black text-gray-900 leading-tight">{{ person_name }}</h3>
|
||||||
<div class="w-full">
|
|
||||||
<h3 class="text-xl font-bold text-gray-900">{{ person_name }}</h3>
|
|
||||||
|
|
||||||
{{ render_partial('partials/workout_tags.html', person_id=person_id, workout_id=workout_id,
|
{{ render_partial('partials/workout_tags.html', person_id=person_id, workout_id=workout_id,
|
||||||
tags=tags) }}
|
tags=tags) }}
|
||||||
|
|
||||||
</div>
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
|
||||||
|
{{ render_partial('partials/start_date.html', person_id=person_id, workout_id=workout_id,
|
||||||
</div>
|
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-2">
|
|
||||||
{{ render_partial('partials/start_date.html', person_id=person_id,
|
|
||||||
workout_id=workout_id,
|
|
||||||
start_date=start_date) }}
|
start_date=start_date) }}
|
||||||
|
{{ render_partial('partials/workout_note.html', person_id=person_id, workout_id=workout_id,
|
||||||
|
|
||||||
{{ render_partial('partials/workout_note.html', person_id=person_id,
|
|
||||||
workout_id=workout_id,
|
|
||||||
note=note) }}
|
note=note) }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="absolute right-0 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white mr-2"
|
class="absolute top-4 right-4 text-gray-400 bg-transparent hover:bg-gray-100 hover:text-gray-900 rounded-lg text-sm p-2 transition-colors inline-flex items-center"
|
||||||
hx-get="{{ url_for('workout.delete_workout', person_id=person_id, workout_id=workout_id) }}"
|
hx-get="{{ url_for('workout.delete_workout', person_id=person_id, workout_id=workout_id) }}"
|
||||||
hx-confirm="Are you sure you wish to delete this workout?" hx-push-url="true"
|
hx-confirm="Are you sure you wish to delete this workout?" hx-push-url="true"
|
||||||
hx-target="#container">
|
hx-target="#container">
|
||||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"
|
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"
|
||||||
xmlns="http://www.w3.org/2000/svg" data-darkreader-inline-fill=""
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
style="--darkreader-inline-fill:currentColor;">
|
|
||||||
<path fill-rule="evenodd"
|
<path fill-rule="evenodd"
|
||||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||||
clip-rule="evenodd"></path>
|
clip-rule="evenodd"></path>
|
||||||
</svg>
|
</svg>
|
||||||
<span class="sr-only">Close modal</span>
|
<span class="sr-only">Delete workout</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Multi-Category Breakdown Stripes -->
|
||||||
|
<div class="bg-gray-50/50 border-b divide-y divide-gray-100">
|
||||||
|
{{ render_partial('partials/workout_breakdown.html', person_id=person_id, workout_id=workout_id,
|
||||||
|
distribution=muscle_distribution, category_name='Muscle Group') }}
|
||||||
|
|
||||||
|
{{ render_partial('partials/workout_breakdown.html', person_id=person_id, workout_id=workout_id,
|
||||||
|
distribution=equipment_distribution, category_name='Machine vs Free Weight') }}
|
||||||
|
|
||||||
|
{{ render_partial('partials/workout_breakdown.html', person_id=person_id, workout_id=workout_id,
|
||||||
|
distribution=movement_distribution, category_name='Compound vs Isolation') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="relative bg-white rounded-lg shadow mt-4">
|
<!-- Workout Content Card -->
|
||||||
<div class="p-2 md:p-4 border-0 md:border-b rounded-t">
|
<div class="p-0">
|
||||||
<!-- Modal footer -->
|
<div class="p-2 md:p-4 border-0 md:border-b">
|
||||||
<div class="flex items-center p-1 md:p-2 rounded-b dark:border-gray-600">
|
<!-- Modal footer / New Set Form -->
|
||||||
|
<div class="flex items-center p-1 md:p-2 rounded-b">
|
||||||
{{ render_partial('partials/new_set_form.html', person_id=person_id,
|
{{ render_partial('partials/new_set_form.html', person_id=person_id,
|
||||||
workout_id=workout_id,
|
workout_id=workout_id,
|
||||||
exercises=exercises,
|
exercises=exercises,
|
||||||
has_value=False) }}
|
has_value=False) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal body -->
|
<!-- Modal body / Top Sets Table -->
|
||||||
<div class="p-3 md:p-6 space-y-6">
|
<div class="p-3 md:p-6 space-y-6">
|
||||||
<table class="items-center w-full bg-transparent border-collapse table-fixed">
|
<table class="items-center w-full bg-transparent border-collapse table-fixed">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -129,21 +127,21 @@
|
|||||||
{% if top_sets|length == 0 %}
|
{% if top_sets|length == 0 %}
|
||||||
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert"
|
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert"
|
||||||
id="no-workouts">
|
id="no-workouts">
|
||||||
No top_sets found.
|
No sets recorded for this session.
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="exercise-progress" class="mx-0 md:mx-5">
|
<div id="exercise-progress" class="mx-0 md:mx-5">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="hidden" hx-get="{{ url_for('get_stats') }}" hx-vals='{"person_id": "{{ person_id }}"}' hx-trigger="load"
|
<div class="hidden" hx-get="{{ url_for('get_stats') }}" hx-vals='{"person_id": "{{ person_id }}"}' hx-trigger="load"
|
||||||
hx-target="#stats" hx-swap="innerHTML">
|
hx-target="#stats" hx-swap="innerHTML">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user