Skip to content

Commit

Permalink
Webapp: more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinepouille committed Sep 24, 2024
1 parent 7aa8d10 commit d57f370
Show file tree
Hide file tree
Showing 50 changed files with 70 additions and 57 deletions.
6 changes: 3 additions & 3 deletions gui/JsSim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ let onload (_ : 'a) : bool Js.t =
let () = Dom.appendChild main (Panel_tabs.navtabs ()) in
let () = Dom.appendChild main (Panel_tabs.navcontents ()) in
let () =
Dom.appendChild main (Tyxml_js.To_dom.of_div (Panel_settings.content ()))
Dom.appendChild main (Tyxml_js.To_dom.of_div (Panel_preferences.content ()))
in

let () = Panel_projects.onload () in
let () = Panel_tabs.onload () in
let () = Panel_settings.onload () in
let () = Panel_preferences.onload () in

let _ =
Dom_html.window##.onresize :=
Dom_html.handler (fun _ ->
let () = Panel_projects.onresize () in
let () = Panel_tabs.onresize () in
let () = Panel_settings.onresize () in
let () = Panel_preferences.onresize () in
Js._true)
in
Js._true
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions gui/state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Files in `state` manages state logic from different app part, similar to a `model` in a Control/Model/View architecture.

`state_error.ml` manages errors at the webapp level

`state_ui.ml` call _init_ and _sync_ for `state_*` files

`state_file.ml` mainly manages editor & kasa stuff, but is accessed too from settings, state_ui

`state_perturbation.ml` manages simulation perturbations, only used from panel preferences

`state_runtime.ml` defines worker runtime, used from other `states_*` + preferences + projects controller

`state_simulation.ml` sets simulation controls and functions to interact with simulation data
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions gui/state/state_ui.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
open Lwt.Infix

let sync () : unit Lwt.t =
State_settings.sync () >>= State_runtime.sync >>= State_project.sync
State_preferences.sync () >>= State_runtime.sync >>= State_project.sync
>>= fun _ ->
State_file.sync () >>= fun _ -> Lwt.return_unit

let init () : unit Lwt.t =
Lwt.return_unit >>= State_settings.init >>= State_runtime.init
Lwt.return_unit >>= State_preferences.init >>= State_runtime.init
>>= State_project.init >>= State_file.init >>= State_simulation.init >>= sync

let onload () : unit = Common.async __LOC__ (fun () -> Lwt.return_unit >>= init)
44 changes: 22 additions & 22 deletions gui/ui/panel_settings.ml → gui/ui/panel_preferences.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let visible_on_states ?(a_class = [])
a_class @ hidden_class))

module FormPerturbation : Ui_common.Div = struct
let id = "panel_settings_perturbation"
let id = "panel_preferences_perturbation"

let input =
Html.input
Expand Down Expand Up @@ -71,7 +71,7 @@ module FormPerturbation : Ui_common.Div = struct
let () =
form_dom##.onsubmit :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.intervene_simulation () in
let () = Panel_preferences_controller.intervene_simulation () in
Js._false)
in
let () = input_dom##.onchange := Dom.handler handler in
Expand All @@ -85,7 +85,7 @@ let signal_change input_dom signal_handler =
Js._true)

module InputPauseCondition : Ui_common.Div = struct
let id = "panel_settings_pause_condition"
let id = "panel_preferences_pause_condition"

let input =
Html.input
Expand Down Expand Up @@ -121,7 +121,7 @@ module InputPauseCondition : Ui_common.Div = struct
end

module InputPlotPeriod : Ui_common.Div = struct
let id = "panel_settings_plot_period"
let id = "panel_preferences_plot_period"

let format_float_string value =
let n = string_of_float value in
Expand Down Expand Up @@ -175,9 +175,9 @@ end

module DivErrorMessage : Ui_common.Div = struct
let id = "configuration_error_div"
let message_nav_inc_id = "panel_settings_message_nav_inc_id"
let message_nav_dec_id = "panel_settings_message_nav_dec_id"
let message_file_label_id = "panel_settings_message_file_label"
let message_nav_inc_id = "panel_preferences_message_nav_inc_id"
let message_nav_dec_id = "panel_preferences_message_nav_dec_id"
let message_file_label_id = "panel_preferences_message_file_label"
let error_index, error_index_set = Hooked.S.create ~debug:"error_index" None

