Private
Public Access
1
0

totaldisct in ajax call

This commit is contained in:
Sander Roosendaal
2020-05-06 21:56:19 +02:00
parent cf47afe538
commit 4711a9f860
2 changed files with 72 additions and 28 deletions

View File

@@ -58,16 +58,16 @@
<td>Number of workouts</td><td>{{ totalsdict|lookup:"nrworkouts"}}</td>
</tr>
<tr>
<td>Average heart rate</td><td>{{ totalsdict|lookup:"hrmean"}} bpm</td>
<td>Average heart rate</td><td><span id="total_hr"></span> bpm</td>
</tr>
<tr>
<td>Maximum heart rate</td><td>{{ totalsdict|lookup:"hrmax"}} bpm</td>
<td>Maximum heart rate</td><td><span id="total_maxhr"></span> bpm</td>
</tr>
<tr>
<td>Average power</td><td>{{ totalsdict|lookup:"powermean"}} W</td>
<td>Average power</td><td><span id="total_power"></span> W</td>
</tr>
<tr>
<td>Maximum power</td><td>{{ totalsdict|lookup:"powermax"}} W</td>
<td>Maximum power</td><td><span id="total_maxpower"></span> W</td>
</tr>
</tbody>
</table>
@@ -125,17 +125,21 @@
<script>
$(function($) {
console.log('loading script for chart');
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/', function(json) {
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ startdate|date:"Y-m-d" }}&{{ enddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
var script = json.script;
var div = json.div;
var totalsdict = json.totalsdict
$("#id_sitready").remove();
$("#id_chart").append(div);
console.log(div);
// $("#id_script").append("<s"+"cript>"+script+"</s"+"cript>");
$("#id_script").append(script);
$("#total_hr").append(totalsdict.hrmean);
$("#total_maxhr").append(totalsdict.hrmax);
$("#total_power").append(totalsdict.powermean);
$("#total_maxpower").append(totalsdict.powermax);
});
});
</script>