diff --git a/projects/tentacles/src/python/tentacles/blueprints/job_ui.py b/projects/tentacles/src/python/tentacles/blueprints/job_ui.py index 7e9bc4a..7d3c5fc 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/job_ui.py +++ b/projects/tentacles/src/python/tentacles/blueprints/job_ui.py @@ -42,11 +42,17 @@ def manipulate_jobs(): flash("Could not duplicate", category="error") case "cancel": - ctx.db.cancel_job(uid=ctx.uid, jid=int(request.form.get("job_id"))) + ctx.db.cancel_job( + uid=None if ctx.is_admin else ctx.uid, + jid=int(request.form.get("job_id")), + ) flash("Cancellation reqested", category="info") case "delete": - ctx.db.delete_job(uid=ctx.uid, jid=int(request.form.get("job_id"))) + ctx.db.delete_job( + uid=None if ctx.is_admin else ctx.uid, + jid=int(request.form.get("job_id")), + ) flash("Job deleted", category="info") case _: diff --git a/projects/tentacles/src/python/tentacles/sql/files.sql b/projects/tentacles/src/python/tentacles/sql/files.sql index ec0c01d..ec10187 100644 --- a/projects/tentacles/src/python/tentacles/sql/files.sql +++ b/projects/tentacles/src/python/tentacles/sql/files.sql @@ -40,7 +40,7 @@ SELECT , (SELECT COUNT(*) FROM jobs WHERE file_id = f.id AND status_id < 0) AS `print_failures` FROM files f WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) ; -- name: delete-file! @@ -67,7 +67,7 @@ SELECT * FROM files WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND id = :fid ; diff --git a/projects/tentacles/src/python/tentacles/sql/jobs.sql b/projects/tentacles/src/python/tentacles/sql/jobs.sql index 777b7f6..748846e 100644 --- a/projects/tentacles/src/python/tentacles/sql/jobs.sql +++ b/projects/tentacles/src/python/tentacles/sql/jobs.sql @@ -183,7 +183,7 @@ UPDATE jobs SET cancelled_at = datetime('now') WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND id = :jid ; @@ -208,7 +208,7 @@ WHERE -- name: delete-jobs-by-fid! DELETE FROM jobs WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND file_id = :fid ; diff --git a/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 b/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 index 772728c..ef907d8 100644 --- a/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 @@ -1,6 +1,6 @@ {% import "macros.html.j2" as macros %}

Files

-{% with files = ctx.db.list_files(uid=ctx.uid) %} +{% with files = ctx.db.list_files(uid=None if ctx.is_admin else ctx.uid) %} {% if files %} {% for file in files %}
@@ -17,6 +17,12 @@ {{ file.print_failures }}
+ {% if file.user_id != ctx.uid %} +
+ + {{ ctx.db.fetch_user(uid=file.user_id).name }} +
+ {% endif %}
{{ macros.start_job(file.id) }} diff --git a/projects/tentacles/src/python/tentacles/templates/jobs_history.html.j2 b/projects/tentacles/src/python/tentacles/templates/jobs_history.html.j2 index d270691..05bd85c 100644 --- a/projects/tentacles/src/python/tentacles/templates/jobs_history.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/jobs_history.html.j2 @@ -1,13 +1,13 @@ {% import "macros.html.j2" as macros %}

Job history

-{% with jobs = ctx.db.list_job_history(uid=ctx.uid) %} +{% with jobs = ctx.db.list_job_history(uid=None if ctx.is_admin else ctx.uid) %} {% if jobs %} {% for job in jobs %}
- {{ctx.db.fetch_file(ctx.uid, job.file_id).filename or "it's a secret"}} + {{ctx.db.fetch_file(None if ctx.is_admin else ctx.uid, job.file_id).filename or "it's a secret"}}
{% if job.printer_id %}
@@ -21,6 +21,13 @@ {{ (datetime.fromisoformat(job.finished_at) - datetime.fromisoformat(job.started_at)) }}
{% endif %} +
+ {% if job.user_id != ctx.uid %} +
+ + {{ ctx.db.fetch_user(uid=job.user_id).name }} +
+ {% endif %}
diff --git a/projects/tentacles/src/python/tentacles/templates/jobs_list.html.j2 b/projects/tentacles/src/python/tentacles/templates/jobs_list.html.j2 index b9e543a..7400b5e 100644 --- a/projects/tentacles/src/python/tentacles/templates/jobs_list.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/jobs_list.html.j2 @@ -1,6 +1,6 @@ {% import "macros.html.j2" as macros %}

Job queue

-{% with jobs = ctx.db.list_job_queue(uid=ctx.uid) %} +{% with jobs = ctx.db.list_job_queue(uid=None if ctx.is_admin else ctx.uid) %} {% if jobs %} {% for job in jobs %}
@@ -25,11 +25,17 @@ {{ job.filament_name }}
-
+
{{ job.max_x }}mm x{{ job.max_y }}mm x{{ job.max_z }}mm, bed {{ job.max_bed }}c, end {{ job.max_end }}c, nozzle {{ "%.2f"|format(job.nozzle_diameter) }}mm
{% endif %} + {% if job.user_id != ctx.uid %} +
+ + {{ ctx.db.fetch_user(uid=job.user_id).name }} +
+ {% endif %}