Skip to content

Commit

Permalink
Also hide form feedback when login is successful + adress mypy no typ…
Browse files Browse the repository at this point in the history
…e issue
  • Loading branch information
vanderlindenma committed Nov 8, 2024
1 parent e85277d commit ba48e07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions app/callbacks/data_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Output("username_input", "style"),
Output("password_input", "style"),
Output("send_form_button", "style"),
Output("form_feedback_area", "style"),
Output("loading_spinner", "style"),
],
Input("send_form_button", "n_clicks"),
Expand All @@ -60,10 +61,10 @@ def login_callback(n_clicks, username, password, user_headers):
the login form is hidden and a spinner is displayed.
Returns:
dash.dependencies.Output: Updated user credentials and headers, and form feedback + styles to hide/show login and loading spinners.
dash.dependencies.Output: Updated user credentials and headers, and form feedback + styles to hide/show login elements and loading spinners.
"""
input_style_unchanged = {"width": "250px"}
connection_button_style_unchanged = {}
empty_style_unchanged = {"": ""}
hide_element_style = {"display": "none"}
show_spinner_style = {"transform": "scale(4)"}

Expand All @@ -74,7 +75,8 @@ def login_callback(n_clicks, username, password, user_headers):
dash.no_update,
input_style_unchanged,
input_style_unchanged,
connection_button_style_unchanged,
empty_style_unchanged,
empty_style_unchanged,
hide_element_style,
)

Expand All @@ -95,7 +97,8 @@ def login_callback(n_clicks, username, password, user_headers):
form_feedback,
input_style_unchanged,
input_style_unchanged,
connection_button_style_unchanged,
empty_style_unchanged,
empty_style_unchanged,
hide_element_style,
)
else:
Expand All @@ -110,6 +113,7 @@ def login_callback(n_clicks, username, password, user_headers):
hide_element_style,
hide_element_style,
hide_element_style,
hide_element_style,
show_spinner_style,
)
except Exception:
Expand All @@ -122,7 +126,8 @@ def login_callback(n_clicks, username, password, user_headers):
form_feedback,
input_style_unchanged,
input_style_unchanged,
connection_button_style_unchanged,
empty_style_unchanged,
empty_style_unchanged,
hide_element_style,
)

Expand Down
6 changes: 3 additions & 3 deletions app/pages/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def login_layout():
color="primary",
className="ml-3",
),
html.Div(style={"height": "15px"}), # Spacing
# Feedback message area
html.Div(id="form_feedback_area"),
html.Div(
dbc.Spinner(size="xl"),
id="loading_spinner",
style={"display": "none"},
),
html.Div(style={"height": "15px"}), # Spacing
# Feedback message area
html.Div(id="form_feedback_area"),
],
),
]
Expand Down

0 comments on commit ba48e07

Please sign in to comment.