Fix styling
This commit is contained in:
committed by
github-actions[bot]
parent
41fb6a1fc9
commit
d86274cc37
@@ -12,9 +12,13 @@ use Visus\Cuid2\Cuid2;
|
||||
class ResourceOperations extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public $projectUuid;
|
||||
|
||||
public $environmentName;
|
||||
|
||||
public $projects;
|
||||
|
||||
public $servers;
|
||||
|
||||
public function mount()
|
||||
@@ -25,28 +29,29 @@ class ResourceOperations extends Component
|
||||
$this->projects = Project::ownedByCurrentTeam()->get();
|
||||
$this->servers = currentTeam()->servers;
|
||||
}
|
||||
|
||||
public function cloneTo($destination_id)
|
||||
{
|
||||
$new_destination = StandaloneDocker::find($destination_id);
|
||||
if (!$new_destination) {
|
||||
if (! $new_destination) {
|
||||
$new_destination = SwarmDocker::find($destination_id);
|
||||
}
|
||||
if (!$new_destination) {
|
||||
if (! $new_destination) {
|
||||
return $this->addError('destination_id', 'Destination not found.');
|
||||
}
|
||||
$uuid = (string)new Cuid2(7);
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$server = $new_destination->server;
|
||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'fqdn' => generateFqdn($server, $uuid),
|
||||
'status' => 'exited',
|
||||
'destination_id' => $new_destination->id,
|
||||
]);
|
||||
$new_resource->save();
|
||||
if ($new_resource->destination->server->proxyType() !== 'NONE') {
|
||||
$customLabels = str(implode("|", generateLabelsApplication($new_resource)))->replace("|", "\n");
|
||||
$customLabels = str(implode('|', generateLabelsApplication($new_resource)))->replace('|', "\n");
|
||||
$new_resource->custom_labels = base64_encode($customLabels);
|
||||
$new_resource->save();
|
||||
}
|
||||
@@ -60,7 +65,7 @@ class ResourceOperations extends Component
|
||||
$persistentVolumes = $this->resource->persistentStorages()->get();
|
||||
foreach ($persistentVolumes as $volume) {
|
||||
$newPersistentVolume = $volume->replicate()->fill([
|
||||
'name' => $new_resource->uuid . '-' . str($volume->name)->afterLast('-'),
|
||||
'name' => $new_resource->uuid.'-'.str($volume->name)->afterLast('-'),
|
||||
'resource_id' => $new_resource->id,
|
||||
]);
|
||||
$newPersistentVolume->save();
|
||||
@@ -69,9 +74,10 @@ class ResourceOperations extends Component
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'application_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if (
|
||||
} elseif (
|
||||
$this->resource->getMorphClass() === 'App\Models\StandalonePostgresql' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneMongodb' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneMysql' ||
|
||||
@@ -81,10 +87,10 @@ class ResourceOperations extends Component
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneDragonfly' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneClickhouse'
|
||||
) {
|
||||
$uuid = (string)new Cuid2(7);
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'status' => 'exited',
|
||||
'started_at' => null,
|
||||
'destination_id' => $new_destination->id,
|
||||
@@ -95,29 +101,30 @@ class ResourceOperations extends Component
|
||||
$payload = [];
|
||||
if ($this->resource->type() === 'standalone-postgresql') {
|
||||
$payload['standalone_postgresql_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-redis') {
|
||||
} elseif ($this->resource->type() === 'standalone-redis') {
|
||||
$payload['standalone_redis_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mongodb') {
|
||||
} elseif ($this->resource->type() === 'standalone-mongodb') {
|
||||
$payload['standalone_mongodb_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mysql') {
|
||||
} elseif ($this->resource->type() === 'standalone-mysql') {
|
||||
$payload['standalone_mysql_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mariadb') {
|
||||
} elseif ($this->resource->type() === 'standalone-mariadb') {
|
||||
$payload['standalone_mariadb_id'] = $new_resource->id;
|
||||
}
|
||||
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
|
||||
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
|
||||
$newEnvironmentVariable->save();
|
||||
}
|
||||
$route = route('project.database.configuration', [
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'database_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if ($this->resource->type() === 'service') {
|
||||
$uuid = (string)new Cuid2(7);
|
||||
} elseif ($this->resource->type() === 'service') {
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'destination_id' => $new_destination->id,
|
||||
]);
|
||||
$new_resource->save();
|
||||
@@ -136,44 +143,50 @@ class ResourceOperations extends Component
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'service_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function moveTo($environment_id)
|
||||
{
|
||||
try {
|
||||
$new_environment = Environment::findOrFail($environment_id);
|
||||
$this->resource->update([
|
||||
'environment_id' => $environment_id
|
||||
'environment_id' => $environment_id,
|
||||
]);
|
||||
if ($this->resource->type() === 'application') {
|
||||
$route = route('project.application.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'application_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if (str($this->resource->type())->startsWith('standalone-')) {
|
||||
} elseif (str($this->resource->type())->startsWith('standalone-')) {
|
||||
$route = route('project.database.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'database_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if ($this->resource->type() === 'service') {
|
||||
} elseif ($this->resource->type() === 'service') {
|
||||
$route = route('project.service.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'service_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.resource-operations');
|
||||
|
||||
Reference in New Issue
Block a user