@@ -423,36 +423,59 @@ def update_map_and_alert_info(sequence_on_display, cameras):
423423
424424
425425@app .callback (
426- Output ("to_acknowledge" , "data" ),
427- [Input ("acknowledge-button" , "n_clicks" )],
426+ [Output ("confirmation-modal" , "style" ), Output ("to_acknowledge" , "data" )],
428427 [
429- State ("sequence_id_on_display" , "data" ),
430- State ("user_token" , "data" ),
428+ Input ("acknowledge-button" , "n_clicks" ),
429+ Input ("confirm-wildfire" , "n_clicks" ),
430+ Input ("confirm-non-wildfire" , "n_clicks" ),
431+ Input ("cancel-confirmation" , "n_clicks" ),
431432 ],
433+ [State ("sequence_id_on_display" , "data" ), State ("user_token" , "data" )],
432434 prevent_initial_call = True ,
433435)
434- def acknowledge_event (n_clicks , sequence_id_on_display , user_token ):
435- """
436- Acknowledges the selected event and updates the state to reflect this.
437-
438- Parameters:
439- - n_clicks (int): Number of clicks on the acknowledge button.
440- - sequence_id_on_display (int): Currently displayed event ID.
441- - user_token (dict): User authorization headers for API requests.
442-
443- Returns:
444- - int: The ID of the event that has been acknowledged.
445- """
446- if sequence_id_on_display == 0 or n_clicks == 0 :
447- raise PreventUpdate
448-
449- if cfg .SAFE_DEV_MODE == "True" :
450- raise PreventUpdate
451-
452- api_client .token = user_token
453- # call_api(api_client.acknowledge_event, user_credentials)(event_id=int(sequence_id_on_display))
436+ def acknowledge_event (
437+ acknowledge_clicks , confirm_wildfire , confirm_non_wildfire , cancel , sequence_id_on_display , user_token
438+ ):
439+ ctx = dash .callback_context
454440
455- return sequence_id_on_display
441+ if not ctx .triggered :
442+ raise dash .exceptions .PreventUpdate
443+
444+ triggered_id = ctx .triggered [0 ]["prop_id" ].split ("." )[0 ]
445+
446+ # Modal styles
447+ modal_visible_style = {
448+ "position" : "fixed" ,
449+ "top" : "50%" ,
450+ "left" : "50%" ,
451+ "transform" : "translate(-50%, -50%)" ,
452+ "z-index" : "1000" ,
453+ "background-color" : "rgba(0, 0, 0, 0.5)" ,
454+ }
455+ modal_hidden_style = {"display" : "none" }
456+
457+ if triggered_id == "acknowledge-button" :
458+ # Show the modal
459+ if acknowledge_clicks > 0 :
460+ return modal_visible_style , dash .no_update
461+
462+ elif triggered_id == "confirm-wildfire" :
463+ # Send wildfire confirmation to the API
464+ api_client .token = user_token
465+ api_client .label_sequence (sequence_id_on_display , True )
466+ return modal_hidden_style , sequence_id_on_display
467+
468+ elif triggered_id == "confirm-non-wildfire" :
469+ # Send non-wildfire confirmation to the API
470+ api_client .token = user_token
471+ api_client .label_sequence (sequence_id_on_display , False )
472+ return modal_hidden_style , sequence_id_on_display
473+
474+ elif triggered_id == "cancel-confirmation" :
475+ # Cancel action
476+ return modal_hidden_style , dash .no_update
477+
478+ raise dash .exceptions .PreventUpdate
456479
457480
458481# Modal issue let's add this later
0 commit comments