[chronojump-server] Missing files in the last commit for sprints and stations both templates and javascript files
- From: Marcos Venteo Garcia <mventeo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Missing files in the last commit for sprints and stations both templates and javascript files
- Date: Sun, 25 Jun 2017 22:34:49 +0000 (UTC)
commit f31a2c60b1d5781268ab80d3e234319613f7b8b8
Author: Marcos Venteo García <mventeo gmail com>
Date: Mon Jun 26 00:34:36 2017 +0200
Missing files in the last commit for sprints and stations both templates and javascript files
chronojumpserver/js/sprints.js | 237 ++++++++++++++++++++++++++
chronojumpserver/js/stations.js | 94 ++++++++++
chronojumpserver/templates/sprints.html | 48 +++++
chronojumpserver/templates/station_list.html | 59 +++++++
4 files changed, 438 insertions(+), 0 deletions(-)
---
diff --git a/chronojumpserver/js/sprints.js b/chronojumpserver/js/sprints.js
new file mode 100644
index 0000000..cc1401b
--- /dev/null
+++ b/chronojumpserver/js/sprints.js
@@ -0,0 +1,237 @@
+/*!
+ * Results javascript functions for Chronojump Server
+ * Author: Marcos Venteo <mventeo gmail com>
+ * version: 1.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+$(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 - 1);
+ if (date >= d) {
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }
+
+
+ }
+ );
+
+ var table = $('#sprints').DataTable({
+ "columns": [{
+ type: "num",
+ title: "id",
+ data: "id",
+ visible: false
+ },
+ {
+ type: "date",
+ data: "dt",
+ visible: false
+ },
+ {
+ type: "customdate",
+ title: "Data",
+ data: "dt",
+ render: function(value) {
+ // Compare with today
+ today = new Date();
+ var dd = today.getDate();
+ var mm = today.getMonth();
+ var yy = today.getFullYear();
+
+ var dt = new Date(value);
+ var dd2 = dt.getDate();
+ var mm2 = dt.getMonth();
+ var yy2 = dt.getFullYear();
+ var hh = dt.getHours();
+ var MM = dt.getMinutes();
+ if (dd == dd2 && mm == mm2 && yy == yy2) {
+ // Today, show the result hours and minute
+ return hh + ":" + MM;
+ } else if (yy == yy2) {
+ // Same year
+ return dd2 + "/" + (mm2 + 1) + " " + hh + ":" + MM;
+ } else {
+ return dd2 + "/" + (mm2 + 1) + "/" + yy2 + " " + hh + ":" + MM;
+ }
+
+ }
+ },
+ {
+ type: "html",
+ data: "personId",
+ title: "Jugador"
+ },
+ {
+ type: "html",
+ title: "Distancia",
+ data: "distances"
+ },
+ {
+ type: "html",
+ title: "Temps",
+ data: "times"
+ },
+ {
+ type: "num",
+ data: "k",
+ title: "k",
+ className: 'colResult',
+ render: $.fn.dataTable.render.number('', ',', 2)
+ },
+ {
+ type: "num",
+ title: "VMax",
+ data: "vmax",
+ className: 'colResult',
+ render: $.fn.dataTable.render.number('', ',', 2)
+ },
+ {
+ type: "num",
+ title: "AMax",
+ data: "amax",
+ className: 'colResult',
+ render: $.fn.dataTable.render.number('', ',', 2)
+ },
+ {
+ type: "num",
+ title: "FMax",
+ data: "fmax",
+ className: 'colResult',
+ render: $.fn.dataTable.render.number('', ',', 2)
+ },
+ {
+ type: "num",
+ title: "PMax",
+ data: "pmax",
+ className: 'colResult',
+ render: $.fn.dataTable.render.number('', ',', 2)
+ }
+ ],
+ "pageLength": 10,
+ "order": [
+ [0, 'desc']
+ ],
+ "ajax": "/api/v1/sprints",
+ "processing": true,
+ "severSide": true,
+ "language": {
+ "lengthMenu": "Mostrant _MENU_ resultats per pàgina",
+ "zeroRecords": "No hi han resultats per mostrar",
+ "info": "Mostrant els resultats _START_ a _END_ d'un total de _TOTAL_",
+ "infoEmpty": "La busqueda no ha retornat resultats",
+ "infoFiltered": "(filtrat de _MAX_ resultats)",
+ "decimal": ",",
+ "thousands": ".",
+ "paginate": {
+ "first": '<i class="fa fa-fast-backward"></i>',
+ "last": '<i class="fa fa-fast-forward"></i>',
+ "next": '<i class="fa fa-forward"></i>',
+ "previous": '<i class="fa fa-backward"></i>'
+ },
+ "search": "Cerca:"
+ },
+ initComplete: function() {
+ /*
+ The following functions are to create the filters for results view,
+ by player, exercice and station.
+ */
+ this.api().columns().every(function() {
+
+ var column = this;
+ var idx = column.index();
+ if (idx == 3) {
+ var select = $('<select class="form-control"><option value="">Tots els jugadors</option></select>')
+ .appendTo($('#filterByPlayer'))
+ .on('change', function() {
+ // Player selected
+ var val = $.fn.dataTable.util.escapeRegex(
+ $(this).val()
+ );
+
+ column
+ .search(val ? '^' + val + '$' : '', true, false)
+ .draw();
+ // Hide column if is a selected Player
+ //console.log(val);
+ column.visible(val == '');
+ });
+
+ column.data().unique().sort().each(function(d, j) {
+ select.append('<option value="' + d + '">' + d + '</option>')
+ });
+ } else if (idx == 4) {
+ var select = $('<select class="form-control"><option value="">Totes les
estacions</option></select>')
+ .appendTo($('#filterByStation'))
+ .on('change', function() {
+ var val = $.fn.dataTable.util.escapeRegex(
+ $(this).val()
+ );
+
+ column
+ .search(val ? '^' + val + '$' : '', true, false)
+ .draw();
+ column.visible(val == '');
+ });
+
+ column.data().unique().sort().each(function(d, j) {
+ select.append('<option value="' + d + '">' + d + '</option>')
+ });
+ } else if (idx == 5) {
+ var select = $('<select class="form-control"><option value="">Tots els
exercicis</option></select>')
+ .appendTo($('#filterByExercice'))
+ .on('change', function() {
+ var val = $.fn.dataTable.util.escapeRegex(
+ $(this).val()
+ );
+
+ column
+ .search(val ? '^' + val + '$' : '', true, false)
+ .draw();
+ column.visible(val == '');
+ });
+
+ column.data().unique().sort().each(function(d, j) {
+ select.append('<option value="' + d + '">' + d + '</option>')
+ });
+ }
+ });
+ }
+ });
+
+
+ setInterval(function() {
+ /* Set the interval for refresh */
+ table.ajax.reload(null, false);
+ }, 5000);
+
+});
diff --git a/chronojumpserver/js/stations.js b/chronojumpserver/js/stations.js
new file mode 100644
index 0000000..6e3c060
--- /dev/null
+++ b/chronojumpserver/js/stations.js
@@ -0,0 +1,94 @@
+/*!
+ * Station javascript functions for Chronojump Server
+ * Author: Marcos Venteo <mventeo gmail com>
+ * version: 1.0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+function loadExercises(station_id, first=false) {
+ if ( first == false) {
+ $('#exercises').DataTable().destroy();
+ }
+ var table = $('#exercises').DataTable({
+ "columns": [
+ {
+ type: "num",
+ title: "id",
+ data: 'id',
+ visible: false
+ },
+ {
+ type: "html",
+ data: "name",
+ title: "Nom"
+ },
+ {
+ type: "num",
+ data: 'percentBodyMassDisplaced',
+ title: "% Masa de Cos Desplaçada",
+ render: $.fn.dataTable.render.number('', ',', 2)
+ }
+ ],
+ "pageLength": 10,
+ "ajax": {
+ 'url': "/api/v1/exercises",
+ 'method': 'GET',
+ 'data': {
+ station_id: station_id
+ }
+ },
+ "processing": true,
+ "severSide": true,
+ "searching": false,
+ "bPaginate": false,
+ "bLengthChange": false,
+ "bFilter": true,
+ "bInfo": false,
+ "bAutoWidth": false,
+ "language": {
+ "lengthMenu": "Mostrant _MENU_ exercisis per pàgina",
+ "zeroRecords": "No hi han exercisis per mostrar",
+ "info": "Mostrant els exercisis _START_ a _END_ d'un total de _TOTAL_",
+ "infoEmpty": "La busqueda no ha retornat resultats",
+ "infoFiltered": "(filtrat de _MAX_ jugadors)",
+ "decimal": ",",
+ "thousands": ".",
+ "paginate": {
+ "first": '<i class="fa fa-fast-backward"></i>',
+ "last": '<i class="fa fa-fast-forward"></i>',
+ "next": '<i class="fa fa-forward"></i>',
+ "previous": '<i class="fa fa-backward"></i>'
+ },
+ "search": "Cerca:"
+ }
+ });
+ //table.ajax.reload(null, false);
+}
+
+
+/*
+ Load Players and tasks
+*/
+$(document).ready(function() {
+ var stationSelected = 1;
+
+ // Load the exercises of first station
+ loadExercises(stationSelected, true);
+
+
+
+});
diff --git a/chronojumpserver/templates/sprints.html b/chronojumpserver/templates/sprints.html
new file mode 100644
index 0000000..535542c
--- /dev/null
+++ b/chronojumpserver/templates/sprints.html
@@ -0,0 +1,48 @@
+{% extends "layout.html" %}
+
+{% block head %}
+{{ super() }}
+<link href="{{ url_for('assets', filename='DataTables/media/css/dataTables.bootstrap.min.css') }}"
rel="stylesheet" />
+{% endblock %}
+
+
+{% block content %}
+<h2>Sprints</h2>
+<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="filterByDayOptions" id="filterByDay1" value="1" >1d
+ </label>
+ <label class="radio-inline dayfilter" style="margin-top:5px">
+ <input type="radio" name="filterByDayOptions" id="filterByDay2" value="3">3d
+ </label>
+ <label class="radio-inline dayfilter" style="margin-top:5px">
+ <input type="radio" name="filterByDayOptions" id="filterByDay3" value="7">7d
+ </label>
+ <label class="radio-inline dayfilter" style="margin-top:5px">
+ <input type="radio" name="filterByDayOptions" id="filterByDay4" value="14">14d
+ </label>
+ <label class="radio-inline dayfilter" style="margin-top:5px">
+ <input type="radio" name="filterByDayOptions" id="filterByDay5" value="all" checked>Tots
+ </label>
+ </div>
+ <div class="col-sm-3">
+ <label for="player_filter" class="sr-only">Per Jugador</label>
+ <div id="filterByPlayer"></div>
+ </div>
+</div>
+
+<div class="row" style="margin-top:20px">
+ <table id="sprints" class="table table-hovered" cellspacing="0" width="100%">
+ </table>
+</div>
+
+
+{% endblock %}
+
+{% block script %}
+{{ super() }}
+<script src="{{ url_for('assets', filename='DataTables/media/js/jquery.dataTables.min.js') }}"></script>
+<script src="{{ url_for('assets', filename='DataTables/media/js/dataTables.bootstrap.min.js') }}"></script>
+<script src="{{ url_for('js', filename='sprints.js') }}"></script>
+{% endblock %}
diff --git a/chronojumpserver/templates/station_list.html b/chronojumpserver/templates/station_list.html
new file mode 100644
index 0000000..9b6afb6
--- /dev/null
+++ b/chronojumpserver/templates/station_list.html
@@ -0,0 +1,59 @@
+{% extends 'layout.html' %}
+
+{% block head %} {{ super() }}
+<link href="{{ url_for('assets', filename='DataTables/media/css/dataTables.bootstrap.min.css') }}"
rel="stylesheet" />
+{% endblock %}
+
+{% block content %}
+<div class="row">
+ <div class="col-sm-4">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">Estacions</h3><button id="btnAddStation" class="btn btn-default
btn-sm">Afegir Estació</button>
+ </div>
+ <ul class="list-group">
+ {% for station in stations %}
+ <li class="list-group-item"><a
onclick="loadExercises({{station.id}});">{{station.name}}</a></li>
+ {% endfor %}
+ </ul>
+ </div>
+
+
+ </div>
+ <div class="col-sm-8">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h2 class="panel-title">Detall de l'Estació <span
id="stationName">{{stations[0].name}}</span></h2>
+ </div>
+ <div class="panel-body">
+ <form class="form-inline">
+ <div class="form-group">
+ <label class="control-label">Nom:</label>
+ <input class="form-control" name="stationName" id="stationName" type="text"
value="{{stations[0].name}}" />
+ </div>
+ <div class="form-group">
+ <label class="control-label">Tipus:</label>
+ <input class="form-control" name="stationType" id="stationType" type="text"
value="{{stations[0].type}}" />
+ </div>
+ <button class="btn btn-primary">Actualitzar Estació</button>
+ </form>
+ </div>
+ </div>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">Exercisis de l'Estació</h3><button id="btnAddExercise" class="btn
btn-default btn-sm">Afegir Exercisi</button>
+ </div>
+ <table id="exercises" class="table table-hovered">
+ </table>
+ </div>
+ </div>
+</div>
+{% endblock %}
+
+{% block script %}
+{{ super() }}
+<script src="{{ url_for('assets', filename='DataTables/media/js/jquery.dataTables.min.js') }}"></script>
+<script src="{{ url_for('assets', filename='DataTables/media/js/dataTables.bootstrap.min.js') }}"></script>
+<script src="{{ url_for('js', filename='stations.js') }}"></script>
+{% endblock %}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]