Jarvis/jarvis/followup/templates/chronos/list.html

303 lines
12 KiB
HTML

{% extends "listing.html" %}
{% block datacontent %}
<div class="card mb-0">
<div class="card-header">
<div class="row">
<div class="col-8">
<h4 class="">
{% if gymnast %}
<i><a href="{% url 'gymnast_details_tab' gymnast.id 'scores' %}">{{ gymnast }}</a></i>'s
{% endif %} chronos listing
</h4>
</div>
<div class="col-1 ml-auto">
<div class="text-right">
<a
href="{% if gymnast %}{% url 'chrono_create_for_gymnast' gymnast.id %}{% else %}{% url 'chrono_create' %}{% endif %}">
<button type="submit" value="add" class="btn btn-icon btn-warning ">
<i class="fas fa-plus"></i>
</button>
</a>
</div>
</div>
</div>
</div>
<div class="card-body vh-100">
{% if gymnast %}
<div class="row">
<div class="col-md-6">
<table class="table table-striped tablesorter" id="chrono_table">
<thead>
<tr>
<th style="width: 8%">&nbsp;</th>
<th style="width: 12%" class="header text-center">Date</th>
<th style="width: 20%" class="header text-center">Routine</th>
<th style="width: 15%" class="header text-center">Type</th>
<th style="width: 10%" class="header text-center">Score</th>
<th style="width: 10%" class="header text-center">TOF</th>
</tr>
</thead>
<tbody>
{% for chrono in chrono_list %}
<tr role="row" class="{% cycle 'odd' 'even' %}">
<td>
<a href="{% url 'chrono_update' chrono.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
&nbsp;
<a href="{% url 'jump_chrono_values_create_or_update' chrono.id %}">
<span class="far fa-search-plus text-warning"></span>
</a>
</td>
<td class="text-center">
{% if chrono.details.all %}
<a href="{% url 'jump_chrono_details' chrono.id %}">
{% endif %}
{{ chrono.date | date:"j-n-Y" }}
{% if chrono.details.all %}
</a>
{% endif %}
</td>
<td class="text-center">
{% if chrono.routine %}
{{ chrono.routine.long_label }}
{% else %}
{{ chrono.get_chrono_type_display }}
{% endif %}
</td>
<td class="text-center">{{ chrono.get_score_type_display }}</td>
<td class="text-center">{{ chrono.score }}</td>
<td class="text-center">{{ chrono.tof }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-6 pl-0 pr-0 pt-3">
<canvas id="chart_chrono" class="chartjs" width="100%">Your browser doesn't support canvas</canvas>
</div>
</div>
{% else %}
{% if chrono_list %}
<div class="table-responsive">
<table class="table table-striped tablesorter" id="chrono_table">
<thead>
<tr>
<th style="width: 6%">&nbsp;</th>
<th style="width: 12%" class="header">Date</th>
<th style="width: 25%" class="header text-left">Gymnast</th>
<th style="width: 25%" class="header text-left">Routine</th>
<th style="width: 15%" class="header">Type</th>
<th style="width: 10%" class="header text-center">Score</th>
<th style="width: 10%" class="header text-center">TOF</th>
</tr>
</thead>
<tbody>
{% for chrono in chrono_list %}
<tr role="row" class="{% cycle 'odd' 'even' %}">
<td>
<a href="{% url 'chrono_update' chrono.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
&nbsp;
<a href="{% url 'jump_chrono_values_create_or_update' chrono.id %}">
<span class="far fa-search-plus text-warning"></span>
</a>
</td>
<td>{% if chrono.details.all %}<a href="{% url 'jump_chrono_details' chrono.id %}">{% endif %}{{ chrono.date | date:"j-n-Y" }}{% if chrono.details.all %}</a>{% endif %}</td>
<td class="text-left">
{% if chrono.gymnast.id in request.session.available_gymnast or request.user.is_superuser %}<a href="{% url 'gymnast_details_tab' chrono.gymnast.id 'scores' %}">{% endif %}
{{ chrono.gymnast }}
</a>
</td>
<td class="text-left">
{% if chrono.routine %}
{{ chrono.routine.long_label }}
{% else %}
{{ chrono.get_chrono_type_display }}
{% endif %}
</td>
<td>{{ chrono.get_score_type_display }}</td>
<td class="text-center">{{ chrono.score }}</td>
<td class="text-center">{{ chrono.tof }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">There are no chronos corresponding to your criterias.</p>
{% endif %}
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% block footerscript %}
<script type="text/javascript">
$(document).ready(function () {
$('#chrono_table').tablesorter({
headers: {
0: { sorter: false },
},
dateFormat: "uk",
sortList: [[1, 1], [2, 1]]
});
$('#chrono_table').DataTable({
scrollY: '50vh',
scrollCollapse: true,
paging: false,
searching: false,
ordering: false,
"bInfo": false,
});
});
{% if chrono_list %}
var timeFormat = 'DD-MM-YYYY';
var ctx = document.getElementById('chart_chrono').getContext('2d');
var gradient_stroke_1 = ctx.createLinearGradient(0, 230, 0, 50);
var gradient_stroke_2 = ctx.createLinearGradient(0, 230, 0, 50);
var gradient_stroke_3 = ctx.createLinearGradient(0, 230, 0, 50);
var gradient_stroke_4 = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_1.addColorStop(0.75, 'rgba(75, 192, 192, 0.3)');
gradient_stroke_1.addColorStop(0.5, 'rgba(75, 192, 192, 0.2)');
gradient_stroke_1.addColorStop(0.25, 'rgba(75, 192, 192, 0)');
gradient_stroke_2.addColorStop(1, 'rgba(255, 99, 132, 0.4)');
gradient_stroke_2.addColorStop(0.75, 'rgba(255, 99, 132, 0.3)');
gradient_stroke_2.addColorStop(0.5, 'rgba(255, 99, 132, 0.2)');
gradient_stroke_2.addColorStop(0.25, 'rgba(255, 99, 132, 0)');
gradient_stroke_3.addColorStop(1, 'rgba(255, 159, 64, 0.4)');
gradient_stroke_3.addColorStop(0.75, 'rgba(255, 159, 64, 0.3)');
gradient_stroke_3.addColorStop(0.5, 'rgba(255, 159, 64, 0.2)');
gradient_stroke_3.addColorStop(0.25, 'rgba(255, 159, 64, 0)');
gradient_stroke_4.addColorStop(1, 'rgba(54, 162, 235, 0.4)');
gradient_stroke_4.addColorStop(0.75, 'rgba(54, 162, 235, 0.3)');
gradient_stroke_4.addColorStop(0.5, 'rgba(54, 162, 235, 0.2)');
gradient_stroke_4.addColorStop(0.25, 'rgba(54, 162, 235, 0)');
var straightjump_values = [
{% for chrono in chrono_10c %}
{
x: '{{ chrono.date | date:"d-m-Y" }}',
y: '{{ chrono.score_avg | floatformat:3 }}'
},
{% endfor %}
];
var compulsory_routine_values = [
{% for chrono in chrono_r1 %}
{
x: '{{ chrono.date | date:"d-m-Y" }}',
y: '{{ chrono.score_avg | floatformat:3 }}'
},
{% endfor %}
];
var volontary_routine_values = [
{% for chrono in chrono_r2 %}
{
x: '{{ chrono.date | date:"d-m-Y" }}',
y: '{{ chrono.score_avg | floatformat:3 }}'
},
{% endfor %}
];
var final_routine_values = [
{% for chrono in chrono_rf %}
{
x: '{{ chrono.date | date:"d-m-Y" }}',
y: '{{ chrono.score_avg | floatformat:3 }}'
},
{% endfor %}
];
var chrono_values = {
datasets: [
{% if chrono_10c %}
{
label: '10 |',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_1,
borderColor: 'rgb(75, 192, 192)',
pointBackgroundColor: 'rgb(75, 192, 192)',
fill: true,
data: straightjump_values,
},
{% endif %}
{% if chrono_r1 %}
{
label: 'Q1R1',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_2,
borderColor: 'rgb(255, 99, 132)',
pointBackgroundColor: 'rgb(255, 99, 132)',
fill: true,
data: compulsory_routine_values,
},
{% endif %}
{% if chrono_r2 %}
{
label: 'Q1R2',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_3,
borderColor: 'rgb(255, 159, 64)',
pointBackgroundColor: 'rgb(255, 159, 64)',
fill: true,
data: volontary_routine_values,
},
{% endif %}
{% if chrono_rf %}
{
label: 'Q2R1',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_4,
borderColor: 'rgb(255, 205, 86)',
pointBackgroundColor: 'rgb(255, 205, 86)',
fill: true,
data: final_routine_values,
},
{% endif %}
]
}
new Chart(ctx, {
type: 'line',
data: chrono_values,
options: {
scales: {
x: {
type: 'time',
display: true,
scaleLabel: {
display: true,
labelString: 'Date',
ticks: {
autoSkip: true,
source: 'data',
},
},
time: {
parser: timeFormat,
tooltipFormat: 'LL',
round: 'day',
},
},
},
plugins: {
legend: {
display: true,
position: 'bottom',
}
}
},
});
{% endif %}
</script>
{% endblock %}