Skip to content

Commit

Permalink
Handle aiidalab#924
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Nov 11, 2024
1 parent 6baf3d4 commit 3ccda42
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/aiidalab_qe/app/result/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def render(self):
self._update_clean_scratch_button_layout()

def can_reset(self):
"Checks if process is running (active), which disallows a reset."
return self.state is not self.State.ACTIVE

def reset(self):
Expand All @@ -153,20 +154,22 @@ def _on_kill_button_click(self, _):
self._update_kill_button_layout()

def _on_update_results_button_click(self, _):
self.node_view.node = None
self.node_view.node = self._model.get_process_node()
self._update_node_view(self.process_tree.selected_nodes, refresh=True)

def _on_clean_scratch_button_click(self, _):
self._model.clean_remote_data()
self._update_clean_scratch_button_layout()

def _update_node_view(self, nodes):
def _update_node_view(self, nodes, refresh=False):
"""Update the node view based on the selected nodes.
parameters
----------
`nodes`: `list`
List of selected nodes.
`refresh`: `bool`, optional
If True, the viewer will be refreshed.
Occurs when user presses the "Update results" button.
"""
from aiidalab_widgets_base.viewers import viewer

Expand All @@ -175,14 +178,14 @@ def _update_node_view(self, nodes):
# only show the first selected node
node = nodes[0]
# check if the viewer is already added
if node.uuid in self.node_views:
node_view = self.node_views[node.uuid]
if node.uuid in self.node_views and not refresh:
self.node_view = self.node_views[node.uuid]
else:
node_view = viewer(node)
self.node_views[node.uuid] = node_view
self.node_view = viewer(node)
self.node_views[node.uuid] = self.node_view
self.process_status.children = [
self.process_tree,
node_view,
self.node_view,
]

def _update_kill_button_layout(self):
Expand Down

0 comments on commit 3ccda42

Please sign in to comment.