chore: Refactor terminal component and select form layout
This commit is contained in:
@@ -11,6 +11,7 @@ class Terminal extends Component
|
|||||||
#[On('send-terminal-command')]
|
#[On('send-terminal-command')]
|
||||||
public function sendTerminalCommand($isContainer, $identifier, $serverUuid)
|
public function sendTerminalCommand($isContainer, $identifier, $serverUuid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$server = Server::ownedByCurrentTeam()->whereUuid($serverUuid)->firstOrFail();
|
$server = Server::ownedByCurrentTeam()->whereUuid($serverUuid)->firstOrFail();
|
||||||
|
|
||||||
// if (auth()->user()) {
|
// if (auth()->user()) {
|
||||||
@@ -21,9 +22,7 @@ class Terminal extends Component
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if ($isContainer) {
|
if ($isContainer) {
|
||||||
ray($identifier);
|
|
||||||
$status = getContainerStatus($server, $identifier);
|
$status = getContainerStatus($server, $identifier);
|
||||||
ray($status);
|
|
||||||
if ($status !== 'running') {
|
if ($status !== 'running') {
|
||||||
return handleError(new \Exception('Container is not running'), $this);
|
return handleError(new \Exception('Container is not running'), $this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Livewire\Component;
|
|||||||
|
|
||||||
class RunCommand extends Component
|
class RunCommand extends Component
|
||||||
{
|
{
|
||||||
public $selected_uuid;
|
public $selected_uuid = 'default';
|
||||||
|
|
||||||
public $servers = [];
|
public $servers = [];
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ class RunCommand extends Component
|
|||||||
public function mount($servers)
|
public function mount($servers)
|
||||||
{
|
{
|
||||||
$this->servers = $servers;
|
$this->servers = $servers;
|
||||||
$this->selected_uuid = $servers[0]->uuid;
|
|
||||||
$this->containers = $this->getAllActiveContainers();
|
$this->containers = $this->getAllActiveContainers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +82,11 @@ class RunCommand extends Component
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatedSelectedUuid($value)
|
||||||
|
{
|
||||||
|
$this->connectToContainer();
|
||||||
|
}
|
||||||
|
|
||||||
#[On('connectToContainer')]
|
#[On('connectToContainer')]
|
||||||
public function connectToContainer()
|
public function connectToContainer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
@if ($label)
|
@if ($label)
|
||||||
<label class="flex items-center gap-1 mb-1 text-sm font-medium">{{ $label }}
|
<label class="flex gap-1 items-center mb-1 text-sm font-medium">{{ $label }}
|
||||||
@if ($required)
|
@if ($required)
|
||||||
<x-highlighted text="*" />
|
<x-highlighted text="*" />
|
||||||
@endif
|
@endif
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
@endif
|
@endif
|
||||||
</label>
|
</label>
|
||||||
@endif
|
@endif
|
||||||
<select {{ $attributes->merge(['class' => $defaultClass]) }} @required($required) wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'
|
<select {{ $attributes->merge(['class' => $defaultClass]) }} @required($required)
|
||||||
|
wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'
|
||||||
wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" name={{ $id }}
|
wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" name={{ $id }}
|
||||||
@if ($attributes->whereStartsWith('wire:model')->first()) {{ $attributes->whereStartsWith('wire:model')->first() }} @else wire:model={{ $id }} @endif>
|
@if ($attributes->whereStartsWith('wire:model')->first()) {{ $attributes->whereStartsWith('wire:model')->first() }} @else wire:model={{ $id }} @endif>
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
|
|||||||
@@ -117,8 +117,8 @@
|
|||||||
if (data === '\x04' || (data === '\r' && stripAnsiCommands(commandBuffer).trim() === 'exit')) {
|
if (data === '\x04' || (data === '\r' && stripAnsiCommands(commandBuffer).trim() === 'exit')) {
|
||||||
checkIfProcessIsRunningAndKillIt();
|
checkIfProcessIsRunningAndKillIt();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
term.reset();
|
|
||||||
$data.terminalActive = false;
|
$data.terminalActive = false;
|
||||||
|
term.reset();
|
||||||
}, 500);
|
}, 500);
|
||||||
commandBuffer = '';
|
commandBuffer = '';
|
||||||
} else if (data === '\r') {
|
} else if (data === '\r') {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
<div>
|
<div>
|
||||||
<form class="flex flex-col justify-center gap-2 xl:items-end xl:flex-row"
|
<form class="flex flex-col gap-2 justify-center xl:items-end xl:flex-row"
|
||||||
wire:submit="$dispatchSelf('connectToContainer')">
|
wire:submit="$dispatchSelf('connectToContainer')">
|
||||||
<x-forms.select label="Select Server or Container" id="server" required wire:model="selected_uuid">
|
<x-forms.select id="server" required wire:model.live="selected_uuid">
|
||||||
@foreach ($servers as $server)
|
@foreach ($servers as $server)
|
||||||
@if ($loop->first)
|
@if ($loop->first)
|
||||||
<option selected value="{{ $server->uuid }}">{{ $server->name }}</option>
|
<option disabled value="default">Select a server or container</option>
|
||||||
@else
|
|
||||||
<option value="{{ $server->uuid }}">{{ $server->name }}</option>
|
|
||||||
@endif
|
@endif
|
||||||
|
<option value="{{ $server->uuid }}">{{ $server->name }}</option>
|
||||||
@foreach ($containers as $container)
|
@foreach ($containers as $container)
|
||||||
@if ($container['server_uuid'] == $server->uuid)
|
@if ($container['server_uuid'] == $server->uuid)
|
||||||
<option value="{{ $container['uuid'] }}">
|
<option value="{{ $container['uuid'] }}">
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
Terminal | Coolify
|
Terminal | Coolify
|
||||||
</x-slot>
|
</x-slot>
|
||||||
<h1>Terminal</h1>
|
<h1>Terminal</h1>
|
||||||
<div class="subtitle">Execute commands on your servers without leaving the browser.</div>
|
<div class="flex gap-2 items-end subtitle">
|
||||||
|
<div>Execute commands on your servers and containers without leaving the browser.</div>
|
||||||
|
<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>
|
||||||
@if ($servers->count() > 0)
|
@if ($servers->count() > 0)
|
||||||
<livewire:run-command :servers="$servers" />
|
<livewire:run-command :servers="$servers" />
|
||||||
@else
|
@else
|
||||||
|
|||||||
Reference in New Issue
Block a user