Skip to content

Commit

Permalink
adjust GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiepeng committed Jul 11, 2024
1 parent 4e4fe4f commit 588b290
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 64 deletions.
26 changes: 12 additions & 14 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate

from utils import load_config
from utils import load_config, save_config

from view_callbacks.test_case_view import get_test_case_view_callbacks
from view_callbacks.control_view import get_control_view_callbacks
Expand Down Expand Up @@ -82,7 +82,7 @@ def on_modal_open(modal_open):
data_path = config.get("DATA_PATH", DATA_PATH)

config["DATA_PATH"] = data_path
json.dump(config, open("./config.json", "w+"))
save_config(config, "./config.json")

return {
"data_path": data_path,
Expand Down Expand Up @@ -130,7 +130,7 @@ def on_path_change(data_path, refresh):

config["DATA_PATH"] = data_path
config["CASE"] = case_val
json.dump(config, open("./config.json", "w+"))
save_config(config, "./config.json")

return {
"case_options": options,
Expand Down Expand Up @@ -209,7 +209,7 @@ def on_case_change(case_val, data_path):
config["DATA_PATH"] = data_path
config["CASE"] = case_val
config["FILE"] = file_value
json.dump(config, open("./config.json", "w+"))
save_config(config, "./config.json")

return {
"file_value": file_value,
Expand Down Expand Up @@ -255,7 +255,7 @@ def on_modal_close(
config["DATA_PATH"] = data_path
config["CASE"] = case_val
config["FILE"] = file_value
json.dump(config, open("./config.json", "w+"))
save_config(config, "./config.json")

if current_file == file_value:
return {
Expand Down Expand Up @@ -296,14 +296,12 @@ def open_modal(select_modal):
return {"modal_is_open": True}


"""
This clientside callback function disables the interval component based on
the number of clicks on the play button and stop button. If the play button
is clicked and the number of play clicks is greater than 0, the interval
component is disabled. If the stop button is clicked and the number of stop
clicks is greater than 0, the interval component is enabled. If neither button
is clicked, the interval component remains unchanged.
"""
# This clientside callback function disables the interval component based on
# the number of clicks on the play button and stop button. If the play button
# is clicked and the number of play clicks is greater than 0, the interval
# component is disabled. If the stop button is clicked and the number of stop
# clicks is greater than 0, the interval component is enabled. If neither button
# is clicked, the interval component remains unchanged.
app.clientside_callback(
"""
function(play_clicks, stop_clicks) {
Expand Down Expand Up @@ -353,5 +351,5 @@ def open_modal(select_modal):
# serve(app.server, listen="*:8000")

FlaskUI(
app=app.server, server="flask", port=46754, profile_dir_prefix="sensorview"
app=app.server, server="flask", port=45678, profile_dir_prefix="sensorview"
).run()
99 changes: 50 additions & 49 deletions app_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
target="c-picker-3d",
placement="top",
),
]
],
size="sm",
),
width=3,
),
Expand All @@ -184,7 +185,8 @@
target="colormap-3d",
placement="top",
),
]
],
size="sm",
),
width=3,
),
Expand Down Expand Up @@ -225,7 +227,7 @@
"uirevision": "no_change",
},
},
style={"height": "85vh"},
style={"height": "80vh"},
),
className="mt-2",
),
Expand Down Expand Up @@ -267,11 +269,14 @@
),
dbc.Row(
[
dcc.Interval(
id="interval-component",
interval=2 * 100, # in milliseconds
disabled=True,
n_intervals=0,
dbc.Col(
dcc.Interval(
id="interval-component",
interval=2 * 100, # in milliseconds
disabled=True,
n_intervals=0,
),
width=4,
),
dbc.Col(
dbc.ButtonGroup(
Expand Down Expand Up @@ -308,9 +313,35 @@
color="secondary",
n_clicks=0,
),
]
],
className="w-100 mx-auto",
),
width=4,
),
dbc.Col(
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(
"Export all frames as an HTML video",
id="export-scatter3d",
n_clicks=0,
),
dbc.DropdownMenuItem(
"Filtered Data (Current Frame)",
id="export-data-current",
n_clicks=0,
),
dbc.DropdownMenuItem(
"Filtered Data (All Frames)",
id="export-data-all",
n_clicks=0,
),
],
label="Export",
right=True,
style={"float": "right"},
),
width=2,
width=4,
),
dbc.Tooltip(
"Previous frame",
Expand All @@ -332,38 +363,11 @@
target="next-button",
placement="top",
),
],
justify="center",
),
html.Div(
[
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(
"Export all frames as an HTML video",
id="export-scatter3d",
n_clicks=0,
),
dbc.DropdownMenuItem(
"Filtered Data (Current Frame)",
id="export-data-current",
n_clicks=0,
),
dbc.DropdownMenuItem(
"Filtered Data (All Frames)",
id="export-data-all",
n_clicks=0,
),
],
label="Export",
right=True,
style={"float": "right"},
),
html.Div(
id="hidden-scatter3d",
style={"display": "none"},
),
]
],
),
]
),
Expand Down Expand Up @@ -444,7 +448,7 @@
),
]
),
style={"overflow-y": "scroll", "height": "110vh"},
style={"overflow-y": "scroll", "height": "100vh"},
),
]
)
Expand Down Expand Up @@ -1316,16 +1320,13 @@ def get_app_layout():
width=1,
),
dbc.Col(
html.Div(
[
dbc.Button(
html.I(className="bi bi-link-45deg"),
id="button-add",
n_clicks=0,
size="sm",
)
],
className="d-grid",
dbc.Button(
html.I(className="bi bi-link-45deg"),
id="button-add",
n_clicks=0,
color="secondary",
size="sm",
className="w-100",
),
width=12,
className="my-2",
Expand Down
1 change: 0 additions & 1 deletion config.json

This file was deleted.

12 changes: 12 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def load_config(json_file):
return json.load(read_file)


def save_config(json_dict, json_file):
"""
Save configuration file.
Parameters:
- json_dict (dict): Python dict
- json_file (str): The path to the JSON configuration file.
"""
with open(json_file, "w+", encoding="utf-8") as write_file:
json.dump(json_dict, write_file, indent=4)


def load_data(file, file_list):
"""
Load data from file(s).
Expand Down

0 comments on commit 588b290

Please sign in to comment.