From 69de3faf11cb26a79f645ebace0f5b271e8cc4c1 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Sat, 28 Dec 2024 14:08:56 +0000 Subject: [PATCH] Redesign summary view --- .../app/result/components/summary/model.py | 2 +- .../app/result/components/summary/summary.py | 38 +++- src/aiidalab_qe/app/static/styles/summary.css | 44 ++++ .../static/templates/workflow_summary.jinja | 188 ++++++++---------- tests/test_result.py | 6 +- 5 files changed, 161 insertions(+), 117 deletions(-) create mode 100644 src/aiidalab_qe/app/static/styles/summary.css diff --git a/src/aiidalab_qe/app/result/components/summary/model.py b/src/aiidalab_qe/app/result/components/summary/model.py index 74b1b635a..c0ecf71e0 100644 --- a/src/aiidalab_qe/app/result/components/summary/model.py +++ b/src/aiidalab_qe/app/result/components/summary/model.py @@ -53,7 +53,7 @@ def generate_report_html(self): from aiidalab_qe.app.static import styles, templates def _fmt_yes_no(truthy): - return "Yes" if truthy else "No" + return "yes" if truthy else "no" env = Environment() env.filters.update( diff --git a/src/aiidalab_qe/app/result/components/summary/summary.py b/src/aiidalab_qe/app/result/components/summary/summary.py index aab7390da..5c9568390 100644 --- a/src/aiidalab_qe/app/result/components/summary/summary.py +++ b/src/aiidalab_qe/app/result/components/summary/summary.py @@ -26,12 +26,44 @@ def _render(self): def _render_summary(self): if not self._model.has_process: return - report = self._model.generate_report_html() - self.children = [ipw.HTML(report)] + + settings_summary = ipw.HTML( + value=self._model.generate_report_html(), + ) + settings_summary.add_class("summary-panel") + + self.output_download_container = ipw.VBox( + children=[ + ipw.HTML(""" +
+

Download the data

+ Once the workflow is finished, you can download raw data + (i.e. input and output files) and/or the AiiDA archive + (ready to be shared or imported into another AiiDA profile). +
+ """), + ipw.HTML("Download buttons will appear here when available."), + ], + ) + self.output_download_container.add_class("summary-panel") + + self.container = ipw.HBox( + children=[ + settings_summary, + self.output_download_container, + ], + ) + self.container.add_class("workflow-summary-container") + self.children = [self.container] self.has_report = True def _render_output(self): process_node = self._model.fetch_process_node() if process_node and process_node.is_terminated: - self.children += (WorkChainOutputs(node=process_node),) + output_download_widget = WorkChainOutputs(node=process_node) + output_download_widget.layout.width = "100%" + self.output_download_container.children = [ + self.output_download_container.children[0], # type: ignore + output_download_widget, + ] self.has_output = True diff --git a/src/aiidalab_qe/app/static/styles/summary.css b/src/aiidalab_qe/app/static/styles/summary.css new file mode 100644 index 000000000..6e6d8bd00 --- /dev/null +++ b/src/aiidalab_qe/app/static/styles/summary.css @@ -0,0 +1,44 @@ +.workflow-summary-container { + width: 75%; + margin: 0 auto; + gap: 10px; +} + +@media (max-width: 1199px) { + .workflow-summary-container { + width: 92%; + } +} + +@media (max-width: 991px) { + .workflow-summary-container { + width: 100%; + } +} + +.summary-panel { + width: 100%; + border: 1px solid #9e9e9e; + padding: 0 20px 10px; + margin: 0; +} + +.settings-summary { + margin: 2px; + font-family: Arial, sans-serif; + line-height: 1.6; +} + +.settings-summary ul { + list-style-type: none; + padding: 0; + margin: 0; +} + +.settings-summary ul ul { + margin-left: 20px; +} + +.settings-summary a { + text-decoration: none; +} diff --git a/src/aiidalab_qe/app/static/templates/workflow_summary.jinja b/src/aiidalab_qe/app/static/templates/workflow_summary.jinja index 7d96c9d24..704644cec 100644 --- a/src/aiidalab_qe/app/static/templates/workflow_summary.jinja +++ b/src/aiidalab_qe/app/static/templates/workflow_summary.jinja @@ -1,130 +1,100 @@ -
-
-

Standard settings

- - - - - +
+

Main settings

+
    +
  • + Structure geometry optimized: {{ relaxed | fmt_yes_no }} +
  • {% if relaxed %} -
- - - +
  • + Optimization method: {{ relax_method }} +
  • {% endif %} - - - - - - - - - - - - - - - - +
  • + Protocol: {{ protocol }} +
  • +
  • + Magnetism: {{ material_magnetic }} +
  • +
  • + Electronic type: {{ electronic_type }} +
  • +
  • + Periodicity: {{ periodicity }} +
  • + -
    Structure geometry optimized{{ relaxed | fmt_yes_no }}
    Optimization method{{ relax_method }}
    Protocol{{ protocol }}
    Magnetism{{ material_magnetic }}
    Electronic type{{ electronic_type }}
    Periodicity{{ periodicity }}
    -
    -
    -

    Advanced settings

    - - - - - - - - - - - - - - - - - - - - - +

    Advanced settings

    + - - - - - - - +
      +
    • + Smearing width (degauss): {{ degauss }} Ry +
    • +
    • + Smearing type: {{ smearing }} +
    • +
    {% endif %} - - - - +
  • + K-point mesh distance (SCF): {{ scf_kpoints_distance }} Å-1 +
  • {% if bands_computed %} - - - - +
  • + K-point line distance (Bands): {{ bands_kpoints_distance }} Å-1 +
  • {% endif %} {% if pdos_computed %} - - - - +
  • + K-point mesh distance (NSCF): {{ nscf_kpoints_distance }} Å-1 +
  • {% endif %} - - - - - - - - - +
  • + Total charge: {{ tot_charge }} +
  • +
  • + Van der Waals correction: {{ vdw_corr }} +
  • + {% if material_magnetic == "collinear" %} {% if tot_magnetization %} - - - - +
  • + Total magnetization: {{ tot_magnetization }} +
  • {% else %} - - - - +
  • + Initial magnetic moments: {{ initial_magnetic_moments }} +
  • + {% endif %} {% endif %} {% if hubbard_u %} - - - - +
  • + DFT+U: {{ hubbard_u }} +
  • {% endif %} {% if spin_orbit %} - - - - +
  • + Spin-orbit coupling: {{ spin_orbit }} +
  • {% endif %} - -
    Functional - - {{ functional }} - -
    Pseudopotential library - - {{ pseudo_library }} {{ pseudo_protocol }} v{{ pseudo_version }} - -
    Energy cutoff (wave functions){{ energy_cutoff_wfc }} Ry
    Energy cutoff (charge density){{ energy_cutoff_rho }} Ry
    Occupation type (SCF){{ occupation_type }}
    Smearing width (degauss){{ degauss }} Ry
    Smearing type{{ smearing }}
    K-point mesh distance (SCF){{ scf_kpoints_distance }} Å-1
    K-point line distance (Bands){{ bands_kpoints_distance }} Å-1
    K-point mesh distance (NSCF){{ nscf_kpoints_distance }} Å-1
    Total charge{{ tot_charge }}
    Van der Waals correction{{ vdw_corr }}
    Total magnetization{{ tot_magnetization }}
    Initial magnetic moments{{ initial_magnetic_moments }}
    DFT+U{{ hubbard_u }}
    Spin-orbit coupling{{ spin_orbit }}
    +
    -
    diff --git a/tests/test_result.py b/tests/test_result.py index 3bc2e7f84..3a86c176d 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -71,15 +71,13 @@ def test_summary_view(generate_qeapp_workchain): model.process_uuid = workchain.node.uuid report_html = model.generate_report_html() parsed = BeautifulSoup(report_html, "html.parser") - # find the td with the text "Initial Magnetic Moments" parameters = { "Energy cutoff (wave functions)": "30.0 Ry", "Total charge": "0.0", - "Initial magnetic moments": "", } for key, value in parameters.items(): - td = parsed.find("td", text=key).find_next_sibling("td") - assert td.text == value + li = parsed.find_all(lambda tag, key=key: tag.name == "li" and key in tag.text) + assert value in li[0].text def test_structure_results_panel(generate_qeapp_workchain):