1- open Unix
21// open Lwt
32// open Cohttp
43// open Cohttp_lwt_unix
@@ -8,37 +7,12 @@ module ReactDOM = React.Dom
87
98type paramState = Executed | Executing | Canceled | Error ;
109
11- // TODO FIX BUG: make param history permanently available until GobView is closed again => clear afterwards
1210[@ react . component ]
13- let make = (~parameters) => {
14-
15- let initParams =
16- parameters
17- |> String . split_on_char(' ' )
18- |> List . map((s) => { String . sub(s, 1 , String . length(s)- 2 )})
19- |> String . concat(" " );
20-
21- let timeToString = (time) => {
22- string_of_int(time. tm_min)
23- |> String . cat(":" )
24- |> String . cat(string_of_int(time. tm_hour))
25- |> String . cat(" " );
26- }
27-
28- let getLocalTime = () => {
29- Unix . time()
30- |> Unix . localtime
31- |> timeToString;
32- }
11+ let make = (~parameters, ~history, ~setHistory) => {
3312
34- let (history , setHistory ) = React . useState(_ => [| (initParams, getLocalTime() , Executed )|] );
35- let (value , setValue ) = React . useState(_ => initParams);
13+ let (value , setValue ) = React . useState(_ => parameters);
3614 let (disableCancel , setDisableCancel ) = React . useState(_ => true );
3715
38- React . useEffect1(() => {
39- None
40- }, [| history|] );
41-
4216 React . useEffect1(() => {
4317 None
4418 }, [| value|] );
@@ -48,7 +22,7 @@ let make = (~parameters) => {
4822 };
4923
5024 let on_submit = () => {
51- let newHistory = Array . append(history, [| (value, getLocalTime() , Executing )|] )
25+ let newHistory = Array . append(history, [| (value, Time . getLocalTime() , Executing )|] )
5226 setHistory(_ => newHistory)
5327
5428 // TODO transform param string with "' '" seperation mask
@@ -101,7 +75,7 @@ let make = (~parameters) => {
10175 )
10276 };
10377
104- let list_elements = map_history_entry_to_list_entry( history) ;
78+ let list_elements = history |> map_history_entry_to_list_entry ;
10579
10680 <div >
10781 <div className= "input-group mb-2" >
0 commit comments