diff options
Diffstat (limited to 'guix-data-service/web')
-rw-r--r-- | guix-data-service/web/jobs/controller.scm | 41 | ||||
-rw-r--r-- | guix-data-service/web/jobs/html.scm | 9 |
2 files changed, 42 insertions, 8 deletions
diff --git a/guix-data-service/web/jobs/controller.scm b/guix-data-service/web/jobs/controller.scm index 7683a12..24a1274 100644 --- a/guix-data-service/web/jobs/controller.scm +++ b/guix-data-service/web/jobs/controller.scm @@ -19,6 +19,7 @@ #:use-module (ice-9 match) #:use-module (guix-data-service web render) #:use-module (guix-data-service web query-parameters) + #:use-module (guix-data-service web util) #:use-module (guix-data-service jobs load-new-guix-revision) #:use-module (guix-data-service web jobs html) #:export (jobs-controller)) @@ -79,14 +80,38 @@ (assq-ref query-parameters 'before_id) limit-results)) (recent-events (select-recent-job-events conn))) - (render-html - #:sxml (view-jobs - query-parameters - jobs - recent-events - (and limit-results - (>= (length jobs) - limit-results)))))) + (case (most-appropriate-mime-type + '(application/json text/html) + mime-types) + ((application/json) + (render-json + `((recent-events + . ,(list->vector + (map (match-lambda + ((_ commit _ _ event occurred_at) + `((commit . ,commit) + (event . ,event) + (occurred_at . ,occurred_at)))) + recent-events))) + (jobs + . ,(list->vector + (map (match-lambda + ((_ commit source _ created-at _ events log) + `((commit . ,commit) + (source . ,source) + (created-at . ,created-at) + (events . ,events) + (log . ,log)))) + jobs)))))) + (else + (render-html + #:sxml (view-jobs + query-parameters + jobs + recent-events + (and limit-results + (>= (length jobs) + limit-results)))))))) (define (render-job-events mime-types conn query-parameters) (let* ((limit-results diff --git a/guix-data-service/web/jobs/html.scm b/guix-data-service/web/jobs/html.scm index bf6b369..742d7bd 100644 --- a/guix-data-service/web/jobs/html.scm +++ b/guix-data-service/web/jobs/html.scm @@ -109,6 +109,15 @@ (class "btn btn-lg btn-primary")) "Update results"))))))) (div + (@ (class "btn-group pull-right") + (role "group")) + (a (@ (class "btn btn-lg btn-default") + (href ,(string-append + "/jobs.json")) + (role "button")) + "View JSON")) + + (div (@ (class "row")) (div (@ (class "col-sm-12")) |