Add new queue page and status indicator on the homepage

This commit is contained in:
n07070 committed 2026-11-18 13:46:15 +01:00
1 parent dd27581358
commit e5c4b3d5e6
2 files changed
+58 -1

No files matched your search

+11 -1
View File
@@ -22,6 +22,16 @@
<a class="nav-link" href="/webcam">Webcam</a>
</li>
</ul>
<div class="border border-2 bg-subtle-inverse nav-item">
<button type="button" class="btn-styled btn btn-outline theme-primary position-relative">
<a href="/queue">🖶</a>
<span class="badge position-absolute top-0 start-100 translate-middle bg-danger border border-bg rounded-circle" id="status-printers" title="Javascript is disabled, could not get printer status."><span id="number-task">0</span>
<span class="visually-hidden"></span>
</span>
</button>
</div>
</div>
</nav>
@@ -45,7 +55,6 @@
{% endif %}
{% endwith %}
{% block content %}
@@ -57,5 +66,6 @@
</footer>
</body>
<script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
<script type="module" src="{{ url_for('static', filename='js/status.js') }}"></script>
</html>
+47
View File
@@ -0,0 +1,47 @@
{% extends 'base.html' %}
{% block content %}
<h4 class="float-end">Worker state : {{ worker_state.state }}</h4>
<h3>Current tasks</h3>
<hr>
{% if not tasks %}
<div class="alert alert-success" role="alert">No tasks in queue</div>
{% endif %}
<div class="row row-cols-1 row-cols-md-5 g-4">
{% for task in tasks %}
<div class="col-sm-6 mb-3 mb-sm-0">
<div class="card">
{% if task.type == "TaskType.IMAGE" %}
{% set img_path = task.content.img.split('/')[-1] %}
<img src="{{ url_for('static', filename="uploads/" + img_path) }}" class="card-img-top" alt="Image could not be loaded">
{% endif %}
{% if task.type == "TaskType.CUT" %}
<img src="{{ url_for('static', filename="images/cut.png") }}" class="card-img-top" alt="Image could not be loaded">
{% endif %}
<div class="card-body">
{% if task.type == "TaskType.TEXT" %}
<p class="card-text">ID : <code>{{ task.content.txt }}</code> </p>
{% endif %}
<p class="card-text">ID : <code>{{ task.task_id }}</code> </p>
</div>
</div>
</div>
{% endfor %}
</div>
<br>
<h3>Completed tasks</h3>
<hr>
{% if not completed_tasks %}
<div class="alert alert-dark" role="alert">No tasks printed for the moment</div>
{% endif %}
{% for task in completed_tasks %}
<div class="alert alert-success" role="alert">{{ task }}</div>
{% endfor %}
{% endblock %}