guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Mathieu Othacehe
Date: Mon, 19 Apr 2021 13:38:46 -0400 (EDT)

branch: master
commit 626d567679719be37c139ceeabf332d9fcf38869
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Sun Apr 18 21:30:51 2021 +0200

    Add pagination to dashboard page.
    
    * src/cuirass/http.scm (url-handler): Pass previous and next evaluation to
    evaluation-dashboard call.
    * src/cuirass/templates.scm (evaluation-dashboard): Add "prev-eval" and
    "next-eval" arguments.
    * src/static/css/cuirass.css (eval-nav): New section.
---
 src/cuirass/http.scm       | 11 +++++--
 src/cuirass/templates.scm  | 78 +++++++++++++++++++++++++++++++++++++++++++---
 src/static/css/cuirass.css |  4 +++
 3 files changed, 86 insertions(+), 7 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 7bd7aac..5bd78d6 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -861,6 +861,8 @@ into a specification record and return it."
 
     (('GET "eval" (= string->number id) "dashboard")
      (let* ((params (request-parameters request))
+            (names (and=> (assq-ref params 'names)
+                          uri-decode))
             (system (assq-ref params 'system))
             (spec-name (db-get-evaluation-specification id)))
        (if spec-name
@@ -869,13 +871,18 @@ into a specification record and return it."
                   (default-system
                     (if (member "x86_64-linux" systems)
                         "x86_64-linux"
-                        (car systems))))
+                        (car systems)))
+                  (prev (db-get-previous-eval id))
+                  (next (db-get-next-eval id)))
              (respond-html
               (html-page
                "Dashboard"
                (evaluation-dashboard id systems
                                      #:current-system
-                                     (or system default-system))
+                                     (or system default-system)
+                                     #:names names
+                                     #:prev-eval prev
+                                     #:next-eval next)
                `(((#:name . ,spec-name)
                   (#:link . ,(string-append "/jobset/" spec-name)))
                  ((#:name . ,(string-append "Evaluation "
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 3437cf5..446ee54 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -1866,12 +1866,80 @@ text-dark d-flex position-absolute w-100"))
                                      #:colors (list "#3e95cd"))))))))
 
 (define* (evaluation-dashboard evaluation systems
-                               #:key current-system)
+                               #:key
+                               current-system
+                               names
+                               prev-eval
+                               next-eval)
   (let ((jobs
-         (format #f "/api/jobs?evaluation=~a&system=~a"
-                 evaluation current-system)))
-    `((p (@ (class "lead"))
-         ,(format #f "Dasboard evaluation #~a" evaluation))
+         (if names
+             (format #f "/api/jobs?evaluation=~a&names=~a"
+                     evaluation names)
+             (format #f "/api/jobs?evaluation=~a&system=~a"
+                     evaluation current-system))))
+    `((script "
+$(document).ready(function() {
+  var url = new URL(window.location.href);
+  var params = url.searchParams;
+  var size = Array.from(params).length;
+  if (params.get('names')) {
+    $('#get-dashboard').remove();
+  }
+  $('#prev-link').attr('href', function(i, href) {
+    if (size > 0)
+      return href + '?' + params;
+    else
+      return href;
+});
+  $('#next-link').attr('href', function(i, href) {
+   if (size > 0)
+     return href + '?' + params;
+   else
+     return href;
+});
+});")
+      (p (@ (class "lead mb-0"))
+         ,(format #f "Dasboard evaluation #~a" evaluation)
+         (nav
+          (@ (aria-label "Evaluation navigation")
+             (class "eval-nav ml-3"))
+          (ul (@ (class "pagination pagination-sm"))
+              (li (@ (class
+                       ,(string-append "page-item "
+                                       (if prev-eval
+                                           ""
+                                           "disabled"))))
+                  (a
+                   (@ (id "prev-link")
+                      (class "page-link")
+                      (href
+                       ,(if prev-eval
+                            (format #f "/eval/~a/dashboard" prev-eval)
+                            "#")))
+                     (span
+                      (@ (aria-hidden "true"))
+                      "«")
+                     (span
+                      (@ (class "sr-only"))
+                      "Previous")))
+              (li (@ (class
+                       ,(string-append "page-item "
+                                       (if next-eval
+                                           ""
+                                           "disabled"))))
+                  (a
+                   (@ (id "next-link")
+                      (class "page-link")
+                      (href
+                       ,(if next-eval
+                            (format #f "/eval/~a/dashboard" next-eval)
+                            "#")))
+                     (span
+                      (@ (aria-hidden "true"))
+                      "»")
+                     (span
+                      (@ (class "sr-only"))
+                      "Next"))))))
       (form (@ (id "get-dashboard")
                (class "row g-3 mb-3")
                (action "/eval/" ,evaluation "/dashboard")
diff --git a/src/static/css/cuirass.css b/src/static/css/cuirass.css
index 0d41349..cc5d457 100644
--- a/src/static/css/cuirass.css
+++ b/src/static/css/cuirass.css
@@ -116,3 +116,7 @@ div.tooltip {
     text-align:center;
     z-index:2;
 }
+
+.eval-nav  {
+    display: inline-block;
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]