]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Add log stream to the listing
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 May 2023 15:46:43 +0000 (15:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 May 2023 15:46:43 +0000 (15:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/static/js/job-log-stream.js
src/templates/jobs/modules/list.html
src/templates/jobs/modules/log-stream.html
src/web/jobs.py

index f2fb830ef5a079a8b12f5735e025dcd478beb5e7..0d5e015bb1371661c598298c3e09782c42464705 100644 (file)
@@ -2,6 +2,9 @@ $(".jobs-log-stream").each(function() {
        // Fetch the UUID of the job
        const uuid = $(this).data("uuid");
 
+       // Fetch the limit
+       const limit = $(this).data("limit");
+
        // Find where we are appending lines to
        const log = $(this);
 
@@ -17,8 +20,13 @@ $(".jobs-log-stream").each(function() {
 
                console.log("Message from server: ", data);
 
+               // If there is a limit, reduce the number of rows first
+               while (limit > 0 && log.children().length > limit) {
+                       log.children().first().remove();
+               }
+
                // Create a new line
-               var line = $("<p></p>");
+               var line = $("<li></li>");
 
                // Set the log level
                line.addClass(data.level);
index 16e313ed53a8d032df3791dd6cb2932293fde30e..ea61ed71629063185565602e240a9a7a254a3985 100644 (file)
                                        {% end %}
                                </div>
                        </div>
+
+                       {# Log #}
+                       {% if job.is_running() %}
+                               <div class="panel-block">
+                                       {% module JobsLogStream(job, limit=5) %}
+                               </div>
+                       {% end %}
                </article>
        </div>
 {% end %}
index b2269c99ada87f3a6f2fbe7d94a27c25353b0c60..362374261d272ad41a2fc314e12ef09f75609ecc 100644 (file)
@@ -1 +1,2 @@
-<div class="jobs-log-stream" data-uuid="{{ job.uuid }}"></div>
+<ul class="jobs-log-stream" data-uuid="{{ job.uuid }}"
+       {% if limit %}data-limit="{{ limit }}"{% end %}></ul>
index f15621eba73450499689ccee68629aa784f05b9d..ba317e8c60705bf7b76668a5064a53488d3eb963 100644 (file)
@@ -235,8 +235,8 @@ class ListModule(ui_modules.UIModule):
 
 
 class LogStreamModule(ui_modules.UIModule):
-       def render(self, job):
-               return self.render_string("jobs/modules/log-stream.html", job=job)
+       def render(self, job, limit=None):
+               return self.render_string("jobs/modules/log-stream.html", job=job, limit=limit)
 
        def javascript_files(self):
                return [