Merge branch 'master' of ssh://git.zeus.gent:2222/kelder/rubygoldberg-tracker

This commit is contained in:
Maxime Bloch 2019-09-20 23:50:13 +02:00
commit d0f11b7c22
No known key found for this signature in database
GPG key ID: CE32A7D95B7D6418
4 changed files with 22 additions and 12 deletions

0
client/start.sh Normal file
View file

View file

@ -1,8 +1,11 @@
import datetime
from datetime import datetime
import socketio
from flask import Flask, render_template
sio = socketio.Server()
app = Flask(__name__)
app.wsgi_app = socketio.WSGIApp(sio, app.wsgi_app)
# We request users to send the run number to prevent accidentially getting old requests from a previous run
# This maybe will give to much errors from people forgetting to change their number
@ -24,9 +27,12 @@ def index():
@app.route("/start_run/<run_index>")
def start_run(run_index):
db["current_run"] = run_index
starttime = datetime.datetime.now()
starttime = datetime.now()
if run_index in db["run_data"]:
return "This run is already ran, take another number."
db["run_data"][run_index] = {"starttime": starttime, "data": {}}
# TODO send start request to the first person in the chain. Probably a zeus part already written as example
sio.emit('start_run', run_index)
return f'Run {run_index} started at {starttime}'
@ -35,11 +41,12 @@ def link_start(run, index):
if db["current_run"] != run:
return "Wrong run number, you are probably behind.", 404
else:
link_data = db["run_data"][run]["data"][index]
if link_data["start"]:
run_data = db["run_data"][run]["data"]
if index in run_data:
return "you already started in this run. Ignoring this request."
else:
link_data["start"] = datetime.datetime.now()
run_data[index] = {"start": datetime.now()}
sio.emit('link_start', index)
return "Success."
@ -52,7 +59,7 @@ def link_handoff(run, index):
if link_data["handoff"]:
return "you already handed off control during this run. Ignoring this request"
else:
link_data["handoff"] = datetime.datetime.now()
link_data["handoff"] = datetime.now()
return "Success."

View file

@ -2,7 +2,10 @@ import io from 'socket.io-client';
$(function() {
var socket = io();
socket.on('link_arrived', function(link_id) {
socket.on('start_run', function(run_index){
})
socket.on('link_start', function(link_id) {
$('#current_run').append($('<div class="item>"</div>').text(link_id));
});
});

View file

@ -10,18 +10,19 @@
<body>
<div class="container">
<div class="card">
<div id="current_run" class="card">
<div class="item">
<div>
1
</div>
<div>
time
<button type="button">Start</button>
</div>
<div>
<i class="fas fa-check"></i>
<i class="fas fa-check" style="color:green"></i>
</div>
</div>
<div class="item"></div>
<div class="item">hoi</div>
<div class="item">hoi</div>
@ -35,7 +36,6 @@
<div class="card">
<div class="item">hoi</div>
</div>
</div>
</body>
</html>