From 2fed26a8a79f57141ba6da6bbe7082ad2832e44e Mon Sep 17 00:00:00 2001 From: Brett Williams Date: Wed, 14 Dec 2022 17:07:27 -0800 Subject: [PATCH] HTML / JS / CSS work --- lib/job_server.py | 5 +- lib/render_job.py | 1 + lib/static/{ => images}/cancelled.png | Bin lib/static/images/desktop.png | Bin 0 -> 1116 bytes lib/static/{ => images}/error.png | Bin lib/static/{ => images}/gears.png | Bin lib/static/images/logo.png | Bin 0 -> 2647 bytes lib/static/{ => images}/not_started.png | Bin lib/static/{ => images}/scheduled.png | Bin lib/static/{ => images}/spinner.gif | Bin lib/static/js/job_table.js | 71 ++++++ lib/static/{ => js}/modals.js | 0 templates/details.html | 68 +++--- templates/index.html | 300 +----------------------- templates/layout.html | 236 +++++++++++++++++++ 15 files changed, 349 insertions(+), 332 deletions(-) rename lib/static/{ => images}/cancelled.png (100%) create mode 100644 lib/static/images/desktop.png rename lib/static/{ => images}/error.png (100%) rename lib/static/{ => images}/gears.png (100%) create mode 100644 lib/static/images/logo.png rename lib/static/{ => images}/not_started.png (100%) rename lib/static/{ => images}/scheduled.png (100%) rename lib/static/{ => images}/spinner.gif (100%) create mode 100644 lib/static/js/job_table.js rename lib/static/{ => js}/modals.js (100%) create mode 100644 templates/layout.html diff --git a/lib/job_server.py b/lib/job_server.py index 33ce585..0641740 100755 --- a/lib/job_server.py +++ b/lib/job_server.py @@ -61,7 +61,8 @@ def job_detail(job_id): media_basename = os.path.basename(found_job.file_list()[0]) media_url = f"/api/job/{job_id}/file/{media_basename}" return render_template('details.html', detail_table=table_html, media_url=media_url, - job_status=found_job.render_status().value.title(), job=found_job) + hostname=RenderQueue.host_name, job_status=found_job.render_status().value.title(), + job=found_job, renderer_info=renderer_info()) return f'Cannot find job with ID {job_id}', 400 @@ -111,7 +112,7 @@ def filtered_jobs_json(status_val): return f'Cannot find jobs with status {status_val}', 400 -@server.get('/api/job_status/') +@server.get('/api/job/') def get_job_status(job_id): found_job = RenderQueue.job_with_id(job_id) if found_job: diff --git a/lib/render_job.py b/lib/render_job.py index 060b63d..8e3e6fb 100644 --- a/lib/render_job.py +++ b/lib/render_job.py @@ -47,6 +47,7 @@ class RenderJob: job_dict['status'] = self.render_status().value job_dict['time_elapsed'] = self.time_elapsed() if type(self.time_elapsed) != str else self.time_elapsed job_dict['file_hash'] = self.file_hash if self.file_hash and isinstance(self.file_hash, str) else self.file_hash() + job_dict['percent_complete'] = self.percent_complete() job_dict['file_list'] = self.file_list() job_dict['worker'] = self.worker.__dict__.copy() job_dict['worker']['status'] = job_dict['status'] diff --git a/lib/static/cancelled.png b/lib/static/images/cancelled.png similarity index 100% rename from lib/static/cancelled.png rename to lib/static/images/cancelled.png diff --git a/lib/static/images/desktop.png b/lib/static/images/desktop.png new file mode 100644 index 0000000000000000000000000000000000000000..b04158cf966d5b0378163dc60d01da789039bca4 GIT binary patch literal 1116 zcmV-i1f%DP6of(q z5y4b@71VSnjQ&HQ+0=JC?q z&X&f_q?vhIcRr{0*E8>TzWcuKyfd={^f}Z{96Nse4FInY^RS?vT_-T+kZ%mTo152T zW+vt)h?bX^mc9c3nx3Avq4hUJ^rp1fEHTEQQLiJ8<95-v%|_#xJ~BD^2>~BUipvA7 zHI!2DeZO7we8q7>1?Kl9h2=@baX{3W^hVfef zfH;bP`bEHRw3|F_A+ZoDZKL$Wk=%u5N?1nZw(jM1DOpP@Z#|D1g#pq6q$v!L79dSw zfV2Q<3In7CNOPY7^x#(iV~P@Nh z%N#=Yqh8{utG@52K;IeQR4QG0y86=(G5666fogRffia!DRW6tN=HvmuwrwbNZ{YXc z6u2Kz1Bj^WZ)*}*y_;mi_@2FZ=Go@}0IMt4uu;1uqC;#1>_0F8r8Jb%*neO`N`{;P zp$R%^lSt={1%M%N8C+et*7@ac{&geo?%S{hU=6^NdH3x59#*dZk$1Oe_mu zgr|_P0hvyL%a<e?ED;O;|Az%?Nz=H}+sdxY(n%oagrrog6oq&Rs1 z7#khy+#)mJlu9_qoZZzblLIdc3`$*8C@cL)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tXjQz zWXc1!`pmHY^Q~*|ztBE>vQb@QCK@?&e9`)g9IsZJXpjEpV1%P>^@YK??~N`zGWh7D z55B#*dAnD-X@Qdm*4^h)3qx`0@#~y<>P3F{tz*rA{{vBwhcQyJ69WJM002ovPDHLk FV1lOCDXahh literal 0 HcmV?d00001 diff --git a/lib/static/not_started.png b/lib/static/images/not_started.png similarity index 100% rename from lib/static/not_started.png rename to lib/static/images/not_started.png diff --git a/lib/static/scheduled.png b/lib/static/images/scheduled.png similarity index 100% rename from lib/static/scheduled.png rename to lib/static/images/scheduled.png diff --git a/lib/static/spinner.gif b/lib/static/images/spinner.gif similarity index 100% rename from lib/static/spinner.gif rename to lib/static/images/spinner.gif diff --git a/lib/static/js/job_table.js b/lib/static/js/job_table.js new file mode 100644 index 0000000..2538dc6 --- /dev/null +++ b/lib/static/js/job_table.js @@ -0,0 +1,71 @@ +const grid = new gridjs.Grid({ +columns: [ + { data: (row) => row.id, + name: 'Thumbnail', + formatter: (cell) => gridjs.html(``), + sort: {enabled: false} + }, + { id: 'name', + name: 'Name', + data: (row) => row.name, + formatter: (name, row) => gridjs.html(`${name}`) + }, + { id: 'renderer', data: (row) => `${row.renderer}-${row.worker.renderer_version}`, name: 'Renderer' }, + { id: 'priority', name: 'Priority' }, + { id: 'status', + name: 'Status', + data: (row) => row, + formatter: (cell, row) => gridjs.html(` + ${cell.status} + ${cell.status} + `)}, + { id: 'time_elapsed', name: 'Time Elapsed' }, + { data: (row) => row.worker.total_frames, name: 'Frame Count' }, + { id: 'client', name: 'Client'}, + { data: (row) => row.worker.last_output, + name: 'Last Output', + formatter: (output, row) => gridjs.html(`${output}`) + }, + { data: (row) => row, + name: 'Commands', + formatter: (cell, row) => gridjs.html(` +
+ + + + + +
+ `), + sort: false + } +], +style: { + table: { + 'white-space': 'nowrap' + }, + th: { + 'vertical-align': 'middle', + }, + td: { + 'vertical-align': 'middle', + } +}, +server: { + url: '/api/jobs', + then: results => results, +}, +sort: true, +}).render(document.getElementById('table')); \ No newline at end of file diff --git a/lib/static/modals.js b/lib/static/js/modals.js similarity index 100% rename from lib/static/modals.js rename to lib/static/js/modals.js diff --git a/templates/details.html b/templates/details.html index 203e413..76b200b 100644 --- a/templates/details.html +++ b/templates/details.html @@ -1,52 +1,48 @@ - - - - - - Zordon Dashboard - - - - +{% extends 'layout.html' %} - - -
+{% block body %} +
+
{% if media_url: %} {% elif job_status == 'Running': %} -
- - - Rendering - {{ '{0:0.0f}'.format(job.percent_complete() * 100) }}% - +
+ + + Rendering + Rendering in Progress - {{(job.percent_complete() * 100) | int}}% +
Time Elapsed: {{job.time_elapsed()}} +
+
{% else %}
- - + + {{job_status}}
{% endif %} +
{{detail_table|safe}}
- - - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index a224d3c..f0de9ec 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,296 +1,8 @@ - - - - - - Zordon Dashboard - - - - - - +{% extends 'layout.html' %} - - -
- - - - - - - - - - - - - - - - - - - - - - {% for job in all_jobs %} - - - - - - - - - - - - - - - - {% endfor %} -
PreviewNameRendererPriorityStatusTime Elapsed%Frame CountClientLast OutputCommands
- - - - {{job.name}}{{job.renderer}}-{{job.worker.renderer_version}}{{job.priority}}{{job.render_status().value}}{{job.time_elapsed()}}{{ '{0:0.0f}'.format(job.percent_complete() * 100) }}%{{job.frame_count()}}{{job.client}}{{job.worker.last_output}} -
- - - {% if job.render_status().value in ['running', 'scheduled', 'not_started']: %} - - {% elif job.render_status().value == 'completed': %} - - {% endif %} - -
-
+{% block body %} +
+
- - - - - \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html new file mode 100644 index 0000000..71ac978 --- /dev/null +++ b/templates/layout.html @@ -0,0 +1,236 @@ + + + + + + Zordon Dashboard + + + + + + + + + + + + +{% block body %} +{% endblock %} + + + + + \ No newline at end of file