@@ -164,7 +164,7 @@ def create_context_div(self):
164164 dbc .Button (
165165 "AI Generate Policies for Scenario" ,
166166 id = "presc-button" ,
167- className = "me-1 mb-2" ,
167+ className = "me-1 mb-2 w-25 " ,
168168 n_clicks = 0
169169 )
170170 ]
@@ -229,3 +229,29 @@ def update_ssp_desc(*context_values):
229229 html .H4 ("Custom Scenario Selected" )
230230 ]
231231 )
232+
233+ @app .callback (
234+ Output ("presc-button" , "disabled" , allow_duplicate = True ),
235+ Output ("presc-button" , "children" , allow_duplicate = True ),
236+ Output ("presc-button" , "color" , allow_duplicate = True ),
237+ Input ("presc-button" , "n_clicks" ),
238+ prevent_initial_call = True
239+ )
240+ def disable_button (n_clicks ):
241+ """
242+ Disables the button after it is clicked and displays a loading message.
243+ """
244+ return n_clicks > 0 , "Please wait..." , "warning"
245+
246+ @app .callback (
247+ Output ("presc-button" , "disabled" , allow_duplicate = True ),
248+ Output ("presc-button" , "children" , allow_duplicate = True ),
249+ Output ("presc-button" , "color" , allow_duplicate = True ),
250+ Input ("reset-button" , "disabled" ),
251+ prevent_initial_call = True
252+ )
253+ def enable_button (reset_disabled ):
254+ """
255+ Enables the button when the filtering is done and resets it.
256+ """
257+ return False , "AI Generate Policies for Scenario" , "primary"
0 commit comments