From a0366f06ffbd3f2922d0c97ac63ebeba0a8b32f8 Mon Sep 17 00:00:00 2001 From: zwitschi Date: Thu, 4 Jun 2026 17:13:40 +0200 Subject: [PATCH] feat: add health check endpoint and refactor templates for consistent header usage --- src/arbitrade/api/routes.py | 9 +++++ .../web/templates/{base.html => _base.html} | 2 +- src/arbitrade/web/templates/_header.html | 30 ++++++++++++++++ src/arbitrade/web/templates/audit.html | 21 +++-------- src/arbitrade/web/templates/backtesting.html | 18 +++------- src/arbitrade/web/templates/config.html | 21 +++-------- src/arbitrade/web/templates/dashboard.html | 27 +++----------- src/arbitrade/web/templates/health.html | 35 +++++++++++-------- 8 files changed, 81 insertions(+), 82 deletions(-) rename src/arbitrade/web/templates/{base.html => _base.html} (97%) create mode 100644 src/arbitrade/web/templates/_header.html diff --git a/src/arbitrade/api/routes.py b/src/arbitrade/api/routes.py index 910b9da..cae679e 100644 --- a/src/arbitrade/api/routes.py +++ b/src/arbitrade/api/routes.py @@ -737,6 +737,15 @@ async def home(request: Request) -> HTMLResponse: return await _dashboard_response(request) +@router.get("/dashboard/health", response_class=HTMLResponse) +async def dashboard_health_page(request: Request) -> HTMLResponse: + return templates.TemplateResponse( + request=request, + name="health.html", + context={"title": "Arbitrade Health Check"}, + ) + + @router.get("/dashboard", response_class=HTMLResponse) async def dashboard(request: Request) -> HTMLResponse: return await _dashboard_response(request) diff --git a/src/arbitrade/web/templates/base.html b/src/arbitrade/web/templates/_base.html similarity index 97% rename from src/arbitrade/web/templates/base.html rename to src/arbitrade/web/templates/_base.html index 8ad4cf4..d41c8fe 100644 --- a/src/arbitrade/web/templates/base.html +++ b/src/arbitrade/web/templates/_base.html @@ -140,7 +140,7 @@
- {% block content %}{% endblock %} + {% block header %}{% endblock %} {% block content %}{% endblock %}
{% block scripts %}{% endblock %} diff --git a/src/arbitrade/web/templates/_header.html b/src/arbitrade/web/templates/_header.html new file mode 100644 index 0000000..b7a5d85 --- /dev/null +++ b/src/arbitrade/web/templates/_header.html @@ -0,0 +1,30 @@ +
+
+

{{ page_title }}

+

{{ page_subtitle }}

+
+ {% set nav_links = [ {"url": "/dashboard", "label": "Dashboard", "class": + "secondary"}, {"url": "/dashboard/config", "label": "Config", "class": + "secondary"}, {"url": "/dashboard/backtesting", "label": "Backtesting", + "class": "secondary"}, {"url": "/dashboard/health", "label": "Health", + "class": "secondary"}, ] %} +
+ {% for link in nav_links %} + + {{ link.label }} + + {% endfor %} +
+
diff --git a/src/arbitrade/web/templates/audit.html b/src/arbitrade/web/templates/audit.html index ca05366..e52b048 100644 --- a/src/arbitrade/web/templates/audit.html +++ b/src/arbitrade/web/templates/audit.html @@ -1,19 +1,8 @@ -{% extends "base.html" %} {% block title %}Audit Trail{% endblock %} {% block -main_class %}shell{% endblock %} {% block content %} -
-
-

Audit Trail

-

- System activity, configuration changes, and execution decisions. -

-
- -
+{% extends "_base.html" %} {% block title %}Audit Trail{% endblock %} {% block +main_class %}shell{% endblock %} {% block header %} {% with page_title="Audit +Trail", page_subtitle="System activity, configuration changes, and execution +decisions." %} {% include "_header.html" %} {% endwith %} {% endblock %} {% +block content %}
-
-

Backtesting

-

- Replay controls, run status, and recent summary reports. -

-
-
- Dashboard -
-
+{% extends "_base.html" %} {% block title %}{{ title }}{% endblock %} {% block +main_class %}shell{% endblock %} {% block header %} {% with +page_title="Backtesting", page_subtitle="Replay controls, run status, and recent +summary reports." %} {% include "_header.html" %} {% endwith %} {% endblock %} +{% block content %}
-
-

Configuration

-

- Runtime settings, alerts, exchange, risk, and strategy. -

-
- -
+{% extends "_base.html" %} {% block title %}{{ title }}{% endblock %} {% block +main_class %}shell{% endblock %} {% block header %} {% with +page_title="Configuration", page_subtitle="Runtime settings, alerts, exchange, +risk, and strategy." %} {% include "_header.html" %} {% endwith %} {% endblock +%} {% block content %}
-{% endblock %} {% block main_class %}shell{% endblock %} {% block content %} -
-
-

Arbitrade Dashboard

-

Live execution, P&L, and system state.

-
- -
+{% endblock %} {% block header %} {% with page_title="Arbitrade Dashboard", +page_subtitle="Live execution, P&L, and system state." %} {% include +"_header.html" %} {% endwith %} {% endblock %} {% block main_class %}shell{% +endblock %} {% block content %}
-

Arbitrade Bootstrap Complete

-

Status: {{ status }}

-

UTC: {{ time }}

-

- Health JSON: - refresh -

-
{"status":"ok","service":"arbitrade"}
-
-{% endblock %} +{% extends "_base.html" %} {% block title %}Arbitrade Health Check{% endblock %} +{% block header %} {% with page_title="Arbitrade Health Check", +page_subtitle="Live system state." %} {% include "_header.html" %} {% endwith %} +{% endblock %} {% block main_class %}shell{% endblock %} {% block content %} +
+

Arbitrade Bootstrap Complete

+

Status: {{ status }}

+

UTC: {{ time }}

+

+ Health JSON: + refresh +

+
{"status":"ok","service":"arbitrade"}
+
+{% endblock %} {% block scripts %}{% endblock %}