]> git.ipfire.org Git - pbs.git/commitdiff
templates: Tried to refactor job list
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 May 2022 14:37:43 +0000 (14:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 May 2022 14:37:43 +0000 (14:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builders.py
src/buildservice/jobs.py
src/templates/index.html
src/templates/modules/jobs/list.html

index 208fc4aeec0540d7dc070c156a2c9ec9c4312980..070a92cd05c038cb5d8467fc2bb8db679685adb3 100644 (file)
@@ -128,6 +128,9 @@ class Builder(base.DataObject):
 
                return NotImplemented
 
+       def __str__(self):
+               return self.hostname
+
        def log(self, action, user=None):
                user_id = None
                if user:
index 462fc9d353a4a52d992af804f3b8a3a1973af4d4..59d2789f7824ce98305615db6f10a1abbf44d730 100644 (file)
@@ -243,6 +243,21 @@ class Job(base.DataObject):
 
                return job
 
+       def is_active(self):
+               """
+                       Returns True if this job is active
+               """
+               return self.time_started and not self.time_finished
+
+       def has_finished(self):
+               if self.time_finished:
+                       return True
+
+               return False
+
+       def has_failed(self):
+               return self.state == "failed"
+
        def delete(self):
                """
                        Deletes a job from the database
index a05ce2b42628d5f8c42879cb09c61259972662e0..d92be77648e83c1f2e85114f5e331f4ed9462728 100644 (file)
@@ -7,11 +7,9 @@
        <h3 class="text-center">{{ _("Development Powered By Community") }}</h3>
 
        {% if jobs %}
-               <div class="callout">
-                       <h5>{{ _("Current Jobs") }}</h5>
+               <h5>{{ _("Current Jobs") }}</h5>
 
-                       {% module JobsList(jobs) %}
-               </div>
+               {% module JobsList(jobs) %}
        {% end %}
 
        <a class="button expanded" href="/queue">
index 0ed2630030ff3d14de05417e1b32101233a0e745..b812dd5b4a868f11097b2e2341173c01732877d7 100644 (file)
@@ -1,60 +1,42 @@
-<!--
-       The documentation says <table class="table table-striped table-hover table-responsive">
-       but we have to use a div class instead to get the table width enough
--->
-<div class="table-responsive">
-       <table class="table table-striped table-hover">
-               <thead>
-                       <tr>
-                               <th></th>
-                               <th scope="col" >{{ _("Build job") }}</th>
-                               <th scope="col" >{{ _("Builder") }}</th>
-                               <th scope="col" >{{ _("Runtime") }}</th>
-                       </tr>
-               </thead>
+{% for job in jobs %}
+       <div class="callout {% if job.has_failed() %}alert{% end %}">
+               <div class="grid-x grid-padding-x align-middle">
+                       <div class="cell medium-5">
+                               <h5>
+                                       <a href="/job/{{ job.uuid }}">
+                                               {{ job }}
+                                       </a>
+                               </h5>
+                       </div>
 
-               <tbody>
-                       {% for job in jobs %}
-                               {% if job.state in ("running",) %}
-                                       <tr class="table-primary">
-                               {% elif job.state in ("dispatching", "uploading") %}
-                                       <tr class="table-info">
-                               {% elif job.state in ("aborted", "failed") %}
-                                       <tr class="table-danger">
-                               {% else %}
-                                       <tr>
-                               {% end %}
+                       <div class="cell medium-7">
+                               <div class="menu vertical align-right">
+                                       {% if job.is_active() %}
+                                               <li class="menu-text">
+                                                       {{ format_time(job.duration, shorter=True) }}
+                                               </li>
+                                       {% elif job.has_finished() %}
+                                               <li class="menu-text">
+                                                       {{ _("Finished %s") % \
+                                                               locale.format_date(job.time_finished, shorter=True) }}
+                                               </li>
+                                       {% end %}
 
-                                       <td>
-                                               {% module JobState(job, show_icon=True) %}
-                                       </td>
+                                       {% if job.build.owner %}
+                                               <li>
+                                                       {{ _("by %s") % job.build.owner }}
+                                               </li>
+                                       {% end %}
 
-                                       <td>
-                                               <a href="/build/{{ job.build.uuid }}">
-                                                       {{ job.build.name }}</a>.<a href="/job/{{ job.uuid }}">{{ job.arch }}</a>
-
-                                               {% if job.build.type == "scratch" %}
-                                                       <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Scratch build") }}">S</span>
-                                               {% elif job.test %}
-                                                       <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Test build") }}">T</span>
-                                               {% end %}
-                                       </td>
-
-                                       <td>
-                                               {% if job.builder %}
-                                                       <a href="/builders/{{ job.builder.name }}">
-                                                               {{ job.builder.name }}
+                                       {% if job.builder %}
+                                               <li>
+                                                       <a href="/builders/{{ job.builder.hostname }}">
+                                                               {{ _("on %s") % job.builder }}
                                                        </a>
-                                               {% else %}
-                                                       {{ _("N/A") }}
-                                               {% end %}
-                                       </td>
-
-                                       <td>
-                                               {{ format_time(job.duration, shorter=True) }}
-                                       </td>
-                               </tr>
-                       {% end %}
-               </tbody>
-       </table>
-</div>
+                                               </li>
+                                       {% end %}
+                               </div>
+                       </div>
+               </div>
+       </div>
+{% end %}