From 355835df5ea20124a3740e1f1bbfa1bb0990c54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Mon, 7 Dec 2020 16:33:19 +0100 Subject: [PATCH] Show status in job overview --- lib/dune | 2 +- lib/views.ml | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/dune b/lib/dune index 09c03b4..ff590ef 100644 --- a/lib/dune +++ b/lib/dune @@ -1,3 +1,3 @@ (library (name builder_web) - (libraries builder opium bos rresult duration)) + (libraries builder opium tyxml bos rresult duration)) diff --git a/lib/views.ml b/lib/views.ml index 65deb57..b95a2f9 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -2,6 +2,15 @@ open Tyxml.Html let txtf fmt = Fmt.kstrf txt fmt +let check_icon check = + if check + then + span ~a:[a_style "color: green;"] + [txt "☑"] + else + span ~a:[a_style "color: red;"] + [txt "☒"] + let layout ~title:title_ body_ = html (head (title (txt title_)) @@ -33,7 +42,10 @@ let job name runs = ul (List.map (fun run -> li [ a ~a:[a_href Fpath.(to_string (v "run" / Uuidm.to_string run.Model.uuid) ^ "/")] - [txtf "%a" (Ptime.pp_human ()) run.Model.start]; + [ + txtf "%a" (Ptime.pp_human ()) run.Model.start; + check_icon (match run.result with Builder.Exited 0 -> true | _ -> false); + ]; ]) runs); @@ -42,12 +54,15 @@ let job name runs = let job_run { Model.meta = { Model.job_info = { Builder.name; _ }; - uuid; result; _ }; + start; finish; uuid; result }; out; _ } = + let ptime_pp = Ptime.pp_human () in + let delta = Ptime.diff finish start in layout ~title:(Printf.sprintf "Job run %s (%s)" name (Uuidm.to_string uuid)) - [ h1 [txtf "Job build %s (%a)" name Uuidm.pp uuid]; - p [txtf "Status: %a" Builder.pp_execution_result result]; + [ h1 [txtf "Job build %s %a (%a)" name ptime_pp start Uuidm.pp uuid]; + p [txtf "Took %a." Ptime.Span.pp delta ]; + p [txtf "Status: %a." Builder.pp_execution_result result]; div (List.concat_map (fun (ts, line) -> [ code [txtf "%d ms %s" (Duration.to_ms (Int64.of_int ts)) line];