Skip to content

Commit e048afb

Browse files
committed
tools: dashboard: add starter input
Signed-off-by: Starbeuck <solenn.daumand@gmail.com>
1 parent 6d850fd commit e048afb

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

cogip/tools/dashboard/templates/dashboard.html

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,21 @@
5353
</div>
5454

5555
<footer class="mt-auto bg-zinc-900 text-grey-color mx-2">
56-
<div class="container-lg pt-2">
57-
<span class="text-muted float-left" id="connection">
56+
<div class="container-lg pt-2 flex items-center justify-between">
57+
<span class="text-muted inline" id="connection">
5858
<pre
59-
class="text-grey-color text-sm inline"><img class="mr-5 w-[20px] inline" src="{{ url_for('static', path='img/cross_red_circle.svg') }}" /></pre>
59+
class="text-grey-color text-sm"><img class="mr-5 w-[20px]" src="{{ url_for('static', path='img/cross_red_circle.svg') }}" /></pre>
6060
</span>
6161
{% if robot_id != 0 %}
62-
<span class="text-muted float-right inline" id="state">
62+
<span class="text-muted text-sm inline" id="state">
6363
<pre id="state_robot"></pre>
6464
<pre id="order_robot"></pre>
6565
</span>
66+
<span class="text-muted text-sm z-10" id="starter">
67+
<label>
68+
<input type="checkbox" class="checked:accent-red-cogip checked:border-red-cogip" disabled> Starter
69+
</label>
70+
</span>
6671
{% endif %}
6772
</div>
6873
</footer>
@@ -147,9 +152,13 @@ <h5 class="text-lg font-medium text-grey-color">Score</h5>
147152
socket.on("connect", function () {
148153
socketModule.onConnection(this);
149154
})
150-
.on("disconnect", function () {
155+
.on("disconnect", function () {
151156
socketModule.onDisconnect();
152157
})
158+
.on("virtual", function (robot_id, msg) {
159+
console.log(!msg)
160+
document.querySelector("#starter input").disabled = !msg;
161+
})
153162
.on("tool_menu", function (menu) {
154163
socketModule.onMenu(menu, "tool", this);
155164
virtualKeyboard._actualize();
@@ -178,8 +187,16 @@ <h5 class="text-lg font-medium text-grey-color">Score</h5>
178187
})
179188
.on("obstacles", function (robot_id, msg) {
180189
drawModule.updateObstacles(robot_id, msg);
190+
})
191+
.on("starter_changed", function(robot_id, pushed) {
192+
document.querySelector("#starter input").checked = pushed;
181193
});
182194

195+
// add event listener on click for starter input
196+
document.querySelector("#starter input").addEventListener("click", function () {
197+
socket.emit("starter_changed", this.checked);
198+
});
199+
183200
if (robotId !== 0) {
184201
import("../static/js/scoreModule.js").then((scoreModule) => {
185202
socket.on("score", function (score) {
@@ -218,11 +235,10 @@ <h5 class="text-lg font-medium text-grey-color">Score</h5>
218235
console.log(`Delete robot ${robot_id} dashboard`);
219236
drawModule.deleteTab(robot_id);
220237
})
221-
222238
}
223239
});
224240

225241
</script>
226242
</body>
227243

228-
</html>
244+
</html>

cogip/tools/server/namespaces/dashboard.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ async def on_connected(self, sid):
2626
if self.context.shell_menu:
2727
await self.emit("shell_menu", (self.context.robot_id, self.context.shell_menu.model_dump()), to=sid)
2828

29+
if self.context.virtual:
30+
await self.emit("virtual", (self.context.robot_id, self.context.virtual), to=sid)
31+
2932
def on_disconnect(self, sid):
3033
logger.info("Dashboard disconnected.")
3134

0 commit comments

Comments
 (0)