[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Add a jobs toggle button.
From: |
Mathieu Othacehe |
Subject: |
branch master updated: Add a jobs toggle button. |
Date: |
Thu, 08 Apr 2021 07:50:00 -0400 |
This is an automated email from the git hooks/post-receive script.
mothacehe pushed a commit to branch master
in repository guix-cuirass.
The following commit(s) were added to refs/heads/master by this push:
new 245d0b5 Add a jobs toggle button.
245d0b5 is described below
commit 245d0b5e5a60b43facde9c57586848d4e3033371
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Thu Apr 8 13:49:02 2021 +0200
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.
---
src/cuirass/database.scm | 6 +-
src/cuirass/templates.scm | 157 +++++++++++++++++++++++++++-------------------
2 files changed, 95 insertions(+), 68 deletions(-)
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 212ff5e..7c83723 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -479,7 +479,7 @@ priority, systems FROM Specifications ORDER BY name ASC;")))
(with-db-worker-thread db
(let ((query "
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
LEFT JOIN Evaluations ON Specifications.name = Evaluations.specification
WHERE Evaluations.status = 0
@@ -494,9 +494,11 @@ GROUP BY Jobs.evaluation) b on evals.max = b.evaluation;"))
(summary '()))
(match rows
(() (reverse summary))
- (((specification percentage succeeded failed scheduled) . rest)
+ (((specification percentage succeeded
+ failed scheduled evaluation) . rest)
(loop rest
(cons `((#:specification . ,specification)
+ (#:evaluation . ,evaluation)
(#:percentage . ,(number percentage))
(#:succeeded . ,(number succeeded))
(#:failed . ,(number failed))
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 09f660d..213e580 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -264,12 +264,17 @@ columnDefs: [
"Return HTML for the SPECS table."
`((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/"))
- (button (@ (class "btn btn-outline-warning float-right")
+ (button (@ (class "btn btn-outline-warning mr-1 float-right")
(type "button"))
- (span (@(class "oi oi-rss text-warning align-right")
- (title "RSS")
- (aria-hidden "true"))
+ (span (@ (class "oi oi-rss text-warning align-right")
+ (title "RSS")
+ (aria-hidden "true"))
"")))
(a (@ (class "btn btn-outline-primary mr-1 float-right")
(href "/specification/add/")
@@ -278,6 +283,12 @@ columnDefs: [
(title "Add")
(aria-hidden "true"))
"")))
+ (script "
+$(document).ready(function() {
+$('.job-toggle').click(function() {
+ $('.job-per').toggle();
+ $('.job-val').toggle();
+})});")
(table
(@ (id "spec-table")
(class "table table-sm table-hover"))
@@ -293,69 +304,83 @@ columnDefs: [
(tbody
,@(map
(lambda (spec)
- `(tr (td (a (@ (href "/jobset/"
+ `(tr
+ (td (a (@ (href "/jobset/"
+ ,(specification-name spec)))
+ ,(specification-name spec)))
+ (td ,(match (specification-build spec)
+ ((? symbol? build)
+ (symbol->string build))
+ ((build _ ...)
+ (symbol->string build))))
+ (td ,(string-join
+ (map (lambda (channel)
+ (format #f "~a (on ~a)"
+ (channel-name channel)
+ (channel-branch channel)))
+ (specification-channels spec)) ", "))
+ (td ,(number->string
+ (specification-priority spec)))
+ (td ,(string-join
+ (sort (specification-systems spec)
+ string<?)
+ ", "))
+ (td
+ ,@(let ((summary
+ (spec-summary
+ (specification-name spec))))
+ (if summary
+ `((div
+ (@ (class "badge badge-success job-per")
+ (title "Percentage succeeded"))
+ ,(format #f "~1,2f%"
+ (assq-ref summary #:percentage)))
+ " "
+ (div
+ (@ (class "job-val")
+ (style "display:none"))
+ (div
+ (@ (class "badge badge-success")
+ (title "Succeeded"))
+ ,(assq-ref summary #:succeeded))
+ (div
+ (@ (class "badge badge-danger")
+ (title "Failed"))
+ ,(assq-ref summary #:failed))
+ (div
+ (@ (class "badge badge-secondary")
+ (title "Scheduled"))
+ ,(assq-ref summary #:scheduled))))
+ '())))
+ (td
+ ,(let ((eval (and=> (spec-summary
+ (specification-name spec))
+ (cut assq-ref <> #:evaluation))))
+ `(a (@ (href "/eval/" ,eval
+ "/dashboard"))
+ (div
+ (@ (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")
+ (href "#")
+ (data-toggle "dropdown")
+ (role "button")
+ (aria-haspopup "true")
+ (aria-expanded "false"))
+ " ")
+ (div (@ (class "dropdown-menu"))
+ (a (@ (class "dropdown-item")
+ (href "/specification/edit/"
,(specification-name spec)))
- ,(specification-name spec)))
- (td ,(match (specification-build spec)
- ((? symbol? build)
- (symbol->string build))
- ((build _ ...)
- (symbol->string build))))
- (td ,(string-join
- (map (lambda (channel)
- (format #f "~a (on ~a)"
- (channel-name channel)
- (channel-branch channel)))
- (specification-channels spec)) ", "))
- (td ,(number->string
- (specification-priority spec)))
- (td ,(string-join
- (sort (specification-systems spec)
- string<?)
- ", "))
- (td
- ,@(let ((summary
- (spec-summary
- (specification-name spec))))
- (if summary
- `((div
- (@ (class "badge badge-success")
- (title "Percentage succeeded"))
- ,(format #f "~1,2f%"
- (assq-ref summary #:percentage)))
- " "
- (div
- (@ (class "badge badge-success")
- (title "Succeeded"))
- ,(assq-ref summary #:succeeded))
- (div
- (@ (class "badge badge-danger")
- (title "Failed"))
- ,(assq-ref summary #:failed))
- (div
- (@ (class "badge badge-secondary")
- (title "Scheduled"))
- ,(assq-ref summary #:scheduled)))
- '())))
- (td
- (div
- (@ (class "dropdown"))
- (a (@ (class "oi oi-menu dropdown-toggle
no-dropdown-arrow")
- (href "#")
- (data-toggle "dropdown")
- (role "button")
- (aria-haspopup "true")
- (aria-expanded "false"))
- " ")
- (div (@ (class "dropdown-menu"))
- (a (@ (class "dropdown-item")
- (href "/specification/edit/"
- ,(specification-name spec)))
- " Edit")
- (a (@ (class "dropdown-item")
- (href "/admin/specifications/delete/"
- ,(specification-name spec)))
- " Delete"))))))
+ " Edit")
+ (a (@ (class "dropdown-item")
+ (href "/admin/specifications/delete/"
+ ,(specification-name spec)))
+ " Delete"))))))
specs)))))))
(define* (specification-edit #:optional spec)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Add a jobs toggle button.,
Mathieu Othacehe <=