rename instance settings

This commit is contained in:
Andras Bacsai 2023-04-25 09:38:05 +02:00
parent 85a311b3ae
commit 07c952d75b
10 changed files with 91 additions and 50 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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');
}
};

View File

@ -1,28 +0,0 @@
<?php
namespace Database\Seeders;
use App\Models\Application;
use App\Models\ApplicationSetting;
use App\Models\CoolifyInstanceSettings;
use App\Models\Environment;
use App\Models\GithubApp;
use App\Models\StandaloneDocker;
use App\Models\SwarmDocker;
use Illuminate\Database\Seeder;
class CoolifyInstanceSettingsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
CoolifyInstanceSettings::create([
'id' => 1,
'wildcard_domain' => 'coolify.io',
'is_https_forced' => false,
'is_registration_enabled' => true,
]);
}
}

View File

@ -9,7 +9,7 @@ class DatabaseSeeder extends Seeder
public function run(): void
{
$this->call([
CoolifyInstanceSettingsSeeder::class,
InstanceSettingsSeeder::class,
UserSeeder::class,
TeamSeeder::class,
PrivateKeySeeder::class,

View File

@ -0,0 +1,22 @@
<?php
namespace Database\Seeders;
use App\Models\InstanceSettings;
use Illuminate\Database\Seeder;
class InstanceSettingsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
InstanceSettings::create([
'id' => 0,
'wildcard_domain' => 'coolify.io',
'is_https_forced' => false,
'is_registration_enabled' => true,
]);
}
}

View File

@ -10,6 +10,9 @@
<a href="/demo">Demo</a>
@endenv
<a href="/profile">Profile</a>
@if (auth()->user()->isRoot())
<a href="/settings">Settings</a>
@endif
<form action="/logout" method="POST">
@csrf
<button type="submit">Logout</button>

View File

@ -0,0 +1,4 @@
<x-layout>
<h1>Settings</h1>
</x-layout>

View File

@ -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');
});