feat: add health check endpoint and refactor templates for consistent header usage
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<main class="{% block main_class %}shell{% endblock %}">
|
||||
{% block content %}{% endblock %}
|
||||
{% block header %}{% endblock %} {% block content %}{% endblock %}
|
||||
</main>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
@@ -0,0 +1,30 @@
|
||||
<section class="hero">
|
||||
<div>
|
||||
<h1 class="title">{{ page_title }}</h1>
|
||||
<p class="subtitle">{{ page_subtitle }}</p>
|
||||
</div>
|
||||
{% 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"}, ] %}
|
||||
<div class="toolbar">
|
||||
{% for link in nav_links %}
|
||||
<a
|
||||
class="button{% if link.class %} {{ link.class }}{% endif %}"
|
||||
href="{{ link.url }}"
|
||||
{%
|
||||
if
|
||||
link.hx_get
|
||||
%}hx-get="{{ link.hx_get }}"
|
||||
hx-target="{{ link.hx_target }}"
|
||||
hx-swap="{{ link.hx_swap | default('outerHTML') }}"
|
||||
{%
|
||||
endif
|
||||
%}
|
||||
>
|
||||
{{ link.label }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
@@ -1,19 +1,8 @@
|
||||
{% extends "base.html" %} {% block title %}Audit Trail{% endblock %} {% block
|
||||
main_class %}shell{% endblock %} {% block content %}
|
||||
<section class="hero">
|
||||
<div>
|
||||
<h1 class="title">Audit Trail</h1>
|
||||
<p class="subtitle">
|
||||
System activity, configuration changes, and execution decisions.
|
||||
</p>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<a class="button secondary" href="/dashboard">Dashboard</a>
|
||||
<a class="button secondary" href="/dashboard/config">Config</a>
|
||||
<a class="button secondary" href="/dashboard/backtesting">Backtesting</a>
|
||||
<a class="button secondary" href="/health">Health</a>
|
||||
</div>
|
||||
</section>
|
||||
{% 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 %}
|
||||
|
||||
<section
|
||||
id="audit-shell"
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
{% extends "base.html" %} {% block title %}{{ title }}{% endblock %} {% block
|
||||
content %}
|
||||
<section class="hero">
|
||||
<div>
|
||||
<h1 class="title">Backtesting</h1>
|
||||
<p class="subtitle">
|
||||
Replay controls, run status, and recent summary reports.
|
||||
</p>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<a class="button secondary" href="{{ dashboard_endpoint }}">Dashboard</a>
|
||||
</div>
|
||||
</section>
|
||||
{% 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 %}
|
||||
|
||||
<section
|
||||
id="backtesting-shell"
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
{% extends "base.html" %} {% block title %}{{ title }}{% endblock %} {% block
|
||||
main_class %}shell{% endblock %} {% block content %}
|
||||
<section class="hero">
|
||||
<div>
|
||||
<h1 class="title">Configuration</h1>
|
||||
<p class="subtitle">
|
||||
Runtime settings, alerts, exchange, risk, and strategy.
|
||||
</p>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<a class="button secondary" href="/dashboard">Dashboard</a>
|
||||
<a class="button secondary" href="/dashboard/backtesting">Backtesting</a>
|
||||
<a class="button secondary" href="/dashboard/audit">Audit</a>
|
||||
<a class="button secondary" href="/health">Health</a>
|
||||
</div>
|
||||
</section>
|
||||
{% 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 %}
|
||||
|
||||
<section
|
||||
id="fees-shell"
|
||||
|
||||
@@ -1,28 +1,11 @@
|
||||
{% extends "base.html" %} {% block title %}{{ title }}{% endblock %} {% block
|
||||
{% extends "_base.html" %} {% block title %}{{ title }}{% endblock %} {% block
|
||||
head_scripts %}
|
||||
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
|
||||
{% endblock %} {% block main_class %}shell{% endblock %} {% block content %}
|
||||
<section class="hero">
|
||||
<div>
|
||||
<h1 class="title">Arbitrade Dashboard</h1>
|
||||
<p class="subtitle">Live execution, P&L, and system state.</p>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<a
|
||||
class="button"
|
||||
href="{{ metrics_endpoint }}"
|
||||
hx-get="{{ metrics_endpoint }}"
|
||||
hx-target="#metrics-panel"
|
||||
hx-swap="outerHTML"
|
||||
>Refresh metrics</a
|
||||
>
|
||||
<a class="button secondary" href="/health">Health</a>
|
||||
<a class="button secondary" href="/dashboard/config">Config</a>
|
||||
<a class="button secondary" href="/dashboard/backtesting">Backtesting</a>
|
||||
<a class="button secondary" href="/dashboard/audit">Audit</a>
|
||||
</div>
|
||||
</section>
|
||||
{% 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 %}
|
||||
|
||||
<section
|
||||
id="metrics-shell"
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<section class="card">
|
||||
{% 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 %}
|
||||
<section class="card">
|
||||
<h1>Arbitrade Bootstrap Complete</h1>
|
||||
<p><span class="badge">Status: {{ status }}</span></p>
|
||||
<p>UTC: {{ time }}</p>
|
||||
<p>
|
||||
Health JSON:
|
||||
<a href="/health" hx-get="/health" hx-target="#health-json" hx-swap="innerHTML">refresh</a>
|
||||
<a
|
||||
href="/health"
|
||||
hx-get="/health"
|
||||
hx-target="#health-json"
|
||||
hx-swap="innerHTML"
|
||||
>refresh</a
|
||||
>
|
||||
</p>
|
||||
<pre id="health-json">{"status":"ok","service":"arbitrade"}</pre>
|
||||
</section>
|
||||
{% endblock %}
|
||||
</section>
|
||||
{% endblock %} {% block scripts %}{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user