Private
Public Access
1
0
Files
rowsandall/rowers/templates/performancemanager.html
2020-12-02 11:56:40 +01:00

131 lines
3.5 KiB
HTML

{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block title %}Rowsandall Fitness Progress {% endblock %}
{% block scripts %}
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
</script>
<script>
function submit_form() {
console.log("form changed");
var frm = $("#performanceform");
var data = new FormData(frm[0]);
$.ajax({
url:"/rowers/performancemanager/user/{{ rower.user.id }}/",
type: "POST",
contentType: false,
processData: false,
data: data,
dataType: 'json',
success: function(data) {
console.log(data);
// var parsedJSON = $.parseJSON(data); //
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
console.log('done');
}
});
};
$(document).ready(function() {
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
console.log("CSRF token",csrftoken);
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
$("#performanceform").on('change', function(evt) {
submit_form();
});
});
</script>
{% endblock %}
{% block main %}
<script src="https://cdn.pydata.org/bokeh/release/bokeh-2.2.3.min.js"></script>
<script async="true" type="text/javascript">
Bokeh.set_log_level("info");
</script>
<div id="id_script">
{{ chartscript |safe }}
</div>
{% if rower.user %}
<h1>Fitness Progress for {{ rower.user.first_name }} </h1>
{% else %}
<h1>Fitness Progress for {{ user.first_name }} </h1>
{% endif %}
<ul class="main-content">
<li class="grid_4">
<div id="id_chart">
{{ the_div|safe }}
</div>
</li>
<li class="grid_2">
<form id="performanceform" enctype="multipart/form-data" method="post">
<table>
{{ form.as_table }}
</table>
{% csrf_token %}
<input name='form' class="button" type="submit" value="Submit">
</form>
</li>
<li class="grid_2">
<p>
The Performance Manager on this page is based on scientific literature
on modeling human performance. A good description can be found
<a href="https://fellrnr.com/wiki/Modeling_Human_Performance" target="_">here</a>.
Every person is different. This statement has implications for training and modeling of
training impact. Each person differs in their response to training, diet, rest, or
other factors. You are an experiment of one, a unique person and all models are
wrong (but some are useful). Be prepared to learn from this chart, to experiment
and perhaps to go against established advice.
</p>
<p>
The chart models your performance over a time period that you can set with the form
on the left. The model balances out after a few weeks of regular training, so don't
make this chart shorter than a few months.
</p>
<p>
The time constants used in generating this performance chart were
a fitness decay constant of {{ rower.kfit }} days
and a fatigue decay constant of {{ rower.kfatigue }} days.
You can change these values in your <a href="/rowers/me/preferences/">Profile Settings</a>.
</p>
</li>
</ul>
{% endblock %}
{% block sidebar %}
{% include 'menu_analytics.html' %}
{% endblock %}