Skip to content

Commit

Permalink
Make the setup new codes widget part of the code selection widget opt…
Browse files Browse the repository at this point in the history
…ional
  • Loading branch information
edan-bainglass committed Dec 8, 2024
1 parent 2677368 commit 0266afc
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions aiidalab_widgets_base/computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __init__(
enable_detailed_setup=True,
clear_after=None,
default_calc_job_plugin=None,
include_setup_widget=True,
fetch_codes=True,
**kwargs,
):
"""Dropdown for Codes for one input plugin.
Expand Down Expand Up @@ -95,33 +97,45 @@ def __init__(
self.refresh, names=["allow_disabled_computers", "allow_hidden_codes"]
)

self.btn_setup_new_code = ipw.ToggleButton(description="Setup new code")
self.btn_setup_new_code.observe(self._setup_new_code, "value")
self._default_user_email = orm.User.collection.get_default().email

self._setup_new_code_output = ipw.Output(layout={"width": self._output_width})
selection_row = ipw.HBox(
children=[
self.code_select_dropdown,
]
)

self._default_user_email = orm.User.collection.get_default().email
children = [selection_row]

children = [
ipw.HBox([self.code_select_dropdown, self.btn_setup_new_code]),
self._setup_new_code_output,
self.output,
]
super().__init__(children=children, **kwargs)
if include_setup_widget:
self.btn_setup_new_code = ipw.ToggleButton(description="Setup new code")
self.btn_setup_new_code.observe(self._setup_new_code, "value")

# Computer/code setup
self.resource_setup = _ResourceSetupBaseWidget(
default_calc_job_plugin=self.default_calc_job_plugin,
enable_quick_setup=enable_quick_setup,
enable_detailed_setup=enable_detailed_setup,
)
self.resource_setup.observe(self.refresh, "success")
tl.dlink(
(self.resource_setup, "message"),
(self.setup_message, "message"),
)
selection_row.children += (self.btn_setup_new_code,)

self.refresh()
self._setup_new_code_output = ipw.Output(
layout={"width": self._output_width}
)
children.append(self._setup_new_code_output)

# Computer/code setup
self.resource_setup = _ResourceSetupBaseWidget(
default_calc_job_plugin=self.default_calc_job_plugin,
enable_quick_setup=enable_quick_setup,
enable_detailed_setup=enable_detailed_setup,
)
self.resource_setup.observe(self.refresh, "success")
tl.dlink(
(self.resource_setup, "message"),
(self.setup_message, "message"),
)

children.append(self.output)

super().__init__(children=children, **kwargs)

if fetch_codes:
self.refresh()

def _get_codes(self):
"""Query the list of available codes."""
Expand Down

0 comments on commit 0266afc

Please sign in to comment.