Files
laurent 30e4b3e144 feat: dashboard web FastAPI Sprint 4
Ajout d'un dashboard lecture seule par-dessus la DB SQLite existante.

Fichiers créés :
  - tickettracker/web/queries.py   : 7 fonctions SQL (stats, compare, historique...)
  - tickettracker/web/api.py       : router /api/* JSON (FastAPI)
  - tickettracker/web/app.py       : routes HTML + Jinja2 + point d'entrée uvicorn
  - tickettracker/web/templates/   : base.html, index.html, compare.html, product.html, receipt.html
  - tickettracker/web/static/style.css : personnalisations Pico CSS
  - tests/test_web.py              : 19 tests (96 passent, 1 xfail OCR)

Fichiers modifiés :
  - requirements.txt : +fastapi, uvicorn[standard], jinja2, python-multipart, httpx
  - config.py        : +DB_PATH (lu depuis TICKETTRACKER_DB_PATH)

Lancement : python -m tickettracker.web.app

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 20:04:55 +01:00

105 lines
2.7 KiB
HTML

{% extends "base.html" %}
{% block title %}Accueil — TicketTracker{% endblock %}
{% block content %}
<h1>Tableau de bord</h1>
{% if empty %}
<article>
<p>
Aucun ticket importé. Utilisez la CLI pour importer vos tickets :
</p>
<pre><code>python -m tickettracker.cli import chemin/vers/ticket.html # Picnic
python -m tickettracker.cli import chemin/vers/ticket.pdf # Leclerc</code></pre>
</article>
{% else %}
<!-- Cartes de statistiques -->
<div class="stat-grid">
<article class="stat-card">
<h3>{{ stats.total_receipts }}</h3>
<p>Tickets importés</p>
</article>
<article class="stat-card">
<h3>{{ "%.2f"|format(stats.total_spent) }} €</h3>
<p>Total dépensé</p>
</article>
<article class="stat-card">
<h3>{{ stats.distinct_products }}</h3>
<p>Produits distincts</p>
</article>
<article class="stat-card">
<h3>{{ stats.total_items }}</h3>
<p>Articles scannés</p>
</article>
</div>
<!-- Graphique dépenses par mois -->
<article>
<h2>Dépenses par mois</h2>
<div class="chart-container">
<canvas id="monthlyChart"></canvas>
</div>
</article>
<script>
(function () {
const data = {{ chart_data | tojson }};
const ctx = document.getElementById("monthlyChart").getContext("2d");
new Chart(ctx, {
type: "bar",
data: data,
options: {
responsive: true,
plugins: {
legend: { position: "top" }
},
scales: {
x: { stacked: true },
y: {
stacked: true,
ticks: {
callback: function(value) { return value + " €"; }
}
}
}
}
});
})();
</script>
<!-- Tableau des derniers tickets -->
<article>
<h2>Derniers tickets</h2>
<div class="overflow-auto">
<table>
<thead>
<tr>
<th>#</th>
<th>Enseigne</th>
<th>Date</th>
<th>Total</th>
<th>Articles</th>
<th></th>
</tr>
</thead>
<tbody>
{% for r in receipts %}
<tr>
<td>{{ r.id }}</td>
<td>{{ r.store }}</td>
<td>{{ r.date }}</td>
<td>{{ "%.2f"|format(r.total) }} €</td>
<td>{{ r.nb_items }}</td>
<td><a href="/receipt/{{ r.id }}">Voir</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</article>
{% endif %}
{% endblock %}