Feat: Improving breaks; show other users' jobs & files to admins
This commit is contained in:
parent
f5bb2765a7
commit
72a8753639
6 changed files with 36 additions and 11 deletions
|
@ -42,11 +42,17 @@ def manipulate_jobs():
|
||||||
flash("Could not duplicate", category="error")
|
flash("Could not duplicate", category="error")
|
||||||
|
|
||||||
case "cancel":
|
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")
|
flash("Cancellation reqested", category="info")
|
||||||
|
|
||||||
case "delete":
|
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")
|
flash("Job deleted", category="info")
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
|
|
|
@ -40,7 +40,7 @@ SELECT
|
||||||
, (SELECT COUNT(*) FROM jobs WHERE file_id = f.id AND status_id < 0) AS `print_failures`
|
, (SELECT COUNT(*) FROM jobs WHERE file_id = f.id AND status_id < 0) AS `print_failures`
|
||||||
FROM files f
|
FROM files f
|
||||||
WHERE
|
WHERE
|
||||||
user_id = :uid
|
(:uid IS NULL OR user_id = :uid)
|
||||||
;
|
;
|
||||||
|
|
||||||
-- name: delete-file!
|
-- name: delete-file!
|
||||||
|
@ -67,7 +67,7 @@ SELECT
|
||||||
*
|
*
|
||||||
FROM files
|
FROM files
|
||||||
WHERE
|
WHERE
|
||||||
user_id = :uid
|
(:uid IS NULL OR user_id = :uid)
|
||||||
AND id = :fid
|
AND id = :fid
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ UPDATE jobs
|
||||||
SET
|
SET
|
||||||
cancelled_at = datetime('now')
|
cancelled_at = datetime('now')
|
||||||
WHERE
|
WHERE
|
||||||
user_id = :uid
|
(:uid IS NULL OR user_id = :uid)
|
||||||
AND id = :jid
|
AND id = :jid
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ WHERE
|
||||||
-- name: delete-jobs-by-fid!
|
-- name: delete-jobs-by-fid!
|
||||||
DELETE FROM jobs
|
DELETE FROM jobs
|
||||||
WHERE
|
WHERE
|
||||||
user_id = :uid
|
(:uid IS NULL OR user_id = :uid)
|
||||||
AND file_id = :fid
|
AND file_id = :fid
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% import "macros.html.j2" as macros %}
|
{% import "macros.html.j2" as macros %}
|
||||||
<h2>Files</h2>
|
<h2>Files</h2>
|
||||||
{% 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 %}
|
{% if files %}
|
||||||
{% for file in files %}
|
{% for file in files %}
|
||||||
<div class="file row u-flex">
|
<div class="file row u-flex">
|
||||||
|
@ -17,6 +17,12 @@
|
||||||
<label>Failures</label>
|
<label>Failures</label>
|
||||||
<span>{{ file.print_failures }}</span>
|
<span>{{ file.print_failures }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% if file.user_id != ctx.uid %}
|
||||||
|
<div class="file-user u-flex">
|
||||||
|
<label>Owner</label>
|
||||||
|
{{ ctx.db.fetch_user(uid=file.user_id).name }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="controls u-flex u-ml-auto u-mv-auto">
|
<div class="controls u-flex u-ml-auto u-mv-auto">
|
||||||
{{ macros.start_job(file.id) }}
|
{{ macros.start_job(file.id) }}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{% import "macros.html.j2" as macros %}
|
{% import "macros.html.j2" as macros %}
|
||||||
<h2>Job history</h2>
|
<h2>Job history</h2>
|
||||||
{% 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 %}
|
{% if jobs %}
|
||||||
{% for job in jobs %}
|
{% for job in jobs %}
|
||||||
<div class="job row u-flex">
|
<div class="job row u-flex">
|
||||||
<div class="details eight columns u-flex u-flex-wrap u-overflow-elipsis">
|
<div class="details eight columns u-flex u-flex-wrap u-overflow-elipsis">
|
||||||
<div class="job-filename u-flex u-flex-break">
|
<div class="job-filename u-flex u-flex-break">
|
||||||
<label for="filename">File</label>
|
<label for="filename">File</label>
|
||||||
<span name="filename">{{ctx.db.fetch_file(ctx.uid, job.file_id).filename or "it's a secret"}}</span>
|
<span name="filename">{{ctx.db.fetch_file(None if ctx.is_admin else ctx.uid, job.file_id).filename or "it's a secret"}}</span>
|
||||||
</div>
|
</div>
|
||||||
{% if job.printer_id %}
|
{% if job.printer_id %}
|
||||||
<div class="job-printer u-flex">
|
<div class="job-printer u-flex">
|
||||||
|
@ -21,6 +21,13 @@
|
||||||
<span name="Runtime">{{ (datetime.fromisoformat(job.finished_at) - datetime.fromisoformat(job.started_at)) }}</span>
|
<span name="Runtime">{{ (datetime.fromisoformat(job.finished_at) - datetime.fromisoformat(job.started_at)) }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="u-flex-break"></div>
|
||||||
|
{% if job.user_id != ctx.uid %}
|
||||||
|
<div class="job-user u-flex">
|
||||||
|
<label>Owner</label>
|
||||||
|
{{ ctx.db.fetch_user(uid=job.user_id).name }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="two columns">
|
<div class="two columns">
|
||||||
<div class="job-status u-flex">
|
<div class="job-status u-flex">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% import "macros.html.j2" as macros %}
|
{% import "macros.html.j2" as macros %}
|
||||||
<h2>Job queue</h2>
|
<h2>Job queue</h2>
|
||||||
{% 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 %}
|
{% if jobs %}
|
||||||
{% for job in jobs %}
|
{% for job in jobs %}
|
||||||
<div class="job row u-flex">
|
<div class="job row u-flex">
|
||||||
|
@ -25,11 +25,17 @@
|
||||||
<label>Material</label>
|
<label>Material</label>
|
||||||
{{ job.filament_name }}
|
{{ job.filament_name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="job-constraint u-flex">
|
<div class="job-constraint u-flex u-flex-break">
|
||||||
<label>Limits</label>
|
<label>Limits</label>
|
||||||
{{ 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
|
{{ 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
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if job.user_id != ctx.uid %}
|
||||||
|
<div class="job-user u-flex">
|
||||||
|
<label>Owner</label>
|
||||||
|
{{ ctx.db.fetch_user(uid=job.user_id).name }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="two columns">
|
<div class="two columns">
|
||||||
<div class="job-status u-flex">
|
<div class="job-status u-flex">
|
||||||
|
|
Loading…
Reference in a new issue