Add job detail template with execution history and metrics display
- Created a new job_detail.html template extending base.html - Implemented a macro for rendering nested data structures - Added sections for job identification, schedule & timing, status, configuration, execution history, and results - Included a timeline for execution history with visual indicators for job status - Displayed job metrics including total executions, success rate, and average duration - Handled cases for displaying results or indicating absence of results based on job status
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Recon Ranger</title>
|
||||
<link id="favicon" rel="icon" type="image/x-icon" href="static/images/favicon.ico">
|
||||
<link rel="stylesheet" href="static/css/styles.css">
|
||||
<link id="favicon" rel="icon" type="image/x-icon" href="/static/images/favicon.ico">
|
||||
<link rel="stylesheet" href="/static/css/styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -19,7 +19,7 @@
|
||||
<ul>
|
||||
<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>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,191 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="dashboard-container">
|
||||
<div class="dashboard-container dashboard-stack">
|
||||
<h1>{{ title }}</h1>
|
||||
<p>Dashboard coming soon.</p>
|
||||
|
||||
<div class="timeline-wrap">
|
||||
{% for tl in timelines %}
|
||||
<section class="timeline-day">
|
||||
<header class="timeline-header">
|
||||
<h2>{{ tl.date.strftime('%a %d %b %Y') }}{% if tl.is_today %} <span class="timeline-today-tag">Today</span>{% endif %}</h2>
|
||||
<div class="timeline-legend">
|
||||
<span class="legend-item"><span class="swatch swatch-completed"></span>Completed</span>
|
||||
<span class="legend-item"><span class="swatch swatch-running"></span>Running</span>
|
||||
<span class="legend-item"><span class="swatch swatch-scheduled"></span>Scheduled</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="timeline-axis">
|
||||
{% for h in tl.hours %}
|
||||
<span class="tick" style="left: {{ (h / 24 * 100) }}%">
|
||||
<span class="tick-label">{{ '%02d' % h }}</span>
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="timeline-track" style="--lane-count: {{ tl.lane_count }}">
|
||||
{% for h in tl.hours %}
|
||||
<span class="gridline" style="left: {{ (h / 24 * 100) }}%"></span>
|
||||
{% endfor %}
|
||||
|
||||
{% if tl.now_pct is not none %}
|
||||
<span class="now-marker" style="left: {{ tl.now_pct }}%" title="Now"></span>
|
||||
{% endif %}
|
||||
|
||||
{% if tl.entries | length == 0 %}
|
||||
<div class="timeline-empty">No jobs</div>
|
||||
{% else %}
|
||||
{% for e in tl.entries %}
|
||||
<a class="job-bar job-bar-{{ e.kind }}"
|
||||
href="/jobs/{{ e.id }}"
|
||||
style="left: {{ e.left }}%; width: {{ e.width }}%; --lane: {{ e.lane }}"
|
||||
title="{{ e.name }} — {{ e.kind }}{% if e.start %} | start {{ e.start }}{% endif %}{% if e.finish %} | finish {{ e.finish }}{% endif %}{% if e.due and not e.start %} | due {{ e.due }}{% endif %}">
|
||||
<span class="job-bar-label">{{ e.name }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{# ── Metrics mini-reports ─────────────────────────────── #}
|
||||
{% set m = metrics %}
|
||||
<div class="metrics-grid">
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Job Outcomes</h3>
|
||||
<table class="metric-table">
|
||||
<thead>
|
||||
<tr><th></th><th>✓ Done</th><th>✗ Failed</th><th>Running</th><th>Pending</th><th>Success</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Today</th>
|
||||
<td class="num good">{{ m.jobs.today.completed }}</td>
|
||||
<td class="num bad">{{ m.jobs.today.failed }}</td>
|
||||
<td class="num warn">{{ m.jobs.today.running }}</td>
|
||||
<td class="num">{{ m.jobs.today.created }}</td>
|
||||
<td class="num">{% if m.jobs.success_rate_today is not none %}{{ '%.0f' % m.jobs.success_rate_today }}%{% else %}—{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Yesterday</th>
|
||||
<td class="num good">{{ m.jobs.yesterday.completed }}</td>
|
||||
<td class="num bad">{{ m.jobs.yesterday.failed }}</td>
|
||||
<td class="num">{{ m.jobs.yesterday.running }}</td>
|
||||
<td class="num">{{ m.jobs.yesterday.created }}</td>
|
||||
<td class="num">{% if m.jobs.success_rate_yesterday is not none %}{{ '%.0f' % m.jobs.success_rate_yesterday }}%{% else %}—{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Last 7 days</th>
|
||||
<td class="num good">{{ m.jobs.week.completed }}</td>
|
||||
<td class="num bad">{{ m.jobs.week.failed }}</td>
|
||||
<td class="num">{{ m.jobs.week.running }}</td>
|
||||
<td class="num">{{ m.jobs.week.created }}</td>
|
||||
<td class="num">{% if m.jobs.success_rate_week is not none %}{{ '%.0f' % m.jobs.success_rate_week }}%{% else %}—{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>All time</th>
|
||||
<td class="num good">{{ m.jobs.total.completed }}</td>
|
||||
<td class="num bad">{{ m.jobs.total.failed }}</td>
|
||||
<td class="num">{{ m.jobs.total.running }}</td>
|
||||
<td class="num">{{ m.jobs.total.created }}</td>
|
||||
<td class="num">{% if m.jobs.success_rate_total is not none %}{{ '%.0f' % m.jobs.success_rate_total }}%{% else %}—{% endif %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Active Configs</h3>
|
||||
<div class="big-stat">
|
||||
<span class="big-stat-value">{{ m.configs.active }}</span>
|
||||
<span class="big-stat-sub">of {{ m.configs.total }} total</span>
|
||||
</div>
|
||||
<ul class="kv-list">
|
||||
{% for freq, n in m.configs.by_frequency %}
|
||||
<li><span>{{ freq }}</span><span class="num">{{ n }}</span></li>
|
||||
{% endfor %}
|
||||
<li class="muted"><span>Drafts</span><span class="num">{{ m.configs.draft }}</span></li>
|
||||
{% if m.configs.archived %}
|
||||
<li class="muted"><span>Archived</span><span class="num">{{ m.configs.archived }}</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Performance — Today</h3>
|
||||
<ul class="kv-list">
|
||||
<li><span>Avg duration</span><span class="num">{{ m.performance.avg_duration_today or '—' }}</span></li>
|
||||
<li><span>Longest run</span>
|
||||
<span class="num" title="{{ m.performance.longest_today_name or '' }}">
|
||||
{{ m.performance.longest_today_duration or '—' }}
|
||||
</span>
|
||||
</li>
|
||||
{% if m.performance.longest_today_name %}
|
||||
<li class="muted"><span>↳ {{ m.performance.longest_today_name }}</span><span></span></li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<span>On-time start</span>
|
||||
<span class="num">
|
||||
{% if m.performance.on_time_rate_today is not none %}
|
||||
{{ '%.0f' % m.performance.on_time_rate_today }}%
|
||||
<span class="muted">({{ m.performance.on_time }}/{{ m.performance.on_time + m.performance.late }})</span>
|
||||
{% else %}—{% endif %}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Match Quality</h3>
|
||||
<ul class="kv-list">
|
||||
<li><span>Matched (today)</span><span class="num good">{{ '{:,}'.format(m.match_quality.matched_today) }}</span></li>
|
||||
<li><span>Unmatched (today)</span><span class="num bad">{{ '{:,}'.format(m.match_quality.unmatched_today) }}</span></li>
|
||||
<li><span>Match rate (today)</span>
|
||||
<span class="num">{% if m.match_quality.match_rate_today is not none %}{{ '%.1f' % m.match_quality.match_rate_today }}%{% else %}—{% endif %}</span>
|
||||
</li>
|
||||
<li class="muted"><span>Match rate (7d)</span>
|
||||
<span class="num">{% if m.match_quality.match_rate_week is not none %}{{ '%.1f' % m.match_quality.match_rate_week }}%{% else %}—{% endif %}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Recent Failures</h3>
|
||||
{% if m.recent_failures %}
|
||||
<ul class="kv-list">
|
||||
{% for f in m.recent_failures %}
|
||||
<li>
|
||||
<a class="row-link" href="/jobs/{{ f.id }}">
|
||||
<span><strong>{{ f.name }}</strong><br><span class="muted">{{ f.when }} · {{ f.reason }}</span></span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="empty-note good">No recent failures 🎉</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Upcoming Today</h3>
|
||||
{% if m.upcoming_today %}
|
||||
<ul class="kv-list">
|
||||
{% for u in m.upcoming_today %}
|
||||
<li>
|
||||
<a class="row-link" href="/jobs/{{ u.id }}">
|
||||
<span>{{ u.name }}</span><span class="num">{{ u.due }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="empty-note muted">Nothing scheduled for the rest of today.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
{% 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 dashboard-stack">
|
||||
|
||||
<div class="detail-header">
|
||||
<div class="detail-crumbs">
|
||||
<a href="/">Dashboard</a> ›
|
||||
<a href="/results">Results</a> ›
|
||||
<span class="muted">Job #{{ job.id }}</span>
|
||||
</div>
|
||||
<h1>
|
||||
{{ job.name }}
|
||||
<span class="badge badge-status-{{ job.status }}">{{ job.status }}</span>
|
||||
</h1>
|
||||
<div class="detail-subtitle muted">
|
||||
As-at {{ job.as_at_date.isoformat() }}
|
||||
· config <code>{{ job.recon_config_reference }}</code>
|
||||
· ran by {{ job.username }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── Execution history timeline ─────────────────────── #}
|
||||
<section class="timeline-day history-timeline">
|
||||
<header class="timeline-header">
|
||||
<h2>Execution history</h2>
|
||||
<div class="timeline-legend">
|
||||
<span class="legend-item"><span class="swatch swatch-completed"></span>Completed</span>
|
||||
<span class="legend-item"><span class="swatch swatch-failed"></span>Failed</span>
|
||||
<span class="legend-item"><span class="swatch swatch-running"></span>Running</span>
|
||||
<span class="legend-item"><span class="swatch swatch-scheduled"></span>Scheduled</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{% if history.entries | length == 0 %}
|
||||
<p class="empty-note muted">No executions on record.</p>
|
||||
{% else %}
|
||||
<div class="timeline-axis">
|
||||
{% for t in history.ticks %}
|
||||
<span class="tick" style="left: {{ t.left }}%">
|
||||
<span class="tick-label">{{ t.label }}</span>
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="history-track">
|
||||
{% for t in history.ticks %}
|
||||
<span class="gridline" style="left: {{ t.left }}%"></span>
|
||||
{% endfor %}
|
||||
{% for e in history.entries %}
|
||||
<a class="history-dot history-dot-{{ e.kind }}{% if e.id == job.id %} is-current{% endif %}"
|
||||
href="/jobs/{{ e.id }}"
|
||||
style="left: {{ e.left }}%"
|
||||
title="{{ e.name }} · {{ e.as_at }}{% if e.when %} · {{ e.when }}{% endif %} · {{ e.status }}">
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="history-footnote muted">
|
||||
{{ history.entries | length }} executions
|
||||
from {{ history.first_date.isoformat() }} to {{ history.last_date.isoformat() }}
|
||||
({{ history.days }} days)
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
{# ── Attribute / result cards ───────────────────────── #}
|
||||
<div class="metrics-grid">
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Identification</h3>
|
||||
<ul class="kv-list">
|
||||
<li><span>Job ID</span><span class="num">#{{ job.id }}</span></li>
|
||||
<li><span>Name</span><span>{{ job.name }}</span></li>
|
||||
<li><span>Config ref</span><span><code>{{ job.recon_config_reference }}</code></span></li>
|
||||
<li><span>Username</span><span>{{ job.username }}</span></li>
|
||||
<li><span>As-at date</span><span>{{ job.as_at_date.isoformat() }}</span></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Schedule & Timing</h3>
|
||||
<ul class="kv-list">
|
||||
<li><span>Due</span><span>{{ job.due_datetime.isoformat(timespec='minutes') if job.due_datetime else '—' }}</span></li>
|
||||
<li><span>Started</span><span>{{ job.start_datetime.isoformat(timespec='minutes') if job.start_datetime else '—' }}</span></li>
|
||||
<li><span>Finished</span><span>{{ job.finish_datetime.isoformat(timespec='minutes') if job.finish_datetime else '—' }}</span></li>
|
||||
<li><span>Duration</span><span class="num">{{ duration_str or '—' }}</span></li>
|
||||
<li><span>Lateness</span><span>{{ lateness_str or '—' }}</span></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Status</h3>
|
||||
<div class="big-stat">
|
||||
<span class="big-stat-value badge badge-status-{{ job.status }}">{{ job.status }}</span>
|
||||
</div>
|
||||
{% if job.status_reason %}
|
||||
<p class="empty-note muted">Reason: {{ job.status_reason }}</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>Config</h3>
|
||||
{% if config %}
|
||||
<ul class="kv-list">
|
||||
<li><span>Name</span><span>{{ config.name }}</span></li>
|
||||
<li><span>Reference</span><span><code>{{ config.reference }}</code></span></li>
|
||||
<li><span>Status</span><span>{{ config.status }}</span></li>
|
||||
<li><span>Frequency</span><span>{{ config.frequency }}</span></li>
|
||||
<li><span>Business process</span><span>{{ config.business_process }}</span></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="empty-note muted">Config <code>{{ job.recon_config_reference }}</code> not found.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="metric-card">
|
||||
<h3>History — this recon</h3>
|
||||
<ul class="kv-list">
|
||||
<li><span>Total executions</span><span class="num">{{ stats.total }}</span></li>
|
||||
<li><span>Completed</span><span class="num good">{{ stats.completed }}</span></li>
|
||||
<li><span>Failed</span><span class="num bad">{{ stats.failed }}</span></li>
|
||||
<li><span>Success rate</span>
|
||||
<span class="num">
|
||||
{% if stats.success_rate is not none %}{{ '%.0f' % stats.success_rate }}%{% else %}—{% endif %}
|
||||
</span>
|
||||
</li>
|
||||
<li><span>Avg duration</span><span class="num">{{ stats.avg_duration or '—' }}</span></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
{% if job.results %}
|
||||
<section class="metric-card metric-card-wide">
|
||||
<h3>Results</h3>
|
||||
<table class="metric-table results-table">
|
||||
<tbody>
|
||||
{% for k, v in job.results.items() %}
|
||||
<tr>
|
||||
<th>{{ k }}</th>
|
||||
<td>
|
||||
{% if k == 'Status' %}
|
||||
<span class="badge badge-{{ v | lower }}">{{ v }}</span>
|
||||
{% elif k == 'Flag' %}
|
||||
<span class="badge badge-{{ 'none' if v == 'None' else 'flag' }}">{{ v }}</span>
|
||||
{% else %}
|
||||
{{ render_nested(v) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{% else %}
|
||||
<section class="metric-card">
|
||||
<h3>Results</h3>
|
||||
<p class="empty-note muted">
|
||||
{% if job.status in ('created', 'running') %}
|
||||
This job has not produced results yet.
|
||||
{% else %}
|
||||
No results recorded for this run.
|
||||
{% endif %}
|
||||
</p>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -55,20 +55,24 @@
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% if results | length > 0 %}
|
||||
{% if result_rows | length > 0 %}
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for key in results[0].keys() %}
|
||||
<th>Job</th>
|
||||
{% for key in result_rows[0].data.keys() %}
|
||||
<th>{{ key }}</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in results %}
|
||||
{% for row in result_rows %}
|
||||
<tr>
|
||||
{% for key, value in row.items() %}
|
||||
<td>
|
||||
<a class="job-link" href="/jobs/{{ row.job_id }}">{{ row.name }}<span class="muted"> #{{ row.job_id }}</span></a>
|
||||
</td>
|
||||
{% for key, value in row.data.items() %}
|
||||
<td>
|
||||
{% if key == 'Status' %}
|
||||
<span class="badge badge-{{ value | lower }}">{{ value }}</span>
|
||||
|
||||
Reference in New Issue
Block a user