This commit is contained in:
Andras Bacsai
2023-11-28 15:49:24 +01:00
parent 706e4b13ee
commit c505a6ce9c
12 changed files with 198 additions and 55 deletions

View File

@@ -31,6 +31,7 @@ class Index extends Component
public ?string $remoteServerHost = null;
public ?int $remoteServerPort = 22;
public ?string $remoteServerUser = 'root';
public bool $isPartOfSwarm = false;
public ?Server $createdServer = null;
public Collection $projects;
@@ -182,7 +183,9 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'private_key_id' => $this->createdPrivateKey->id,
'team_id' => currentTeam()->id,
]);
$this->createdServer->save();
$this->createdServer->settings->is_part_of_swarm = $this->isPartOfSwarm;
$this->createdServer->settings->save();
$this->createdServer->addInitialNetwork();
$this->validateServer();
}
public function validateServer()

View File

@@ -14,6 +14,8 @@ class Dashboard extends Component
public function mount()
{
$this->servers = Server::ownedByCurrentTeam()->get();
ray($this->servers[1]);
ray($this->servers[1]->standaloneDockers);
$this->projects = Project::ownedByCurrentTeam()->get();
}
// public function getIptables()

View File

@@ -126,6 +126,7 @@ class Select extends Component
{
$this->server_id = $server->id;
$this->standaloneDockers = $server->standaloneDockers;
ray($server);
$this->swarmDockers = $server->swarmDockers;
$this->current_step = 'destinations';
}

View File

@@ -17,14 +17,14 @@ class Form extends Component
protected $listeners = ['serverRefresh'];
protected $rules = [
'server.name' => 'required|min:6',
'server.name' => 'required',
'server.description' => 'nullable',
'server.ip' => 'required',
'server.user' => 'required',
'server.port' => 'required',
'server.settings.is_cloudflare_tunnel' => 'required',
'server.settings.is_cloudflare_tunnel' => 'required|boolean',
'server.settings.is_reachable' => 'required',
'server.settings.is_part_of_swarm' => 'required',
'server.settings.is_part_of_swarm' => 'required|boolean',
'wildcard_domain' => 'nullable|url',
];
protected $validationAttributes = [
@@ -49,9 +49,14 @@ class Form extends Component
}
public function instantSave()
{
refresh_server_connection($this->server->privateKey);
$this->validateServer();
$this->server->settings->save();
try {
refresh_server_connection($this->server->privateKey);
$this->validateServer(false);
$this->server->settings->save();
$this->emit('success', 'Server updated successfully.');
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function installDocker()
{
@@ -100,6 +105,12 @@ class Form extends Component
$install && $this->installDocker();
return;
}
if ($this->server->isSwarm()) {
$swarmInstalled = $this->server->validateDockerSwarm();
if ($swarmInstalled) {
$install && $this->emit('success', 'Docker Swarm is initiated.');
}
}
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {

View File

@@ -29,6 +29,7 @@ class ByIp extends Component
'ip' => 'required',
'user' => 'required|string',
'port' => 'required|integer',
'is_part_of_swarm' => 'required|boolean',
];
protected $validationAttributes = [
'name' => 'Name',
@@ -36,6 +37,7 @@ class ByIp extends Component
'ip' => 'IP Address/Domain',
'user' => 'User',
'port' => 'Port',
'is_part_of_swarm' => 'Is part of swarm',
];
public function mount()
@@ -72,11 +74,11 @@ class ByIp extends Component
'proxy' => [
"type" => ProxyTypes::TRAEFIK_V2->value,
"status" => ProxyStatus::EXITED->value,
]
],
]);
$server->settings->is_part_of_swarm = $this->is_part_of_swarm;
$server->settings->save();
$server->addInitialNetwork();
return redirect()->route('server.show', $server->uuid);
} catch (\Throwable $e) {
return handleError($e, $this);