Add task status to tasks page

This commit is contained in:
rubenwardy
2025-04-27 17:09:26 +01:00
parent 1543965e5f
commit 4011cc56b6
3 changed files with 11 additions and 2 deletions

View File

@@ -42,6 +42,14 @@ async function pollTask(poll_url, disableTimeout) {
console.error(e);
}
if (res && res.status) {
let status = res.status.toLowerCase();
if (status === "pending") {
status = "pending or unknown";
}
document.getElementById("status").textContent = `Status: ${status}`;
}
if (res && res.status === "SUCCESS") {
console.log("Got result")
return res.result;

View File

@@ -64,7 +64,7 @@ class FlaskCelery(Celery):
def make_celery(app):
celery = FlaskCelery(app.import_name, backend=app.config['CELERY_RESULT_BACKEND'],
broker=app.config['CELERY_BROKER_URL'])
broker=app.config['CELERY_BROKER_URL'], task_track_started=True)
celery.init_app(app)
return celery

View File

@@ -10,11 +10,12 @@
{% block content %}
<h1>{{ self.title() }}</h1>
<p id="status"></p>
{% if "error" in info or info.status == "FAILURE" or info.status == "REVOKED" %}
<pre style="white-space: pre-wrap; word-wrap: break-word;">{{ info.error }}</pre>
{% else %}
<script src="/static/js/polltask.js"></script>
<script src="/static/js/polltask.js?v=2"></script>
<script>
// @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later