Skip to content

Commit 1f86a2e

Browse files
committed
Add time for when run was started and redesign param history
1 parent dd459c1 commit 1f86a2e

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

src/ui/icons/IconClock.re

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[@react.component]
2+
let make = () => {
3+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-clock" viewBox="0 0 16 16">
4+
<path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z"/>
5+
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/>
6+
</svg>
7+
}

src/ui/panel/ParameterView.re

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open Unix
2+
13
module 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

Comments
 (0)