From 1dff7b151b804f52a625b28e077e21b6ea6c236f Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Tue, 27 Feb 2024 21:06:55 +0100 Subject: [PATCH] added success message alert --- src/web/layout/alerts.py | 18 +++++++++++++----- src/web/layout/stores.py | 23 ++++++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/web/layout/alerts.py b/src/web/layout/alerts.py index a067849..8be4a69 100644 --- a/src/web/layout/alerts.py +++ b/src/web/layout/alerts.py @@ -1,15 +1,23 @@ -from dash import html +from __future__ import annotations + import dash_bootstrap_components as dbc +from dash import html alerts_element = html.Div( children=[ dbc.Alert( - children="", - id="alert-element", + children='', + id='alert-element', dismissable=True, fade=False, is_open=False, - ) - ] + ), + dbc.Alert( + children='', + id='success-element', + is_open=False, + duration=1000, + ), + ], ) diff --git a/src/web/layout/stores.py b/src/web/layout/stores.py index 9a9f58a..7ac3060 100644 --- a/src/web/layout/stores.py +++ b/src/web/layout/stores.py @@ -1,18 +1,23 @@ -from dash import html, dcc +from __future__ import annotations + import logging import os -storage_type = "session" -if "ENV" in os.environ and os.getenv("ENV") == "DEV": - storage_type = "memory" +from dash import dcc +from dash import html + +storage_type = 'session' +if 'ENV' in os.environ and os.getenv('ENV') == 'DEV': + storage_type = 'memory' logging.info( - "ENV=DEV -> dcc.Stores changed to storage_type=%s", - storage_type + 'ENV=DEV -> dcc.Stores changed to storage_type=%s', + storage_type, ) stores_element = html.Div( children=[ - dcc.Store(id="alert-message", storage_type=storage_type, data=""), - dcc.Store(id="vis-com-name", storage_type=storage_type, data=""), - ] + dcc.Store(id='alert-message', storage_type=storage_type, data=''), + dcc.Store(id='success-message', storage_type=storage_type, data=''), + dcc.Store(id='vis-com-name', storage_type=storage_type, data=''), + ], )