This commit is contained in:
Laila van Reenen 2024-08-12 21:43:14 +02:00
parent 1b24417acb
commit dc24bdfa6d
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769
3 changed files with 23 additions and 7 deletions

View File

@ -230,16 +230,19 @@
let lockBtn = document.createElement("div");
lockBtn.className = "btn";
lockBtn.innerHTML = lockIcon;
lockBtn.ariaLabel = "lock";
lockBtn.addEventListener('click', lockBoat);
boatCells[3].append(lockBtn);
let freeBtn = document.createElement("div");
freeBtn.className = "btn";
freeBtn.innerHTML = freeIcon;
lockBtn.ariaLabel = "free";
freeBtn.addEventListener('click', freeBoat);
boatCells[3].append(freeBtn);
let logBtn = document.createElement("div");
logBtn.className = "btn";
logBtn.innerHTML = logIcon;
lockBtn.ariaLabel = "view log";
logBtn.addEventListener('click', getBoatLog);
boatCells[3].append(logBtn);
for (cell in boatCells)

View File

@ -78,6 +78,7 @@ async def free_boat(boat):
for client in Clients:
if client["boat"] is not None and client["boat"]['id'] == boat:
client["boat"] = None
await client['ws'].send("FAIL")
break
for b in Boats:
if b['id'] == boat and b['state'] != BOAT_STATE_TERMINATED:
@ -89,6 +90,7 @@ async def lock_boat(boat):
for client in Clients:
if client["boat"] is not None and client["boat"]['id'] == boat:
client["boat"] = None
await client['ws'].send("FAIL")
break
for b in Boats:
if b['id'] == boat and b['state'] != BOAT_STATE_TERMINATED:
@ -116,11 +118,11 @@ async def kick_client(clientId):
"""kick a client"""
for client in Clients:
if client['id'] == client and client['state'] == "terminated":
if client['state'] is not None:
if client['boat'] is not None:
client['boat']['state'] = BOAT_STATE_AVAILABLE
client['boat'] = None
client['state'] = "kicked"
await client['ws'].send("FAIL")
client['state'] = "kicked"
await client['ws'].send("FAIL")
return
@ -151,6 +153,7 @@ async def on_message(message, client):
elif data[1] == "d":
if client['boat'] is None:
print("WARN: controll cmd (" + client['id'] + ") to None: " + data[2])
await client['ws'].send("FAIL")
elif client['boat']['lastMsg'] + BOAT_DATA_INTERVAL_MAX < datetime.timestamp(datetime.now()):
# print("INFO: controll cmd (" + client['id'] + ") to " + client['boat']['name'] + ": " + data[2])
await sendToBoat(client['boat'], "d:" + data[2] + "\n")

View File

@ -66,14 +66,23 @@
let el = document.createElement("div");
el.style.textAlign = "center";
el.style.borderRadius = "10px";
el.style.backgroundColor = "#242495";
el.style.padding = "10px";
el.style.margin = "5px 25%";
el.style.color = "white";
el.style.cursor = "pointer";
if (boat[2] == 'available')
{
el.style.backgroundColor = "#242495";
el.style.color = "white";
el.style.cursor = "pointer";
el.addEventListener('click', selectBoat);
}
else
{
el.style.backgroundColor = "#CCCCCC";
el.style.color = "black";
el.style.cursor = "not-allowed";
}
el.id = "boat" + boat[0];
el.innerHTML = boat[1];
el.addEventListener('click', selectBoat);
boatListEl.appendChild(el);
}
}
@ -88,6 +97,7 @@
{
console.error("ground station send FAIL");
connection.send(clientId + ';boats');
state = "connected";
}
else
{