let () =
Expand Down Expand Up @@ -303,7 +303,7 @@ module DivErrorMessage : Ui_common.Div = struct
Dom.handler (fun _ ->
let () =
Common.debug ~loc:__LOC__
(Js.string "[Panel_settings] clicked file_click_handler")
(Js.string "[Panel_preferences] clicked file_click_handler")
in
let message : Api_types_t.message option =
get_message
Expand All @@ -317,7 +317,7 @@ module DivErrorMessage : Ui_common.Div = struct
in
let () =
match range with
| Some range -> Panel_settings_controller.focus_range range
| Some range -> Panel_preferences_controller.focus_range range
| None -> ()
in
Js._true)
Expand All @@ -330,7 +330,7 @@ module DivErrorMessage : Ui_common.Div = struct
Dom.handler (fun _ ->
let () =
Common.debug ~loc:__LOC__
(Js.string "[Panel_settings] clicked index_click_handler")
(Js.string "[Panel_preferences] clicked index_click_handler")
in
let index : int option =
sanitize_index
Expand Down Expand Up @@ -364,7 +364,7 @@ module DivErrorMessage : Ui_common.Div = struct
end

module ButtonStart : Ui_common.Div = struct
let id = "panel_settings_start_button"
let id = "panel_preferences_start_button"

let button =
Html.button
Expand Down Expand Up @@ -393,15 +393,15 @@ module ButtonStart : Ui_common.Div = struct
let () =
start_button_dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.start_simulation () in
let () = Panel_preferences_controller.start_simulation () in
Js._true)
in

()
end

module ButtonClear : Ui_common.Div = struct
let id = "panel_settings_clear_button"
let id = "panel_preferences_clear_button"

let button =
Html.button
Expand All @@ -420,14 +420,14 @@ module ButtonClear : Ui_common.Div = struct
let () =
dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.stop_simulation () in
let () = Panel_preferences_controller.stop_simulation () in
Js._true)
in
()
end

module ButtonPause : Ui_common.Div = struct
let id = "panel_settings_pause_button"
let id = "panel_preferences_pause_button"

let button =
Html.button
Expand All @@ -446,14 +446,14 @@ module ButtonPause : Ui_common.Div = struct
let () =
button_dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.pause_simulation () in
let () = Panel_preferences_controller.pause_simulation () in
Js._true)
in
()
end

module ButtonTrace : Ui_common.Div = struct
let id = "panel_settings_get_trace_button"
let id = "panel_preferences_get_trace_button"

let button =
Html.button
Expand Down Expand Up @@ -483,14 +483,14 @@ module ButtonTrace : Ui_common.Div = struct
let () =
button_dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.simulation_trace () in
let () = Panel_preferences_controller.simulation_trace () in
Js._true)
in
()
end

module ButtonOutputs : Ui_common.Div = struct
let id = "panel_settings_outputs_button"
let id = "panel_preferences_outputs_button"

let button =
Html.button
Expand All @@ -509,14 +509,14 @@ module ButtonOutputs : Ui_common.Div = struct
let () =
button_dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.simulation_outputs () in
let () = Panel_preferences_controller.simulation_outputs () in
Js._true)
in
()
end

module ButtonContinue : Ui_common.Div = struct
let id = "panel_settings_continue_button"
let id = "panel_preferences_continue_button"

let button =
Html.button
Expand All @@ -535,7 +535,7 @@ module ButtonContinue : Ui_common.Div = struct
let () =
button_dom##.onclick :=
Dom.handler (fun _ ->
let () = Panel_settings_controller.continue_simulation () in
let () = Panel_preferences_controller.continue_simulation () in
Js._true)
in
()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ let set_action () =

let set_and_save_action () =
set_action ();
State_settings.set_parameters_as_default ();
State_preferences.set_parameters_as_default ();
State_project.set_parameters_as_default ()

let onload () =
Expand Down Expand Up @@ -252,12 +252,12 @@ let onload () =

Js._false);

let () = State_settings.updateFontSize ~delta:0. in
let () = State_preferences.updateFontSize ~delta:0. in
(Tyxml_js.To_dom.of_button increase_font)##.onclick
:= Dom_html.handler (fun _ ->
let () = State_settings.updateFontSize ~delta:0.2 in
let () = State_preferences.updateFontSize ~delta:0.2 in
Js._false);
(Tyxml_js.To_dom.of_button decrease_font)##.onclick
:= Dom_html.handler (fun _ ->
let () = State_settings.updateFontSize ~delta:(-0.2) in
let () = State_preferences.updateFontSize ~delta:(-0.2) in
Js._false)
File renamed without changes.
4 changes: 2 additions & 2 deletions gui/ui/panel_projects.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let project_id_input =
()

