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 a jobs toggle button.

* src/cuirass/database.scm (db-get-specifications-summary): Return the latest
evaluation.
* src/cuirass/templates.scm (specifications-table): Add a monitor and a toggle
button.
This commit is contained in:
Mathieu Othacehe 2021-04-08 13:49:02 +02:00
parent c5dd74afce
commit 245d0b5e5a
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 95 additions and 68 deletions

View file

@ -479,7 +479,7 @@ priority, systems FROM Specifications ORDER BY name ASC;")))
(with-db-worker-thread db (with-db-worker-thread db
(let ((query " (let ((query "
SELECT specification, 100 * CAST(succeeded AS FLOAT) / total, SELECT specification, 100 * CAST(succeeded AS FLOAT) / total,
succeeded, failed, scheduled FROM succeeded, failed, scheduled, evaluation FROM
(SELECT DISTINCT ON(specification) specification, MAX(id) FROM Specifications (SELECT DISTINCT ON(specification) specification, MAX(id) FROM Specifications
LEFT JOIN Evaluations ON Specifications.name = Evaluations.specification LEFT JOIN Evaluations ON Specifications.name = Evaluations.specification
WHERE Evaluations.status = 0 WHERE Evaluations.status = 0
@ -494,9 +494,11 @@ GROUP BY Jobs.evaluation) b on evals.max = b.evaluation;"))
(summary '())) (summary '()))
(match rows (match rows
(() (reverse summary)) (() (reverse summary))
(((specification percentage succeeded failed scheduled) . rest) (((specification percentage succeeded
failed scheduled evaluation) . rest)
(loop rest (loop rest
(cons `((#:specification . ,specification) (cons `((#:specification . ,specification)
(#:evaluation . ,evaluation)
(#:percentage . ,(number percentage)) (#:percentage . ,(number percentage))
(#:succeeded . ,(number succeeded)) (#:succeeded . ,(number succeeded))
(#:failed . ,(number failed)) (#:failed . ,(number failed))

View file

@ -264,8 +264,13 @@ columnDefs: [
"Return HTML for the SPECS table." "Return HTML for the SPECS table."
`((p (@ (class "lead")) "Specifications" `((p (@ (class "lead")) "Specifications"
(button (@ (class "btn btn-outline-primary float-right job-toggle")
(type "button"))
(span (@ (class "oi oi-contrast d-inline-block")
(title "Toggle jobs"))))
(a (@ (href "/events/rss/")) (a (@ (href "/events/rss/"))
(button (@ (class "btn btn-outline-warning float-right") (button (@ (class "btn btn-outline-warning mr-1 float-right")
(type "button")) (type "button"))
(span (@ (class "oi oi-rss text-warning align-right") (span (@ (class "oi oi-rss text-warning align-right")
(title "RSS") (title "RSS")
@ -278,6 +283,12 @@ columnDefs: [
(title "Add") (title "Add")
(aria-hidden "true")) (aria-hidden "true"))
""))) "")))
(script "
$(document).ready(function() {
$('.job-toggle').click(function() {
$('.job-per').toggle();
$('.job-val').toggle();
})});")
(table (table
(@ (id "spec-table") (@ (id "spec-table")
(class "table table-sm table-hover")) (class "table table-sm table-hover"))
@ -293,7 +304,8 @@ columnDefs: [
(tbody (tbody
,@(map ,@(map
(lambda (spec) (lambda (spec)
`(tr (td (a (@ (href "/jobset/" `(tr
(td (a (@ (href "/jobset/"
,(specification-name spec))) ,(specification-name spec)))
,(specification-name spec))) ,(specification-name spec)))
(td ,(match (specification-build spec) (td ,(match (specification-build spec)
@ -319,11 +331,14 @@ columnDefs: [
(specification-name spec)))) (specification-name spec))))
(if summary (if summary
`((div `((div
(@ (class "badge badge-success") (@ (class "badge badge-success job-per")
(title "Percentage succeeded")) (title "Percentage succeeded"))
,(format #f "~1,2f%" ,(format #f "~1,2f%"
(assq-ref summary #:percentage))) (assq-ref summary #:percentage)))
" " " "
(div
(@ (class "job-val")
(style "display:none"))
(div (div
(@ (class "badge badge-success") (@ (class "badge badge-success")
(title "Succeeded")) (title "Succeeded"))
@ -335,11 +350,21 @@ columnDefs: [
(div (div
(@ (class "badge badge-secondary") (@ (class "badge badge-secondary")
(title "Scheduled")) (title "Scheduled"))
,(assq-ref summary #:scheduled))) ,(assq-ref summary #:scheduled))))
'()))) '())))
(td (td
,(let ((eval (and=> (spec-summary
(specification-name spec))
(cut assq-ref <> #:evaluation))))
`(a (@ (href "/eval/" ,eval
"/dashboard"))
(div (div
(@ (class "dropdown")) (@ (class "oi oi-monitor d-inline-block ml-2")
(title "Dashboard")
(aria-hidden "true"))
"")))
(div
(@ (class "dropdown d-inline-block ml-2"))
(a (@ (class "oi oi-menu dropdown-toggle no-dropdown-arrow") (a (@ (class "oi oi-menu dropdown-toggle no-dropdown-arrow")
(href "#") (href "#")
(data-toggle "dropdown") (data-toggle "dropdown")