Skip to content

Commit

Permalink
Reduce code for calling toolbars
Browse files Browse the repository at this point in the history
  • Loading branch information
proy30 committed Jan 6, 2025
1 parent 5f520be commit 7550126
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
44 changes: 15 additions & 29 deletions src/python/impactx/dashboard/Toolbar/toolbarMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,21 @@ def dashboard_info():

class Toolbars:
"""
Builds section toolbars for various pages.
Builds toolbar for dashboard.
"""

@staticmethod
def input_toolbar():
"""
Builds toolbar for the 'Input' page.
"""

(ToolbarElements.dashboard_info(),)
vuetify.VSpacer()
ToolbarElements.export_input_data()

@staticmethod
def run_toolbar():
"""
Builds toolbar for the 'Run' page.
"""

(ToolbarElements.dashboard_info(),)
(vuetify.VSpacer(),)
(ToolbarElements.run_simulation_button(),)

@staticmethod
def analyze_toolbar():
"""
Builds toolbar for the 'Analyze' page.
"""

(ToolbarElements.dashboard_info(),)
vuetify.VSpacer()
ToolbarElements.plot_options()
def dashboard_toolbar(toolbar_name: str) -> None:
toolbar_name = toolbar_name.lower()
if toolbar_name == "input":
(ToolbarElements.dashboard_info(),)
vuetify.VSpacer()
ToolbarElements.export_input_data()
elif toolbar_name == "run":
(ToolbarElements.dashboard_info(),)
(vuetify.VSpacer(),)
(ToolbarElements.run_simulation_button(),)
elif toolbar_name == "analyze":
(ToolbarElements.dashboard_info(),)
vuetify.VSpacer()
ToolbarElements.plot_options()
6 changes: 3 additions & 3 deletions src/python/impactx/dashboard/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def application():
layout.title.hide()
with layout.toolbar:
with vuetify.Template(v_if="$route.path == '/Analyze'"):
Toolbars.analyze_toolbar()
Toolbars.dashboard_toolbar("analyze")
with vuetify.Template(v_if="$route.path == '/Input'"):
Toolbars.input_toolbar()
Toolbars.dashboard_toolbar("input")
with vuetify.Template(v_if="$route.path == '/Run'"):
Toolbars.run_toolbar()
Toolbars.dashboard_toolbar("run")

with layout.drawer as drawer:
drawer.width = 200
Expand Down

0 comments on commit 7550126

Please sign in to comment.