- Aggiunto sistema completo di build/deploy Docker, Makefile, compose, .env, workflow CI/CD (Gitea, GitHub Actions) - Nuovo servizio DatabaseService con migrations, healthcheck, backup, ottimizzazione, info - Endpoint /health per healthcheck container - Impostazioni avanzate di avvio aste (ricorda stato, auto-start, default nuove aste) - Nuovo tema grafico WPF: palette, sidebar, layout griglia, log colorati, badge, cards, modali, responsività - Migliorato calcolo valore prodotto, logica convenienza, blocco puntate non convenienti, log dettagliati - Semplificate e migliorate pagine FreeBids, Settings, Statistics; rimossa Browser.razor - Aggiornato .gitignore, documentazione, struttura progetto - Base solida per future funzionalità avanzate e deploy professionale
224 lines
8.4 KiB
Plaintext
224 lines
8.4 KiB
Plaintext
@page "/statistics"
|
|
@inject StatsService StatsService
|
|
@inject IJSRuntime JSRuntime
|
|
|
|
<PageTitle>Statistiche - AutoBidder</PageTitle>
|
|
|
|
<div class="statistics-container animate-fade-in p-4">
|
|
<div class="d-flex align-items-center justify-content-between mb-4 animate-fade-in-down">
|
|
<div class="d-flex align-items-center">
|
|
<i class="bi bi-bar-chart-fill text-primary me-3" style="font-size: 2.5rem;"></i>
|
|
<h2 class="mb-0 fw-bold">Statistiche Prodotti</h2>
|
|
</div>
|
|
<button class="btn btn-primary hover-lift" @onclick="RefreshStats" disabled="@isLoading">
|
|
@if (isLoading)
|
|
{
|
|
<span class="spinner-border spinner-border-sm me-2"></span>
|
|
}
|
|
else
|
|
{
|
|
<i class="bi bi-arrow-clockwise me-1"></i>
|
|
}
|
|
Aggiorna
|
|
</button>
|
|
</div>
|
|
|
|
@if (errorMessage != null)
|
|
{
|
|
<div class="alert alert-danger border-0 shadow-sm animate-shake mb-4">
|
|
<div class="d-flex align-items-center">
|
|
<i class="bi bi-exclamation-triangle-fill me-3" style="font-size: 2rem;"></i>
|
|
<div>
|
|
<h5 class="mb-1">Errore nel caricamento statistiche</h5>
|
|
<p class="mb-0">@errorMessage</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@if (stats != null && stats.Any())
|
|
{
|
|
<div class="card shadow-hover animate-fade-in-up delay-100">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover mb-0">
|
|
<thead>
|
|
<tr class="bg-primary text-white">
|
|
<th><i class="bi bi-box-seam me-2"></i>Prodotto</th>
|
|
<th><i class="bi bi-eye me-2"></i>Aste Viste</th>
|
|
<th><i class="bi bi-hand-index me-2"></i>Puntate Medie</th>
|
|
<th><i class="bi bi-currency-euro me-2"></i>Prezzo Medio</th>
|
|
<th><i class="bi bi-clock-history me-2"></i>Ultima Vista</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var stat in stats.OrderByDescending(s => s.LastSeen))
|
|
{
|
|
<tr class="transition-all">
|
|
<td class="fw-semibold">@stat.ProductName</td>
|
|
<td>
|
|
<span class="badge bg-info">@stat.TotalAuctions</span>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-secondary">@stat.AverageBidsUsed.ToString("F1")</span>
|
|
</td>
|
|
<td class="fw-bold text-success">
|
|
€@stat.AverageFinalPrice.ToString("F2")
|
|
</td>
|
|
<td class="text-muted">
|
|
<i class="bi bi-calendar3"></i> @stat.LastSeen.ToString("dd/MM/yyyy HH:mm")
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stats-summary mt-4 animate-fade-in-up delay-200">
|
|
<div class="row g-3">
|
|
<div class="col-md-4">
|
|
<div class="card border-0 shadow-sm text-center hover-lift">
|
|
<div class="card-body">
|
|
<i class="bi bi-bar-chart-line-fill text-primary" style="font-size: 2rem;"></i>
|
|
<h4 class="mt-3 mb-1 fw-bold">@stats.Count</h4>
|
|
<p class="text-muted mb-0">Prodotti Tracciati</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="card border-0 shadow-sm text-center hover-lift">
|
|
<div class="card-body">
|
|
<i class="bi bi-trophy-fill text-warning" style="font-size: 2rem;"></i>
|
|
<h4 class="mt-3 mb-1 fw-bold">@stats.Sum(s => s.TotalAuctions)</h4>
|
|
<p class="text-muted mb-0">Aste Totali</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="card border-0 shadow-sm text-center hover-lift">
|
|
<div class="card-body">
|
|
<i class="bi bi-currency-euro text-success" style="font-size: 2rem;"></i>
|
|
<h4 class="mt-3 mb-1 fw-bold">€@stats.Average(s => s.AverageFinalPrice).ToString("F2")</h4>
|
|
<p class="text-muted mb-0">Prezzo Medio</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
else if (!isLoading && errorMessage == null)
|
|
{
|
|
<div class="alert alert-info border-0 shadow-sm animate-scale-in">
|
|
<div class="d-flex align-items-center">
|
|
<i class="bi bi-info-circle-fill me-3" style="font-size: 2rem;"></i>
|
|
<div>
|
|
<h5 class="mb-1">Nessuna statistica disponibile</h5>
|
|
<p class="mb-0">Le statistiche verranno raccolte automaticamente durante il monitoraggio delle aste.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@if (isLoading)
|
|
{
|
|
<div class="text-center py-5">
|
|
<div class="spinner-border text-primary" style="width: 3rem; height: 3rem;" role="status">
|
|
<span class="visually-hidden">Caricamento...</span>
|
|
</div>
|
|
<p class="mt-3 text-muted">Caricamento statistiche...</p>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<style>
|
|
.statistics-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.stats-summary .card {
|
|
border-radius: 12px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.stats-summary .card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
|
|
}
|
|
|
|
.table thead {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 10;
|
|
}
|
|
|
|
@@keyframes shake {
|
|
0%, 100% { transform: translateX(0); }
|
|
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
|
|
20%, 40%, 60%, 80% { transform: translateX(5px); }
|
|
}
|
|
|
|
.animate-shake {
|
|
animation: shake 0.5s ease-in-out;
|
|
}
|
|
</style>
|
|
|
|
@code {
|
|
private List<ProductStat>? stats;
|
|
private string? errorMessage;
|
|
private bool isLoading = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
await RefreshStats();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errorMessage = $"Errore inizializzazione: {ex.Message}";
|
|
stats = new List<ProductStat>();
|
|
Console.WriteLine($"[ERROR] Statistics OnInitializedAsync: {ex}");
|
|
}
|
|
}
|
|
|
|
private async Task RefreshStats()
|
|
{
|
|
try
|
|
{
|
|
isLoading = true;
|
|
errorMessage = null;
|
|
StateHasChanged();
|
|
|
|
// Tentativo caricamento con timeout
|
|
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
|
stats = await StatsService.GetAllStatsAsync();
|
|
|
|
if (stats == null)
|
|
{
|
|
stats = new List<ProductStat>();
|
|
errorMessage = "Nessuna statistica disponibile. Il database potrebbe non essere inizializzato.";
|
|
}
|
|
}
|
|
catch (TaskCanceledException)
|
|
{
|
|
errorMessage = "Timeout durante caricamento statistiche. Riprova più tardi.";
|
|
stats = new List<ProductStat>();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errorMessage = $"Si è verificato un errore: {ex.Message}";
|
|
stats = new List<ProductStat>();
|
|
Console.WriteLine($"[ERROR] Statistics RefreshStats: {ex}");
|
|
Console.WriteLine($"[ERROR] Stack trace: {ex.StackTrace}");
|
|
}
|
|
finally
|
|
{
|
|
isLoading = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
}
|