diff --git a/app/Http/Livewire/Project/New/Select.php b/app/Http/Livewire/Project/New/Select.php index c6ec91bb3..0ea7fd8c1 100644 --- a/app/Http/Livewire/Project/New/Select.php +++ b/app/Http/Livewire/Project/New/Select.php @@ -22,34 +22,52 @@ class Select extends Component public Collection|array $swarmDockers = []; public array $parameters; + public ?string $existingPostgresqlUrl = null; + protected $queryString = [ 'server', ]; public function mount() { $this->parameters = get_route_parameters(); + if (isDev()) { + $this->existingPostgresqlUrl = 'postgres://coolify:password@coolify-db:5432'; + } } - public function set_type(string $type) + // public function addExistingPostgresql() + // { + // try { + // instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'"); + // $this->emit('success', 'Successfully connected to the database.'); + // } catch (\Exception $e) { + // return general_error_handler($e, $this); + // } + // } + public function setType(string $type) { $this->type = $type; + if ($type === "existing-postgresql") { + $this->current_step = $type; + return; + } if (count($this->servers) === 1) { $server = $this->servers->first(); - $this->set_server($server); + $this->setServer($server); if (count($server->destinations()) === 1) { - $this->set_destination($server->destinations()->first()->uuid); + $this->setDestination($server->destinations()->first()->uuid); } } if (!is_null($this->server)) { $foundServer = $this->servers->where('id', $this->server)->first(); if ($foundServer) { - return $this->set_server($foundServer); + return $this->setServer($foundServer); } } $this->current_step = 'servers'; } - public function set_server(Server $server) + public function setServer(Server $server) { $this->server_id = $server->id; $this->standaloneDockers = $server->standaloneDockers; @@ -57,7 +75,7 @@ public function set_server(Server $server) $this->current_step = 'destinations'; } - public function set_destination(string $destination_uuid) + public function setDestination(string $destination_uuid) { $this->destination_uuid = $destination_uuid; redirect()->route('project.resources.new', [ diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 781fe6fc8..5b7965461 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -93,7 +93,18 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s return $ssh_command; } - +function instantCommand(string $command, $throwError = true) { + $process = Process::run($command); + $output = trim($process->output()); + $exitCode = $process->exitCode(); + if ($exitCode !== 0) { + if (!$throwError) { + return null; + } + throw new \RuntimeException($process->errorOutput(), $exitCode); + } + return $output; +} function instant_remote_process(array $command, Server $server, $throwError = true, $repeat = 1) { $command_string = implode("\n", $command); diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index 2abc8a91e..36fa0870f 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -26,7 +26,8 @@ class="absolute inset-y-0 left-0 flex items-center pl-2 cursor-pointer hover:tex wire:model.defer={{ $id }} wire:dirty.class.remove='text-white' wire:dirty.class="input-warning" wire:loading.attr="disabled" type="{{ $type }}" @readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}" - placeholder="{{ $attributes->get('placeholder') }}"> + placeholder="{{ $attributes->get('placeholder') }}" + aria-placeholder="{{ $attributes->get('placeholder') }}"> @else diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index be76d5e66..3bada4dca 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -10,8 +10,7 @@