Private
Public Access
1
0

adding slider

This commit is contained in:
Sander Roosendaal
2020-02-22 15:26:45 +01:00
parent 0703505219
commit ada370f007
3 changed files with 61 additions and 12 deletions

View File

@@ -742,6 +742,8 @@ class PowerIntervalUpdateForm(forms.Form):
required=True,
initial='power',
label='Use')
activeminutesmin = forms.IntegerField(required=False,initial=0,widget=forms.HiddenInput())
activeminutesmax = forms.IntegerField(required=False,initial=0,widget=forms.HiddenInput())
# Form used to update interval stats
class IntervalUpdateForm(forms.Form):

View File

@@ -7,6 +7,27 @@
{% block scripts %}
{% include "monitorjobs.html" %}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
console.log({{ activeminutesmin }}, {{ activeminutesmax}}, 'active range');
$( "#slider-range" ).slider({
range: true,
min: 0,
max: {{ maxminutes }},
values: [ {{ activeminutesmin }}, {{ activeminutesmax }} ],
slide: function( event, ui ) {
$( "#amount" ).val(ui.values[ 0 ] + " min - " + ui.values[ 1 ] + " min " );
$("#id_activeminutesmin").val(ui.values[0]);
$("#id_activeminutesmax").val(ui.values[1]);
}
});
$( "#amount" ).val($( "#slider-range" ).slider( "values", 0 ) +
" min - " + $( "#slider-range" ).slider( "values", 1 ) + " min ");
} );
</script>
{% endblock %}
{% block main %}
@@ -47,22 +68,28 @@
{{ form.as_table }}
</table>
{% csrf_token %}
<input class="button green" type="submit" value="Update">
<input class="button" type="submit" value="Update">
</form>
<h1>Intervals by Power/Pace</h1>
<p>With this form, you can specify a power or pace level. Everything faster/harder than the
specified pace/power will become a work interval. Everything slower will become a rest
interval.
interval. Use the slider to limit the active range. Everything outside the active range will
become rest (warming up and cooling down).
</p>
<form ecntype="multipart/form-data" method="post">
<div id="slider-range"></div>
<p>
<label for="amount">Active Range:</label>
<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
</p>
<table>
{{ powerupdateform.as_table }}
</table>
{% csrf_token %}
<input class="button green" type="submit" value="Submit">
<input class="button" type="submit" value="Submit">
</form>
</li>
<li class="grid_2">
@@ -70,7 +97,7 @@
<script async="true" type="text/javascript">
Bokeh.set_log_level("info");
</script>
{{ interactiveplot |safe }}
{{ the_div |safe }}
@@ -106,7 +133,7 @@
<h1>Detailed Summary Edit</h1>
<p>This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save in the Updated Summary section. You can use the restore original button to restore the original values.</p>
<form enctype="multipart/form-data" action="/rowers/workout/{{ workout.id|encode }}/editintervals/" method="post">
<table width=100%>
<table width=100%>
<thead>
<tr>
<th>#</th><th>Time</th><th>Distance</th><th>Type</th>
@@ -131,18 +158,18 @@
</table>
{% csrf_token %}
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
<input class="button green" type="submit" value="Update">
<input class="button" type="submit" value="Update">
</form>
</li>
<li class="grid_4">
<h1 id="howto">Interval Shorthand How-To</h1>
<p>This is a quick way to enter the intervals using a special mini-language.</p>
<p>You enter something like <em>8x500m/3min</em>, press "Update" and the site will interpret this for you and update the summary on the right. If you're happy with the result, press the green Save button to update the values. Nothing will be changed permanently until you hit Save.</p>
<p>Special characters are <em>x</em> (times), <em>+</em> and <em>/</em> (denotes a rest interval), as well as <em>(</em> and <em>)</em>. Units are <em>min</em> (minutes), <em>sec</em> (seconds), <em>m</em> (meters) and <em>km</em> (km). </p>
<p>A typical interval is described as "<b>10min/5min</b>", with the work part before the "<b>/</b>" and the rest part after it. A zero rest can be omitted, so a single 1000m piece could be described either as "<b>1km</b>" or "<b>1000m</b>". The basic units can be combined with "<b>+</b>" and "<b>Nx</b>". You can use parentheses as in the example below.</p>
<p>Here are a few examples.</p>
<table class="listtable" width=100%>
<tr>

View File

@@ -5605,6 +5605,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
return HttpResponse("Error: CSV Data File Not Found")
nrintervals = len(idist)
activeminutesmax = int(rowdata.duration/60.)
activeminutesmin = 0
maxminutes = activeminutesmax
savebutton = 'nosavebutton'
formvalues = {}
@@ -5638,6 +5641,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'selector': 'power',
'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
}
powerorpace = 'power'
@@ -5673,6 +5678,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
value_power = request.POST['value_power']
value_work = request.POST['value_work']
value_spm = request.POST['value_spm']
activeminutesmin = request.POST['activeminutesmin']
activeminutesmax = request.POST['activeminutesmax']
if powerorpace == 'power':
try:
power = int(value_power)
@@ -5745,7 +5752,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'pace': datetime.timedelta(seconds=int(pace_secs)),
'work': work,
'selector': powerorpace,
'spm': int(normspm)
'spm': int(normspm),
'activeminutesmin': activeminutesmin,
'activeminutesmax': activeminutesmax,
}
form = SummaryStringForm()
powerupdateform = PowerIntervalUpdateForm(initial=data)
@@ -5792,6 +5801,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'selector': 'power',
'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
})
savebutton = 'savestringform'
@@ -5805,6 +5816,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
pace = cd['pace']
work = cd['work']
spm = cd['spm']
activeminutesmin = cd['activeminutesmin']
activeminutesmax = cd['activeminutesmax']
try:
pace_secs = pace.seconds+pace.microseconds/1.0e6
except AttributeError:
@@ -5849,6 +5862,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'value_pace': pace_secs,
'value_work': work,
'value_spm': spm,
'activeminutesmin': activeminutesmin,
'activeminutesmax': activeminutesmax,
}
powerupdateform = PowerIntervalUpdateForm(initial=cd)
form = SummaryStringForm()
@@ -5917,6 +5932,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
'selector': 'power',
'work': int(normw),
'spm': int(normspm),
'activeminutesmin': 0,
'activeminutesmax': activeminutesmax,
})
@@ -6000,6 +6017,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
return render(request, 'summary_edit.html',
{'form':form,
'activeminutesmax':activeminutesmax,
'activeminutesmin':activeminutesmin,
'maxminutes': maxminutes,
'detailform':detailform,
'powerupdateform':powerupdateform,
'workout':row,