mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 23:24:46 +02:00
Scope power buttons to current server (#849)
* Scope setServerState to current server * Use match statement * Reset this
This commit is contained in:
parent
00ae3b8b61
commit
3a7ddfca5e
@ -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()),
|
||||
];
|
||||
}
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user