Refactor code and add additional destinations
This commit is contained in:
@@ -87,22 +87,6 @@ class Heading extends Component
|
||||
$this->application->save();
|
||||
$this->application->refresh();
|
||||
}
|
||||
public function restartNew()
|
||||
{
|
||||
$this->setDeploymentUuid();
|
||||
queue_application_deployment(
|
||||
application: $this->application,
|
||||
deployment_uuid: $this->deploymentUuid,
|
||||
restart_only: true,
|
||||
is_new_deployment: true,
|
||||
);
|
||||
return redirect()->route('project.application.deployment.show', [
|
||||
'project_uuid' => $this->parameters['project_uuid'],
|
||||
'application_uuid' => $this->parameters['application_uuid'],
|
||||
'deployment_uuid' => $this->deploymentUuid,
|
||||
'environment_name' => $this->parameters['environment_name'],
|
||||
]);
|
||||
}
|
||||
public function restart()
|
||||
{
|
||||
$this->setDeploymentUuid();
|
||||
|
||||
@@ -2,11 +2,43 @@
|
||||
|
||||
namespace App\Livewire\Project\Shared;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
class Destination extends Component
|
||||
{
|
||||
public $resource;
|
||||
public $servers = [];
|
||||
public $additional_servers = [];
|
||||
public $networks = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->loadData();
|
||||
}
|
||||
public function loadData()
|
||||
{
|
||||
$all_networks = collect([]);
|
||||
$all_networks = $all_networks->push($this->resource->destination);
|
||||
$all_networks = $all_networks->merge($this->resource->additional_networks);
|
||||
|
||||
$this->networks = Server::isUsable()->get()->map(function ($server) {
|
||||
return $server->standaloneDockers;
|
||||
})->flatten();
|
||||
$this->networks = $this->networks->reject(function ($network) use ($all_networks) {
|
||||
return $all_networks->pluck('id')->contains($network->id);
|
||||
});
|
||||
}
|
||||
public function addServer(int $network_id, int $server_id)
|
||||
{
|
||||
$this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);
|
||||
$this->resource->load(['additional_networks']);
|
||||
$this->loadData();
|
||||
|
||||
}
|
||||
public function removeServer(int $network_id, int $server_id)
|
||||
{
|
||||
$this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]);
|
||||
$this->resource->load(['additional_networks']);
|
||||
$this->loadData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class All extends Component
|
||||
}
|
||||
$environment->save();
|
||||
$this->refreshEnvs();
|
||||
$this->dispatch('success', 'Environment variable added successfully.');
|
||||
$this->dispatch('success', 'Environment variable added.');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user