[chronojump-server] Second concept of Airport Page. Missing Stylesheet



commit 87b4d5116590d8bfad084bd32933d2e3dc570f74
Author: Marcos Venteo GarcĂ­a <mventeo gmail com>
Date:   Wed Jun 28 00:33:23 2017 +0200

    Second concept of Airport Page. Missing Stylesheet

 chronojumpserver/api.py                 |   11 +++++++++
 chronojumpserver/js/airport.js          |   35 ++++++++++++++++--------------
 chronojumpserver/models.py              |    2 +-
 chronojumpserver/static/style.css       |   12 +++++-----
 chronojumpserver/templates/airport.html |   14 +++++++++--
 chronojumpserver/views.py               |    3 +-
 6 files changed, 50 insertions(+), 27 deletions(-)
---
diff --git a/chronojumpserver/api.py b/chronojumpserver/api.py
index fdde071..fafabc7 100755
--- a/chronojumpserver/api.py
+++ b/chronojumpserver/api.py
@@ -271,3 +271,14 @@ def players_with_active_tasks_in_station(station_id):
     print players
 
     return jsonify(data=players)
+
+@app.route('/api/v1/station/active_tasks_player')
+def active_tasks_in_station():
+
+    # Get the players in this station with active tasks
+    players_stations = []
+    for player in Person.query.all():
+        stations = [ task.stationId for task in player.active_tasks]
+        players_stations.append({ 'id' : player.id, 'stations': stations})
+
+    return jsonify(players_stations=players_stations)
diff --git a/chronojumpserver/js/airport.js b/chronojumpserver/js/airport.js
index 9ac3380..10155bf 100644
--- a/chronojumpserver/js/airport.js
+++ b/chronojumpserver/js/airport.js
@@ -19,23 +19,26 @@
  */
 
 $(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" : " "
-            }
+
+
+
+    $.ajax({
+        url: '/api/v1/station/active_tasks_player'
+    }).done(function(data) {
+        //console.log(data.players_stations);
+        $.each(data.players_stations, function(i, item) {
+            //console.log('Stations of player ' + item.id);
+            var playerId = item.id;
+            $.each(item.stations, function(i, stationId) {
+                //console.log('Has tasks in station ' + item);
+                $('#cell_'+stationId+'_'+playerId).addClass('playerWithActiveTasks');
+            })
+
         })
+    }).fail(function(xhr, status, error){
+        var err = eval("(" + xhr.responseText + ")");
+        alert(err.msg);
     });
 
+
 });
diff --git a/chronojumpserver/models.py b/chronojumpserver/models.py
index 03f3665..ef827d7 100755
--- a/chronojumpserver/models.py
+++ b/chronojumpserver/models.py
@@ -61,7 +61,7 @@ class Person(HelperMixin, Base):
         """Return object data in easily serializeable format."""
         return {
             'id':        self.id,
-            'name':      self.name,
+            'name':      self.name.decode('utf-8'),
             'weight':    self.weight,
             'height':    self.height,
             'rfid':      self.rfid,
diff --git a/chronojumpserver/static/style.css b/chronojumpserver/static/style.css
index fe34ffd..d8e7a5a 100755
--- a/chronojumpserver/static/style.css
+++ b/chronojumpserver/static/style.css
@@ -77,17 +77,17 @@ body.home {
 */
 
 #airportStationTable thead tr th {
-    border-bottom: none;
+    /*border-bottom: none;*/
 }
 
 #airportStationTable tbody tr td {
-    border-top: none;
+    /*border-top: none;*/
 }
 
-.playerStationTable thead tr {
-    visibility: hidden;
+.airportPlayerStationCell {
+
 }
 
-.playerStationTable tbody tr td {
-    border-top: none;
+.playerWithActiveTasks {
+    background-color: green;
 }
diff --git a/chronojumpserver/templates/airport.html b/chronojumpserver/templates/airport.html
index 49b183b..6f3315d 100644
--- a/chronojumpserver/templates/airport.html
+++ b/chronojumpserver/templates/airport.html
@@ -26,6 +26,9 @@
 <table id="airportStationTable" class="table table-hovered" style="margin-top: 40px">
     <thead>
         <tr>
+            <th width="100">
+                Jugador
+            </th>
         {% for station in stations %}
             <th>
                 {{ station.name }}
@@ -33,11 +36,16 @@
         {% endfor %}
         </tr>
         <tbody>
-            <tr>
-                {% for station in stations %}
+                {% for player in players %}
+                <tr>
                     <td>
-                        <table class="table table-hovered playerStationTable" 
data-station-id="{{station.id}}"></table>
+                        {{player.name}}
                     </td>
+                    {% for station in stations %}
+                        <td id="cell_{{station.id}}_{{player.id}}" class="airportPlayerStationCell">
+                        </td>
+                    {% endfor %}
+                </tr>
                 {% endfor %}
             </tr>
         </tbody>
diff --git a/chronojumpserver/views.py b/chronojumpserver/views.py
index 30cc9aa..e336e57 100755
--- a/chronojumpserver/views.py
+++ b/chronojumpserver/views.py
@@ -20,7 +20,8 @@ def index():
 def airport():
     """Airport mode."""
     stations = [ station.serialize for station in Station.query.filter(Station.type != 'S')]
-    return render_template('airport.html', stations=stations)
+    players =  [ player.serialize for player in Person.query.all()]
+    return render_template('airport.html', stations=stations, players=players)
 
 @app.route('/results')
 def show_results():


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