|
2 | 2 | open Cohttp |
3 | 3 | open Cohttp_lwt |
4 | 4 |
|
| 5 | +module Js = Js_of_ocaml.Js |
5 | 6 | module Client = Cohttp_lwt_jsoo.Client |
6 | 7 | module ReactDOM = React.Dom |
7 | 8 |
|
@@ -75,6 +76,18 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR |
75 | 76 | setSortDesc(_ => !sortDesc); |
76 | 77 | } |
77 | 78 |
|
| 79 | + let on_add_parameter = (ev) => { |
| 80 | + let target = React.Event.Mouse.target(ev) |> ReactDOM.domElement_of_js; |
| 81 | + let unresolved_parameter = target##.textContent |> Js.Opt.to_option; |
| 82 | + |
| 83 | + let parameter = switch unresolved_parameter { |
| 84 | + | Some(p) => Js.to_string(p) ++ " " |
| 85 | + | None => "" |
| 86 | + }; |
| 87 | + |
| 88 | + setInputValue(inputVal => String.cat(parameter, inputVal)); |
| 89 | + } |
| 90 | + |
78 | 91 | let is_input_invalid = (parameter_list: list((string, string)), is_malformed, input_val): inputState => { |
79 | 92 | if (String.length(input_val) == 0) { |
80 | 93 | Empty |
@@ -156,6 +169,9 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR |
156 | 169 | Client.post(config_uri, ~body=config_body, ~headers=headers) >>= |
157 | 170 | ((res, body)) => { |
158 | 171 | let code = res |> Response.status |> Code.code_of_status; |
| 172 | + /*let msg_from_body = Cohttp_lwt.Body.to_string(body) >|= (body) => { |
| 173 | + Lwt.return(body) |
| 174 | + }*/ |
159 | 175 | let _ = Body.drain_body(body); |
160 | 176 |
|
161 | 177 | if (code < 200 || code >= 400) { |
@@ -271,7 +287,9 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR |
271 | 287 | </div> |
272 | 288 | <div className="col"> |
273 | 289 | {parameter_grouping |> List.mapi((j,e) => { |
274 | | - <span key={"pill_" ++ string_of_int(j)} className="m-1 badge rounded-pill bg-secondary text">{e |> React.string}</span> |
| 290 | + <span key={"pill_" ++ string_of_int(j)} className="m-1 badge rounded-pill bg-secondary text" style={ReactDOM.Style.make(~cursor="pointer", ())} onClick=on_add_parameter> |
| 291 | + {e |> React.string} |
| 292 | + </span> |
275 | 293 | }) |> React.list} |
276 | 294 | </div> |
277 | 295 | </div> |
|
0 commit comments