Merge branch 'master' of ssh://git.zeus.gent:2222/kelder/rubygoldberg-tracker
This commit is contained in:
commit
d0f11b7c22
4 changed files with 22 additions and 12 deletions
0
client/start.sh
Normal file
0
client/start.sh
Normal file
|
@ -1,8 +1,11 @@
|
||||||
import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import socketio
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
|
|
||||||
|
sio = socketio.Server()
|
||||||
app = Flask(__name__)
|
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
|
# 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
|
# 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>")
|
@app.route("/start_run/<run_index>")
|
||||||
def start_run(run_index):
|
def start_run(run_index):
|
||||||
db["current_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": {}}
|
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
|
# 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}'
|
return f'Run {run_index} started at {starttime}'
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,11 +41,12 @@ def link_start(run, index):
|
||||||
if db["current_run"] != run:
|
if db["current_run"] != run:
|
||||||
return "Wrong run number, you are probably behind.", 404
|
return "Wrong run number, you are probably behind.", 404
|
||||||
else:
|
else:
|
||||||
link_data = db["run_data"][run]["data"][index]
|
run_data = db["run_data"][run]["data"]
|
||||||
if link_data["start"]:
|
if index in run_data:
|
||||||
return "you already started in this run. Ignoring this request."
|
return "you already started in this run. Ignoring this request."
|
||||||
else:
|
else:
|
||||||
link_data["start"] = datetime.datetime.now()
|
run_data[index] = {"start": datetime.now()}
|
||||||
|
sio.emit('link_start', index)
|
||||||
return "Success."
|
return "Success."
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +59,7 @@ def link_handoff(run, index):
|
||||||
if link_data["handoff"]:
|
if link_data["handoff"]:
|
||||||
return "you already handed off control during this run. Ignoring this request"
|
return "you already handed off control during this run. Ignoring this request"
|
||||||
else:
|
else:
|
||||||
link_data["handoff"] = datetime.datetime.now()
|
link_data["handoff"] = datetime.now()
|
||||||
return "Success."
|
return "Success."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,10 @@ import io from 'socket.io-client';
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var socket = io();
|
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));
|
$('#current_run').append($('<div class="item>"</div>').text(link_id));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,18 +10,19 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="card">
|
<div id="current_run" class="card">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div>
|
<div>
|
||||||
1
|
1
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
time
|
<button type="button">Start</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<i class="fas fa-check"></i>
|
<i class="fas fa-check" style="color:green"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item"></div>
|
<div class="item"></div>
|
||||||
<div class="item">hoi</div>
|
<div class="item">hoi</div>
|
||||||
<div class="item">hoi</div>
|
<div class="item">hoi</div>
|
||||||
|
@ -35,7 +36,6 @@
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="item">hoi</div>
|
<div class="item">hoi</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue