]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Add pagination to new page
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 15:47:38 +0000 (15:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 15:47:38 +0000 (15:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/jobs/index.html
src/web/jobs.py

index 72508e88747da7e12fa120fc17e899699446e4d3..4c896b75013d804f890410e84adfc02e67a7039e 100644 (file)
 
        <section class="section">
                <div class="container">
-                       {% module JobsQueue(jobs) %}
+                       <div class="block">
+                               {% module JobsQueue(jobs) %}
+                       </div>
+
+                       <div class="block">
+                               <nav class="pagination is-centered" role="navigation" aria-label="pagination">
+                                       <a class="pagination-previous {% if not offset %}is-disabled{% end %}"
+                                                       href="{{ make_url("/jobs", offset=offset - limit, limit=limit) }}">
+                                               {{ _("Previous Page") }}
+                                       </a>
+
+                                       <a class="pagination-next"
+                                                       href="{{ make_url("/jobs", offset=offset + limit, limit=limit) }}">
+                                               {{ _("Next Page") }}
+                                       </a>
+                               </nav>
+                       </div>
                </div>
        </section>
 {% end block %}
index 180aa1574eec431832077195efbb8a5c2e5abbd0..303a42fa085b0304fd1698f3b26ab4cabc3a1b65 100644 (file)
@@ -141,10 +141,14 @@ class APIv1LogStreamHandler(base.BackendMixin, tornado.websocket.WebSocketHandle
 
 class IndexHandler(base.BaseHandler):
        def get(self):
+               # Pagination
+               offset = self.get_argument_int("offset", None) or 0
+               limit  = self.get_argument_int("limit", None) or 50
+
                with self.db.transaction():
-                       jobs = self.backend.jobs.get_finished(limit=50)
+                       jobs = self.backend.jobs.get_finished(limit=limit, offset=offset)
 
-               self.render("jobs/index.html", jobs=jobs)
+               self.render("jobs/index.html", jobs=jobs, limit=limit, offset=offset)
 
 
 class LogHandler(base.BaseHandler):