Skip to content

Commit

Permalink
move function to GeneralFunctions
Browse files Browse the repository at this point in the history
Future pr needs to split up generalFunctions
  • Loading branch information
proy30 committed Feb 11, 2025
1 parent 02d7fd9 commit 4729288
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/python/impactx/dashboard/Input/components.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from .. import setup_server, html, vuetify
from .. import html, setup_server, vuetify
from .generalFunctions import generalFunctions

server, state, ctrl = setup_server()
Expand Down Expand Up @@ -40,32 +40,10 @@ def documentation_icon(section_name: str) -> vuetify.VIcon:
:param section_name: The name for the input section.
"""

def open_documentation():
"""
Retrieves the documentation link with the provided section_name
and opens the documentation sidebar on the dashoard.
"""

DOCUMENTATION = {
"input_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#impactx.ImpactX",
"lattice_configuration": "https://impactx.readthedocs.io/en/latest/usage/python.html#lattice-elements",
"distribution_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#initial-beam-distributions",
"space_charge": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#space-charge",
"csr": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#coherent-synchrotron-radiation-csr",
}


new_url = DOCUMENTATION.get(section_name)
if state.documentation_drawer_open and state.documentation_url == new_url:
state.documentation_drawer_open = False
else:
state.documentation_url = new_url
state.documentation_drawer_open = True

return vuetify.VIcon(
"mdi-information",
style="color: #00313C;",
click=open_documentation,
click=lambda: generalFunctions.open_documentation(section_name),
)

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions src/python/impactx/dashboard/Input/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ class DashboardDefaults:
"beta": "m",
"emitt": "m",
}

DOCUMENTATION = {
"input_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#impactx.ImpactX",
"lattice_configuration": "https://impactx.readthedocs.io/en/latest/usage/python.html#lattice-elements",
"distribution_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#initial-beam-distributions",
"space_charge": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#space-charge",
"csr": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#coherent-synchrotron-radiation-csr",
}
16 changes: 16 additions & 0 deletions src/python/impactx/dashboard/Input/generalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@


class generalFunctions:
@staticmethod
def open_documentation(section_name):
"""
Retrieves the documentation link with the provided section_name
and opens the documentation sidebar on the dashoard.
:param section_name: The name for the input section.
"""

new_url = DashboardDefaults.DOCUMENTATION.get(section_name)
if state.documentation_drawer_open and state.documentation_url == new_url:
state.documentation_drawer_open = False
else:
state.documentation_url = new_url
state.documentation_drawer_open = True

@staticmethod
def get_default(parameter, type):
parameter_type_dictionary = getattr(DashboardDefaults, f"{type.upper()}", None)
Expand Down

0 comments on commit 4729288

Please sign in to comment.