mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 09:54:44 +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')
|
Action::make('start')
|
||||||
->color('primary')
|
->color('primary')
|
||||||
->size(ActionSize::ExtraLarge)
|
->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()),
|
->disabled(fn () => $server->isInConflictState() || !$this->status->isStartable()),
|
||||||
Action::make('restart')
|
Action::make('restart')
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->size(ActionSize::ExtraLarge)
|
->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()),
|
->disabled(fn () => $server->isInConflictState() || !$this->status->isRestartable()),
|
||||||
Action::make('stop')
|
Action::make('stop')
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->size(ActionSize::ExtraLarge)
|
->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())
|
->hidden(fn () => $this->status->isStartingOrStopping() || $this->status->isKillable())
|
||||||
->disabled(fn () => $server->isInConflictState() || !$this->status->isStoppable()),
|
->disabled(fn () => $server->isInConflictState() || !$this->status->isStoppable()),
|
||||||
Action::make('kill')
|
Action::make('kill')
|
||||||
@ -95,7 +95,7 @@ class Console extends Page
|
|||||||
->modalDescription('This can result in data corruption and/or data loss!')
|
->modalDescription('This can result in data corruption and/or data loss!')
|
||||||
->modalSubmitActionLabel('Kill Server')
|
->modalSubmitActionLabel('Kill Server')
|
||||||
->size(ActionSize::ExtraLarge)
|
->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()),
|
->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({
|
socket.send(JSON.stringify({
|
||||||
'event': 'set state',
|
'event': 'set state',
|
||||||
'args': [state]
|
'args': [state]
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
$wire.$on('sendServerCommand', ({ command }) => {
|
$wire.on('sendServerCommand', ({ command }) => {
|
||||||
socket.send(JSON.stringify({
|
socket.send(JSON.stringify({
|
||||||
'event': 'send command',
|
'event': 'send command',
|
||||||
'args': [command]
|
'args': [command]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user