// 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);
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);
{% end %}
</div>
</div>
+
+ {# Log #}
+ {% if job.is_running() %}
+ <div class="panel-block">
+ {% module JobsLogStream(job, limit=5) %}
+ </div>
+ {% end %}
</article>
</div>
{% end %}
-<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>
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 [