adding slider
This commit is contained in:
@@ -742,6 +742,8 @@ class PowerIntervalUpdateForm(forms.Form):
|
|||||||
required=True,
|
required=True,
|
||||||
initial='power',
|
initial='power',
|
||||||
label='Use')
|
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
|
# Form used to update interval stats
|
||||||
class IntervalUpdateForm(forms.Form):
|
class IntervalUpdateForm(forms.Form):
|
||||||
|
|||||||
@@ -7,6 +7,27 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{% include "monitorjobs.html" %}
|
{% 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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
@@ -47,22 +68,28 @@
|
|||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input class="button green" type="submit" value="Update">
|
<input class="button" type="submit" value="Update">
|
||||||
</form>
|
</form>
|
||||||
<h1>Intervals by Power/Pace</h1>
|
<h1>Intervals by Power/Pace</h1>
|
||||||
|
|
||||||
<p>With this form, you can specify a power or pace level. Everything faster/harder than the
|
<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
|
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>
|
</p>
|
||||||
|
|
||||||
<form ecntype="multipart/form-data" method="post">
|
<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>
|
<table>
|
||||||
{{ powerupdateform.as_table }}
|
{{ powerupdateform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input class="button green" type="submit" value="Submit">
|
<input class="button" type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
@@ -131,7 +158,7 @@
|
|||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
|
<input type="hidden" name="nrintervals" value={{ nrintervals }}>
|
||||||
<input class="button green" type="submit" value="Update">
|
<input class="button" type="submit" value="Update">
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_4">
|
<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")
|
return HttpResponse("Error: CSV Data File Not Found")
|
||||||
nrintervals = len(idist)
|
nrintervals = len(idist)
|
||||||
|
|
||||||
|
activeminutesmax = int(rowdata.duration/60.)
|
||||||
|
activeminutesmin = 0
|
||||||
|
maxminutes = activeminutesmax
|
||||||
|
|
||||||
savebutton = 'nosavebutton'
|
savebutton = 'nosavebutton'
|
||||||
formvalues = {}
|
formvalues = {}
|
||||||
@@ -5638,6 +5641,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
'selector': 'power',
|
'selector': 'power',
|
||||||
'work': int(normw),
|
'work': int(normw),
|
||||||
'spm': int(normspm),
|
'spm': int(normspm),
|
||||||
|
'activeminutesmin': 0,
|
||||||
|
'activeminutesmax': activeminutesmax,
|
||||||
}
|
}
|
||||||
|
|
||||||
powerorpace = 'power'
|
powerorpace = 'power'
|
||||||
@@ -5673,6 +5678,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
value_power = request.POST['value_power']
|
value_power = request.POST['value_power']
|
||||||
value_work = request.POST['value_work']
|
value_work = request.POST['value_work']
|
||||||
value_spm = request.POST['value_spm']
|
value_spm = request.POST['value_spm']
|
||||||
|
activeminutesmin = request.POST['activeminutesmin']
|
||||||
|
activeminutesmax = request.POST['activeminutesmax']
|
||||||
if powerorpace == 'power':
|
if powerorpace == 'power':
|
||||||
try:
|
try:
|
||||||
power = int(value_power)
|
power = int(value_power)
|
||||||
@@ -5745,7 +5752,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
'pace': datetime.timedelta(seconds=int(pace_secs)),
|
'pace': datetime.timedelta(seconds=int(pace_secs)),
|
||||||
'work': work,
|
'work': work,
|
||||||
'selector': powerorpace,
|
'selector': powerorpace,
|
||||||
'spm': int(normspm)
|
'spm': int(normspm),
|
||||||
|
'activeminutesmin': activeminutesmin,
|
||||||
|
'activeminutesmax': activeminutesmax,
|
||||||
}
|
}
|
||||||
form = SummaryStringForm()
|
form = SummaryStringForm()
|
||||||
powerupdateform = PowerIntervalUpdateForm(initial=data)
|
powerupdateform = PowerIntervalUpdateForm(initial=data)
|
||||||
@@ -5792,6 +5801,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
'selector': 'power',
|
'selector': 'power',
|
||||||
'work': int(normw),
|
'work': int(normw),
|
||||||
'spm': int(normspm),
|
'spm': int(normspm),
|
||||||
|
'activeminutesmin': 0,
|
||||||
|
'activeminutesmax': activeminutesmax,
|
||||||
})
|
})
|
||||||
savebutton = 'savestringform'
|
savebutton = 'savestringform'
|
||||||
|
|
||||||
@@ -5805,6 +5816,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
pace = cd['pace']
|
pace = cd['pace']
|
||||||
work = cd['work']
|
work = cd['work']
|
||||||
spm = cd['spm']
|
spm = cd['spm']
|
||||||
|
activeminutesmin = cd['activeminutesmin']
|
||||||
|
activeminutesmax = cd['activeminutesmax']
|
||||||
try:
|
try:
|
||||||
pace_secs = pace.seconds+pace.microseconds/1.0e6
|
pace_secs = pace.seconds+pace.microseconds/1.0e6
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -5849,6 +5862,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
'value_pace': pace_secs,
|
'value_pace': pace_secs,
|
||||||
'value_work': work,
|
'value_work': work,
|
||||||
'value_spm': spm,
|
'value_spm': spm,
|
||||||
|
'activeminutesmin': activeminutesmin,
|
||||||
|
'activeminutesmax': activeminutesmax,
|
||||||
}
|
}
|
||||||
powerupdateform = PowerIntervalUpdateForm(initial=cd)
|
powerupdateform = PowerIntervalUpdateForm(initial=cd)
|
||||||
form = SummaryStringForm()
|
form = SummaryStringForm()
|
||||||
@@ -5917,6 +5932,8 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
'selector': 'power',
|
'selector': 'power',
|
||||||
'work': int(normw),
|
'work': int(normw),
|
||||||
'spm': int(normspm),
|
'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',
|
return render(request, 'summary_edit.html',
|
||||||
{'form':form,
|
{'form':form,
|
||||||
|
'activeminutesmax':activeminutesmax,
|
||||||
|
'activeminutesmin':activeminutesmin,
|
||||||
|
'maxminutes': maxminutes,
|
||||||
'detailform':detailform,
|
'detailform':detailform,
|
||||||
'powerupdateform':powerupdateform,
|
'powerupdateform':powerupdateform,
|
||||||
'workout':row,
|
'workout':row,
|
||||||
|
|||||||
Reference in New Issue
Block a user