summaryrefslogtreecommitdiff
path: root/dashboard_website/dashboard.py
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard_website/dashboard.py')
-rw-r--r--dashboard_website/dashboard.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/dashboard_website/dashboard.py b/dashboard_website/dashboard.py
index 77832aa..757324d 100644
--- a/dashboard_website/dashboard.py
+++ b/dashboard_website/dashboard.py
@@ -73,16 +73,18 @@ def requestRoute():
if not ( (type(content['longitude']) is float ) and (type(content['latitude']) is float)):
return jsonify({'status' : "ERROR 2"})
-
+
+ bike, clue = db.getBikeCluePair(content['team_index'])
+ if clue == None: # bike disabled or without clue -- should not ping bike yet
+ return jsonify({'status' : "ERROR 5"})
+
if db.pingBike(content['team_index'], content['latitude'], content['longitude']) == 4:
return jsonify({'status' : "ERROR 4"})
if db.currently_updating:
return jsonify({'status' : "ERROR 3"})
- bike, clue = db.getBikeCluePair(content['team_index'])
- if clue == None:
- return jsonify({'status' : "ERROR 5"})
+
route = router.getRouteFullJSON(bike, clue)
if route['code'] != 'Ok': # or some other code indicating routing problem?
@@ -257,6 +259,7 @@ def getLatestInfo():
'clues_changed' : False,
'home_changed' : False,
'routes_changed' : False,
+ 'routes_to_commit' : db.routesToCommit,
'route_update_staged' : db.is_route_update_required() }
cl = db.getCluesJSON(last_timestamp)
if cl != False:
@@ -266,10 +269,11 @@ def getLatestInfo():
if h != False:
data['home_changed'] = True
data['homebase'] = h
- r = db.getRoutesJSON(last_timestamp)
- if r != False:
+ p, r = db.getRoutesJSON(last_timestamp)
+ if p != False:
data['routes_changed'] = True
data['routes'] = r
+ data['preview_routes'] = p
data['calculating_routes'] = db.currently_updating
data['bikes'] = db.getBikesJSON()
data['status'] = "OK"
@@ -328,7 +332,15 @@ def siteControls():
elif cmd == "generateRoutes":
if db.updateRoutes() != 0:
return jsonify({"status" : "ERROR"})
- return jsonify({"status" : "OK"})
+ return jsonify({"status" : "OK"})
+ elif cmd == "stopGenerating":
+ db.force_stop()
+ return jsonify({"status" : "OK"})
+ elif cmd == "commitRoutes":
+ if db.routesToCommit:
+ db.applyPreviewRoutes()
+ return jsonify({"status" : "OK"})
+
return render_template("controls.html")