From b28878088926f25287a08ebceca5d587b1b71bc1 Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Thu, 19 Dec 2024 08:33:07 +0100 Subject: [PATCH] Rename job history and convert the button to a link to a new tab (#995) * Rename to calculation history * Convert "Job history" button on top to a link to a new tab * Add space between Quantum Espresso * make the table expand to full page width --- job_list.ipynb => calculation_history.ipynb | 23 +++++++--- .../app/static/templates/guide.jinja | 2 +- src/aiidalab_qe/app/wrapper.py | 44 +++++-------------- start.py | 2 +- 4 files changed, 31 insertions(+), 40 deletions(-) rename job_list.ipynb => calculation_history.ipynb (67%) diff --git a/job_list.ipynb b/calculation_history.ipynb similarity index 67% rename from job_list.ipynb rename to calculation_history.ipynb index cedc6d0c8..e1170b012 100644 --- a/job_list.ipynb +++ b/calculation_history.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# AiiDAlab QuantumESPRESSO App" + "# AiiDAlab Quantum ESPRESSO App" ] }, { @@ -19,6 +19,17 @@ "load_profile()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from aiidalab_widgets_base.utils.loaders import load_css\n", + "\n", + "load_css(css_path=\"src/aiidalab_qe/app/static/styles\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -27,9 +38,9 @@ "source": [ "from aiidalab_qe.app.utils.search_jobs import QueryInterface\n", "\n", - "job_history = QueryInterface()\n", - "job_history.setup_table()\n", - "job_history.filters_layout" + "calculation_history = QueryInterface()\n", + "calculation_history.setup_table()\n", + "calculation_history.filters_layout" ] }, { @@ -38,13 +49,13 @@ "metadata": {}, "outputs": [], "source": [ - "job_history.table" + "calculation_history.table" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, diff --git a/src/aiidalab_qe/app/static/templates/guide.jinja b/src/aiidalab_qe/app/static/templates/guide.jinja index 0a1a5bcf1..3123a1662 100644 --- a/src/aiidalab_qe/app/static/templates/guide.jinja +++ b/src/aiidalab_qe/app/static/templates/guide.jinja @@ -23,7 +23,7 @@

- Completed workflows can be viewed in the Job History section. + Completed workflows can be viewed in the Calculation history section.

diff --git a/src/aiidalab_qe/app/wrapper.py b/src/aiidalab_qe/app/wrapper.py index 8ecedb45a..3c171bd6e 100644 --- a/src/aiidalab_qe/app/wrapper.py +++ b/src/aiidalab_qe/app/wrapper.py @@ -52,7 +52,6 @@ def enable_toggles(self) -> None: """Enable the toggle buttons.""" self._view.guide_toggle.disabled = False self._view.about_toggle.disabled = False - self._view.job_history_toggle.disabled = False @without_triggering("about_toggle") def _on_guide_toggle(self, change: dict): @@ -69,7 +68,6 @@ def _on_guide_toggle(self, change: dict): ), ] self._view.info_container.layout.display = "flex" - self._view.job_history_toggle.value = False else: self._view.info_container.children = [] self._view.info_container.layout.display = "none" @@ -80,26 +78,10 @@ def _on_about_toggle(self, change: dict): if change["new"]: self._view.info_container.children = [self._view.about] self._view.info_container.layout.display = "flex" - self._view.job_history_toggle.value = False else: self._view.info_container.children = [] self._view.info_container.layout.display = "none" - def _on_job_history_toggle(self, change: dict): - """Toggle the job list section.""" - if change["new"]: - self._view.about_toggle.value = False - self._view.guide_toggle.value = False - self._old_view = self._view.main.children - self._view.main.children = [LoadingWidget("Loading job history")] - self._view.job_history.setup_table() - self._view.main.children = [ - self._view.job_history.filters_layout, - self._view.job_history.table, - ] - else: - self._view.main.children = self._old_view - def _on_guide_category_select(self, change: dict): self._view.guide_selection.options = guide_manager.get_guides(change["new"]) self._update_active_guide() @@ -131,10 +113,6 @@ def _set_event_handlers(self) -> None: self._on_about_toggle, "value", ) - self._view.job_history_toggle.observe( - self._on_job_history_toggle, - "value", - ) self._view.guide_category_selection.observe( self._on_guide_category_select, "value", @@ -168,9 +146,7 @@ def __init__(self) -> None: from jinja2 import Environment from aiidalab_qe.app.static import templates - from aiidalab_qe.app.utils.search_jobs import QueryInterface from aiidalab_qe.common.infobox import InfoBox - from aiidalab_qe.common.widgets import LoadingWidget from aiidalab_qe.version import __version__ ################################################# @@ -208,21 +184,21 @@ def __init__(self) -> None: disabled=True, ) - self.job_history_toggle = ipw.ToggleButton( + self.calculation_history_button = ipw.Button( layout=ipw.Layout(width="auto"), button_style="", icon="list", - value=False, - description="Job History", - tooltip="View all jobs run with this app", - disabled=True, + description="Calculation history", + tooltip="View all calculations run with this app", ) + self.calculation_history_button.on_click(self._open_calculation_history) + info_toggles = ipw.HBox( children=[ self.guide_toggle, self.about_toggle, - self.job_history_toggle, + self.calculation_history_button, ] ) info_toggles.add_class("info-toggles") @@ -242,8 +218,6 @@ def __init__(self) -> None: ) self.guide_selection = ipw.RadioButtons(layout=ipw.Layout(margin="2px 20px")) - self.job_history = QueryInterface() - self.info_container = InfoBox() header = ipw.VBox( @@ -275,3 +249,9 @@ def __init__(self) -> None: footer, ], ) + + def _open_calculation_history(self, _): + from IPython.display import Javascript + + url = "./calculation_history.ipynb" + display(Javascript(f"window.open('{url}', '_blank')")) diff --git a/start.py b/start.py index bdf98f6a3..5462a95a3 100644 --- a/start.py +++ b/start.py @@ -23,7 +23,7 @@ def get_start_widget(appbase, jupbase, notebase): # noqa: ARG001