Skip to content

Commit ed8b89e

Browse files
Dashboard: Add about dialog (BLAST-ImpactX#1076)
* add about update fix hyperlinks to open in new tab * remove comma * add q&a * change color * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 11bfd0c commit ed8b89e

File tree

1 file changed

+118
-5
lines changed

1 file changed

+118
-5
lines changed

src/python/impactx/dashboard/Toolbar/general.py

Lines changed: 118 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,38 @@
88

99
import os
1010

11-
from .. import ctrl, state, vuetify
11+
from .. import ctrl, html, state, vuetify
1212
from ..Input.components import CardComponents
13-
from .sim_history.ui import SimulationHistory
14-
15-
state.show_dashboard_alert = True
16-
1713
from .analyze import AnalyzeToolbar
1814
from .input import InputToolbar
1915
from .run import RunToolbar
16+
from .sim_history.ui import SimulationHistory
17+
18+
state.show_dashboard_alert = True
19+
state.about_dialog = False
2020

2121

2222
@ctrl.trigger("force_quit")
2323
def _force_quit() -> None:
2424
os._exit(0)
2525

2626

27+
def _about_button(
28+
icon_name: str, text: str, link: str, color: str = "primary"
29+
) -> vuetify.VBtn:
30+
"""
31+
Returns a button for the about section.
32+
"""
33+
return vuetify.VBtn(
34+
prepend_icon=icon_name,
35+
text=text,
36+
color=color,
37+
classes="justify-start text-none",
38+
variant="outlined",
39+
click=f"window.open('{link}', '_blank')",
40+
)
41+
42+
2743
class GeneralToolbar:
2844
"""
2945
Contains toolbar components displayed on all pages.
@@ -53,6 +69,7 @@ def dashboard_toolbar(toolbar_name: str) -> None:
5369
GeneralToolbar.simulation_history_button()
5470
vuetify.VDivider(vertical=True, classes="mr-2")
5571
InputToolbar.collapse_all_sections_button()
72+
GeneralToolbar.about_button()
5673
GeneralToolbar.force_quit_button()
5774
elif toolbar_name == "run":
5875
(GeneralToolbar.dashboard_info(),)
@@ -61,6 +78,7 @@ def dashboard_toolbar(toolbar_name: str) -> None:
6178
vuetify.VDivider(vertical=True, classes="mx-2")
6279
(GeneralToolbar.simulation_history_button())
6380
vuetify.VDivider(vertical=True, classes="mx-2")
81+
GeneralToolbar.about_button()
6482
(GeneralToolbar.force_quit_button())
6583
elif toolbar_name == "analyze":
6684
(GeneralToolbar.dashboard_info(),)
@@ -71,6 +89,7 @@ def dashboard_toolbar(toolbar_name: str) -> None:
7189
vuetify.VDivider(vertical=True, classes="mx-2")
7290
GeneralToolbar.simulation_history_button()
7391
vuetify.VDivider(vertical=True, classes="mx-2")
92+
GeneralToolbar.about_button()
7493
GeneralToolbar.force_quit_button()
7594

7695
@staticmethod
@@ -125,3 +144,97 @@ def force_quit_button():
125144
description="Force Quit",
126145
color="error",
127146
)
147+
148+
@staticmethod
149+
def about_button() -> vuetify.VBtn:
150+
"""
151+
Displays a button to open the about dialog.
152+
"""
153+
GeneralToolbar.about_dialog()
154+
155+
return CardComponents.card_button(
156+
icon_name="mdi-information-outline",
157+
click="about_dialog = true",
158+
description="About",
159+
color="primary",
160+
classes="mr-2",
161+
)
162+
163+
@staticmethod
164+
def about_dialog() -> None:
165+
"""
166+
Creates the about dialog with information and links to ImpactX resources.
167+
"""
168+
HEADER_1 = "About ImpactX Dashboard"
169+
MESSAGE_1 = "This dashboard is a web-based interface for monitoring and analyzing particle accelerator simulations based on Trame."
170+
MESSAGE_2 = "This dashboard provides visualization and analysis tools for ImpactX simulations, however it is a subset of the complete ImpactX ecosystem."
171+
HEADER_2 = "Get the Full ImpactX Experience"
172+
MESSAGE_3 = "For complete simulation capabilities and local installations:"
173+
HEADER_3 = "Documentation"
174+
BUG_MESSAGE = "Found a bug or have a feature request? "
175+
176+
IMPACTX_DOCUMENTATION_URL = "https://impactx.readthedocs.io/"
177+
IMPACTX_EXAMPLES_URL = (
178+
"https://impactx.readthedocs.io/en/latest/usage/examples.html"
179+
)
180+
GITHUB_URL = "https://github.com/BLAST-ImpactX/impactx"
181+
GITHUB_ISSUES_URL = "https://github.com/BLAST-ImpactX/impactx/issues/new"
182+
DISCUSSIONS_URL = "https://github.com/orgs/BLAST-ImpactX/discussions"
183+
184+
with vuetify.VDialog(v_model=("about_dialog", False), max_width="500px"):
185+
with vuetify.VCard(elevation=10, classes="rounded-lg"):
186+
with vuetify.VToolbar(color="primary", classes="px-4"):
187+
html.Div(
188+
HEADER_1,
189+
style="font-size: 1.125rem;",
190+
)
191+
vuetify.VSpacer()
192+
vuetify.VBtn(icon="mdi-close", click="about_dialog = false")
193+
194+
with vuetify.VCardText(classes="pa-6"):
195+
with html.Div(classes="mb-4"):
196+
html.P(MESSAGE_1, classes="mb-3")
197+
html.P(MESSAGE_2, classes="mb-4")
198+
vuetify.VDivider(classes="my-4")
199+
with html.Div(classes="mb-4"):
200+
html.H4(HEADER_2, classes="text-h6 mb-3")
201+
html.P(MESSAGE_3, classes="mb-3 text-body-2")
202+
203+
with html.Div(classes="d-flex flex-column ga-3 mb-4"):
204+
_about_button(
205+
icon_name="mdi-book-open-variant",
206+
text=HEADER_3,
207+
link=IMPACTX_DOCUMENTATION_URL,
208+
)
209+
_about_button(
210+
icon_name="mdi-github",
211+
text="Source Code",
212+
color="secondary",
213+
link=GITHUB_URL,
214+
)
215+
_about_button(
216+
icon_name="mdi-play-circle-outline",
217+
text="Examples",
218+
link=IMPACTX_EXAMPLES_URL,
219+
color="info",
220+
)
221+
_about_button(
222+
icon_name="mdi-comment-question-outline",
223+
text="Questions & Answers",
224+
link=DISCUSSIONS_URL,
225+
color="settings",
226+
)
227+
228+
with vuetify.VAlert(
229+
type="info", variant="tonal", density="compact"
230+
):
231+
with vuetify.Template(v_slot_prepend=True):
232+
vuetify.VIcon("mdi-bug-outline")
233+
html.Span(BUG_MESSAGE)
234+
html.A(
235+
"Report it on GitHub",
236+
href=GITHUB_ISSUES_URL,
237+
target="_blank",
238+
classes="text-decoration-underline",
239+
style="color: #1976d2; cursor: pointer;",
240+
)

0 commit comments

Comments
 (0)