fix: show defined resources in server tab, so you will know what you need to delete before you can delete the server.

This commit is contained in:
Andras Bacsai
2023-11-27 09:39:43 +01:00
parent ec21155c9e
commit d396f649df
16 changed files with 85 additions and 14 deletions

View File

@@ -137,7 +137,7 @@ class ProjectController extends Controller
}
$service->parse(isNew: true);
return redirect()->route('project.service', [
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,

View File

@@ -129,7 +129,7 @@ class DockerCompose extends Component
$service->parse(isNew: true);
return redirect()->route('project.service', [
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,

View File

@@ -41,7 +41,7 @@ class Application extends Component
try {
$this->application->delete();
$this->emit('success', 'Application deleted successfully.');
return redirect()->route('project.service', $this->parameters);
return redirect()->route('project.service.configuration', $this->parameters);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -47,7 +47,14 @@ class Application extends BaseModel
$application->environment_variables_preview()->delete();
});
}
public function link()
{
return route('project.application.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'application_uuid' => $this->uuid
]);
}
public function settings()
{
return $this->hasOne(ApplicationSetting::class);

View File

@@ -194,6 +194,12 @@ class Server extends BaseModel
{
return instant_remote_process(["df /| tail -1 | awk '{ print $5}' | sed 's/%//g'"], $this, false);
}
public function definedResources() {
$applications = $this->applications();
$databases = $this->databases();
$services = $this->services();
return $applications->concat($databases)->concat($services->get());
}
public function hasDefinedResources()
{
$applications = $this->applications()->count() > 0;

View File

@@ -361,6 +361,14 @@ class Service extends BaseModel
}
}
}
public function link()
{
return route('project.service.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'service_uuid' => $this->uuid
]);
}
public function documentation()
{
$services = getServiceTemplates();

View File

@@ -41,6 +41,14 @@ class StandaloneMariadb extends BaseModel
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);

View File

@@ -48,6 +48,14 @@ class StandaloneMongodb extends BaseModel
{
return data_get($this, 'is_log_drain_enabled', false);
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function mongoInitdbRootPassword(): Attribute
{
return Attribute::make(

View File

@@ -41,6 +41,14 @@ class StandaloneMysql extends BaseModel
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function type(): string
{
return 'standalone-mysql';

View File

@@ -41,7 +41,14 @@ class StandalonePostgresql extends BaseModel
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);

View File

@@ -36,7 +36,14 @@ class StandaloneRedis extends BaseModel
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);