-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherror_manager.py
More file actions
65 lines (57 loc) · 1.86 KB
/
Copy patherror_manager.py
File metadata and controls
65 lines (57 loc) · 1.86 KB
1
2
3
4
5
6
7
8
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from trame.widgets import vuetify3 as vuetify, html
from state_manager import state, server
def add_error(title, msg):
if not server.running:
# Outside of a Trame app (e.g. check_model.py), raise a Python error
# to surface the error to the caller.
raise RuntimeError(f"{title}: {msg}")
# Otherwise: Inside a Trame app, add the error to the state.
state.errors.append(
{
"id": state.error_counter,
"title": title,
"msg": msg,
}
)
state.error_counter += 1
state.dirty("errors")
def remove_error(i):
state.errors.pop(int(i))
state.dirty("errors")
def remove_all_errors():
state.errors = []
state.dirty("errors")
def error_panel():
with vuetify.VExpansionPanels(
v_if=("errors.length != 0",),
dense=True,
popout=True,
style="width: 350px; z-index: 20000; position: fixed; bottom: 16px; left: 16px;",
):
with vuetify.VExpansionPanel(
dense=True,
title=("errors.length + ' Errors Generated'",),
expand_icon="mdi-alert",
disable_icon_rotate=True,
color="error",
):
with vuetify.VExpansionPanelText(
dense=True,
):
with vuetify.VAlert(
v_for="(alert, i) in errors",
key="alert.id",
dense=True,
closable=True,
click_close=(remove_error, "[i]"),
):
html.H4("{{alert.title}}")
html.P("{{alert.msg}}")
vuetify.VBtn(
"Close all",
dense=True,
click=remove_all_errors,
color="error",
variant="text",
block=True,
)