2026-04-14 13:20:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Server\Sentinel;
|
|
|
|
|
|
2026-09-07 14:46:37 +00:00
|
|
|
use App\Actions\Server\StartSentinel;
|
2026-04-14 13:20:01 +00:00
|
|
|
use App\Models\Server;
|
2026-06-15 10:31:30 +00:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2026-06-03 09:10:13 +00:00
|
|
|
use Illuminate\View\View;
|
2026-04-14 13:20:01 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Logs extends Component
|
|
|
|
|
{
|
2026-06-15 10:31:30 +00:00
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
2026-04-14 13:20:01 +00:00
|
|
|
public ?Server $server = null;
|
|
|
|
|
|
2026-06-03 09:10:13 +00:00
|
|
|
public array $parameters = [];
|
2026-04-14 13:20:01 +00:00
|
|
|
|
2026-06-03 09:10:13 +00:00
|
|
|
public function mount(): void
|
2026-04-14 13:20:01 +00:00
|
|
|
{
|
|
|
|
|
$this->parameters = get_route_parameters();
|
|
|
|
|
try {
|
2026-06-03 09:10:13 +00:00
|
|
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail();
|
2026-04-14 13:20:01 +00:00
|
|
|
} catch (\Throwable $e) {
|
2026-06-03 09:10:13 +00:00
|
|
|
handleError($e, $this);
|
2026-06-15 10:31:30 +00:00
|
|
|
|
|
|
|
|
return;
|
2026-04-14 13:20:01 +00:00
|
|
|
}
|
2026-06-15 10:31:30 +00:00
|
|
|
|
|
|
|
|
$this->authorize('viewSentinel', $this->server);
|
2026-04-14 13:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
2026-09-07 14:46:37 +00:00
|
|
|
public function enableSentinel(): void
|
|
|
|
|
{
|
|
|
|
|
$this->authorize('manageSentinel', $this->server);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$this->server->refresh();
|
|
|
|
|
if ($this->server->isBuildServer()) {
|
|
|
|
|
$this->dispatch('error', 'Sentinel cannot be enabled on build servers.');
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($this->server->isSwarm()) {
|
|
|
|
|
$this->dispatch('error', 'Sentinel cannot be enabled on Swarm servers.');
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($this->server->isSentinelEnabled()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StartSentinel::run($this->server, true);
|
|
|
|
|
$this->server->refresh();
|
|
|
|
|
$this->dispatch('refreshServerShow');
|
|
|
|
|
$this->dispatch('success', 'Sentinel has been enabled.');
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
handleError($e, $this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-03 09:10:13 +00:00
|
|
|
public function render(): View
|
2026-04-14 13:20:01 +00:00
|
|
|
{
|
|
|
|
|
return view('livewire.server.sentinel.logs');
|
|
|
|
|
}
|
|
|
|
|
}
|