1+ open Unix
2+
13module ReactDOM = React . Dom
24
35[@react. component]
@@ -9,7 +11,20 @@ let make = (~parameters) => {
911 |> List . map((s) => { String . sub(s, 1 , String . length(s)- 2 )})
1012 |> String . concat(" " );
1113
12- let (history , setHistory ) = React . useState(_ => [| params|] );
14+ let timeToString = (time) => {
15+ string_of_int(time. tm_min)
16+ |> String . cat(":" )
17+ |> String . cat(string_of_int(time. tm_hour))
18+ |> String . cat(" " );
19+ }
20+
21+ let getLocalTime = () => {
22+ Unix . time()
23+ |> Unix . localtime
24+ |> timeToString;
25+ }
26+
27+ let (history , setHistory ) = React . useState(_ => [| (params, getLocalTime() )|] );
1328 let (value , setValue ) = React . useState(_ => params);
1429
1530
@@ -26,7 +41,7 @@ let make = (~parameters) => {
2641 };
2742
2843 let on_submit = () => {
29- let new_history = Array . append(history, [| value|] )
44+ let new_history = Array . append(history, [| ( value, getLocalTime () ) |] )
3045 setHistory(_ => new_history)
3146
3247 // TODO transform param string with "' '" seperation mask
@@ -39,13 +54,17 @@ let make = (~parameters) => {
3954 </Button >;
4055
4156 let map_history_entry_to_list_entry = (arr) => {
42- arr |> Array . mapi((i, entry) =>
57+ arr |> Array . mapi((i, ( entry, time) ) =>
4358 {<li key= {String . cat("params_" , string_of_int(i))} className= "list-group-item" >
4459 <div className= "container text-center" >
4560 <div className= "row" >
46- <div className= "col-1 " >
61+ <div className= "col-2 " >
4762 <IconCheckmark />
4863 </div >
64+ <div className= "col-2" >
65+ <IconClock />
66+ {time |> React . string}
67+ </div >
4968 <div className= "col" >
5069 {entry |> React . string}
5170 </div >
@@ -58,7 +77,7 @@ let make = (~parameters) => {
5877 let list_elements = map_history_entry_to_list_entry(history);
5978
6079 <div >
61- <div className= "input-group" >
80+ <div className= "input-group mb-2 " >
6281 {playButton}
6382 <Button color= {` Danger } outline= {true}>
6483 {"Cancel" |> React . string}
@@ -69,8 +88,23 @@ let make = (~parameters) => {
6988 <div className= "row align-items-center" >
7089 {"History" |> React . string}
7190 </div >
72- <div className= "row" style= {ReactDOM . Style . make(~height= "120px " , ~maxHeight= "100% " , ~overflow= "auto" , () )}>
91+ <div className= "row" style= {ReactDOM . Style . make(~height= "115px " , ~maxHeight= "100% " , ~overflow= "auto" , () )}>
7392 <ol key= {"params_list" } className= "list-group" >
93+ {<li key= {"params_header_item" } className= "list-group-item" >
94+ <div className= "container text-center" >
95+ <div className= "row" >
96+ <div className= "col-2" >
97+ {"Status" |> React . string}
98+ </div >
99+ <div className= "col-2" >
100+ {"Time" |> React . string}
101+ </div >
102+ <div className= "col" >
103+ {"Parameters" |> React . string}
104+ </div >
105+ </div >
106+ </div >
107+ </li >}
74108 {list_elements |> Array . to_list |> React . list}
75109 </ol >
76110 </div >
0 commit comments