Skip to content

Commit fe7485e

Browse files
committed
Add property descriptions
1 parent 4dea2d1 commit fe7485e

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

src/fourc_webviewer/fourc_webserver.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import numpy as np
1111
import pyvista as pv
12+
from fourcipp import ALL_SECTIONS, CONFIG, LEGACY_SECTIONS, SECTIONS
1213
from trame.app import get_server
1314
from trame.decorators import TrameApp, change, controller
1415

@@ -67,6 +68,8 @@ def __init__(
6768
# create temporary directory
6869
self._server_vars["temp_dir_object"] = tempfile.TemporaryDirectory()
6970

71+
self._server_vars["json_schema"] = CONFIG["json_schema"]
72+
7073
# initialize state variables for the different modes and
7174
# statuses of the client (e.g. view mode versus edit mode,
7275
# read-in and export status, ...)
@@ -295,6 +298,8 @@ def init_general_sections_state_and_server_vars(self):
295298
approach to add them up to the main section SOLVERS.
296299
"""
297300

301+
self.state.json_schema = self._server_vars["json_schema"]
302+
298303
# define substrings of section names to exclude
299304
substr_to_exclude = ["DESIGN", "TOPOLOGY", "ELEMENTS", "NODE", "FUNCT"]
300305
# define full section names to exclude

src/fourc_webviewer/gui_utils.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,19 @@ def _prop_value_table():
448448
),
449449
key="item_key",
450450
):
451-
html.Td(v_text=("item_key",), classes="text-center")
451+
with html.Td(classes="text-center"):
452+
with vuetify.VTooltip(location="bottom"):
453+
with html.Template(v_slot_activator="{ props }"):
454+
html.P(v_text=("item_key",), v_bind="props")
455+
html.P(
456+
v_text=(
457+
"json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'",
458+
),
459+
v_if=(
460+
"json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']",
461+
),
462+
style="max-width: 450px;",
463+
)
452464
html.Td(
453465
v_if="edit_mode == all_edit_modes['view_mode']",
454466
v_text=("item_val",),
@@ -490,7 +502,7 @@ def _materials_panel():
490502
items=("Object.keys(materials_section)",),
491503
)
492504
# show material type
493-
with html.Div(classes="d-flex align-center ga-3 mb-5 pl-5 w-full"):
505+
with html.Div(classes="d-flex align-center ga-3 mb-1 pl-5 w-full"):
494506
html.Span("TYPE: ", classes="text-h6")
495507
# view mode: text
496508
html.Span(
@@ -510,8 +522,20 @@ def _materials_panel():
510522
dense=True,
511523
hide_details=True,
512524
)
525+
html.P(
526+
classes="ga-3 mb-5 pl-5 pr-5 w-full",
527+
v_if=("edit_mode == all_edit_modes['view_mode']",),
528+
v_text=(
529+
"json_schema?.properties?.MATERIALS?.items?.oneOf?"
530+
".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?.properties?"
531+
".[materials_section[selected_material]?.TYPE]?.description || 'Error on material description'",
532+
),
533+
style="color: #999;",
534+
)
535+
513536
# show relationships to other materials (linked materials
514537
# and master material) -> only in view mode
538+
515539
with html.Div(
516540
v_if=("edit_mode == all_edit_modes['view_mode']",),
517541
):
@@ -552,6 +576,7 @@ def _materials_panel():
552576
html.Th(
553577
"Value",
554578
classes="text-center font-weight-bold",
579+
style="width: 50%;",
555580
)
556581
with html.Tbody():
557582
with html.Tr(
@@ -560,7 +585,19 @@ def _materials_panel():
560585
),
561586
classes="text-center",
562587
):
563-
html.Td(v_text=("param_key",))
588+
with html.Td(classes="text-center"):
589+
with vuetify.VTooltip(location="bottom"):
590+
with html.Template(v_slot_activator="{ props }"):
591+
html.P(v_text=("param_key",), v_bind="props")
592+
html.P(
593+
v_text=(
594+
"json_schema?.properties?.MATERIALS?.items?.oneOf?"
595+
".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?"
596+
".properties?.[materials_section[selected_material]?.TYPE]?.properties?"
597+
".[param_key]?.description || 'Error on parameter description'",
598+
),
599+
style="max-width: 450px;",
600+
)
564601
html.Td(
565602
v_text=("param_val",),
566603
)

0 commit comments

Comments
 (0)