diff --git a/app/Filament/Server/Pages/Console.php b/app/Filament/Server/Pages/Console.php index b067cfc1c..d6b15bce3 100644 --- a/app/Filament/Server/Pages/Console.php +++ b/app/Filament/Server/Pages/Console.php @@ -75,17 +75,17 @@ class Console extends Page Action::make('start') ->color('primary') ->size(ActionSize::ExtraLarge) - ->action(fn () => $this->dispatch('setServerState', state: 'start')) + ->action(fn () => $this->dispatch('setServerState', state: 'start', uuid: $server->uuid)) ->disabled(fn () => $server->isInConflictState() || !$this->status->isStartable()), Action::make('restart') ->color('gray') ->size(ActionSize::ExtraLarge) - ->action(fn () => $this->dispatch('setServerState', state: 'restart')) + ->action(fn () => $this->dispatch('setServerState', state: 'restart', uuid: $server->uuid)) ->disabled(fn () => $server->isInConflictState() || !$this->status->isRestartable()), Action::make('stop') ->color('danger') ->size(ActionSize::ExtraLarge) - ->action(fn () => $this->dispatch('setServerState', state: 'stop')) + ->action(fn () => $this->dispatch('setServerState', state: 'stop', uuid: $server->uuid)) ->hidden(fn () => $this->status->isStartingOrStopping() || $this->status->isKillable()) ->disabled(fn () => $server->isInConflictState() || !$this->status->isStoppable()), Action::make('kill') @@ -95,7 +95,7 @@ class Console extends Page ->modalDescription('This can result in data corruption and/or data loss!') ->modalSubmitActionLabel('Kill Server') ->size(ActionSize::ExtraLarge) - ->action(fn () => $this->dispatch('setServerState', state: 'kill')) + ->action(fn () => $this->dispatch('setServerState', state: 'kill', uuid: $server->uuid)) ->hidden(fn () => $server->isInConflictState() || !$this->status->isKillable()), ]; } diff --git a/resources/views/filament/components/server-console.blade.php b/resources/views/filament/components/server-console.blade.php index 05806114d..a28b960c4 100644 --- a/resources/views/filament/components/server-console.blade.php +++ b/resources/views/filament/components/server-console.blade.php @@ -167,14 +167,19 @@ })); }; - Livewire.on('setServerState', ({ state }) => { + Livewire.on('setServerState', ({ state, uuid }) => { + const serverUuid = "{{ $this->server->uuid }}"; + if (uuid !== serverUuid) { + return; + } + socket.send(JSON.stringify({ 'event': 'set state', 'args': [state] })); }); - $wire.$on('sendServerCommand', ({ command }) => { + $wire.on('sendServerCommand', ({ command }) => { socket.send(JSON.stringify({ 'event': 'send command', 'args': [command]