builder-web/lib/views.ml

55 lines
1.4 KiB
OCaml
Raw Normal View History

2020-12-02 13:33:15 +00:00
open Tyxml.Html
2020-12-07 09:17:49 +00:00
let txtf fmt = Fmt.kstrf txt fmt
2020-12-02 13:33:15 +00:00
let layout ~title:title_ body_ =
html
(head (title (txt title_))
[])
(body body_)
let builder jobs =
layout ~title:"Builder Web"
[ h1 [txt "Builder web"];
p [
2020-12-07 09:17:49 +00:00
txtf "We have currently %d jobs."
(List.length jobs);
2020-12-02 13:33:15 +00:00
];
ul (List.map (fun job ->
2020-12-07 09:17:49 +00:00
li [
2020-12-07 09:43:57 +00:00
a ~a:[a_href ("job/" ^ Model.job_name job ^ "/")]
2020-12-07 09:17:49 +00:00
[txt (Model.job_name job)];
])
2020-12-02 13:33:15 +00:00
jobs);
]
2020-12-07 09:17:49 +00:00
let job job =
let name = Model.job_name job in
layout ~title:(Printf.sprintf "Job %s" name)
[ h1 [txtf "Job %s" name];
p [
txtf "Currently %d job runs."
(List.length job.Model.runs)
];
ul (List.map (fun (run : Fpath.t) ->
li [
2020-12-07 09:43:57 +00:00
a ~a:[a_href Fpath.(to_string (v "run" // run) ^ "/")]
2020-12-07 09:17:49 +00:00
[txtf "%a" Fpath.pp run];
])
job.Model.runs);
]
let job_run { Model.job_info = { Builder.name; _ };
uuid; result; out; _ } =
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];
div (List.concat_map (fun (ts, line) ->
[
code [txtf "%d ms %s" (Duration.to_ms (Int64.of_int ts)) line];
br ();
])
(List.rev out));
]