format muhahaha

This commit is contained in:
Andras Bacsai
2023-08-11 20:48:52 +02:00
parent c762195c8a
commit 82a01b4483
109 changed files with 295 additions and 244 deletions

View File

@@ -24,7 +24,7 @@ class Controller extends BaseController
abort(404);
}
return view('subscription', [
'settings' => InstanceSettings::get()
'settings' => InstanceSettings::get(),
]);
}
@@ -34,7 +34,7 @@ class Controller extends BaseController
abort(404);
}
return view('settings.license', [
'settings' => InstanceSettings::get()
'settings' => InstanceSettings::get(),
]);
}
@@ -63,13 +63,11 @@ class Controller extends BaseController
$settings = InstanceSettings::get();
$database = StandalonePostgresql::whereName('coolify-db')->first();
if ($database) {
$backup = $database->scheduledBackups->first();
$s3s = S3Storage::whereTeamId(0)->get();
}
return view('settings.configuration', [
'settings' => $settings,
'database' => $database,
'backup' => $backup ?? null,
's3s' => $s3s ?? [],
]);
} else {

View File

@@ -31,7 +31,6 @@ class S3Test extends Component
} catch (\Throwable $th) {
return general_error_handler($th, $this, false);
}
}
public function get_files()

View File

@@ -54,18 +54,13 @@ class BackupEdit extends Component
} catch (\Exception $e) {
$this->emit('error', $e->getMessage());
}
}
private function custom_validate()
{
// if ($this->backup->save_s3) {
// if (!is_numeric($this->selected_storage_id)) {
// throw new \Exception('Invalid S3 Storage');
// } else {
// $this->backup->s3_storage_id = $this->selected_storage_id;
// }
// }
if (!is_numeric($this->backup->s3_storage_id)) {
$this->backup->s3_storage_id = null;
}
$isValid = validate_cron_expression($this->backup->frequency);
if (!$isValid) {
throw new \Exception('Invalid Cron / Human expression');

View File

@@ -11,7 +11,6 @@ class BackupExecution extends Component
public function download()
{
}
public function delete(): void

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Livewire\Project\Database;
use App\Jobs\DatabaseBackupJob;
use Livewire\Component;
class BackupNow extends Component
{
public $backup;
public function backup_now()
{
dispatch(new DatabaseBackupJob(
backup: $this->backup
));
$this->emit('success', 'Backup queued. It will be available in a few minutes');
}
}

View File

@@ -42,7 +42,7 @@ class General extends Component
public function save_init_script($script)
{
$this->database->init_scripts = filter($this->database->init_scripts, fn($s) => $s['filename'] !== $script['filename']);
$this->database->init_scripts = filter($this->database->init_scripts, fn ($s) => $s['filename'] !== $script['filename']);
$this->database->init_scripts = array_merge($this->database->init_scripts, [$script]);
$this->database->save();
$this->emit('success', 'Init script saved successfully.');
@@ -53,8 +53,8 @@ class General extends Component
$collection = collect($this->database->init_scripts);
$found = $collection->firstWhere('filename', $script['filename']);
if ($found) {
ray($collection->filter(fn($s) => $s['filename'] !== $script['filename'])->toArray());
$this->database->init_scripts = $collection->filter(fn($s) => $s['filename'] !== $script['filename'])->toArray();
ray($collection->filter(fn ($s) => $s['filename'] !== $script['filename'])->toArray());
$this->database->init_scripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename'])->toArray();
$this->database->save();
$this->refresh();
$this->emit('success', 'Init script deleted successfully.');

View File

@@ -2,12 +2,12 @@
namespace App\Http\Livewire\Settings;
use App\Jobs\DatabaseBackupJob;
use App\Models\InstanceSettings;
use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use App\Models\Server;
use App\Models\StandalonePostgresql;
use App\Jobs\DatabaseBackupJob;
use Livewire\Component;
class Backup extends Component
@@ -16,6 +16,7 @@ class Backup extends Component
public $s3s;
public StandalonePostgresql|null $database = null;
public ScheduledDatabaseBackup|null $backup = null;
public $executions = [];
protected $rules = [
'database.uuid' => 'required',
@@ -33,9 +34,13 @@ class Backup extends Component
'database.postgres_password' => 'postgres password',
];
public function mount()
{
$this->backup = $this->database->scheduledBackups->first();
$this->executions = $this->backup->executions;
}
public function add_coolify_database()
{
ray('add_coolify_database');
$server = Server::find(0);
$out = instant_remote_process(['docker inspect coolify-db'], $server);
$envs = format_docker_envs_to_json($out);
@@ -68,7 +73,8 @@ class Backup extends Component
$this->s3s = S3Storage::whereTeamId(0)->get();
}
public function backup_now() {
public function backup_now()
{
dispatch(new DatabaseBackupJob(
backup: $this->backup
));
@@ -78,5 +84,4 @@ class Backup extends Component
{
$this->emit('success', 'Backup updated successfully');
}
}

View File

@@ -77,35 +77,35 @@ class Configuration extends Component
$schema = $url->getScheme();
$traefik_dynamic_conf = [
'http' =>
[
'routers' =>
[
'routers' =>
[
'coolify-http' =>
[
'entryPoints' => [
0 => 'http',
],
'service' => 'coolify',
'rule' => "Host(`{$host}`)",
],
],
'services' =>
[
'coolify' =>
[
'loadBalancer' =>
[
'servers' =>
[
0 =>
[
'url' => 'http://coolify:80',
],
],
],
],
'coolify-http' =>
[
'entryPoints' => [
0 => 'http',
],
'service' => 'coolify',
'rule' => "Host(`{$host}`)",
],
],
'services' =>
[
'coolify' =>
[
'loadBalancer' =>
[
'servers' =>
[
0 =>
[
'url' => 'http://coolify:80',
],
],
],
],
],
],
];
if ($schema === 'https') {

View File

@@ -70,7 +70,6 @@ class Create extends Component
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}
}
private function test_s3_connection()

View File

@@ -20,7 +20,7 @@ class TrustProxies extends Middleware
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |