Skip to content

Commit fc58b5e

Browse files
committed
Use template instead of global config and add favicon to the template
1 parent e69125f commit fc58b5e

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ test: ## Run tests with coverage
3939
pytest --cov simdec --cov-report term-missing
4040

4141
serve-dev: ## Serve Panel dashboard - Dev mode
42-
panel serve panel/app.py --show --autoreload --reuse-sessions --global-loading-spinner
42+
panel serve panel/app.py \
43+
--show --autoreload \
44+
--static-dirs _static=docs/_static \
45+
--reuse-sessions --global-loading-spinner
4346

4447
serve: ## Serve Panel dashboard - Prod mode
4548
PANEL_BASIC_AUTH=$(PANEL_TOKEN) panel serve panel/app.py \

panel/app.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@
1616

1717

1818
# panel app
19-
pn.extension(template="material")
2019
pn.extension("tabulator")
2120
pn.extension("gridstack")
2221

22+
template = pn.template.MaterialTemplate(
23+
title="Simulation Decomposition Dashboard",
24+
# logo="_static/logo.gif",
25+
favicon="_static/favicon.png",
26+
meta_description="Simulation Decomposition",
27+
meta_keywords=(
28+
"Sensitivity Analysis, Visualization, Data Analysis, Auditing, "
29+
"Factors priorization, Colorization, Histogram"
30+
),
31+
)
32+
2333
pn.config.sizing_mode = "stretch_width"
2434
pn.config.throttled = True
2535
font_size = "12pt"
@@ -369,7 +379,7 @@ def csv_data(
369379
# App layout
370380

371381
# Sidebar
372-
pn_params = pn.layout.WidgetBox(
382+
sidebar_area = pn.layout.WidgetBox(
373383
pn.pane.Markdown("## Data", styles={"color": blue_color}),
374384
text_fname,
375385
selector_output,
@@ -384,33 +394,37 @@ def csv_data(
384394
color_pickers,
385395
max_width=350,
386396
sizing_mode="stretch_width",
387-
).servable(area="sidebar")
397+
)
398+
399+
template.sidebar.append(sidebar_area)
388400

389401
# Main window
390-
gstack = GridStack(name="SimDec Analysis", sizing_mode="stretch_both", min_height=600)
402+
main_area = GridStack(
403+
name="SimDec Analysis", sizing_mode="stretch_both", min_height=600
404+
)
391405

392-
gstack[0:3, 0:3] = pn.pane.Matplotlib(
406+
main_area[0:3, 0:3] = pn.pane.Matplotlib(
393407
interactive_figure,
394408
tight=True,
395409
format="svg",
396410
)
397411

398-
gstack[0:3, 3:5] = pn.Column(
412+
main_area[0:3, 3:5] = pn.Column(
399413
pn.pane.Markdown("## Scenarios", styles={"color": blue_color}),
400414
interactive_tableau,
401415
)
402416

403-
gstack[3:5, 3:5] = pn.Column(
417+
main_area[3:5, 3:5] = pn.Column(
404418
pn.pane.Markdown("## Details on inputs' states", styles={"color": blue_color}),
405419
interactive_tableau_states,
406420
)
407421

408-
gstack[3:5, 0:2] = pn.Column(
422+
main_area[3:5, 0:2] = pn.Column(
409423
pn.pane.Markdown("## Sensitivity Indices", styles={"color": blue_color}),
410424
interactive_sensitivity_indices_table,
411425
)
412426

413-
gstack.servable(title="Simulation Decomposition Dashboard")
427+
template.main.append(main_area)
414428

415429
# Header
416430
icon_size = "1.5em"
@@ -458,10 +472,15 @@ def csv_data(
458472
logout_button = pn.widgets.Button(name="Log out", width=100)
459473
logout_button.js_on_click(code="""window.location.href = './logout'""")
460474

461-
pn.Row(
475+
header_area = pn.Row(
462476
pn.HSpacer(),
463477
download_file_button,
464478
info_button,
465479
issue_button,
466480
# logout_button,
467-
).servable(area="header")
481+
)
482+
483+
template.header.append(header_area)
484+
485+
# serve the template
486+
template.servable()

0 commit comments

Comments
 (0)