server forms

This commit is contained in:
Andras Bacsai 2023-04-25 10:47:13 +02:00
parent 50316c9cf6
commit 18a2d0bd90
13 changed files with 90 additions and 32 deletions

View File

@ -1,17 +0,0 @@
<?php
namespace App\Http\Controllers;
class HomeController extends Controller
{
public function show()
{
$projects = session('currentTeam')->load(['projects'])->projects;
$servers = session('currentTeam')->load(['servers'])->servers;
return view('home', [
'servers' => $servers,
'projects' => $projects
]);
}
}

View File

@ -68,6 +68,7 @@ class General extends Component
} }
public function submit() public function submit()
{ {
$this->validate();
$this->application->save(); $this->application->save();
} }
} }

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Livewire\Server;
use App\Models\Server;
use Illuminate\Support\Facades\Validator;
use Livewire\Component;
class Form extends Component
{
public $server_id;
public Server $server;
protected $rules = [
'server.name' => 'required|min:6',
'server.description' => 'nullable',
'server.ip' => 'required',
'server.user' => 'required',
'server.port' => 'required',
];
public function mount()
{
$this->server = Server::find($this->server_id);
}
public function submit()
{
$this->validate();
// $validation = Validator::make($this->server->toArray(), [
// 'ip' => [
// 'ip'
// ],
// ]);
// if ($validation->fails()) {
// foreach ($validation->errors()->getMessages() as $key => $value) {
// $this->addError("server.{$key}", $value[0]);
// }
// return;
// }
$this->server->save();
}
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Http\Livewire\Settings;
use App\Models\InstanceSettings as ModelsInstanceSettings; use App\Models\InstanceSettings as ModelsInstanceSettings;
use Livewire\Component; use Livewire\Component;
class InstanceSettings extends Component class Form extends Component
{ {
public ModelsInstanceSettings $settings; public ModelsInstanceSettings $settings;
public $do_not_track; public $do_not_track;
@ -41,6 +41,7 @@ class InstanceSettings extends Component
$this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.'); $this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.');
return; return;
} }
$this->validate();
$this->settings->save(); $this->settings->save();
} }
} }

View File

@ -395,7 +395,6 @@ class DeployApplicationJob implements ShouldQueue
if ($this->source->is_public) { if ($this->source->is_public) {
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository}.git {$this->workdir}"; $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository}.git {$this->workdir}";
$git_clone_command = $this->setGitImportSettings($git_clone_command); $git_clone_command = $this->setGitImportSettings($git_clone_command);
dump($git_clone_command);
return [ return [
$this->execute_in_builder($git_clone_command) $this->execute_in_builder($git_clone_command)
]; ];

View File

@ -14,7 +14,6 @@ class InstanceSettingsSeeder extends Seeder
{ {
InstanceSettings::create([ InstanceSettings::create([
'id' => 0, 'id' => 0,
'wildcard_domain' => 'coolify.io',
'is_https_forced' => false, 'is_https_forced' => false,
'is_registration_enabled' => true, 'is_registration_enabled' => true,
]); ]);

View File

@ -10,7 +10,7 @@ class ProjectSettingSeeder extends Seeder
public function run(): void public function run(): void
{ {
$first_project = Project::find(1); $first_project = Project::find(1);
$first_project->settings->wildcard_domain = 'wildcard.example.com'; // $first_project->settings->wildcard_domain = 'wildcard.example.com';
$first_project->settings->save(); $first_project->settings->save();
} }
} }

View File

@ -1,14 +1,14 @@
<x-layout> <x-layout>
<h1>Servers</h1>
@forelse ($servers as $server)
<a href="{{ route('project.environments', [$server->uuid]) }}">{{ data_get($server, 'name') }}</a>
@empty
<p>No servers found.</p>
@endforelse
<h1>Projects</h1> <h1>Projects</h1>
@forelse ($projects as $project) @forelse ($projects as $project)
<a href="{{ route('project.environments', [$project->uuid]) }}">{{ data_get($project, 'name') }}</a> <a href="{{ route('project.environments', [$project->uuid]) }}">{{ data_get($project, 'name') }}</a>
@empty @empty
<p>No projects found.</p> <p>No projects found.</p>
@endforelse @endforelse
<h1>Servers</h1>
@forelse ($servers as $server)
<a href="{{ route('server.dashboard', [$server->uuid]) }}">{{ data_get($server, 'name') }}</a>
@empty
<p>No servers found.</p>
@endforelse
</x-layout> </x-layout>

View File

@ -0,0 +1,18 @@
<div>
<form wire:submit.prevent='submit' class="flex flex-col">
<div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-96">
<x-input name="server.name" label="Name" required />
<x-input name="server.description" label="Description" />
</div>
<div class="flex flex-col w-96">
<x-input name="server.ip" label="IP Address" required />
<x-input name="server.user" label="User" required />
<x-input type="number" name="server.port" label="Port" required />
</div>
</div>
<button class="w-16 mt-4" type="submit">
Submit
</button>
</form>
</div>

View File

@ -10,7 +10,7 @@
<x-input type="number" name="settings.public_port_max" label="Public Port Max" /> <x-input type="number" name="settings.public_port_max" label="Public Port Max" />
</div> </div>
</div> </div>
<button class="flex mx-auto mt-4" type="submit"> <button class="w-16 mt-4" type="submit">
Submit Submit
</button> </button>
</form> </form>

View File

@ -0,0 +1,4 @@
<x-layout>
<h1>Server</h1>
<livewire:server.form :server_id="$server_id" />
</x-layout>

View File

@ -1,4 +1,4 @@
<x-layout> <x-layout>
<h1>Settings</h1> <h1>Settings</h1>
<livewire:instance-settings :settings="$settings" /> <livewire:settings.form :settings="$settings" />
</x-layout> </x-layout>

View File

@ -24,8 +24,8 @@ Route::middleware(['auth'])->group(function () {
$projects = session('currentTeam')->load(['projects'])->projects; $projects = session('currentTeam')->load(['projects'])->projects;
$servers = session('currentTeam')->load(['servers'])->servers; $servers = session('currentTeam')->load(['servers'])->servers;
return view('home', [ return view('home', [
'servers' => $servers, 'servers' => $servers->sortBy('name'),
'projects' => $projects 'projects' => $projects->sortBy('name')
]); ]);
})->name('home'); })->name('home');
@ -54,6 +54,18 @@ Route::middleware(['auth'])->group(function () {
})->name('demo'); })->name('demo');
}); });
Route::middleware(['auth'])->group(function () {
Route::get('/server/{server_uuid}', function () {
$server = session('currentTeam')->load(['servers'])->servers->firstWhere('uuid', request()->server_uuid);
if (!$server) {
abort(404);
}
return view('server.dashboard', [
'server_id' => $server->id,
]);
})->name('server.dashboard');
});
Route::middleware(['auth'])->group(function () { Route::middleware(['auth'])->group(function () {
Route::get( Route::get(
'/project/{project_uuid}', '/project/{project_uuid}',