let li_new = Html.li [ Html.a [ Html.cdata "New project" ] ]
let li_prefs = Html.li (Modal_preferences.content ())
let li_prefs = Html.li (Panel_preferences_modal.content ())
let project_id_input_dom = Tyxml_js.To_dom.of_input project_id_input

let content () =
Expand Down Expand Up @@ -121,7 +121,7 @@ let content () =
]

let onload () =
let () = Modal_preferences.onload () in
let () = Panel_preferences_modal.onload () in
let () =
Common.jquery_on
("#" ^ project_id_modal_id)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gui/ui/tabs/tab_din.ml → gui/ui/panel_tabs/tab_din.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ let content () : [> Html_types.div ] Html.elt list =
]

let navli () : [> `PCDATA | `Span ] Html.elt ReactiveData.RList.t =
Ui_react_sim_status.badge (fun state ->
Ui_track_sim_status.badge (fun state ->
match state with
| None -> 0
| Some state ->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,32 @@ let content () =
let list =
match conclusion with
| [ site_graph ] ->
Utility.print_site_graph site_graph
(Utility.print_newline list)
Html_utility.print_site_graph site_graph
(Html_utility.print_newline list)
| _ :: _ | [] ->
let list = Utility.print_newline list in
let list = Utility.print_string " ]" list in
let list = Html_utility.print_newline list in
let list = Html_utility.print_string " ]" list in
let list =
snd
(List.fold_left
(fun (bool, list) a ->
let list =
if bool then
Utility.print_string " v " list
Html_utility.print_string " v " list
else
list
in
let list =
Utility.print_site_graph a list
Html_utility.print_site_graph a list
in
true, list)
(false, list) (List.rev conclusion))
in
let list = Utility.print_string "[ " list in
let list = Html_utility.print_string "[ " list in
list
in
let list = Utility.print_string " => " list in
let list = Utility.print_site_graph hyp list in
let list = Html_utility.print_string " => " list in
let list = Html_utility.print_site_graph hyp list in
list)
[] (List.rev b)
in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let extract_contact_map = function
| _ -> failwith "Wrong ugly contact_map extractor"

let contact_map_js : Js_contact.contact_map Js.t =
Js_contact.create_contact_map display_id State_settings.agent_coloring
Js_contact.create_contact_map display_id State_preferences.agent_coloring

let contact_map_text : string React.signal =
State_project.on_project_change_async ~on:tab_is_active None accuracy "null"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let tab_was_active = ref false
let site a = [ a, None, Some (Public_data.Bound_to 1), None ]

let print_edge ((a, b), (c, d)) list =
Utility.print_newline (Utility.print_site_graph [ a, site b; c, site d ] list)
Html_utility.print_newline (Html_utility.print_site_graph [ a, site b; c, site d ] list)

let content () =
let scc =
Expand All @@ -29,23 +29,23 @@ let content () =
let scc = List.rev_map List.rev scc in
let output =
if scc = [] || scc = [ [] ] then
Utility.print_string
Html_utility.print_string
"The size of biomolecular compounds is uniformly bounded."
[]
else (
let list =
List.fold_left
(fun list list_edges ->
let list = Utility.print_newline list in
let list = Html_utility.print_newline list in
List.fold_left
(fun list ((a, b), (c, d)) ->
print_edge ((a, b), (c, d)) list)
list list_edges)
[] scc
in
let list = Utility.print_newline list in
let list = Html_utility.print_newline list in
let list =
Utility.print_string
Html_utility.print_string
"The following bonds may form arbitrary long chains of \
agents:"
list
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gui/ui/tabs/tab_log.ml → gui/ui/panel_tabs/tab_log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let line_count state =
state.simulation_info_output.simulation_output_log_messages

let navli () =
Ui_react_sim_status.label_news tab_is_active (fun state -> line_count state)
Ui_track_sim_status.label_news tab_is_active (fun state -> line_count state)

let content () =
let state_log =
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let file_count state =
state.Api_types_t.simulation_info_output
.Api_types_t.simulation_output_file_lines

let navli () = Ui_react_sim_status.badge (fun state -> file_count state)
let navli () = Ui_track_sim_status.badge (fun state -> file_count state)

let xml () =
let select (file_line_ids : string list) : [> Html_types.select ] Html.elt =
Expand Down Expand Up @@ -126,7 +126,7 @@ let select_outputs () : unit =
update_outputs fileindex

let content () =
[ Ui_react_sim_status.toggle_element (fun t -> file_count t > 0) (xml ()) ]
[ Ui_track_sim_status.toggle_element (fun t -> file_count t > 0) (xml ()) ]

let onload () =
let () =
Expand Down
File renamed without changes.
Loading

0 comments on commit d57f370

Please sign in to comment.