now working with ajax
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{ the_script | safe }}
|
<div id="id_script">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
@@ -44,8 +46,24 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
<script type='text/javascript'
|
||||||
|
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function($) {
|
||||||
|
console.log('loading script for chart');
|
||||||
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/trainingzones/user/{{ rower.user.id }}/data/?startdate={{ startdate|date:"Y-m-d" }}&enddate={{ enddate|date:"Y-m-d" }}&zones={{ zones }}', function(json) {
|
||||||
|
var script = json.script;
|
||||||
|
var div = json.div;
|
||||||
|
$("#id_sitready").remove();
|
||||||
|
$("#id_chart").append(div);
|
||||||
|
$("#id_script").append(script);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
{% include 'menu_plan.html' %}
|
{% include 'menu_analytics.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -354,6 +354,8 @@ urlpatterns = [
|
|||||||
re_path(r'^performancemanager/user/(?P<userid>\d+)/(?P<mode>\w+.*)/$',views.performancemanager_view,name='performancemanager_view'),
|
re_path(r'^performancemanager/user/(?P<userid>\d+)/(?P<mode>\w+.*)/$',views.performancemanager_view,name='performancemanager_view'),
|
||||||
re_path(r'^trainingzones/$',views.trainingzones_view,name='trainingzones_view'),
|
re_path(r'^trainingzones/$',views.trainingzones_view,name='trainingzones_view'),
|
||||||
re_path(r'^trainingzones/user/(?P<userid>\d+)/$',views.trainingzones_view,name='trainingzones_view'),
|
re_path(r'^trainingzones/user/(?P<userid>\d+)/$',views.trainingzones_view,name='trainingzones_view'),
|
||||||
|
re_path(r'^trainingzones/user/(?P<userid>\d+)/data/$',views.trainingzones_view_data,name="trainingzones_view_data"),
|
||||||
|
re_path(r'^trainingzones/data/$',views.trainingzones_view_data,name="trainingzones_view_data"),
|
||||||
re_path(r'^ote-bests2/user/(?P<userid>\d+)/$',views.rankings_view2,name='rankings_view2'),
|
re_path(r'^ote-bests2/user/(?P<userid>\d+)/$',views.rankings_view2,name='rankings_view2'),
|
||||||
re_path(r'^ote-bests2/$',views.rankings_view2,name='rankings_view2'),
|
re_path(r'^ote-bests2/$',views.rankings_view2,name='rankings_view2'),
|
||||||
re_path(r'^analysisdata/$',views.analysis_view_data,name='analysis_view_data'),
|
re_path(r'^analysisdata/$',views.analysis_view_data,name='analysis_view_data'),
|
||||||
|
|||||||
@@ -1074,10 +1074,9 @@ def trainingzones_view(request,userid=0,mode='rower',
|
|||||||
enddate = form.cleaned_data['enddate']
|
enddate = form.cleaned_data['enddate']
|
||||||
zones = form.cleaned_data['zones']
|
zones = form.cleaned_data['zones']
|
||||||
|
|
||||||
data = get_zones_report(r,startdate,enddate,trainingzones=zones)
|
|
||||||
|
|
||||||
|
script = ''
|
||||||
script, div = interactive_zoneschart(r,data,startdate,enddate,trainingzones=zones)
|
div = get_call()
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
@@ -1098,9 +1097,40 @@ def trainingzones_view(request,userid=0,mode='rower',
|
|||||||
'the_script':script,
|
'the_script':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
'form':form,
|
'form':form,
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
'zones':zones,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def trainingzones_view_data(request,userid=0):
|
||||||
|
r = getrequestrower(request,userid=userid)
|
||||||
|
|
||||||
|
startdate = timezone.now()-datetime.timedelta(days=365)
|
||||||
|
enddate = timezone.now()
|
||||||
|
zones = 'hr'
|
||||||
|
|
||||||
|
if request.GET.get('zones'):
|
||||||
|
zones = request.GET.get('zones')
|
||||||
|
|
||||||
|
if request.GET.get('startdate'):
|
||||||
|
startdate = datetime.datetime.strptime(request.GET.get('startdate'),"%Y-%m-%d")
|
||||||
|
|
||||||
|
if request.GET.get('enddate'):
|
||||||
|
enddate = datetime.datetime.strptime(request.GET.get('enddate'),"%Y-%m-%d")
|
||||||
|
|
||||||
|
|
||||||
|
data = get_zones_report(r,startdate,enddate,trainingzones=zones)
|
||||||
|
|
||||||
|
script, div = interactive_zoneschart(r,data,startdate,enddate,trainingzones=zones)
|
||||||
|
|
||||||
|
return JSONResponse({
|
||||||
|
'script': script,
|
||||||
|
'div': div,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||||
|
|||||||
Reference in New Issue
Block a user