From 4646027ec628d0e77f999a02f24758f28b9d15ba Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 20 Jul 2022 08:10:05 +0200 Subject: [PATCH] including time range --- rowers/forms.py | 4 ++ rowers/templates/instroke_interactive.html | 63 +++++++++++++++------- rowers/views/workoutviews.py | 35 ++++++++---- 3 files changed, 74 insertions(+), 28 deletions(-) diff --git a/rowers/forms.py b/rowers/forms.py index 5501e224..925174b0 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -153,6 +153,10 @@ class InstrokeForm(forms.Form): metric = forms.ChoiceField(label='metric',choices=(('a','a'),('b','b'))) spm_min = forms.IntegerField(initial=15,label='SPM Min',widget=HiddenInput) spm_max = forms.IntegerField(initial=45,label='SPM Max',widget=HiddenInput) + activeminutesmin = forms.IntegerField( + required=False, initial=0, widget=forms.HiddenInput()) + activeminutesmax = forms.IntegerField( + required=False, initial=0, widget=forms.HiddenInput()) def __init__(self, *args, **kwargs): # pragma: no cover choices = kwargs.pop('choices', []) diff --git a/rowers/templates/instroke_interactive.html b/rowers/templates/instroke_interactive.html index ade61f5c..7679dd0b 100644 --- a/rowers/templates/instroke_interactive.html +++ b/rowers/templates/instroke_interactive.html @@ -64,18 +64,40 @@ $( function() { max: 60, values: [ {{ spm_min }}, {{ spm_max }} ], slide: function( event, ui ) { + $( "#amountspm" ).val(ui.values[ 0 ] + " - " + ui.values[ 1 ] ); $( "#id_spm_min" ).val( ui.values[ 0 ]); $( "#id_spm_max" ).val(ui.values[ 1 ] ); - $( "#spm_min_info" ).text( ui.values[ 0 ]); - $( "#spm_max_info" ).text(ui.values[ 1 ] ); + } }); + $( "#amountspm" ).val($( "#slider-range" ).slider( "values", 0 ) + + " - " + $( "#slider-range" ).slider( "values", 1 )); + +} ); + + + {% endblock %} @@ -97,6 +119,25 @@ $( function() {

In Stroke Metrics

    +
  • +
    + {% csrf_token %} + + {{ form.as_table }} +
    +
    +

    + + +

    +
    +

    + + +

    + +
    +
  • {{ dd|safe }} @@ -107,22 +148,6 @@ $( function() { {{ the_div|safe }}
  • -
  • -
    - {% csrf_token %} - - {{ form.as_table }} -
    -
    - SPM (slide to change): - {{ spm_min }} -  -  - {{ spm_max }} -
    -
    - -
    -
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 34e57910..0ba1d350 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -2934,26 +2934,40 @@ def instroke_chart_interactive(request, id=0): spm_min = 15 spm_max = 45 + activeminutesmax = int(rowdata.duration/60.) + activeminutesmin = 0 + maxminutes = activeminutesmax + if request.method == 'POST': form = InstrokeForm(request.POST,choices=instrokemetrics) if form.is_valid(): metric = form.cleaned_data['metric'] spm_min = form.cleaned_data['spm_min'] spm_max = form.cleaned_data['spm_max'] + activeminutesmin = form.cleaned_data['activeminutesmin'] + activeminutesmax = form.cleaned_data['activeminutesmax'] + + activesecondsmin = 60.*activeminutesmin + activesecondsmax = 60.*activeminutesmax - data = rowdata.get_instroke_data(metric, - spm_min=spm_min, - spm_max=spm_max) + data = rowdata.get_instroke_data( + metric, + spm_min=spm_min, + spm_max=spm_max, + ) - script, div = instroke_interactive_chart(data, metric, w, - spm_min, - spm_max) + script, div = instroke_interactive_chart( + data, metric, w, + spm_min, + spm_max, + ) # change to range spm_min to spm_max - vals, units, typ = rowdata.updateinterval_metric( - ' Cadence (stokes/min)', spm_min, mode='larger', - debug=False, smoothwindow=2.,) + vals, units, typ = rowdata.updateinterval_range( + ' Cadence (stokes/min)', spm_min, spm_max, + debug=False, smoothwindow=2., + activewindow=[activesecondsmin, activesecondsmax]) intervalstats = rowdata.allstats() itime, idist, itype = rowdata.intervalstats_values() @@ -3013,6 +3027,9 @@ def instroke_chart_interactive(request, id=0): 'spm_max': spm_max, 'ds': ds, 'dd': dd, + 'activeminutesmin': activeminutesmin, + 'activeminutesmax': activeminutesmax, + 'maxminutes': maxminutes, })