This commit is contained in:
Stefanescu Mihai
2026-03-18 13:32:36 +02:00
parent 6ad100d331
commit 274f6a378e
22 changed files with 1217 additions and 42 deletions
@@ -0,0 +1,73 @@
<x-report-layout :website="$website" :from="$from" :to="$to" :title="'Event: ' . $eventName">
<div class="space-y-6">
{{-- Trending Chart --}}
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
<h3 class="text-base font-semibold text-gray-900 mb-4">Trend</h3>
<div style="height: 240px;">
<canvas id="event-trend-chart"></canvas>
</div>
</div>
{{-- Detail Table --}}
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
@if ($details->isEmpty())
<div class="px-6 py-12 text-center text-sm text-gray-500">No detail breakdown available.</div>
@else
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Label</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Count</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Total Value</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@foreach ($details as $row)
<tr>
<td class="px-6 py-3 text-sm text-gray-900">{{ $row->action ?? '—' }}</td>
<td class="px-6 py-3 text-sm text-gray-500">{{ $row->label ?? '—' }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ number_format($row->total) }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ $row->total_value ? number_format($row->total_value, 2) : '—' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
<x-slot name="scripts">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const raw = @json($trending);
new Chart(document.getElementById('event-trend-chart'), {
type: 'bar',
data: {
labels: raw.map(d => d.period),
datasets: [{
label: '{{ $eventName }}',
data: raw.map(d => d.total),
backgroundColor: 'rgba(99, 102, 241, 0.7)',
borderRadius: 4,
}],
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: {
x: { grid: { display: false }, ticks: { maxTicksLimit: 12, font: { size: 11 }, color: '#9ca3af' } },
y: { beginAtZero: true, grid: { color: 'rgba(0,0,0,0.04)' }, ticks: { precision: 0, font: { size: 11 }, color: '#9ca3af' } },
},
},
});
});
</script>
</x-slot>
</x-report-layout>
@@ -0,0 +1,38 @@
<x-report-layout :website="$website" :from="$from" :to="$to" title="Events Overview">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
@if ($events->isEmpty())
<div class="px-6 py-12 text-center text-sm text-gray-500">No events tracked for this period.</div>
@else
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Event Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Total</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Unique Visitors</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Total Value</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@foreach ($events as $row)
<tr>
<td class="px-6 py-3 text-sm text-gray-900 font-medium">{{ $row->name }}</td>
<td class="px-6 py-3 text-sm text-gray-500">{{ $row->category ?? '—' }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ number_format($row->total) }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ number_format($row->unique_visitors) }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ $row->total_value ? number_format($row->total_value, 2) : '—' }}</td>
<td class="px-6 py-3 text-sm text-right">
<a href="{{ route('reports.event-detail', [$website, $row->name] + request()->only(['range', 'from', 'to'])) }}" class="text-indigo-600 hover:text-indigo-800">Details</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</x-report-layout>