Skip to content

Commit 2389a06

Browse files
committed
Impl requests for reruns via REST calls
1 parent 01d7867 commit 2389a06

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

dune-project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@
2323
(name gobview)
2424
(synopsis "Web frontend for Goblint")
2525
(depends
26+
cohttp
27+
cohttp-lwt
28+
cohttp-lwt-jsoo
2629
dune
2730
(ocaml
2831
(>= 4.10.0))
2932
jsoo-react
33+
lwt
34+
uri
3035
(goblint-cil (>= 2.0.0))
3136
ctypes_stubs_js
3237
integers_stubs_js

gobview.opam

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ license: "MIT"
1212
homepage: "https://github.com/goblint/gobview"
1313
bug-reports: "https://github.com/goblint/gobview/issues"
1414
depends: [
15+
"cohttp"
16+
"cohttp-lwt"
17+
"cohttp-lwt-jsoo"
1518
"dune" {>= "2.7"}
1619
"ocaml" {>= "4.10.0"}
1720
"jsoo-react"
21+
"lwt"
22+
"uri"
1823
"goblint-cil" {>= "2.0.0"}
1924
"ctypes_stubs_js"
2025
"integers_stubs_js"

src/dune

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
(modes js)
66
(libraries
77
batteries.unthreaded
8+
cohttp
9+
cohttp-lwt
10+
cohttp-lwt-jsoo
811
fpath
912
gen_js_api
1013
goblint-cil
@@ -20,6 +23,7 @@
2023
lwt
2124
ppx_deriving_yojson.runtime
2225
ppx_deriving.runtime
26+
uri
2327
yojson
2428
zarith
2529
zarith_stubs_js)

src/ui/panel/ParameterView.re

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//open Lwt
2-
//open Cohttp
3-
//open Cohttp_lwt_unix
4-
// TODO use above mentioned packages for http client to call goblint http server
1+
open Lwt
2+
open Cohttp
3+
open Cohttp_lwt
54

5+
module Client = Cohttp_lwt_jsoo.Client
66
module ReactDOM = React.Dom
77

88
type paramState = Executed | Executing | Canceled | Error;
@@ -18,17 +18,31 @@ let make = (~parameters, ~history, ~setHistory) => {
1818
}, [|value|]);
1919

2020
let on_change = (new_value) => {
21-
setValue(_ => new_value)
21+
setValue(_ => new_value);
2222
};
2323

2424
let on_submit = () => {
2525
let newHistory = Array.append(history, [|(value, Time.getLocalTime(), Executing)|])
26-
setHistory(_ => newHistory)
27-
28-
// TODO transform param string with "' '" seperation mask
29-
// TODO execute newly transformed params
26+
setHistory(_ => newHistory);
3027

31-
// TODO use cohttp to call goblint server
28+
let /*parameterList*/ _ = ParameterUtils.constructParameters(value);
29+
let headers = Header.init_with("Content-Type", "application/json");
30+
let body = "{
31+
\"jsonrpc\": \"2.0\",
32+
\"id\": \"5\",
33+
\"method\": \"analyze\",
34+
\"params\": {\"reset\": false}
35+
}"
36+
|> Body.of_string;
37+
let url = "127.0.0.1:8001" |> Uri.of_string;
38+
39+
let _ = Client.put(url, ~body=body, ~headers=headers) >>= ((res, _ /*body*/)) => {
40+
res |> Response.status |> Code.code_of_status |> string_of_int |> Util.log;
41+
/*body |> Body.to_string >|= (b) => {
42+
Util.log(b);
43+
};*/
44+
Lwt.return ();
45+
};
3246

3347
setDisableCancel(_ => false);
3448
};

0 commit comments

Comments
 (0)