Enhance terminal connection handling in execute-container-command view

This commit is contained in:
Andras Bacsai
2025-06-14 12:42:14 +02:00
parent b70a9a6d47
commit 15472aa0b7

View File

@@ -33,11 +33,32 @@
</div> </div>
</div> </div>
</div> </div>
@endif
@if ($type === 'server')
@if ($server->isTerminalEnabled())
<form class="w-full flex gap-2 items-start justify-start" wire:submit="$dispatchSelf('connectToServer')">
<h2 class="pb-4">Terminal</h2>
<x-forms.button type="submit" :disabled="$isConnecting">
Reconnect
</x-forms.button>
{{-- Loading indicator for all connection states --}}
@if (!$containersLoaded || $isConnecting || $connectionStatus)
<span class="text-sm">{{ $connectionStatus }}</span>
@endif
</form>
<div class="mx-auto w-full">
<livewire:project.shared.terminal wire:key="terminal-{{ $this->getId() }}-server" />
</div>
@else
<div>Terminal access is disabled on this server.</div>
@endif
@else @else
@if ($type === 'server') @if (count($containers) === 0)
@if ($server->isTerminalEnabled()) <div class="pt-4">No containers are running on this server or terminal access is disabled.</div>
<form class="w-full flex gap-2 items-start justify-start" @else
wire:submit="$dispatchSelf('connectToServer')"> @if (count($containers) === 1)
<form class="w-full flex gap-2 items-start justify-start pt-4"
wire:submit="$dispatchSelf('connectToContainer')">
<h2 class="pb-4">Terminal</h2> <h2 class="pb-4">Terminal</h2>
<x-forms.button type="submit" :disabled="$isConnecting"> <x-forms.button type="submit" :disabled="$isConnecting">
Reconnect Reconnect
@@ -48,57 +69,32 @@
@if (!$containersLoaded || $isConnecting || $connectionStatus) @if (!$containersLoaded || $isConnecting || $connectionStatus)
<span class="text-sm">{{ $connectionStatus }}</span> <span class="text-sm">{{ $connectionStatus }}</span>
@endif @endif
<div class="mx-auto w-full">
<livewire:project.shared.terminal wire:key="terminal-{{ $this->getId() }}-server" />
</div>
@else @else
<div>Terminal access is disabled on this server.</div> <form class="w-full pt-4 flex gap-2 flex-col" wire:submit="$dispatchSelf('connectToContainer')">
@endif <x-forms.select label="Container" id="container" required wire:model="selected_container">
@else @foreach ($containers as $container)
@if (count($containers) === 0) @if ($loop->first)
<div class="pt-4">No containers are running on this server or terminal access is disabled.</div> <option disabled value="default">Select a container</option>
@else @endif
@if (count($containers) === 1) <option value="{{ data_get($container, 'container.Names') }}">
<form class="w-full flex gap-2 items-start justify-start pt-4" {{ data_get($container, 'container.Names') }}
wire:submit="$dispatchSelf('connectToContainer')"> ({{ data_get($container, 'server.name') }})
<h2 class="pb-4">Terminal</h2> </option>
<x-forms.button type="submit" :disabled="$isConnecting"> @endforeach
Reconnect </x-forms.select>
</x-forms.button> <x-forms.button class="w-full" type="submit" :disabled="$isConnecting">
</form> {{ $isConnecting ? 'Connecting...' : 'Connect' }}
</x-forms.button>
</form>
{{-- Loading indicator for all connection states --}} {{-- Loading indicator for manual connection --}}
@if (!$containersLoaded || $isConnecting || $connectionStatus) @if ($isConnecting || $connectionStatus)
<span class="text-sm">{{ $connectionStatus }}</span> <span class="text-sm">{{ $connectionStatus }}</span>
@endif
@else
<form class="w-full pt-4 flex gap-2 flex-col" wire:submit="$dispatchSelf('connectToContainer')">
<x-forms.select label="Container" id="container" required wire:model="selected_container">
@foreach ($containers as $container)
@if ($loop->first)
<option disabled value="default">Select a container</option>
@endif
<option value="{{ data_get($container, 'container.Names') }}">
{{ data_get($container, 'container.Names') }}
({{ data_get($container, 'server.name') }})
</option>
@endforeach
</x-forms.select>
<x-forms.button class="w-full" type="submit" :disabled="$isConnecting">
{{ $isConnecting ? 'Connecting...' : 'Connect' }}
</x-forms.button>
</form>
{{-- Loading indicator for manual connection --}}
@if ($isConnecting || $connectionStatus)
<span class="text-sm">{{ $connectionStatus }}</span>
@endif
@endif @endif
<div class="mx-auto w-full">
<livewire:project.shared.terminal />
</div>
@endif @endif
<div class="mx-auto w-full">
<livewire:project.shared.terminal />
</div>
@endif @endif
@endif @endif