From 3ccda42d796ef1267fedf6100aa45c2be426f79c Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Mon, 11 Nov 2024 11:41:18 +0000 Subject: [PATCH] Handle #924 --- src/aiidalab_qe/app/result/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/aiidalab_qe/app/result/__init__.py b/src/aiidalab_qe/app/result/__init__.py index b9f5b156b..a53fd2153 100644 --- a/src/aiidalab_qe/app/result/__init__.py +++ b/src/aiidalab_qe/app/result/__init__.py @@ -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): @@ -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 @@ -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):