Skip to content

alert

Alert system and components

Alert #

Alert message settings

This namespace controls what is displayed with AlertSystem and whether it is displayed.

State variables
  • open: whether the menu is open or not
  • message: message to display
  • color: color of the popup. Any of "success","warning","error","info".
  • closeable: whether the popup is closeable
Source code in src/sdss_explorer/dashboard/dataclass/alert.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Alert:
    """Alert message settings

    This namespace controls what is displayed with `AlertSystem` and whether it is displayed.


    State variables:
        * `open`: whether the menu is open or not
        * `message`: message to display
        * `color`: color of the popup. Any of `"success","warning","error","info"`.
        * `closeable`: whether the popup is closeable

    """

    open = sl.reactive(False)
    message = sl.reactive("")
    color = sl.reactive("")
    closeable = sl.reactive(True)

    @staticmethod
    def update(message: str,
               color: str = "info",
               closeable: bool = True) -> None:
        """
        Submit a message

        Args:
            message: message to send
            color: color of popup. Any of `"success","warning","error","info"`.
            closeable: whether the popup is closeable
        """
        # possible colors are success, info, warning, and error
        Alert.color.set(color)
        Alert.message.set(message)
        Alert.closeable.set(closeable)
        Alert.open.set(True)

update(message, color='info', closeable=True) staticmethod #

Submit a message

Parameters:

Name Type Description Default
message str

message to send

required
color str

color of popup. Any of "success","warning","error","info".

'info'
closeable bool

whether the popup is closeable

True
Source code in src/sdss_explorer/dashboard/dataclass/alert.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@staticmethod
def update(message: str,
           color: str = "info",
           closeable: bool = True) -> None:
    """
    Submit a message

    Args:
        message: message to send
        color: color of popup. Any of `"success","warning","error","info"`.
        closeable: whether the popup is closeable
    """
    # possible colors are success, info, warning, and error
    Alert.color.set(color)
    Alert.message.set(message)
    Alert.closeable.set(closeable)
    Alert.open.set(True)

AlertSystem() #

Global alert system

Source code in src/sdss_explorer/dashboard/dataclass/alert.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@sl.component()
def AlertSystem():
    """Global alert system"""
    with rv.Snackbar(
            class_="d-flex justify-left ma-0 pa-0 rounded-pill",
            v_model=Alert.open.value,
            on_v_model=Alert.open.set,
            color=Alert.color.value,
            multi_line=True,
            top=True,
            timeout=3000.0,
    ) as main:
        rv.Alert(
            class_="d-flex justify-center ma-2",
            value=True,
            type=Alert.color.value,
            # prominent=True,
            dense=True,
            children=[Alert.message.value],
        )
        if Alert.closeable.value:
            sl.Button(
                icon=True,
                icon_name="mdi-close",
                on_click=lambda: Alert.open.set(False),
                text=True,
            )
    return main