Merge branch 'next' into mongodb-restore

This commit is contained in:
Evan
2024-04-26 16:42:40 +02:00
committed by GitHub
90 changed files with 972 additions and 450 deletions

View File

@@ -62,7 +62,7 @@ class CleanupStuckedResources extends Command
$keydbs = StandaloneKeydb::withTrashed()->whereNotNull('deleted_at')->get();
foreach ($keydbs as $keydb) {
echo "Deleting stuck keydb: {$keydb->name}\n";
$redis->forceDelete();
$keydb->forceDelete();
}
} catch (\Throwable $e) {
echo "Error in cleaning stuck keydb: {$e->getMessage()}\n";
@@ -71,7 +71,7 @@ class CleanupStuckedResources extends Command
$dragonflies = StandaloneDragonfly::withTrashed()->whereNotNull('deleted_at')->get();
foreach ($dragonflies as $dragonfly) {
echo "Deleting stuck dragonfly: {$dragonfly->name}\n";
$redis->forceDelete();
$dragonfly->forceDelete();
}
} catch (\Throwable $e) {
echo "Error in cleaning stuck dragonfly: {$e->getMessage()}\n";
@@ -80,7 +80,7 @@ class CleanupStuckedResources extends Command
$clickhouses = StandaloneClickhouse::withTrashed()->whereNotNull('deleted_at')->get();
foreach ($clickhouses as $clickhouse) {
echo "Deleting stuck clickhouse: {$clickhouse->name}\n";
$redis->forceDelete();
$clickhouse->forceDelete();
}
} catch (\Throwable $e) {
echo "Error in cleaning stuck clickhouse: {$e->getMessage()}\n";

View File

@@ -20,6 +20,7 @@ class Init extends Command
public function handle()
{
$this->alive();
get_public_ips();
$full_cleanup = $this->option('full-cleanup');
$cleanup_deployments = $this->option('cleanup-deployments');
if ($cleanup_deployments) {
@@ -56,6 +57,7 @@ class Init extends Command
$this->cleanup_stucked_helper_containers();
$this->call('cleanup:stucked-resources');
}
private function restore_coolify_db_backup()
{
try {

View File

@@ -710,7 +710,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
private function save_environment_variables()
{
$envs = collect([]);
$ports = $this->application->settings->is_static ? [80] : $this->application->ports_exposes_array;
$ports = $this->application->main_port();
if ($this->pull_request_id !== 0) {
$this->env_filename = ".env-pr-$this->pull_request_id";
foreach ($this->application->environment_variables_preview as $env) {
@@ -718,22 +718,24 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
} else {
$real_value = escapeEnvVariables($env->real_value);
}
if ($env->is_literal) {
$real_value = '\'' . $real_value . '\'';
if ($env->is_literal) {
$real_value = '\'' . $real_value . '\'';
} else {
$real_value = escapeEnvVariables($env->real_value);
}
}
$envs->push($env->key . '=' . $real_value);
}
// Add PORT if not exists, use the first port as default
if ($this->application->environment_variables_preview->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
if ($this->application->environment_variables_preview->where('key', 'PORT')->isEmpty()) {
$envs->push("PORT={$ports[0]}");
}
// Add HOST if not exists
if ($this->application->environment_variables_preview->filter(fn ($env) => Str::of($env)->startsWith('HOST'))->isEmpty()) {
if ($this->application->environment_variables_preview->where('key', 'HOST')->isEmpty()) {
$envs->push("HOST=0.0.0.0");
}
if ($this->application->environment_variables_preview->filter(fn ($env) => Str::of($env)->startsWith('SOURCE_COMMIT'))->isEmpty()) {
// Add SOURCE_COMMIT if not exists
if ($this->application->environment_variables_preview->where('key', 'SOURCE_COMMIT')->isEmpty()) {
if (!is_null($this->commit)) {
$envs->push("SOURCE_COMMIT={$this->commit}");
} else {
@@ -750,22 +752,24 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
} else {
$real_value = escapeEnvVariables($env->real_value);
}
if ($env->is_literal) {
$real_value = '\'' . $real_value . '\'';
if ($env->is_literal) {
$real_value = '\'' . $real_value . '\'';
} else {
$real_value = escapeEnvVariables($env->real_value);
}
}
$envs->push($env->key . '=' . $real_value);
}
// Add PORT if not exists, use the first port as default
if ($this->application->environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
if ($this->application->environment_variables->where('key', 'PORT')->isEmpty()) {
$envs->push("PORT={$ports[0]}");
}
// Add HOST if not exists
if ($this->application->environment_variables->filter(fn ($env) => Str::of($env)->startsWith('HOST'))->isEmpty()) {
if ($this->application->environment_variables->where('key', 'HOST')->isEmpty()) {
$envs->push("HOST=0.0.0.0");
}
if ($this->application->environment_variables->filter(fn ($env) => Str::of($env)->startsWith('SOURCE_COMMIT'))->isEmpty()) {
// Add SOURCE_COMMIT if not exists
if ($this->application->environment_variables->where('key', 'SOURCE_COMMIT')->isEmpty()) {
if (!is_null($this->commit)) {
$envs->push("SOURCE_COMMIT={$this->commit}");
} else {
@@ -1212,7 +1216,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
private function generate_compose_file()
{
$this->create_workdir();
$ports = $this->application->settings->is_static ? [80] : $this->application->ports_exposes_array;
$ports = $this->application->main_port();
$onlyPort = null;
if (count($ports) > 0) {
$onlyPort = $ports[0];
@@ -1506,7 +1510,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
return $local_persistent_volumes_names;
}
private function generate_environment_variables($ports)
/*private function generate_environment_variables($ports)
{
$environment_variables = collect();
if ($this->pull_request_id === 0) {
@@ -1524,8 +1528,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
if ($env->is_literal) {
$real_value = escapeDollarSign($real_value);
$environment_variables->push("$env->key='$real_value'");
} else {
$environment_variables->push("$env->key=$real_value");
}
$environment_variables->push("$env->key=$real_value");
}
foreach ($this->application->nixpacks_environment_variables as $env) {
if ($env->version === '4.0.0-beta.239') {
@@ -1535,8 +1541,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
if ($env->is_literal) {
$real_value = escapeDollarSign($real_value);
$environment_variables->push("$env->key='$real_value'");
} else {
$environment_variables->push("$env->key=$real_value");
}
$environment_variables->push("$env->key=$real_value");
}
} else {
foreach ($this->application->runtime_environment_variables_preview as $env) {
@@ -1547,8 +1555,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
if ($env->is_literal) {
$real_value = escapeDollarSign($real_value);
$environment_variables->push("$env->key='$real_value'");
} else {
$environment_variables->push("$env->key=$real_value");
}
$environment_variables->push("$env->key=$real_value");
}
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
if ($env->version === '4.0.0-beta.239') {
@@ -1558,8 +1568,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
if ($env->is_literal) {
$real_value = escapeDollarSign($real_value);
$environment_variables->push("$env->key='$real_value'");
} else {
$environment_variables->push("$env->key=$real_value");
}
$environment_variables->push("$env->key=$real_value");
}
}
// Add PORT if not exists, use the first port as default
@@ -1577,8 +1589,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$environment_variables->push("SOURCE_COMMIT=unknown");
}
}
ray($environment_variables->all());
return $environment_variables->all();
}
}*/
private function generate_healthcheck_commands()
{

View File

@@ -27,6 +27,8 @@ class Advanced extends Component
'application.settings.gpu_count' => 'string|required',
'application.settings.gpu_device_ids' => 'string|required',
'application.settings.gpu_options' => 'string|required',
'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',
'application.settings.connect_to_docker_network' => 'boolean|required',
];
public function mount() {
$this->is_force_https_enabled = $this->application->isForceHttpsEnabled();
@@ -54,8 +56,14 @@ class Advanced extends Component
$this->application->settings->is_stripprefix_enabled = $this->is_stripprefix_enabled;
$this->dispatch('resetDefaultLabels', false);
}
if ($this->application->settings->is_raw_compose_deployment_enabled) {
$this->application->parseRawCompose();
} else {
$this->application->parseCompose();
}
$this->application->settings->save();
$this->dispatch('success', 'Settings saved.');
$this->dispatch('configurationChanged');
}
public function submit() {
if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) {

View File

@@ -34,7 +34,8 @@ class General extends Component
public $parsedServiceDomains = [];
protected $listeners = [
'resetDefaultLabels'
'resetDefaultLabels',
'configurationChanged' => '$refresh'
];
protected $rules = [
'application.name' => 'required',
@@ -72,7 +73,6 @@ class General extends Component
'application.post_deployment_command' => 'nullable',
'application.post_deployment_command_container' => 'nullable',
'application.settings.is_static' => 'boolean|required',
'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',
'application.settings.is_build_server_enabled' => 'boolean|required',
'application.watch_paths' => 'nullable',
];
@@ -108,7 +108,6 @@ class General extends Component
'application.docker_compose_custom_start_command' => 'Docker compose custom start command',
'application.docker_compose_custom_build_command' => 'Docker compose custom build command',
'application.settings.is_static' => 'Is static',
'application.settings.is_raw_compose_deployment_enabled' => 'Is raw compose deployment enabled',
'application.settings.is_build_server_enabled' => 'Is build server enabled',
'application.watch_paths' => 'Watch paths',
];
@@ -337,11 +336,6 @@ class General extends Component
check_domain_usage(resource: $this->application);
}
}
if ($this->application->settings->is_raw_compose_deployment_enabled) {
$this->application->parseRawCompose();
} else {
$this->parsedServices = $this->application->parseCompose();
}
}
$this->application->custom_labels = base64_encode($this->customLabels);
$this->application->save();

View File

@@ -12,28 +12,6 @@ class Edit extends Component
'project.name' => 'required|min:3|max:255',
'project.description' => 'nullable|string|max:255',
];
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
public function saveKey($data)
{
try {
$found = $this->project->environment_variables()->where('key', $data['key'])->first();
if ($found) {
throw new \Exception('Variable already exists.');
}
$this->project->environment_variables()->create([
'key' => $data['key'],
'value' => $data['value'],
'is_multiline' => $data['is_multiline'],
'is_literal' => $data['is_literal'],
'type' => 'project',
'team_id' => currentTeam()->id,
]);
$this->project->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function mount()
{
$projectUuid = request()->route('project_uuid');

View File

@@ -16,29 +16,6 @@ class EnvironmentEdit extends Component
'environment.name' => 'required|min:3|max:255',
'environment.description' => 'nullable|min:3|max:255',
];
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
public function saveKey($data)
{
try {
$found = $this->environment->environment_variables()->where('key', $data['key'])->first();
if ($found) {
throw new \Exception('Variable already exists.');
}
$this->environment->environment_variables()->create([
'key' => $data['key'],
'value' => $data['value'],
'is_multiline' => $data['is_multiline'],
'is_literal' => $data['is_literal'],
'type' => 'environment',
'team_id' => currentTeam()->id,
]);
$this->environment->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function mount()
{
$this->parameters = get_route_parameters();

View File

@@ -50,9 +50,9 @@ class Show extends Component
public function checkEnvs()
{
$this->isDisabled = false;
// if (str($this->env->key)->startsWith('SERVICE_FQDN') || str($this->env->key)->startsWith('SERVICE_URL')) {
// $this->isDisabled = true;
// }
if (str($this->env->key)->startsWith('SERVICE_FQDN') || str($this->env->key)->startsWith('SERVICE_URL')) {
$this->isDisabled = true;
}
if ($this->env->is_shown_once) {
$this->isLocked = true;
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Livewire\SharedVariables\Environment;
use App\Models\Project;
use Illuminate\Support\Collection;
use Livewire\Component;
class Index extends Component
{
public Collection $projects;
public function mount() {
$this->projects = Project::ownedByCurrentTeam()->get();
}
public function render()
{
return view('livewire.shared-variables.environment.index');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Livewire\SharedVariables\Environment;
use App\Models\Application;
use App\Models\Project;
use Livewire\Component;
class Show extends Component
{
public Project $project;
public Application $application;
public $environment;
public array $parameters;
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
public function saveKey($data)
{
try {
$found = $this->environment->environment_variables()->where('key', $data['key'])->first();
if ($found) {
throw new \Exception('Variable already exists.');
}
$this->environment->environment_variables()->create([
'key' => $data['key'],
'value' => $data['value'],
'is_multiline' => $data['is_multiline'],
'is_literal' => $data['is_literal'],
'type' => 'environment',
'team_id' => currentTeam()->id,
]);
$this->environment->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function mount()
{
$this->parameters = get_route_parameters();
$this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->first();
$this->environment = $this->project->environments()->where('name', request()->route('environment_name'))->first();
}
public function render()
{
return view('livewire.shared-variables.environment.show');
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Livewire\SharedVariables;
use Livewire\Component;
class Index extends Component
{
public function render()
{
return view('livewire.shared-variables.index');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Livewire\SharedVariables\Project;
use App\Models\Project;
use Illuminate\Support\Collection;
use Livewire\Component;
class Index extends Component
{
public Collection $projects;
public function mount() {
$this->projects = Project::ownedByCurrentTeam()->get();
}
public function render()
{
return view('livewire.shared-variables.project.index');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Livewire\SharedVariables\Project;
use App\Models\Project;
use Livewire\Component;
class Show extends Component
{
public Project $project;
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
public function saveKey($data)
{
try {
$found = $this->project->environment_variables()->where('key', $data['key'])->first();
if ($found) {
throw new \Exception('Variable already exists.');
}
$this->project->environment_variables()->create([
'key' => $data['key'],
'value' => $data['value'],
'is_multiline' => $data['is_multiline'],
'is_literal' => $data['is_literal'],
'type' => 'project',
'team_id' => currentTeam()->id,
]);
$this->project->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function mount()
{
$projectUuid = request()->route('project_uuid');
$teamId = currentTeam()->id;
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
if (!$project) {
return redirect()->route('dashboard');
}
$this->project = $project;
}
public function render()
{
return view('livewire.shared-variables.project.show');
}
}

View File

@@ -1,11 +1,11 @@
<?php
namespace App\Livewire;
namespace App\Livewire\SharedVariables\Team;
use App\Models\Team;
use Livewire\Component;
class TeamSharedVariablesIndex extends Component
class Index extends Component
{
public Team $team;
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
@@ -37,6 +37,6 @@ class TeamSharedVariablesIndex extends Component
}
public function render()
{
return view('livewire.team-shared-variables-index');
return view('livewire.shared-variables.team.index');
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Livewire\Team\Storage;
namespace App\Livewire\Storage;
use App\Models\S3Storage;
use Livewire\Component;
@@ -65,7 +65,7 @@ class Create extends Component
$this->storage->team_id = currentTeam()->id;
$this->storage->testConnection();
$this->storage->save();
return redirect()->route('team.storage.show', $this->storage->uuid);
return redirect()->route('storage.show', $this->storage->uuid);
} catch (\Throwable $e) {
$this->dispatch('error', 'Failed to create storage.', $e->getMessage());
// return handleError($e, $this);

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Livewire\Team\Storage;
namespace App\Livewire\Storage;
use App\Models\S3Storage;
use Livewire\Component;
@@ -43,7 +43,7 @@ class Form extends Component
{
try {
$this->storage->delete();
return redirect()->route('team.storage.index');
return redirect()->route('storage.index');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Livewire\Team\Storage;
namespace App\Livewire\Storage;
use App\Models\S3Storage;
use Livewire\Component;
@@ -13,6 +13,6 @@ class Index extends Component
}
public function render()
{
return view('livewire.team.storage.index');
return view('livewire.storage.index');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Livewire\Storage;
use App\Models\S3Storage;
use Livewire\Component;
class Show extends Component
{
public $storage = null;
public function mount()
{
$this->storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first();
if (!$this->storage) {
abort(404);
}
}
public function render()
{
return view('livewire.storage.show');
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Livewire\Tags;
use App\Models\ApplicationDeploymentQueue;
use Livewire\Component;
class Deployments extends Component
{
public $deployments_per_tag_per_server = [];
public $resource_ids = [];
public function render()
{
return view('livewire.tags.deployments');
}
public function get_deployments()
{
try {
$this->deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn('application_id', $this->resource_ids)->get([
"id",
"application_id",
"application_name",
"deployment_url",
"pull_request_id",
"server_name",
"server_id",
"status"
])->sortBy('id')->groupBy('server_name')->toArray();
} catch (\Exception $e) {
return handleError($e, $this);
}
}
}

View File

@@ -20,32 +20,22 @@ class Index extends Component
public $webhook = null;
public $deployments_per_tag_per_server = [];
public function updatedTag()
public function tag_updated()
{
if ($this->tag == "") {
return;
}
$tag = $this->tags->where('name', $this->tag)->first();
if (!$tag) {
$this->dispatch('error', "Tag ({$this->tag}) not found.");
$this->tag = "";
return;
}
$this->webhook = generatTagDeployWebhook($tag->name);
$this->applications = $tag->applications()->get();
$this->services = $tag->services()->get();
$this->get_deployments();
}
public function get_deployments()
{
try {
$resource_ids = $this->applications->pluck('id');
$this->deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn('application_id', $resource_ids)->get([
"id",
"application_id",
"application_name",
"deployment_url",
"pull_request_id",
"server_name",
"server_id",
"status"
])->sortBy('id')->groupBy('server_name')->toArray();
} catch (\Exception $e) {
return handleError($e, $this);
}
}
public function redeploy_all()
{
try {
@@ -67,7 +57,7 @@ class Index extends Component
{
$this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name');
if ($this->tag) {
$this->updatedTag();
$this->tag_updated();
}
}
public function render()

View File

@@ -17,6 +17,6 @@ class Show extends Component
}
public function render()
{
return view('livewire.team.storage.show');
return view('livewire.storage.show');
}
}

View File

@@ -346,6 +346,10 @@ class Application extends BaseModel
}
return null;
}
public function main_port()
{
return $this->settings->is_static ? [80] : $this->ports_exposes_array;
}
public function environment_variables(): HasMany
{
return $this->hasMany(EnvironmentVariable::class)->where('is_preview', false)->orderBy('key', 'asc');
@@ -579,9 +583,9 @@ class Application extends BaseModel
['repository' => $customRepository, 'port' => $customPort] = $this->customRepository();
$baseDir = $custom_base_dir ?? $this->generateBaseDir($deployment_uuid);
$commands = collect([]);
$git_clone_command = "git clone -b {$this->git_branch}";
$git_clone_command = "git clone -b \"{$this->git_branch}\"";
if ($only_checkout) {
$git_clone_command = "git clone --no-checkout -b {$this->git_branch}";
$git_clone_command = "git clone --no-checkout -b \"{$this->git_branch}\"";
}
if ($pull_request_id !== 0) {
$pr_branch_name = "pr-{$pull_request_id}-coolify";

View File

@@ -48,7 +48,7 @@ class S3Storage extends BaseModel
if ($this->unusable_email_sent === false && is_transactional_emails_active()) {
$mail = new MailMessage();
$mail->subject('Coolify: S3 Storage Connection Error');
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('team.storage.show', ['storage_uuid' => $this->uuid])]);
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);
$users = collect([]);
$members = $this->team->members()->get();
foreach ($members as $user) {

View File

@@ -207,4 +207,7 @@ class StandaloneClickhouse extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return $this->clickhouse_db;
}
}

View File

@@ -207,4 +207,7 @@ class StandaloneDragonfly extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return '0';
}
}

View File

@@ -208,5 +208,7 @@ class StandaloneKeydb extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return '0';
}
}

View File

@@ -208,4 +208,7 @@ class StandaloneMariadb extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return $this->mariadb_database;
}
}

View File

@@ -223,4 +223,7 @@ class StandaloneMongodb extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return $this->mongo_db;
}
}

View File

@@ -209,4 +209,7 @@ class StandaloneMysql extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return $this->mysql_database;
}
}

View File

@@ -208,4 +208,7 @@ class StandalonePostgresql extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return $this->postgres_db;
}
}

View File

@@ -204,4 +204,7 @@ class StandaloneRedis extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
public function database_name() {
return '0';
}
}

View File

@@ -17,11 +17,13 @@ class BackupFailed extends Notification implements ShouldQueue
public $tries = 1;
public string $name;
public string $database_name;
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output)
{
$this->name = $database->name;
$this->database_name = $database->database_name();
$this->frequency = $backup->frequency;
}
@@ -36,6 +38,7 @@ class BackupFailed extends Notification implements ShouldQueue
$mail->subject("Coolify: [ACTION REQUIRED] Backup FAILED for {$this->database->name}");
$mail->view('emails.backup-failed', [
'name' => $this->name,
'database_name' => $this->database_name,
'frequency' => $this->frequency,
'output' => $this->output,
]);
@@ -44,11 +47,11 @@ class BackupFailed extends Notification implements ShouldQueue
public function toDiscord(): string
{
return "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
}
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason: {$this->output}";
return [
"message" => $message,
];

View File

@@ -14,11 +14,13 @@ class BackupSuccess extends Notification implements ShouldQueue
public $tries = 1;
public string $name;
public string $database_name;
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database)
{
$this->name = $database->name;
$this->database_name = $database->database_name();
$this->frequency = $backup->frequency;
}
@@ -33,6 +35,7 @@ class BackupSuccess extends Notification implements ShouldQueue
$mail->subject("Coolify: Backup successfully done for {$this->database->name}");
$mail->view('emails.backup-success', [
'name' => $this->name,
'database_name' => $this->database_name,
'frequency' => $this->frequency,
]);
return $mail;
@@ -40,11 +43,11 @@ class BackupSuccess extends Notification implements ShouldQueue
public function toDiscord(): string
{
return "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was successful.";
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
}
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} with frequency of {$this->frequency} was successful.";
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
return [
"message" => $message,
];

View File

@@ -0,0 +1,38 @@
<?php
namespace App\View\Components\Forms;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Str;
use Illuminate\View\Component;
use Visus\Cuid2\Cuid2;
class Datalist extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public ?string $id = null,
public ?string $name = null,
public ?string $label = null,
public ?string $helper = null,
public bool $required = false,
public string $defaultClass = "input"
) {
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
if (is_null($this->id)) $this->id = new Cuid2(7);
if (is_null($this->name)) $this->name = $this->id;
$this->label = Str::title($this->label);
return view('components.forms.datalist');
}
}

View File

@@ -23,10 +23,11 @@ class Textarea extends Component
public bool $disabled = false,
public bool $readonly = false,
public bool $allowTab = false,
public bool $spellcheck = false,
public ?string $helper = null,
public bool $realtimeValidation = false,
public bool $allowToPeak = true,
public string $defaultClass = "input scrollbar",
public string $defaultClass = "input scrollbar font-mono",
public string $defaultClassInput = "input"
) {
//