Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: terminal view loading in async

Andras Bacsaib58cc05b8aea
diff --git a/app/Livewire/Terminal/Index.php b/app/Livewire/Terminal/Index.php
index 945b25714e..a24a237c58 100644
--- a/app/Livewire/Terminal/Index.php
+++ b/app/Livewire/Terminal/Index.php
@@ -14,13 +14,25 @@ class Index extends Component
public $containers = [];
+ public bool $isLoadingContainers = true;
+
public function mount()
{
if (! auth()->user()->isAdmin()) {
abort(403);
}
$this->servers = Server::isReachable()->get();
- $this->containers = $this->getAllActiveContainers();
+ }
+
+ public function loadContainers()
+ {
+ try {
+ $this->containers = $this->getAllActiveContainers();
+ } catch (\Exception $e) {
+ return handleError($e, $this);
+ } finally {
+ $this->isLoadingContainers = false;
+ }
}
private function getAllActiveContainers()
diff --git a/resources/views/livewire/terminal/index.blade.php b/resources/views/livewire/terminal/index.blade.php
index 3572950022..0471a44a40 100644
--- a/resources/views/livewire/terminal/index.blade.php
+++ b/resources/views/livewire/terminal/index.blade.php
@@ -8,27 +8,32 @@
<x-helper
helper="If you're having trouble connecting to your server, make sure that the port is open.<br><br><a class='underline' href='https://coolify.io/docs/knowledge-base/server/firewall/#terminal' target='_blank'>Documentation</a>"></x-helper>
</div>
- <div>
- <form class="flex flex-col gap-2 justify-center xl:items-end xl:flex-row"
- wire:submit="$dispatchSelf('connectToContainer')">
- <x-forms.select id="server" required wire:model.live="selected_uuid">
- @foreach ($servers as $server)
- @if ($loop->first)
- <option disabled value="default">Select a server or container</option>
- @endif
- <option value="{{ $server->uuid }}">{{ $server->name }}</option>
- @foreach ($containers as $container)
- @if ($container['server_uuid'] == $server->uuid)
- <option value="{{ $container['uuid'] }}">
- {{ $server->name }} -> {{ $container['name'] }}
- </option>
+ <div x-init="$wire.loadContainers()">
+ @if ($isLoadingContainers)
+ <div class="pt-1">
+ <x-loading text="Loading servers and containers..." />
+ </div>
+ @else
+ <form class="flex flex-col gap-2 justify-center xl:items-end xl:flex-row"
+ wire:submit="$dispatchSelf('connectToContainer')">
+ <x-forms.select id="server" required wire:model.live="selected_uuid">
+ @foreach ($servers as $server)
+ @if ($loop->first)
+ <option disabled value="default">Select a server or container</option>
@endif
+ <option value="{{ $server->uuid }}">{{ $server->name }}</option>
+ @foreach ($containers as $container)
+ @if ($container['server_uuid'] == $server->uuid)
+ <option value="{{ $container['uuid'] }}">
+ {{ $server->name }} -> {{ $container['name'] }}
+ </option>
+ @endif
+ @endforeach
@endforeach
- @endforeach
- </x-forms.select>
- <x-forms.button type="submit">Connect</x-forms.button>
- </form>
- <livewire:project.shared.terminal />
+ </x-forms.select>
+ <x-forms.button type="submit">Connect</x-forms.button>
+ </form>
+ <livewire:project.shared.terminal />
+ @endif
</div>
-
</div>