Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repopulate previously loaded data #53

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion eit_dash/callbacks/load_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def load_selected_data(data_path, cancel_load, sig, file_type, fig):


@callback(
Output(ids.DATASET_CONTAINER, "children"),
Output(ids.DATASET_CONTAINER, "children", allow_duplicate=True),
Input(ids.LOAD_CONFIRM_BUTTON, "n_clicks"),
State(ids.NFILES_PLACEHOLDER, "children"),
State(ids.DATASET_CONTAINER, "children"),
Expand Down Expand Up @@ -286,3 +286,16 @@ def store_clicked_file(n_clicks, title):
return state["value"]

return None


# Repopulate data after reload
@callback(
Output(ids.DATASET_CONTAINER, "children", allow_duplicate=True),
Input(ids.POPULATE_DATA, "children"),
prevent_initial_call="initial_duplicate",
)
def repopulate_data(reload):
"""Repopulate data after reloading page."""
# create the info summary card
reloaded_data = data_object.get_all_sequences()
return [create_info_card(element) for element in reloaded_data]
1 change: 1 addition & 0 deletions eit_dash/definitions/element_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
LOAD_CANCEL_BUTTON = "load-cancel-button"
LOAD_RESULTS_TITLE = "load-results-title"
PARENT_DIR = "parent-dir"
POPULATE_DATA = "populate-data"
STORED_CWD = "stored-cwd"
SELECT_CONFIRM_BUTTON = "select-confirm-button"

Expand Down
4 changes: 4 additions & 0 deletions eit_dash/pages/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
],
)

# This is a placeholder for triggering repopulating of data when page is reloaded
populate_loaded_data = html.Div(id=ids.POPULATE_DATA)

layout = dbc.Row(
[
html.H1("LOAD DATA", style=styles.COLUMN_TITLE),
Expand All @@ -160,6 +163,7 @@
results,
placeholder_nfiles,
modal_dialog,
populate_loaded_data,
# TODO: the following is duplicated in multiple pages. To be refactored
html.Div(
[
Expand Down
Loading