perf: make delete statistics modal open instantly

- Remove @entangle which caused server round-trip on modal open
- Pass statistic data inline via Alpine event dispatch instead of fetching from DB
- Add direct deleteStatistic(id) method for simpler deletion
- Modal now opens immediately without any server communication
This commit is contained in:
2025-12-06 07:38:19 -05:00
parent f8427d8773
commit 3508a032db
2 changed files with 68 additions and 43 deletions

View File

@@ -766,6 +766,34 @@ class Statistics extends Component
->paginate(50);
}
public function deleteStatistic($statisticId)
{
if (!$statisticId) {
return;
}
try {
$statistic = ServerStatistics::where('id', $statisticId)
->where('server_id', $this->server->id)
->first();
if (!$statistic) {
$this->notify('Statistics entry not found', 'error');
return;
}
// Clear selection if this is the selected statistic
if ($this->selectedStatisticId == $statisticId) {
$this->selectedStatisticId = null;
}
$statistic->delete();
$this->notify('Statistics entry deleted successfully', 'success');
} catch (\Throwable $e) {
$this->notify('Error deleting statistics: ' . $e->getMessage(), 'error');
}
}
public function confirmDeleteStatistic()
{
if (!$this->statisticToDeleteId) {