fix: compose based terminal
This commit is contained in:
@@ -11,6 +11,8 @@ use Livewire\Component;
|
|||||||
|
|
||||||
class ExecuteContainerCommand extends Component
|
class ExecuteContainerCommand extends Component
|
||||||
{
|
{
|
||||||
|
public $selected_container = 'default';
|
||||||
|
|
||||||
public $container;
|
public $container;
|
||||||
|
|
||||||
public Collection $containers;
|
public Collection $containers;
|
||||||
@@ -83,12 +85,15 @@ class ExecuteContainerCommand extends Component
|
|||||||
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
|
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
|
||||||
}
|
}
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
|
// if container state is running
|
||||||
|
if (data_get($container, 'State') === 'running') {
|
||||||
$payload = [
|
$payload = [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'container' => $container,
|
'container' => $container,
|
||||||
];
|
];
|
||||||
$this->containers = $this->containers->push($payload);
|
$this->containers = $this->containers->push($payload);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} elseif (data_get($this->parameters, 'database_uuid')) {
|
} elseif (data_get($this->parameters, 'database_uuid')) {
|
||||||
if ($this->resource->isRunning()) {
|
if ($this->resource->isRunning()) {
|
||||||
$this->containers = $this->containers->push([
|
$this->containers = $this->containers->push([
|
||||||
@@ -100,7 +105,6 @@ class ExecuteContainerCommand extends Component
|
|||||||
}
|
}
|
||||||
} elseif (data_get($this->parameters, 'service_uuid')) {
|
} elseif (data_get($this->parameters, 'service_uuid')) {
|
||||||
$this->resource->applications()->get()->each(function ($application) {
|
$this->resource->applications()->get()->each(function ($application) {
|
||||||
ray($application);
|
|
||||||
if ($application->isRunning()) {
|
if ($application->isRunning()) {
|
||||||
$this->containers->push([
|
$this->containers->push([
|
||||||
'server' => $this->resource->server,
|
'server' => $this->resource->server,
|
||||||
@@ -131,9 +135,14 @@ class ExecuteContainerCommand extends Component
|
|||||||
#[On('connectToContainer')]
|
#[On('connectToContainer')]
|
||||||
public function connectToContainer()
|
public function connectToContainer()
|
||||||
{
|
{
|
||||||
|
if ($this->selected_container === 'default') {
|
||||||
|
$this->dispatch('error', 'Please select a container.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$container_name = data_get($this->container, 'container.Names');
|
$container = collect($this->containers)->firstWhere('container.Names', $this->selected_container);
|
||||||
if (is_null($container_name)) {
|
if (is_null($container)) {
|
||||||
throw new \RuntimeException('Container not found.');
|
throw new \RuntimeException('Container not found.');
|
||||||
}
|
}
|
||||||
$server = data_get($this->container, 'server');
|
$server = data_get($this->container, 'server');
|
||||||
@@ -141,11 +150,11 @@ class ExecuteContainerCommand extends Component
|
|||||||
if ($server->isForceDisabled()) {
|
if ($server->isForceDisabled()) {
|
||||||
throw new \RuntimeException('Server is disabled.');
|
throw new \RuntimeException('Server is disabled.');
|
||||||
}
|
}
|
||||||
|
$this->dispatch(
|
||||||
$this->dispatch('send-terminal-command',
|
'send-terminal-command',
|
||||||
true,
|
isset($container),
|
||||||
$container_name,
|
data_get($container, 'container.Names'),
|
||||||
$server->uuid,
|
data_get($container, 'server.uuid')
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
@if (count($containers) > 0)
|
@if (count($containers) > 0)
|
||||||
<form class="flex flex-col gap-2 justify-center pt-4 xl:items-end xl:flex-row"
|
<form class="flex flex-col gap-2 justify-center pt-4 xl:items-end xl:flex-row"
|
||||||
wire:submit="$dispatchSelf('connectToContainer')">
|
wire:submit="$dispatchSelf('connectToContainer')">
|
||||||
<x-forms.select label="Container" id="container" required>
|
<x-forms.select label="Container" id="container" required wire:model="selected_container">
|
||||||
<option disabled selected>Select container</option>
|
|
||||||
@foreach ($containers as $container)
|
@foreach ($containers as $container)
|
||||||
|
@if ($loop->first)
|
||||||
|
<option disabled value="default">Select a container</option>
|
||||||
|
@endif
|
||||||
<option value="{{ data_get($container, 'container.Names') }}">
|
<option value="{{ data_get($container, 'container.Names') }}">
|
||||||
{{ data_get($container, 'container.Names') }}
|
{{ data_get($container, 'container.Names') }}
|
||||||
({{ data_get($container, 'server.name') }})
|
({{ data_get($container, 'server.name') }})
|
||||||
|
|||||||
Reference in New Issue
Block a user