[chronojump-server] Enabling filter by 1d,3d,7d and 14d in results
- From: Marcos Venteo Garcia <mventeo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Enabling filter by 1d,3d,7d and 14d in results
- Date: Sun, 28 May 2017 19:27:06 +0000 (UTC)
commit 9851ecca46a5d7120d127051aa4e40a9134d50ec
Author: Marcos Venteo <mventeo gmail com>
Date: Sun May 28 21:26:44 2017 +0200
Enabling filter by 1d,3d,7d and 14d in results
chronojump-flask/chronojump_server.py | 22 ++++++++-
chronojump-flask/templates/results.html | 74 ++++++++++++++++++++++++++----
2 files changed, 84 insertions(+), 12 deletions(-)
---
diff --git a/chronojump-flask/chronojump_server.py b/chronojump-flask/chronojump_server.py
index aca01fc..d070585 100644
--- a/chronojump-flask/chronojump_server.py
+++ b/chronojump-flask/chronojump_server.py
@@ -175,8 +175,26 @@ def get_all_results():
cursor = db.cursor()
cursor.execute(sql)
rows = cursor.fetchall()
-
- return rows
+ _results = []
+ for row in rows:
+ _results.append({
+ 'id': row[0],
+ 'date': row[1],
+ 'person': row[2],
+ 'station': row[3],
+ 'exercise': row[4],
+ 'resistance': row[5],
+ 'repetitions': row[6],
+ 'lossBySpeed': row[7],
+ 'numBySpeed': row[8],
+ 'rangeBySpeed': row[9],
+ 'vmeanBySpeed': row[10],
+ 'vmaxBySpeed': row[11],
+ 'pmeanBySpeed': row[12],
+ 'pmaxBySpeed': row[13],
+ 'comments': row[14]
+ })
+ return _results
def get_all_players():
"""Get all the players, with the tasks associated with them."""
diff --git a/chronojump-flask/templates/results.html b/chronojump-flask/templates/results.html
index 875b0c5..d26c404 100644
--- a/chronojump-flask/templates/results.html
+++ b/chronojump-flask/templates/results.html
@@ -5,25 +5,67 @@
<script src="{{ url_for('static', filename='DataTables/media/js/dataTables.bootstrap.min.js') }}"></script>
<script type="text/javascript">
-jQuery.fn.dataTableExt.oSort["customdate-desc"] = function (x, y) {
- console.log('asc order');
+$.fn.dataTableExt.oSort["customdate-desc"] = function (x, y) {
+ var table = $('#results').DataTable();
+
+
+
+ console.log('Order by id desc');
};
-jQuery.fn.dataTableExt.oSort["customdate-asc"] = function (x, y) {
- console.log('desc order');
-}
+$.fn.dataTableExt.oSort["customdate-asc"] = function (x, y) {
+ var table = $('#results').DataTable();
+
+
+
+ console.log('Order by id asc');
+ }
+
+ $
$(document).ready(function() {
// Initialize datatable with results
+ $("input[name='filterByDayOptions']").on('click', function() {
+ var table = $('#results').DataTable();
+ table.draw();
+ });
+
+ $.fn.dataTable.ext.search.push(
+ function( settings, data, dataIndex ) {
+ var filter = $("input[name='filterByDayOptions']:checked").val();
+ var date = Date.parse(data[1]); // use data for the age column
+ var d = new Date();
+ if (filter != "all") {
+ d.setDate(d.getDate() - filter);
+ if ( date >= d )
+ {
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }
+
+
+ }
+);
+
var table = $('#results').DataTable({
"columns": [{
type: "num",
title: "id",
+ data: "id",
visible: false
},
{
type: "date",
+ data: "date",
+ visible: false
+ },
+ {
+ type: "customdate",
title: "Data",
+ data: "date",
render: function(value) {
// Compare with today
today = new Date();
@@ -51,56 +93,68 @@ jQuery.fn.dataTableExt.oSort["customdate-asc"] = function (x, y) {
},
{
type: "html",
+ data: "person",
title: "Jugador"
},
{
type: "html",
+ data: "station",
title: "Estació"
},
{
type: "html",
+ data: "exercise",
title: "Exercici"
},
{
type: "num",
title: "Càrrega",
+ data: "resistance",
render: $.fn.dataTable.render.number('', ',', 2)
},
{
type: "num",
+ data: "repetitions",
title: "n"
},
{
type: "num",
+ data: "lossBySpeed",
title: "Pèrdua"
},
{
type: "num",
+ data: "numBySpeed",
title: "[rep"
},
{
type: "num",
+ data: "rangeBySpeed",
title: "rang",
render: $.fn.dataTable.render.number('', ',', 2)
},
{
type: "num",
title: "Vm",
+ data: "vmeanBySpeed",
render: $.fn.dataTable.render.number('', ',', 2)
},
{
type: "num",
title: "VM",
+ data: "vmaxBySpeed",
render: $.fn.dataTable.render.number('', ',', 2)
},
{
type: "num",
title: "Pm",
+ data: "pmeanBySpeed",
render: $.fn.dataTable.render.number('', ',', 2)
},
{
type: "num",
title: "PM]",
+ data: "pmaxBySpeed",
render: $.fn.dataTable.render.number('', ',', 2)
}
],
@@ -203,19 +257,19 @@ jQuery.fn.dataTableExt.oSort["customdate-asc"] = function (x, y) {
<div class="row" style="margin-top: 15px;">
<div class="col-sm-3">
<label class="radio-inline dayfilter" style="margin-top:5px">
- <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1" disabled>1d
+ <input type="radio" name="filterByDayOptions" id="filterByDay1" value="1" >1d
</label>
<label class="radio-inline dayfilter" style="margin-top:5px">
- <input type="radio" name="inlineRadioOptions" id="inlineRadio2"
value="option2"disabled="">3d
+ <input type="radio" name="filterByDayOptions" id="filterByDay2" value="3">3d
</label>
<label class="radio-inline dayfilter" style="margin-top:5px">
- <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>7d
+ <input type="radio" name="filterByDayOptions" id="filterByDay3" value="7">7d
</label>
<label class="radio-inline dayfilter" style="margin-top:5px">
- <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>14d
+ <input type="radio" name="filterByDayOptions" id="filterByDay4" value="14">14d
</label>
<label class="radio-inline dayfilter" style="margin-top:5px">
- <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" checked>Tots
+ <input type="radio" name="filterByDayOptions" id="filterByDay5" value="all" checked>Tots
</label>
</div>
<div class="col-sm-3">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]