Moved results list to results view.

This commit is contained in:
2026-05-25 17:23:42 +12:00
parent ddcaa8ac98
commit 6e25dae786
4 changed files with 127 additions and 109 deletions
+12 -3
View File
@@ -23,7 +23,16 @@ router = APIRouter(
) )
@router.get("/", response_class=HTMLResponse) @router.get("/", response_class=HTMLResponse)
async def dashboard_view( async def dashboard_view(request: Request):
return templates.TemplateResponse(
request=request,
name="dashboard.html",
context={"title": "Dashboard"},
)
@router.get("/results", response_class=HTMLResponse)
async def results_view(
request: Request, request: Request,
sessionmaker: Annotated[async_sessionmaker, Depends(get_async_sessionmaker)], sessionmaker: Annotated[async_sessionmaker, Depends(get_async_sessionmaker)],
cursor: int = 999999, cursor: int = 999999,
@@ -61,9 +70,9 @@ async def dashboard_view(
return templates.TemplateResponse( return templates.TemplateResponse(
request=request, request=request,
name="dashboard.html", name="results.html",
context={ context={
"title": "Dashboard", "title": "Results",
"results": results, "results": results,
"next_cursor": next_cursor, "next_cursor": next_cursor,
"prev_cursor": prev_cursor, "prev_cursor": prev_cursor,
+2 -1
View File
@@ -17,7 +17,8 @@
<a href="#">Recon Ranger</a> <a href="#">Recon Ranger</a>
</div> </div>
<ul> <ul>
<li><a href="#">Home</a></li> <li><a href="/">Home</a></li>
<li><a href="/results">Results</a></li>
<li><a href="api/docs/">API</a></li> <li><a href="api/docs/">API</a></li>
<li><a href="mailto:someone@example.com">Contact</a></li> <li><a href="mailto:someone@example.com">Contact</a></li>
</ul> </ul>
+1 -104
View File
@@ -1,111 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% macro render_nested(value) %}
{% if value is mapping %}
{% for k, v in value.items() %}
<div class="nested-item">
<span class="nested-key">{{ k }}:</span>
<span class="nested-value">{{ render_nested(v) }}</span>
</div>
{% endfor %}
{% elif value is iterable and not value is string %}
{% for item in value %}
{{ render_nested(item) }}
{% endfor %}
{% else %}
{{ value }}
{% endif %}
{% endmacro %}
{% block content %} {% block content %}
<div class="dashboard-container"> <div class="dashboard-container">
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<p>Dashboard coming soon.</p>
{# ── Filter bar ─────────────────────────────────────────── #}
<form class="filter-bar" method="get" id="filter-form" onsubmit="
this.querySelectorAll('input').forEach(function(el){ if(!el.value) el.disabled = true; });
">
<div class="filter-group">
<label for="recon_job_name">Job Name</label>
<input type="text" id="recon_job_name" name="recon_job_name"
placeholder="e.g. daily-fx-recon"
value="{{ recon_job_name or '' }}">
</div>
<div class="filter-group">
<label for="as_at_date">As-at Date</label>
<input type="date" id="as_at_date" name="as_at_date"
value="{{ as_at_date or '' }}">
</div>
<div class="filter-actions">
<button type="submit" class="btn btn-primary">Apply</button>
<a href="?" class="btn btn-secondary">Clear</a>
</div>
</form>
<script>
(function () {
var params = new URLSearchParams(window.location.search);
["recon_job_name", "as_at_date"].forEach(function (key) {
var val = params.get(key);
if (val) {
var el = document.getElementById(key);
if (el) el.value = val;
}
});
})();
</script>
{% if results | length > 0 %}
<div class="table-scroll">
<table class="data-table">
<thead>
<tr>
{% for key in results[0].keys() %}
<th>{{ key }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
{% for key, value in row.items() %}
<td>
{% if key == 'Status' %}
<span class="badge badge-{{ value | lower }}">{{ value }}</span>
{% elif key == 'Flag' %}
<span class="badge badge-{{ 'none' if value == 'None' else 'flag' }}">{{ value }}</span>
{% else %}
{{ render_nested(value) }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{# ── Pagination ─────────────────────────────────────────── #}
{% set filter_qs %}{% if recon_job_name %}&recon_job_name={{ recon_job_name }}{% endif %}{% if as_at_date %}&as_at_date={{ as_at_date }}{% endif %}{% endset %}
<div class="pagination">
{% if prev_cursor %}
<a class="btn btn-secondary"
href="?cursor={{ prev_cursor }}{{ filter_qs }}">
← Previous
</a>
{% else %}
<span class="btn btn-secondary btn-disabled">← Previous</span>
{% endif %}
{% if next_cursor %}
<a class="btn btn-secondary"
href="?cursor={{ next_cursor }}{{ filter_qs }}">
Next →
</a>
{% else %}
<span class="btn btn-secondary btn-disabled">Next →</span>
{% endif %}
</div>
{% endif %}
</div> </div>
{% endblock %} {% endblock %}
+111
View File
@@ -0,0 +1,111 @@
{% extends "base.html" %}
{% macro render_nested(value) %}
{% if value is mapping %}
{% for k, v in value.items() %}
<div class="nested-item">
<span class="nested-key">{{ k }}:</span>
<span class="nested-value">{{ render_nested(v) }}</span>
</div>
{% endfor %}
{% elif value is iterable and not value is string %}
{% for item in value %}
{{ render_nested(item) }}
{% endfor %}
{% else %}
{{ value }}
{% endif %}
{% endmacro %}
{% block content %}
<div class="dashboard-container">
<h1>{{ title }}</h1>
{# ── Filter bar ─────────────────────────────────────────── #}
<form class="filter-bar" method="get" id="filter-form" onsubmit="
this.querySelectorAll('input').forEach(function(el){ if(!el.value) el.disabled = true; });
">
<div class="filter-group">
<label for="recon_job_name">Job Name</label>
<input type="text" id="recon_job_name" name="recon_job_name"
placeholder="e.g. daily-fx-recon"
value="{{ recon_job_name or '' }}">
</div>
<div class="filter-group">
<label for="as_at_date">As-at Date</label>
<input type="date" id="as_at_date" name="as_at_date"
value="{{ as_at_date or '' }}">
</div>
<div class="filter-actions">
<button type="submit" class="btn btn-primary">Apply</button>
<a href="?" class="btn btn-secondary">Clear</a>
</div>
</form>
<script>
(function () {
var params = new URLSearchParams(window.location.search);
["recon_job_name", "as_at_date"].forEach(function (key) {
var val = params.get(key);
if (val) {
var el = document.getElementById(key);
if (el) el.value = val;
}
});
})();
</script>
{% if results | length > 0 %}
<div class="table-scroll">
<table class="data-table">
<thead>
<tr>
{% for key in results[0].keys() %}
<th>{{ key }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
{% for key, value in row.items() %}
<td>
{% if key == 'Status' %}
<span class="badge badge-{{ value | lower }}">{{ value }}</span>
{% elif key == 'Flag' %}
<span class="badge badge-{{ 'none' if value == 'None' else 'flag' }}">{{ value }}</span>
{% else %}
{{ render_nested(value) }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{# ── Pagination ─────────────────────────────────────────── #}
{% set filter_qs %}{% if recon_job_name %}&recon_job_name={{ recon_job_name }}{% endif %}{% if as_at_date %}&as_at_date={{ as_at_date }}{% endif %}{% endset %}
<div class="pagination">
{% if prev_cursor %}
<a class="btn btn-secondary"
href="?cursor={{ prev_cursor }}{{ filter_qs }}">
← Previous
</a>
{% else %}
<span class="btn btn-secondary btn-disabled">← Previous</span>
{% endif %}
{% if next_cursor %}
<a class="btn btn-secondary"
href="?cursor={{ next_cursor }}{{ filter_qs }}">
Next →
</a>
{% else %}
<span class="btn btn-secondary btn-disabled">Next →</span>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}