adding slider
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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">
|
||||
@@ -131,7 +158,7 @@
|
||||
</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">
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user