summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFivePixels <dylan.bolger00@gmail.com>2023-02-19 20:52:42 -0600
committerFivePixels <dylan.bolger00@gmail.com>2023-02-19 20:52:42 -0600
commit157ddaa68fafb1f8e0bd0d8335517eb402c5988f (patch)
treec47f545424b5e7cae811fb5d9448c8399bb9d528
parent34988c3d22dd00f5dc7f68ff06ba71d146008257 (diff)
downloadStrengthy-main.tar.xz
Strengthy-main.zip
Add progress page, cleanup timer formattingmain
-rw-r--r--app/routes/basic.py15
-rw-r--r--app/templates/base/layout.html102
-rw-r--r--app/templates/progress.html22
-rw-r--r--app/templates/workout/record.html57
-rw-r--r--app/templates/workout/record_select.html17
5 files changed, 131 insertions, 82 deletions
diff --git a/app/routes/basic.py b/app/routes/basic.py
index 584d837..d5d7461 100644
--- a/app/routes/basic.py
+++ b/app/routes/basic.py
@@ -45,3 +45,18 @@ def home():
return render_template(
"home.html", records=records, sets_completed=sets_completed, top3=top3
)
+
+
+@app.route("/progress", methods=["GET"])
+@login_required
+def progress():
+ exercises = (
+ db.session.query(Exercise)
+ .join(SetRecord)
+ .filter(SetRecord.exercise_id == Exercise.id)
+ .group_by(Exercise.id)
+ .order_by(db.func.count(SetRecord.id).desc())
+ .having(db.func.count(SetRecord.id) > 1)
+ .all()
+ )
+ return render_template("progress.html", exercises=exercises)
diff --git a/app/templates/base/layout.html b/app/templates/base/layout.html
index afe6143..9628eb4 100644
--- a/app/templates/base/layout.html
+++ b/app/templates/base/layout.html
@@ -37,59 +37,68 @@
<div class="navbar-menu" id="nav-menu">
<div class="navbar-start">
{% if current_user.is_authenticated %}
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/home">
- <span class="icon">
- <i class="fa fa-home"></i>
- </span>
- <span>Home</span>
- </a>
- </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/home">
+ <span class="icon">
+ <i class="fa fa-home"></i>
+ </span>
+ <span>Home</span>
+ </a>
+ </span>
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/workout/record">
- <span class="icon">
- <i class="fa fa-pencil"></i>
- </span>
- <span>Record a Workout</span>
- </a>
- </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/workout/record">
+ <span class="icon">
+ <i class="fa fa-pencil"></i>
+ </span>
+ <span>Record a Workout</span>
+ </a>
+ </span>
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/workout/create">
- <span class="icon">
- <i class="fa fa-plus"></i>
- </span>
- <span>Create a Workout</span>
- </a>
- </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/workout/create">
+ <span class="icon">
+ <i class="fa fa-plus"></i>
+ </span>
+ <span>Create a Workout</span>
+ </a>
+ </span>
+
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/progress">
+ <span class="icon">
+ <i class="fa fa-tasks"></i>
+ </span>
+ <span>Your Progress</span>
+ </a>
+ </span>
{% endif %}
</div>
<div class="navbar-end">
{% if current_user.is_authenticated %}
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/logout">
- <span>Log Out</span>
- </a>
- </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/logout">
+ <span>Log Out</span>
+ </a>
+ </span>
{% else %}
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/login">
- <span class="icon">
- <i class="fa fa-user"></i>
- </span>
- <span>Login</span>
- </a>
- </span>
- <span class="navbar-item">
- <a class="button is-white is-outlined" href="/register">
- <span class="icon">
- <i class="fa fa-pencil"></i>
- </span>
- <span>Sign Up</span>
- </a>
- </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/login">
+ <span class="icon">
+ <i class="fa fa-user"></i>
+ </span>
+ <span>Login</span>
+ </a>
+ </span>
+ <span class="navbar-item">
+ <a class="button is-white is-outlined" href="/register">
+ <span class="icon">
+ <i class="fa fa-pencil"></i>
+ </span>
+ <span>Sign Up</span>
+ </a>
+ </span>
{% endif %}
</div>
</div>
@@ -104,4 +113,5 @@
<!-- TODO: footer -->
<script async type="text/javascript" src="/static/js/bulma.js"></script>
</body>
-</html>
+
+</html> \ No newline at end of file
diff --git a/app/templates/progress.html b/app/templates/progress.html
new file mode 100644
index 0000000..c20484c
--- /dev/null
+++ b/app/templates/progress.html
@@ -0,0 +1,22 @@
+{% extends 'base/layout.html' %}
+
+{% block content %}
+<div class="container">
+ {% for completed_workout in exercises %}
+ <div class="columns">
+ <div class="column is-12">
+ <div class="box">
+ <canvas id="chart-{{ loop.index }}">
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+</div>
+
+<script type="text/javascript" src="/static/js/chart.js"></script>
+<script>
+ {% for completed_workout in exercises %}
+ exercise_chart('chart-{{ loop.index }}', {{ exercises[loop.index0].id }}, "{{ exercises[loop.index0].name }}");
+ {% endfor %}
+</script>
+{% endblock %} \ No newline at end of file
diff --git a/app/templates/workout/record.html b/app/templates/workout/record.html
index 1cfeda1..8207e1b 100644
--- a/app/templates/workout/record.html
+++ b/app/templates/workout/record.html
@@ -25,35 +25,36 @@
{% if exercise.type == 'time' %}
<tr data-is-timer=true data-timer-seconds={{ exercise.units}}>
{% else %}
- <tr data-is-reps=true>
- {% endif %}
- <th>{{ loop.index }}</th>
- {% if exercise.type == 'time' %}
- <td>
- <div class='timer' style="display:flex;align-items:center;font-size:1em;">
- <button id='timer-{{ outer_loop.index }}' type="button" onclick="onClickPausePlayTimer(this)" class="button">
- <span class="icon is-small">
- <i class="fa fa-play"></i>
- </span>
- </button>
- <span style='padding-left: 15px;' id='timer-time-{{ outer_loop.index }}'>
- {{ exercise.units }} seconds
- </span>
- </div>
- </td>
- {% else %}
- <td>{{ set['lbs'](class_='input', type='number', onkeydown='onKeyDown(event)') }}</td>
- <td>{{ set['units'](class_='input', onkeydown='onKeyDown(event)') }}</td>
- {% endif %}
- <td>
- <a class="button" onClick="onClickSetCheck(this)">
+ <tr data-is-reps=true>
+ {% endif %}
+ <th>{{ loop.index }}</th>
+ {% if exercise.type == 'time' %}
+ <td>
+ <div class='timer' style="display:flex;align-items:center;font-size:1em;">
+ <button id='timer-{{ outer_loop.index }}' type="button"
+ onclick="onClickPausePlayTimer(this)" class="button">
<span class="icon is-small">
- <i class="fa fa-check"></i>
+ <i class="fa fa-play"></i>
</span>
- </a>
- </td>
- </tr>
- {% endfor %}
+ </button>
+ <span style='padding-left: 15px;' id='timer-time-{{ outer_loop.index }}'>
+ {{ '%02d' % (exercise.units / 60) }}:{{ '%02d' % (exercise.units % 60) }}
+ </span>
+ </div>
+ </td>
+ {% else %}
+ <td>{{ set['lbs'](class_='input', type='number', onkeydown='onKeyDown(event)') }}</td>
+ <td>{{ set['units'](class_='input', onkeydown='onKeyDown(event)') }}</td>
+ {% endif %}
+ <td>
+ <a class="button" onClick="onClickSetCheck(this)">
+ <span class="icon is-small">
+ <i class="fa fa-check"></i>
+ </span>
+ </a>
+ </td>
+ </tr>
+ {% endfor %}
</tbody>
</table>
<div class="buttons is-centered">
@@ -80,4 +81,4 @@
<script async type="text/javascript" src="/static/js/record.js"></script>
-{% endblock %}
+{% endblock %} \ No newline at end of file
diff --git a/app/templates/workout/record_select.html b/app/templates/workout/record_select.html
index e6d88e6..2aaa3f0 100644
--- a/app/templates/workout/record_select.html
+++ b/app/templates/workout/record_select.html
@@ -13,14 +13,15 @@
<div class="content">
Exercises:
{% for exercise in workout.exercises %}
- <p>{{ exercise.sets }} x {{ exercise.units }}{% if exercise.type =='time' %} seconds{% endif %} x {{ exercise.name }}</p>
+ <p>{{ exercise.sets }}{% if exercise.type != 'time' %} x {{ exercise.units }}{% endif %} x {{
+ exercise.name }}</p>
{% endfor %}
- <a class="button is-primary" href="/workout/record/{{ workout.id }}">
- <span class="icon is-small">
- <i class="fa fa-play"></i>
- </span>
- <span>Start</span>
- </a>
+ <a class="button is-primary" href="/workout/record/{{ workout.id }}">
+ <span class="icon is-small">
+ <i class="fa fa-play"></i>
+ </span>
+ <span>Start</span>
+ </a>
</div>
</div>
</div>
@@ -47,4 +48,4 @@
</div>
</div>
-{% endblock %}
+{% endblock %} \ No newline at end of file