|
4 | 4 | import sys |
5 | 5 | import uuid |
6 | 6 | import time |
| 7 | +import psutil |
7 | 8 | from typing import Any |
8 | 9 | from pathlib import Path |
9 | 10 | from streamlit.components.v1 import html |
|
23 | 24 | # Detect system platform |
24 | 25 | OS_PLATFORM = sys.platform |
25 | 26 |
|
| 27 | +@st.fragment(run_every=5) |
| 28 | +def monitor_hardware(): |
| 29 | + cpu_progress = psutil.cpu_percent(interval=None) / 100 |
| 30 | + ram_progress = 1 - psutil.virtual_memory().available / psutil.virtual_memory().total |
26 | 31 |
|
27 | | -# set these variables according to your project |
28 | | -APP_NAME = "NuXL" |
29 | | -REPOSITORY_NAME = "nuxl-app" |
| 32 | + st.text(f"Ram ({ram_progress * 100:.2f}%)") |
| 33 | + st.progress(ram_progress) |
30 | 34 |
|
| 35 | + st.text(f"CPU ({cpu_progress * 100:.2f}%)") |
| 36 | + st.progress(cpu_progress) |
| 37 | + |
| 38 | + st.caption(f"Last fetched at: {time.strftime('%H:%M:%S')}") |
31 | 39 |
|
32 | 40 | def load_params(default: bool = False) -> dict[str, Any]: |
33 | 41 | """ |
@@ -110,7 +118,7 @@ def page_setup(page: str = "") -> dict[str, Any]: |
110 | 118 |
|
111 | 119 | # Set Streamlit page configurations |
112 | 120 | st.set_page_config( |
113 | | - page_title=APP_NAME, |
| 121 | + page_title=st.session_state.settings["app-name"], |
114 | 122 | page_icon="assets/openms_transparent_bg_logo.svg", |
115 | 123 | layout="wide", |
116 | 124 | initial_sidebar_state="auto", |
@@ -202,7 +210,7 @@ def page_setup(page: str = "") -> dict[str, Any]: |
202 | 210 | if "windows" in sys.argv: |
203 | 211 | os.chdir("../nuxl-app-main") |
204 | 212 | # Define the directory where all workspaces will be stored |
205 | | - workspaces_dir = Path("..", "workspaces-" + REPOSITORY_NAME) |
| 213 | + workspaces_dir = Path("..", "workspaces-" + st.session_state.settings["repository-name"]) |
206 | 214 | if "workspace" in st.query_params: |
207 | 215 | st.session_state.workspace = Path(workspaces_dir, st.query_params.workspace) |
208 | 216 | elif st.session_state.location == "online": |
@@ -277,7 +285,7 @@ def render_sidebar(page: str = "") -> None: |
277 | 285 | if page == "main": |
278 | 286 | st.markdown("🖥️ **Workspaces**") |
279 | 287 | # Define workspaces directory outside of repository |
280 | | - workspaces_dir = Path("..", "workspaces-"+REPOSITORY_NAME) |
| 288 | + workspaces_dir = Path("..", "workspaces-"+st.session_state.settings["repository-name"]) |
281 | 289 | # Online: show current workspace name in info text and option to change to other existing workspace |
282 | 290 | if st.session_state.location == "online": |
283 | 291 | # Change workspace... |
@@ -365,8 +373,37 @@ def change_workspace(): |
365 | 373 | **{st.session_state['workspace'].name}** |
366 | 374 | """ |
367 | 375 | ) |
| 376 | + with st.expander("📊 **Resource Utilization**"): |
| 377 | + monitor_hardware() |
| 378 | + |
368 | 379 | st.image("assets/OpenMS_new.png", "powered by") |
369 | | - #st.logo() |
| 380 | + |
| 381 | + |
| 382 | + # Display OpenMS WebApp Template Version from settings.json |
| 383 | + with st.container(): |
| 384 | + st.markdown( |
| 385 | + """ |
| 386 | + <style> |
| 387 | + .version-box { |
| 388 | + border: 1px solid #a4a5ad; |
| 389 | + padding: 10px; |
| 390 | + border-radius: 0.5rem; |
| 391 | + text-align: center; |
| 392 | + display: flex; |
| 393 | + justify-content: center; |
| 394 | + align-items: center; |
| 395 | + } |
| 396 | + </style> |
| 397 | + """, |
| 398 | + unsafe_allow_html=True, |
| 399 | + ) |
| 400 | + version_info = st.session_state.settings["version"] |
| 401 | + app_name = st.session_state.settings["app-name"] |
| 402 | + st.markdown( |
| 403 | + f'<div class="version-box">{app_name}<br>Version: {version_info}</div>', |
| 404 | + unsafe_allow_html=True, |
| 405 | + ) |
| 406 | + |
370 | 407 | return params |
371 | 408 |
|
372 | 409 | def v_space(n: int, col=None) -> None: |
|
0 commit comments