2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2023-12-14 06:03:04 +01:00

Add pagination button on evaluation page.

This commit is contained in:
Mathieu Othacehe 2021-03-25 11:48:42 +01:00
parent 1ed9360108
commit c3a9e9c79f
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 37 additions and 8 deletions

View file

@ -220,6 +220,7 @@ Hydra format."
(define* (evaluation-html-page evaluation
#:key
status
(paginate? #t)
border-high-time border-low-time
border-high-id border-low-id)
"Return the HTML page representing EVALUATION."
@ -236,12 +237,14 @@ Hydra format."
(handle-builds-request
`((evaluation . ,id)
(status . ,(and=> status string->symbol))
(nr . ,%page-size)
(order . finish-time+build-id)
(border-high-time . ,border-high-time)
(border-low-time . ,border-low-time)
(border-high-id . ,border-high-id)
(border-low-id . ,border-low-id)))))
,@(if paginate?
`((nr . ,%page-size)
(border-high-time . ,border-high-time)
(border-low-time . ,border-low-time)
(border-high-id . ,border-high-id)
(border-low-id . ,border-low-id))
'())
(order . finish-time+build-id)))))
(html-page
"Evaluation"
@ -760,6 +763,8 @@ into a specification record and return it."
(('GET "eval" id)
(let* ((params (request-parameters request))
(status (assq-ref params 'status))
(paginate? (let ((arg (assq-ref params 'paginate)))
(if arg (string=? arg "1") #t)))
(border-high-time (assq-ref params 'border-high-time))
(border-low-time (assq-ref params 'border-low-time))
(border-high-id (assq-ref params 'border-high-id))
@ -769,6 +774,7 @@ into a specification record and return it."
(if specification
(respond-html (evaluation-html-page evaluation
#:status status
#:paginate? paginate?
#:border-high-time
border-high-time
#:border-low-time

View file

@ -1087,7 +1087,24 @@ evaluation."
(define duration (- evaltime timestamp))
`((p (@ (class "lead"))
`((script "
$(document).ready(function() {
var url = new URL(window.location.href);
var params = url.searchParams;
var paginate = params.get('paginate');
var href;
console.log(paginate);
if (!paginate || paginate == '1') {
params.set('paginate', 0);
$('#paginate').attr('href', url.toString());
} else if (paginate == '0') {
params.set('paginate', 1);
$('#paginate').attr('class', 'oi oi-collapse-up');
$('#paginate').attr('href', url.toString());
}
});
")
(p (@ (class "lead"))
,(format #f "Evaluation #~a" id))
,@(if (= timestamp 0)
'()
@ -1122,7 +1139,13 @@ evaluation."
,(format #f "~@[~a~] ~:[B~;b~]uilds of evaluation #~a"
(and=> status string-capitalize)
status
id))
id)
" "
(a (@ (id "paginate")
(class "oi oi-collapse-down")
(style "font-size:0.7em")
(href "")
(role "button"))))
(ul (@ (class "nav nav-tabs"))
(li (@ (class "nav-item"))
(a (@ (class ,(string-append "nav-link "