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")
|
||||
|
||||
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 _:
|
||||
|
|
|
@ -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
|
||||
;
|
||||
|
||||
|
|
|
@ -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
|
||||
;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% import "macros.html.j2" as macros %}
|
||||
<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 %}
|
||||
{% for file in files %}
|
||||
<div class="file row u-flex">
|
||||
|
@ -17,6 +17,12 @@
|
|||
<label>Failures</label>
|
||||
<span>{{ file.print_failures }}</span>
|
||||
</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 class="controls u-flex u-ml-auto u-mv-auto">
|
||||
{{ macros.start_job(file.id) }}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{% import "macros.html.j2" as macros %}
|
||||
<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 %}
|
||||
{% for job in jobs %}
|
||||
<div class="job row u-flex">
|
||||
<div class="details eight columns u-flex u-flex-wrap u-overflow-elipsis">
|
||||
<div class="job-filename u-flex u-flex-break">
|
||||
<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>
|
||||
{% if job.printer_id %}
|
||||
<div class="job-printer u-flex">
|
||||
|
@ -21,6 +21,13 @@
|
|||
<span name="Runtime">{{ (datetime.fromisoformat(job.finished_at) - datetime.fromisoformat(job.started_at)) }}</span>
|
||||
</div>
|
||||
{% 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 class="two columns">
|
||||
<div class="job-status u-flex">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% import "macros.html.j2" as macros %}
|
||||
<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 %}
|
||||
{% for job in jobs %}
|
||||
<div class="job row u-flex">
|
||||
|
@ -25,11 +25,17 @@
|
|||
<label>Material</label>
|
||||
{{ job.filament_name }}
|
||||
</div>
|
||||
<div class="job-constraint u-flex">
|
||||
<div class="job-constraint u-flex u-flex-break">
|
||||
<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
|
||||
</div>
|
||||
{% 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 class="two columns">
|
||||
<div class="job-status u-flex">
|
||||
|
|
Loading…
Reference in a new issue