From d1c2456e62e94c4b6284a60a7e9c6ee8f7a9e005 Mon Sep 17 00:00:00 2001 From: Chuck McCallum Date: Thu, 26 Sep 2024 15:00:58 -0400 Subject: [PATCH] move UI to three separate files --- dp_creator_ii/app/__init__.py | 42 +++-------------------------- dp_creator_ii/app/analysis_panel.py | 10 +++++++ dp_creator_ii/app/dataset_panel.py | 12 +++++++++ dp_creator_ii/app/results_panel.py | 17 ++++++++++++ 4 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 dp_creator_ii/app/analysis_panel.py create mode 100644 dp_creator_ii/app/dataset_panel.py create mode 100644 dp_creator_ii/app/results_panel.py diff --git a/dp_creator_ii/app/__init__.py b/dp_creator_ii/app/__init__.py index e3bb1ec..ece1e8c 100644 --- a/dp_creator_ii/app/__init__.py +++ b/dp_creator_ii/app/__init__.py @@ -6,48 +6,14 @@ from dp_creator_ii.template import make_notebook_py, make_script_py from dp_creator_ii.converters import convert_py_to_nb - -def dataset_panel(): - return ui.nav_panel( - "Select Dataset", - "TODO: Pick dataset", - ui.output_text("csv_path_text"), - ui.output_text("unit_of_privacy_text"), - ui.input_action_button("go_to_analysis", "Perform analysis"), - value="dataset_panel", - ) - - -def analysis_panel(): - return ui.nav_panel( - "Perform Analysis", - "TODO: Define analysis", - ui.input_action_button("go_to_results", "Download results"), - value="analysis_panel", - ) - - -def results_panel(): - return ui.nav_panel( - "Download Results", - "TODO: Download Results", - ui.download_button("download_script", "Download script"), - # TODO: Notebook code is badly formatted - # ui.download_button( - # "download_notebook_unexecuted", "Download notebook (unexecuted)" - # ), - # ui.download_button( - # "download_notebook_executed", "Download notebook (executed)" - # ) - value="results_panel", - ) +from dp_creator_ii.app import analysis_panel, dataset_panel, results_panel app_ui = ui.page_bootstrap( ui.navset_tab( - dataset_panel(), - analysis_panel(), - results_panel(), + dataset_panel.dataset_ui(), + analysis_panel.analysis_ui(), + results_panel.results_ui(), id="top_level_nav", ), title="DP Creator II", diff --git a/dp_creator_ii/app/analysis_panel.py b/dp_creator_ii/app/analysis_panel.py new file mode 100644 index 0000000..0406e79 --- /dev/null +++ b/dp_creator_ii/app/analysis_panel.py @@ -0,0 +1,10 @@ +from shiny import App, ui, reactive, render + + +def analysis_ui(): + return ui.nav_panel( + "Perform Analysis", + "TODO: Define analysis", + ui.input_action_button("go_to_results", "Download results"), + value="analysis_panel", + ) diff --git a/dp_creator_ii/app/dataset_panel.py b/dp_creator_ii/app/dataset_panel.py new file mode 100644 index 0000000..a6360c5 --- /dev/null +++ b/dp_creator_ii/app/dataset_panel.py @@ -0,0 +1,12 @@ +from shiny import App, ui, module, reactive, render + + +def dataset_ui(): + return ui.nav_panel( + "Select Dataset", + "TODO: Pick dataset", + ui.output_text("csv_path_text"), + ui.output_text("unit_of_privacy_text"), + ui.input_action_button("go_to_analysis", "Perform analysis"), + value="dataset_panel", + ) diff --git a/dp_creator_ii/app/results_panel.py b/dp_creator_ii/app/results_panel.py new file mode 100644 index 0000000..eae1536 --- /dev/null +++ b/dp_creator_ii/app/results_panel.py @@ -0,0 +1,17 @@ +from shiny import App, ui, reactive, render + + +def results_ui(): + return ui.nav_panel( + "Download Results", + "TODO: Download Results", + ui.download_button("download_script", "Download script"), + # TODO: Notebook code is badly formatted + # ui.download_button( + # "download_notebook_unexecuted", "Download notebook (unexecuted)" + # ), + # ui.download_button( + # "download_notebook_executed", "Download notebook (executed)" + # ) + value="results_panel", + )