[chronojump-server] First concept of Airport Page



commit 2eed608420906737e35fd4d7db2b4f36042dfca8
Author: Marcos Venteo GarcĂ­a <mventeo gmail com>
Date:   Tue Jun 27 23:54:38 2017 +0200

    First concept of Airport Page

 chronojumpserver/api.py                     |   12 ++++++
 chronojumpserver/js/airport.js              |   41 ++++++++++++++++++++
 chronojumpserver/models.py                  |    2 +-
 chronojumpserver/static/style.css           |   25 +++++++++---
 chronojumpserver/templates/airport.html     |   55 +++++++++++++++++++++++++++
 chronojumpserver/templates/layout.html      |    4 ++
 chronojumpserver/templates/player_list.html |    4 +-
 chronojumpserver/views.py                   |    5 ++
 8 files changed, 140 insertions(+), 8 deletions(-)
---
diff --git a/chronojumpserver/api.py b/chronojumpserver/api.py
index dcf735c..fdde071 100755
--- a/chronojumpserver/api.py
+++ b/chronojumpserver/api.py
@@ -259,3 +259,15 @@ def add_modify_delete_exercises():
     response = jsonify(msg=msg.decode('utf-8'))
     response.status_code = status_code
     return response
+
+@app.route('/api/v1/station/<station_id>/active_tasks_player')
+def players_with_active_tasks_in_station(station_id):
+
+    # Get the players in this station with active tasks
+    tasks = [task.serialize for task in Task.query.filter(Task.stationId == station_id and Task.done==False)]
+    players = []
+    for task in tasks:
+        players.append({ 'name' : task['personName'] for task in tasks })
+    print players
+
+    return jsonify(data=players)
diff --git a/chronojumpserver/js/airport.js b/chronojumpserver/js/airport.js
new file mode 100644
index 0000000..9ac3380
--- /dev/null
+++ b/chronojumpserver/js/airport.js
@@ -0,0 +1,41 @@
+/*!
+ * Airport 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() {
+    $('.playerStationTable').each(function(index) {
+        var stationId = $( this ).attr('data-station-id');
+        console.log( "Loading players with active tasks in station " + stationId );
+        var table = $(this).DataTable({
+            "columns" : [
+                {
+                    type: "html",
+                    data: "name",
+                    orderable: false
+                }
+            ],
+            "ajax": "/api/v1/station/"+stationId+"/active_tasks_player",
+            "dom" : "",
+            "language": {
+                "zeroRecords" : " "
+            }
+        })
+    });
+
+});
diff --git a/chronojumpserver/models.py b/chronojumpserver/models.py
index cf34a74..03f3665 100755
--- a/chronojumpserver/models.py
+++ b/chronojumpserver/models.py
@@ -248,7 +248,7 @@ class Task(Base):
             'nreps':       self.nreps,
             'load':        self.load,
             'laterality':  self.laterality,
-            'description': self.description
+            'description': self.comment
         }
 
     def add_free_task(self):
diff --git a/chronojumpserver/static/style.css b/chronojumpserver/static/style.css
index 89fb79f..fe34ffd 100755
--- a/chronojumpserver/static/style.css
+++ b/chronojumpserver/static/style.css
@@ -72,9 +72,22 @@ body.home {
     font-weight: bold;
 }
 
-/*#btnShowStationModalForm, #btnShowExerciseModalForm {
-    position: relative;
-    top: -23px;
-    right: -10px;
-    float: right;
-}*/
+/*
+* AIRPORT PAGE
+*/
+
+#airportStationTable thead tr th {
+    border-bottom: none;
+}
+
+#airportStationTable tbody tr td {
+    border-top: none;
+}
+
+.playerStationTable thead tr {
+    visibility: hidden;
+}
+
+.playerStationTable tbody tr td {
+    border-top: none;
+}
diff --git a/chronojumpserver/templates/airport.html b/chronojumpserver/templates/airport.html
new file mode 100644
index 0000000..49b183b
--- /dev/null
+++ b/chronojumpserver/templates/airport.html
@@ -0,0 +1,55 @@
+{% extends "layout.html" %}
+
+{% block head %} {{ super() }}
+<link href="{{ url_for('assets', filename='DataTables/media/css/dataTables.bootstrap.min.css') }}" 
rel="stylesheet" />
+{% endblock %}
+
+{% block nav %}
+<nav class="navbar navbar-default navbar-fixed-top">
+    <div class="container-fluid">
+        <div class="navbar-header">
+          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" 
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+            <a class="navbar-brand" href="/">
+                <img alt="Brand" src="{{ url_for('static', filename='images/chronojump-logo.png')}}" 
height="48px">
+            </a>
+        </div>
+    </div>
+</nav>
+{% endblock %}
+
+{% block content_fluid %}
+<table id="airportStationTable" class="table table-hovered" style="margin-top: 40px">
+    <thead>
+        <tr>
+        {% for station in stations %}
+            <th>
+                {{ station.name }}
+            </th>
+        {% endfor %}
+        </tr>
+        <tbody>
+            <tr>
+                {% for station in stations %}
+                    <td>
+                        <table class="table table-hovered playerStationTable" 
data-station-id="{{station.id}}"></table>
+                    </td>
+                {% endfor %}
+            </tr>
+        </tbody>
+    </thead>
+</table>
+{% endblock %}
+
+{% block footer %}
+{% 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='airport.js') }}"></script>
+{% endblock %}
diff --git a/chronojumpserver/templates/layout.html b/chronojumpserver/templates/layout.html
index b045799..e4ef16d 100755
--- a/chronojumpserver/templates/layout.html
+++ b/chronojumpserver/templates/layout.html
@@ -45,6 +45,10 @@
         {% block content %}{% endblock %}
     </div>
 
+    <div id="main" class="container-fluid">
+        {% block content_fluid %}{% endblock %}
+    </div>
+
     {% block footer %}
     <nav class="navbar navbar-default navbar-fixed-bottom footer">
         <div class="container-fluid">
diff --git a/chronojumpserver/templates/player_list.html b/chronojumpserver/templates/player_list.html
index 9fe8b38..75a91c5 100755
--- a/chronojumpserver/templates/player_list.html
+++ b/chronojumpserver/templates/player_list.html
@@ -1,7 +1,9 @@
 {% extends 'layout.html' %}
 {% block head %} {{ super() }}
 <link href="{{ url_for('assets', filename='DataTables/media/css/dataTables.bootstrap.min.css') }}" 
rel="stylesheet" />
-{% endblock %} {% block content %}
+{% endblock %}
+
+{% block content %}
 
 <div class="page-header">
        <h1>Jugadors i Tasques</h1>
diff --git a/chronojumpserver/views.py b/chronojumpserver/views.py
index e966344..30cc9aa 100755
--- a/chronojumpserver/views.py
+++ b/chronojumpserver/views.py
@@ -16,6 +16,11 @@ def index():
     """Chronojump Server Home page."""
     return render_template('index.html')
 
+@app.route('/airport')
+def airport():
+    """Airport mode."""
+    stations = [ station.serialize for station in Station.query.filter(Station.type != 'S')]
+    return render_template('airport.html', stations=stations)
 
 @app.route('/results')
 def show_results():


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]