This commit is contained in:
Andras Bacsai
2023-06-15 15:38:15 +02:00
parent c9c56c915c
commit f828cd813b
7 changed files with 82 additions and 36 deletions

View File

@@ -24,16 +24,18 @@ class StandaloneDocker extends Component
];
public function mount()
{
if (!$this->server_id) {
if (request()->query('server_id')) {
$this->server_id = request()->query('server_id');
} else {
if ($this->servers->count() > 0) {
$this->server_id = $this->servers->first()->id;
}
if (request()->query('server_id')) {
$this->server_id = request()->query('server_id');
} else {
if ($this->servers->count() > 0) {
$this->server_id = $this->servers->first()->id;
}
}
$this->network = new Cuid2(7);
if (request()->query('network_name')) {
$this->network = request()->query('network_name');
} else {
$this->network = new Cuid2(7);
}
$this->name = generate_random_name();
}
private function createNetworkAndAttachToProxy()

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Livewire\Destination;
use App\Models\Server;
use Illuminate\Support\Collection;
use Livewire\Component;
class Show extends Component
{
public Server $server;
public Collection|array $networks = [];
public function scan()
{
$alreadyAddedNetworks = $this->server->standaloneDockers;
ray($alreadyAddedNetworks);
$networks = instant_remote_process(['docker network ls --format "{{json .}}"'], $this->server, false);
$this->networks = format_docker_command_output_to_json($networks)->filter(function ($network) {
return $network['Name'] !== 'bridge' && $network['Name'] !== 'host' && $network['Name'] !== 'none';
})->filter(function ($network) use ($alreadyAddedNetworks) {
return !$alreadyAddedNetworks->contains('network', $network['Name']);
});
}
}