From 9f4d5cf4402336aaa4f0b34c9f1d2cdbbefa91d0 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 4 Feb 2020 22:42:08 +0100 Subject: [PATCH] Show client on command and better kitchen command information display --- app/sockets.py | 16 +++++++++------- app/static/css/main.css | 4 ++-- app/static/js/kitchen.js | 8 ++++---- app/static/js/pc.js | 8 ++++---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/sockets.py b/app/sockets.py index 38a45ee..3db8824 100644 --- a/app/sockets.py +++ b/app/sockets.py @@ -22,7 +22,6 @@ def authenticated_only(f): def command_json(c): ingredient = " - ".join([s.id for s in c.content]) sauces = " - ".join([s.id for s in c.sauce]) - sandwich = None if c.error: state = "error" elif c.give: @@ -35,13 +34,16 @@ def command_json(c): state = "waiting" else: state = "unknown" - if c.sandwich_id: - try: - sandwich = User.query.get(c.sandwich_id).username - except AttributeError: - pass + try: + client = User.query.get(c.client_id).username + except AttributeError: + client = None + try: + sandwich = User.query.get(c.sandwich_id).username + except AttributeError: + sandwich = None return {"id": c.number, "plate": c.plate_id, "ingredient": ingredient, "sauce": sauces, "drink": c.drink_id, - "dessert": c.dessert_id, "state": state, "sandwich": sandwich} + "dessert": c.dessert_id, "state": state, "sandwich": sandwich, "client": client} @socketio.on("connect") diff --git a/app/static/css/main.css b/app/static/css/main.css index 262efe9..a7de22d 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -729,11 +729,11 @@ audio{ color: rgb(122, 233, 105); } -#attente div :nth-child(2), #attente div :nth-child(3) { +#attente div :nth-child(2), #attente div :nth-child(4), #attente div :nth-child(5) { display: none; } -#realisee div :nth-child(2), #realisee div :nth-child(3){ +#realisee div :nth-child(2), #realisee div :nth-child(4), #realisee div :nth-child(5){ display: none; } diff --git a/app/static/js/kitchen.js b/app/static/js/kitchen.js index 3551aa8..e95a566 100644 --- a/app/static/js/kitchen.js +++ b/app/static/js/kitchen.js @@ -3,10 +3,10 @@ let WIP = document.getElementById("encours"); let done = document.getElementById("realisee"); let waiting = document.getElementById("attente"); -function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) { +function addcmd(id, plate, ingredient, sauce, drink, dessert, state, client, sandwich) { if (!sandwich) sandwich = ""; - done.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${plate} | ${ingredient}

${sauce}

${drink}

${dessert}

`); + done.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${client}

${plate} | ${ingredient}

${sauce}

${drink}

${dessert}

`); let e = document.getElementById(`cmd${id}`); switch (state) { case "WIP": @@ -75,7 +75,7 @@ socket.on("list command", data => { } } for (let c of data.list) { - addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwich); + addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.client,c.sandwich); } waiter(); }); @@ -88,7 +88,7 @@ socket.on("list service", data => { }); socket.on("new command", data => { - addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwich); + addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.client, data.sandwich); waiter(); }); diff --git a/app/static/js/pc.js b/app/static/js/pc.js index bd43e5a..fb1a76d 100644 --- a/app/static/js/pc.js +++ b/app/static/js/pc.js @@ -9,10 +9,10 @@ let current = {"plate": null, "ingredient": [], "sauce": [], "drink": null, "des let radios = {"plate": null, "drink": null, "dessert": null}; -function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) { +function addcmd(id, plate, ingredient, sauce, drink, dessert, state, client, sandwich) { if (!sandwich) sandwich = ""; - list.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${plate}

${ingredient}

${sauce}

${drink}

${dessert}

`); + list.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${client}

${plate}

${ingredient}

${sauce}

${drink}

${dessert}

`); let e = document.querySelector(`.liste #cmd${id}`); e.addEventListener( "click" ,ev => { ev.stopPropagation(); @@ -172,7 +172,7 @@ socket.on("list command", data => { child = list.lastElementChild; } for (let c of data.list) { - addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwich); + addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.client, c.sandwich); } }); @@ -232,7 +232,7 @@ socket.on("list dessert", data => { }); socket.on("new command", data => { - addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwich); + addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.client, data.sandwich); }); socket.on("cleared command", data => {