From 07c952d75b10a5a3da920caead972ee36f6d9e5e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 25 Apr 2023 09:38:05 +0200 Subject: [PATCH] rename instance settings --- app/Jobs/DeployApplicationJob.php | 4 +- ...tanceSettings.php => InstanceSettings.php} | 2 +- app/Models/User.php | 4 +- ...112813_create_instance_settings_table.php} | 4 +- .../seeders/CoolifyInstanceSettingsSeeder.php | 28 -------- database/seeders/DatabaseSeeder.php | 2 +- database/seeders/InstanceSettingsSeeder.php | 22 ++++++ resources/views/components/navbar.blade.php | 3 + resources/views/settings.blade.php | 4 ++ routes/web.php | 68 +++++++++++++++---- 10 files changed, 91 insertions(+), 50 deletions(-) rename app/Models/{CoolifyInstanceSettings.php => InstanceSettings.php} (77%) rename database/migrations/{2023_03_20_112813_create_coolify_instance_settings_table.php => 2023_03_20_112813_create_instance_settings_table.php} (89%) delete mode 100644 database/seeders/CoolifyInstanceSettingsSeeder.php create mode 100644 database/seeders/InstanceSettingsSeeder.php create mode 100644 resources/views/settings.blade.php diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index ac2a87ddb..fb3844e8f 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -6,7 +6,7 @@ use App\Data\RemoteProcessArgs; use App\Enums\ActivityTypes; use App\Models\Application; -use App\Models\CoolifyInstanceSettings; +use App\Models\InstanceSettings; use DateTimeImmutable; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -77,7 +77,7 @@ public function __construct( public function handle(): void { try { - $coolify_instance_settings = CoolifyInstanceSettings::find(1); + $coolify_instance_settings = InstanceSettings::find(0); $this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first(); // Get Wildcard Domain diff --git a/app/Models/CoolifyInstanceSettings.php b/app/Models/InstanceSettings.php similarity index 77% rename from app/Models/CoolifyInstanceSettings.php rename to app/Models/InstanceSettings.php index b803d2e25..fa9dfa1f8 100644 --- a/app/Models/CoolifyInstanceSettings.php +++ b/app/Models/InstanceSettings.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class CoolifyInstanceSettings extends Model +class InstanceSettings extends Model { use HasFactory; } diff --git a/app/Models/User.php b/app/Models/User.php index 0f1a8a7c2..877ad2c0b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -52,7 +52,9 @@ protected static function boot() $model->uuid = (string) new Cuid2(7); }); } - + public function isRoot() { + return $this->id == 0; + } public function teams() { return $this->belongsToMany(Team::class); diff --git a/database/migrations/2023_03_20_112813_create_coolify_instance_settings_table.php b/database/migrations/2023_03_20_112813_create_instance_settings_table.php similarity index 89% rename from database/migrations/2023_03_20_112813_create_coolify_instance_settings_table.php rename to database/migrations/2023_03_20_112813_create_instance_settings_table.php index 7c81fb26b..d68649e7a 100644 --- a/database/migrations/2023_03_20_112813_create_coolify_instance_settings_table.php +++ b/database/migrations/2023_03_20_112813_create_instance_settings_table.php @@ -11,7 +11,7 @@ */ public function up(): void { - Schema::create('coolify_instance_settings', function (Blueprint $table) { + Schema::create('instance_settings', function (Blueprint $table) { $table->id(); $table->string('fqdn')->nullable(); $table->string('wildcard_domain')->nullable(); @@ -36,6 +36,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('coolify_instance_settings'); + Schema::dropIfExists('instance_settings'); } }; diff --git a/database/seeders/CoolifyInstanceSettingsSeeder.php b/database/seeders/CoolifyInstanceSettingsSeeder.php deleted file mode 100644 index 8f5625d60..000000000 --- a/database/seeders/CoolifyInstanceSettingsSeeder.php +++ /dev/null @@ -1,28 +0,0 @@ - 1, - 'wildcard_domain' => 'coolify.io', - 'is_https_forced' => false, - 'is_registration_enabled' => true, - ]); - } -} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a5bcd329a..9e1e78669 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -9,7 +9,7 @@ class DatabaseSeeder extends Seeder public function run(): void { $this->call([ - CoolifyInstanceSettingsSeeder::class, + InstanceSettingsSeeder::class, UserSeeder::class, TeamSeeder::class, PrivateKeySeeder::class, diff --git a/database/seeders/InstanceSettingsSeeder.php b/database/seeders/InstanceSettingsSeeder.php new file mode 100644 index 000000000..b8a8d1229 --- /dev/null +++ b/database/seeders/InstanceSettingsSeeder.php @@ -0,0 +1,22 @@ + 0, + 'wildcard_domain' => 'coolify.io', + 'is_https_forced' => false, + 'is_registration_enabled' => true, + ]); + } +} diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 87d944886..fc581d903 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -10,6 +10,9 @@ Demo @endenv Profile + @if (auth()->user()->isRoot()) + Settings + @endif
@csrf diff --git a/resources/views/settings.blade.php b/resources/views/settings.blade.php new file mode 100644 index 000000000..de7941cf9 --- /dev/null +++ b/resources/views/settings.blade.php @@ -0,0 +1,4 @@ + +

Settings

+ +
diff --git a/routes/web.php b/routes/web.php index e949df4af..a28e74256 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,7 @@ use App\Http\Controllers\ApplicationController; use App\Http\Controllers\HomeController; use App\Http\Controllers\ProjectController; +use App\Models\InstanceSettings; use Illuminate\Support\Facades\Route; /* @@ -19,26 +20,63 @@ Route::middleware(['auth'])->group(function () { - Route::get('/', [HomeController::class, 'show'])->name('home'); - Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments'); - - Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources'); - - Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.applications.configuration'); - Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.applications.deployments'); - Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ApplicationController::class, 'deployment'])->name('project.applications.deployment'); - - - // Route::get('/database/{database_uuid}', [ProjectController::class, 'database'])->name('project.database'); - // Route::get('//service/{service_uuid}', [ProjectController::class, 'service'])->name('project.service'); + Route::get('/', function () { + $projects = session('currentTeam')->load(['projects'])->projects; + $servers = session('currentTeam')->load(['servers'])->servers; + return view('home', [ + 'servers' => $servers, + 'projects' => $projects + ]); + })->name('home'); Route::get('/profile', function () { return view('profile'); - }); + })->name('profile'); + + Route::get('/settings', function () { + $isRoot = auth()->user()->isRoot(); + if ($isRoot) { + $settings = InstanceSettings::find(0); + return view('settings', [ + 'settings' => $settings + ]); + } else { + return redirect()->route('home'); + } + })->name('settings'); + Route::get('/update', function () { return view('update'); - }); + })->name('update'); + Route::get('/demo', function () { return view('demo'); - }); + })->name('demo'); +}); + +Route::middleware(['auth'])->group(function () { + Route::get( + '/project/{project_uuid}', + [ProjectController::class, 'environments'] + )->name('project.environments'); + + Route::get( + '/project/{project_uuid}/{environment_name}', + [ProjectController::class, 'resources'] + )->name('project.resources'); + + Route::get( + '/project/{project_uuid}/{environment_name}/application/{application_uuid}', + [ApplicationController::class, 'configuration'] + )->name('project.applications.configuration'); + + Route::get( + '/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', + [ApplicationController::class, 'deployments'] + )->name('project.applications.deployments'); + + Route::get( + '/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', + [ApplicationController::class, 'deployment'] + )->name('project.applications.deployment'); });