Fix issue with dashboard_window not showing thumbs

This commit is contained in:
Brett Williams
2023-06-03 14:30:07 -05:00
parent a98bea09cf
commit c4280d95da
3 changed files with 17 additions and 9 deletions

View File

@@ -185,7 +185,7 @@ class DashboardWindow:
job_id = self.selected_job_id() job_id = self.selected_job_id()
if job_id: if job_id:
# update thumb # update thumb
response = self.server_proxy.request(f'job/{job_id}/thumbnail?size=big&video_ok=false') response = self.server_proxy.request(f'job/{job_id}/thumbnail?size=big')
if response.ok: if response.ok:
try: try:
import io import io

View File

@@ -72,7 +72,7 @@ def job_detail(job_id):
@server.route('/api/job/<job_id>/thumbnail') @server.route('/api/job/<job_id>/thumbnail')
def job_thumbnail(job_id): def job_thumbnail(job_id):
big_thumb = request.args.get('size', False) == "big" big_thumb = request.args.get('size', False) == "big"
video_ok = request.args.get('video_ok', True) video_ok = request.args.get('video_ok', False)
found_job = RenderQueue.job_with_id(job_id, none_ok=True) found_job = RenderQueue.job_with_id(job_id, none_ok=True)
if found_job: if found_job:
@@ -92,15 +92,22 @@ def job_thumbnail(job_id):
found_job.status not in [RenderStatus.CANCELLED, RenderStatus.ERROR]: found_job.status not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
generate_thumbnail_for_job(found_job, big_video_path, big_image_path, max_width=800) generate_thumbnail_for_job(found_job, big_video_path, big_image_path, max_width=800)
if big_thumb and video_ok and os.path.exists(big_video_path) and not os.path.exists(big_video_path + '_IN-PROGRESS'): # generated videos
return send_file(big_video_path, mimetype="video/mp4") if video_ok:
elif big_thumb and os.path.exists(big_image_path): if big_thumb and os.path.exists(big_video_path) and not os.path.exists(
big_video_path + '_IN-PROGRESS'):
return send_file(big_video_path, mimetype="video/mp4")
elif os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'):
return send_file(thumb_video_path, mimetype="video/mp4")
# Generated thumbs
if big_thumb and os.path.exists(big_image_path):
return send_file(big_image_path, mimetype='image/jpeg') return send_file(big_image_path, mimetype='image/jpeg')
elif video_ok and os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'):
return send_file(thumb_video_path, mimetype="video/mp4")
elif os.path.exists(thumb_image_path): elif os.path.exists(thumb_image_path):
return send_file(thumb_image_path, mimetype='image/jpeg') return send_file(thumb_image_path, mimetype='image/jpeg')
elif found_job.status == RenderStatus.RUNNING:
# Misc status icons
if found_job.status == RenderStatus.RUNNING:
return send_file('static/images/gears.png', mimetype="image/png") return send_file('static/images/gears.png', mimetype="image/png")
elif found_job.status == RenderStatus.CANCELLED: elif found_job.status == RenderStatus.CANCELLED:
return send_file('static/images/cancelled.png', mimetype="image/png") return send_file('static/images/cancelled.png', mimetype="image/png")
@@ -108,6 +115,7 @@ def job_thumbnail(job_id):
return send_file('static/images/scheduled.png', mimetype="image/png") return send_file('static/images/scheduled.png', mimetype="image/png")
elif found_job.status == RenderStatus.NOT_STARTED: elif found_job.status == RenderStatus.NOT_STARTED:
return send_file('static/images/not_started.png', mimetype="image/png") return send_file('static/images/not_started.png', mimetype="image/png")
# errors
return send_file('static/images/error.png', mimetype="image/png") return send_file('static/images/error.png', mimetype="image/png")

View File

@@ -2,7 +2,7 @@ const grid = new gridjs.Grid({
columns: [ columns: [
{ data: (row) => row.id, { data: (row) => row.id,
name: 'Thumbnail', name: 'Thumbnail',
formatter: (cell) => gridjs.html(`<img src="/api/job/${cell}/thumbnail" style='width: 200px; min-width: 120px;'>`), formatter: (cell) => gridjs.html(`<img src="/api/job/${cell}/thumbnail?video_ok" style='width: 200px; min-width: 120px;'>`),
sort: {enabled: false} sort: {enabled: false}
}, },
{ id: 'name', { id: 'name',