Files
ShooterHub/templates/analyses/detail.html
2026-03-19 16:42:37 +01:00

94 lines
4.0 KiB
HTML

{% extends "base.html" %}
{% block title %}{{ analysis.title }} — The Shooter's Network{% endblock %}
{% block content %}
<div style="display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:1rem;margin-bottom:1.5rem;">
<div>
<div style="font-size:0.82rem;color:#888;margin-bottom:.3rem;">
{% if analysis.session_id %}
<a href="{{ url_for('sessions.detail', session_id=analysis.session_id) }}">{{ _('Session') }}</a> &rsaquo;
{% else %}
<a href="{{ url_for('dashboard.index') }}">{{ _('Dashboard') }}</a> &rsaquo;
{% endif %}
{{ _('Analysis') }}
</div>
<h1 style="margin:0;">{{ analysis.title }}</h1>
<div style="font-size:0.85rem;color:#888;margin-top:.3rem;">
{{ analysis.created_at.strftime('%d %b %Y') }}
&nbsp;&middot;&nbsp; {{ analysis.shot_count }} {{ _('shot(s)') }}
&nbsp;&middot;&nbsp; {{ analysis.group_count }} {{ _('group(s)') }}
</div>
</div>
<div style="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;">
{% if has_pdf %}
<a href="{{ url_for('analyses.download_pdf', analysis_id=analysis.id) }}"
style="background:#1f77b4;color:#fff;border-radius:4px;padding:0.5rem 1.1rem;font-size:0.9rem;text-decoration:none;">
&#8659; {{ _('Download PDF report') }}
</a>
{% endif %}
{% if current_user.is_authenticated and current_user.id == analysis.user_id %}
<form method="post" action="{{ url_for('analyses.delete', analysis_id=analysis.id) }}"
onsubmit="return confirm('{{ _('Delete this analysis? The CSV and PDF will be permanently removed.') | e }}');">
<button type="submit"
style="background:#fff0f0;color:#c0392b;border:1px solid #f5c6c6;border-radius:4px;padding:0.5rem 1.1rem;font-size:0.9rem;cursor:pointer;">
{{ _('Delete') }}
</button>
</form>
{% endif %}
<a href="{{ url_for('analyze') }}" style="font-size:0.9rem;color:#666;">&#8592; {{ _('New analysis') }}</a>
</div>
</div>
<h2>{{ _('Overall Statistics') }}</h2>
<table style="max-width:480px;">
<thead>
<tr><th>{{ _('Metric') }}</th><th>{{ _('Value') }}</th></tr>
</thead>
<tbody>
<tr><td>{{ _('Total shots') }}</td><td>{{ overall.count }}</td></tr>
<tr><td>{{ _('Min speed') }}</td><td>{{ "%.4f"|format(overall.min_speed) }}</td></tr>
<tr><td>{{ _('Max speed') }}</td><td>{{ "%.4f"|format(overall.max_speed) }}</td></tr>
<tr><td>{{ _('Mean speed') }}</td><td>{{ "%.4f"|format(overall.mean_speed) }}</td></tr>
<tr>
<td>{{ _('Std dev (speed)') }}</td>
<td>
{% if overall.std_speed is not none %}{{ "%.4f"|format(overall.std_speed) }}{% else %}&ndash;{% endif %}
</td>
</tr>
</tbody>
</table>
<img class="chart-img" src="data:image/png;base64,{{ overview_chart }}"
alt="Avg speed and std dev per group" style="max-width:600px;margin:1rem 0 1.5rem;">
<h2>{{ _('Groups') }} &mdash; {{ groups_display|length }} {{ _('group(s) detected') }}</h2>
{% for stat, chart_b64 in groups_display %}
<div class="group-section">
<h3>{{ _('Group %(n)s', n=stat.group_index) }}</h3>
<div class="group-meta">
{{ stat.time_start }} &ndash; {{ stat.time_end }} &nbsp;|&nbsp; {{ stat.count }} {{ _('shot(s)') }}
</div>
<table style="max-width:480px;">
<thead>
<tr><th>{{ _('Metric') }}</th><th>{{ _('Value') }}</th></tr>
</thead>
<tbody>
<tr><td>{{ _('Min speed') }}</td><td>{{ "%.4f"|format(stat.min_speed) }}</td></tr>
<tr><td>{{ _('Max speed') }}</td><td>{{ "%.4f"|format(stat.max_speed) }}</td></tr>
<tr><td>{{ _('Mean speed') }}</td><td>{{ "%.4f"|format(stat.mean_speed) }}</td></tr>
<tr>
<td>{{ _('Std dev (speed)') }}</td>
<td>
{% if stat.std_speed is not none %}{{ "%.4f"|format(stat.std_speed) }}{% else %}&ndash;{% endif %}
</td>
</tr>
</tbody>
</table>
<img class="chart-img" src="data:image/png;base64,{{ chart_b64 }}"
alt="Speed chart for group {{ stat.group_index }}">
</div>
{% endfor %}
{% endblock %}