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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user