Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add progress bar to the timer pages to check exercises left to do

Roland Geider114758dabdce
diff --git a/wger/manager/templates/workout/timer.html b/wger/manager/templates/workout/timer.html
index c20dd94d6..d51b2a238 100644
--- a/wger/manager/templates/workout/timer.html
+++ b/wger/manager/templates/workout/timer.html
@@ -54,6 +54,13 @@ a.bottom_button{
bottom: 0px;
}
+div.progress-bar{
+ height: 1px;
+ position: absolute;
+ bottom: 0px;
+ background-color: gray;
+}
+
</style>
<script>
/*
@@ -286,6 +293,7 @@ $(document).ready(function() {
</div>
</div><!-- /grid-a -->
+ <div id="progress-{{step.current_step}}" class="progress-bar" style="width: {{step.step_percent|stringformat:'f'}}%;"></div>
</li>
{% else %}
<li class="timer-step pause-step"
@@ -319,6 +327,8 @@ $(document).ready(function() {
data-role="button"
data-icon="arrow-r"
data-iconpos="right">{% trans "skip" %}</a>
+
+ <div id="progress-{{step.current_step}}" class="progress-bar" style="width: {{step.step_percent|stringformat:'f'}}%;"></div>
</li>
{% endif %}
{% endfor %}
diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py
index 17e409c78..782984122 100644
--- a/wger/manager/views/workout.py
+++ b/wger/manager/views/workout.py
@@ -265,17 +265,17 @@ def timer(request, pk):
day = Day.objects.get(pk=pk, training__user=request.user)
canonical_day = day.canonical_representation
context = {}
- context['day'] = day
step_list = []
+ # Go through the workout day and create the individual 'pages'
for set_dict in canonical_day:
if not set_dict['is_superset']:
for exercise_dict in set_dict['exercise_list']:
exercise = exercise_dict['obj']
for reps in exercise_dict['setting_list']:
-
step_list.append({'current_step': uuid.uuid4().hex,
+ 'step_percent': 0,
'exercise': exercise,
'type': 'exercise',
'reps': reps,
@@ -284,6 +284,7 @@ def timer(request, pk):
reps=reps)})
step_list.append({'current_step': uuid.uuid4().hex,
+ 'step_percent': 0,
'type': 'pause',
'time': 30})
@@ -296,6 +297,7 @@ def timer(request, pk):
exercise = exercise_dict['obj']
step_list.append({'current_step': uuid.uuid4().hex,
+ 'step_percent': 0,
'exercise': exercise,
'type': 'exercise',
'reps': reps,
@@ -304,9 +306,15 @@ def timer(request, pk):
reps=reps)})
step_list.append({'current_step': uuid.uuid4().hex,
- 'type': 'pause',
- 'time': 30})
+ 'step_percent': 0,
+ 'type': 'pause',
+ 'time': 30})
+ # Go through the page list and calculate the correct value for step_percent
+ for i, s in enumerate(step_list):
+ step_list[i]['step_percent'] = (i + 1) * 100.0 / len(step_list),
+
+ context['day'] = day
context['step_list'] = step_list
context['canonical_day'] = canonical_day
context['workout'] = day.training