testing php storm code cleanup and styling

This commit is contained in:
Andras Bacsai
2023-08-08 11:51:36 +02:00
parent a8ee779b31
commit f2228cec7b
368 changed files with 23834 additions and 2623 deletions

View File

@@ -5,12 +5,11 @@ namespace App\Http\Controllers;
use App\Models\ApplicationDeploymentQueue;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Spatie\Activitylog\Models\Activity;
class ApplicationController extends Controller
{
use AuthorizesRequests, ValidatesRequests;
public function configuration()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
@@ -28,6 +27,7 @@ class ApplicationController extends Controller
ray($application->persistentStorages()->get());
return view('project.application.configuration', ['application' => $application]);
}
public function deployments()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();

View File

@@ -2,17 +2,15 @@
namespace App\Http\Controllers;
use App\Http\Livewire\Team\Invitations;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\S3Storage;
use App\Models\Server;
use App\Models\TeamInvitation;
use App\Models\User;
use App\Models\S3Storage;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;
class Controller extends BaseController
{
@@ -27,6 +25,7 @@ class Controller extends BaseController
'settings' => InstanceSettings::get()
]);
}
public function license()
{
if (!isCloud()) {
@@ -36,6 +35,7 @@ class Controller extends BaseController
'settings' => InstanceSettings::get()
]);
}
public function dashboard()
{
$projects = Project::ownedByCurrentTeam()->get();
@@ -55,6 +55,7 @@ class Controller extends BaseController
's3s' => $s3s,
]);
}
public function settings()
{
if (auth()->user()->isInstanceAdmin()) {
@@ -66,6 +67,7 @@ class Controller extends BaseController
return redirect()->route('dashboard');
}
}
public function emails()
{
if (auth()->user()->isInstanceAdmin()) {
@@ -77,6 +79,7 @@ class Controller extends BaseController
return redirect()->route('dashboard');
}
}
public function team()
{
$invitations = [];
@@ -87,18 +90,23 @@ class Controller extends BaseController
'invitations' => $invitations,
]);
}
public function storages() {
public function storages()
{
$s3 = S3Storage::ownedByCurrentTeam()->get();
return view('team.storages.all', [
's3' => $s3,
]);
}
public function storages_show() {
public function storages_show()
{
$storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->firstOrFail();
return view('team.storages.show', [
'storage' => $storage,
]);
}
public function members()
{
$invitations = [];
@@ -109,6 +117,7 @@ class Controller extends BaseController
'invitations' => $invitations,
]);
}
public function acceptInvitation()
{
try {
@@ -135,6 +144,7 @@ class Controller extends BaseController
throw $th;
}
}
public function revokeInvitation()
{
try {
@@ -152,4 +162,4 @@ class Controller extends BaseController
throw $th;
}
}
}
}

View File

@@ -2,15 +2,13 @@
namespace App\Http\Controllers;
use App\Models\ApplicationDeploymentQueue;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Spatie\Activitylog\Models\Activity;
class DatabaseController extends Controller
{
use AuthorizesRequests, ValidatesRequests;
public function configuration()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();

View File

@@ -2,7 +2,6 @@
namespace App\Http\Controllers;
use App\Http\Livewire\Server\PrivateKey;
use App\Models\Environment;
use App\Models\Project;
use App\Models\Server;
@@ -16,24 +15,28 @@ class MagicController extends Controller
'servers' => Server::isUsable()->get()
]);
}
public function destinations()
{
return response()->json([
'destinations' => Server::destinationsByServer(request()->query('server_id'))->sortBy('name')
]);
}
public function projects()
{
return response()->json([
'projects' => Project::ownedByCurrentTeam()->get()
]);
}
public function environments()
{
return response()->json([
'environments' => Project::ownedByCurrentTeam()->whereUuid(request()->query('project_uuid'))->first()->environments
]);
}
public function newProject()
{
$project = Project::firstOrCreate(
@@ -44,6 +47,7 @@ class MagicController extends Controller
'project_uuid' => $project->uuid
]);
}
public function newEnvironment()
{
$environment = Environment::firstOrCreate(
@@ -54,6 +58,7 @@ class MagicController extends Controller
'environment_name' => $environment->name,
]);
}
public function newTeam()
{
$team = Team::create(

View File

@@ -25,6 +25,7 @@ class ProjectController extends Controller
}
return view('project.edit', ['project' => $project]);
}
public function show()
{
$projectUuid = request()->route('project_uuid');
@@ -55,6 +56,7 @@ class ProjectController extends Controller
'type' => $type
]);
}
public function resources()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();

View File

@@ -15,12 +15,6 @@ class ActivityMonitor extends Component
protected $activity;
protected $listeners = ['newMonitorActivity'];
public function hydrateActivity()
{
$this->activity = Activity::query()
->find($this->activityId);
}
public function newMonitorActivity($activityId)
{
$this->activityId = $activityId;
@@ -30,6 +24,12 @@ class ActivityMonitor extends Component
$this->isPollingActive = true;
}
public function hydrateActivity()
{
$this->activity = Activity::query()
->find($this->activityId);
}
public function polling()
{
$this->hydrateActivity();
@@ -45,6 +45,7 @@ class ActivityMonitor extends Component
$this->emit('activityFinished');
}
}
protected function setStatus($status)
{
$this->activity->properties = $this->activity->properties->merge([
@@ -52,4 +53,4 @@ class ActivityMonitor extends Component
]);
$this->activity->save();
}
}
}

View File

@@ -19,11 +19,13 @@ class CheckLicense extends Component
'instance_id' => 'Instance Id (Do not change this)',
'settings.is_resale_license_active' => 'Is License Active',
];
public function mount()
{
$this->instance_id = config('app.id');
$this->settings = InstanceSettings::get();
}
public function submit()
{
$this->validate();

View File

@@ -18,11 +18,13 @@ class Form extends Component
'destination.network' => 'network',
'destination.server.ip' => 'IP Address',
];
public function submit()
{
$this->validate();
$this->destination->save();
}
public function delete()
{
try {

View File

@@ -5,9 +5,9 @@ namespace App\Http\Livewire\Destination\New;
use App\Models\Server;
use App\Models\StandaloneDocker as ModelsStandaloneDocker;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Str;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
use Illuminate\Support\Str;
class StandaloneDocker extends Component
{
@@ -28,6 +28,7 @@ class StandaloneDocker extends Component
'network' => 'network',
'server_id' => 'server'
];
public function mount()
{
if (request()->query('server_id')) {
@@ -44,15 +45,13 @@ class StandaloneDocker extends Component
}
$this->name = Str::kebab("{$this->servers->first()->name}-{$this->network}");
}
public function generate_name() {
public function generate_name()
{
$this->server = Server::find($this->server_id);
$this->name = Str::kebab("{$this->server->name}-{$this->network}");
}
private function createNetworkAndAttachToProxy()
{
instant_remote_process(['docker network create --attachable ' . $this->network], $this->server, throwError: false);
instant_remote_process(["docker network connect $this->network coolify-proxy"], $this->server, throwError: false);
}
public function submit()
{
$this->validate();
@@ -77,4 +76,10 @@ class StandaloneDocker extends Component
return general_error_handler(err: $e);
}
}
}
private function createNetworkAndAttachToProxy()
{
instant_remote_process(['docker network create --attachable ' . $this->network], $this->server, throwError: false);
instant_remote_process(["docker network connect $this->network coolify-proxy"], $this->server, throwError: false);
}
}

View File

@@ -10,6 +10,7 @@ class Show extends Component
{
public Server $server;
public Collection|array $networks = [];
public function scan()
{
$alreadyAddedNetworks = $this->server->standaloneDockers;

View File

@@ -4,33 +4,39 @@ namespace App\Http\Livewire\Dev;
use App\Models\S3Storage;
use Illuminate\Support\Facades\Storage;
use Livewire\WithFileUploads;
use Livewire\Component;
use Livewire\WithFileUploads;
class S3Test extends Component
{
use WithFileUploads;
public $s3;
public $file;
public function mount() {
public function mount()
{
$this->s3 = S3Storage::first();
}
public function save() {
public function save()
{
try {
$this->validate([
'file' => 'required|max:150', // 1MB Max
]);
set_s3_target($this->s3);
$this->file->storeAs('files', $this->file->getClientOriginalName(),'custom-s3');
$this->file->storeAs('files', $this->file->getClientOriginalName(), 'custom-s3');
$this->emit('success', 'File uploaded successfully.');
} catch (\Throwable $th) {
return general_error_handler($th, $this, false);
}
}
public function get_files()
{
set_s3_target($this->s3);
dd(Storage::disk('custom-s3')->files('files'));
}
}
}

View File

@@ -19,6 +19,7 @@ class DiscordSettings extends Component
protected $validationAttributes = [
'model.discord_webhook_url' => 'Discord Webhook',
];
public function instantSave()
{
try {
@@ -29,6 +30,14 @@ class DiscordSettings extends Component
$this->validate();
}
}
public function submit()
{
$this->resetErrorBag();
$this->validate();
$this->saveModel();
}
public function saveModel()
{
ray($this->model);
@@ -38,15 +47,10 @@ class DiscordSettings extends Component
}
$this->emit('success', 'Settings saved.');
}
public function submit()
{
$this->resetErrorBag();
$this->validate();
$this->saveModel();
}
public function sendTestNotification()
{
$this->model->notify(new Test);
$this->emit('success', 'Test notification sent.');
}
}
}

View File

@@ -37,6 +37,13 @@ class EmailSettings extends Component
'model.smtp_username' => 'Username',
'model.smtp_password' => 'Password',
];
public function mount()
{
$this->decrypt();
$this->emails = auth()->user()->email;
}
private function decrypt()
{
if (data_get($this->model, 'smtp_password')) {
@@ -46,11 +53,7 @@ class EmailSettings extends Component
}
}
}
public function mount()
{
$this->decrypt();
$this->emails = auth()->user()->email;
}
public function copyFromInstanceSettings()
{
$settings = InstanceSettings::get();
@@ -78,6 +81,23 @@ class EmailSettings extends Component
$this->emit('error', 'Instance SMTP settings are not enabled.');
}
}
public function sendTestNotification()
{
$this->model->notify(new Test($this->emails));
$this->emit('success', 'Test Email sent successfully.');
}
public function instantSave()
{
try {
$this->submit();
} catch (\Exception $e) {
$this->model->smtp_enabled = false;
$this->validate();
}
}
public function submit()
{
$this->resetErrorBag();
@@ -92,6 +112,7 @@ class EmailSettings extends Component
$this->model->smtp_recipients = str_replace(' ', '', $this->model->smtp_recipients);
$this->saveModel();
}
public function saveModel()
{
$this->model->save();
@@ -101,18 +122,4 @@ class EmailSettings extends Component
}
$this->emit('success', 'Settings saved.');
}
public function sendTestNotification()
{
$this->model->notify(new Test($this->emails));
$this->emit('success', 'Test Email sent successfully.');
}
public function instantSave()
{
try {
$this->submit();
} catch (\Exception $e) {
$this->model->smtp_enabled = false;
$this->validate();
}
}
}
}

View File

@@ -20,6 +20,7 @@ class Change extends Component
'private_key.description' => 'description',
'private_key.private_key' => 'private key'
];
public function delete()
{
try {
@@ -33,6 +34,7 @@ class Change extends Component
return general_error_handler(err: $e, that: $this);
}
}
public function changePrivateKey()
{
try {

View File

@@ -19,6 +19,7 @@ class Create extends Component
'name' => 'name',
'value' => 'private Key',
];
public function createPrivateKey()
{
$this->validate();

View File

@@ -17,12 +17,14 @@ class Form extends Component
protected $validationAttributes = [
'name' => 'name',
];
public function mount()
{
$this->userId = auth()->user()->id;
$this->name = auth()->user()->name;
$this->email = auth()->user()->email;
}
public function submit()
{

View File

@@ -17,6 +17,7 @@ class AddEmpty extends Component
'name' => 'Project Name',
'description' => 'Project Description',
];
public function submit()
{
try {

View File

@@ -17,6 +17,7 @@ class AddEnvironment extends Component
protected $validationAttributes = [
'name' => 'Environment Name',
];
public function submit()
{
try {

View File

@@ -10,10 +10,12 @@ class DeploymentLogs extends Component
public ApplicationDeploymentQueue $application_deployment_queue;
public $isKeepAliveOn = true;
protected $listeners = ['refreshQueue'];
public function refreshQueue()
{
$this->application_deployment_queue->refresh();
}
public function polling()
{
$this->emit('deploymentFinished');

View File

@@ -8,17 +8,16 @@ use App\Models\ApplicationDeploymentQueue;
use App\Models\Server;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Process;
use Livewire\Component;
use Illuminate\Support\Str;
use Livewire\Component;
class DeploymentNavbar extends Component
{
protected $listeners = ['deploymentFinished'];
public ApplicationDeploymentQueue $application_deployment_queue;
public Application $application;
public Server $server;
public bool $is_debug_enabled = false;
protected $listeners = ['deploymentFinished'];
public function mount()
{
@@ -26,10 +25,12 @@ class DeploymentNavbar extends Component
$this->server = $this->application->destination->server;
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
}
public function deploymentFinished()
{
$this->application_deployment_queue->refresh();
}
public function show_debug()
{
$this->application->settings->is_debug_enabled = !$this->application->settings->is_debug_enabled;
@@ -37,6 +38,7 @@ class DeploymentNavbar extends Component
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
$this->emit('refreshQueue');
}
public function cancel()
{
try {
@@ -66,4 +68,4 @@ class DeploymentNavbar extends Component
return general_error_handler(err: $e, that: $this);
}
}
}
}

View File

@@ -20,6 +20,7 @@ class Deployments extends Component
$this->current_url = url()->current();
$this->show_more();
}
private function show_more()
{
if (count($this->deployments) !== 0) {
@@ -30,10 +31,12 @@ class Deployments extends Component
return;
}
}
public function reload_deployments()
{
$this->load_deployments();
}
public function load_deployments(int|null $take = null)
{
if ($take) {

View File

@@ -4,8 +4,8 @@ namespace App\Http\Livewire\Project\Application;
use App\Models\Application;
use App\Models\InstanceSettings;
use Livewire\Component;
use Illuminate\Support\Str;
use Livewire\Component;
use Spatie\Url\Url;
class General extends Component
@@ -65,6 +65,7 @@ class General extends Component
'application.ports_exposes' => 'Ports exposes',
'application.ports_mappings' => 'Ports mappings',
];
public function instantSave()
{
// @TODO: find another way - if possible
@@ -86,6 +87,7 @@ class General extends Component
$this->emit('success', 'Application settings updated!');
$this->checkWildCardDomain();
}
protected function checkWildCardDomain()
{
$coolify_instance_settings = InstanceSettings::get();
@@ -93,6 +95,7 @@ class General extends Component
$this->global_wildcard_domain = data_get($coolify_instance_settings, 'wildcard_domain');
$this->wildcard_domain = $this->server_wildcard_domain ?? $this->global_wildcard_domain ?? null;
}
public function mount()
{
$this->is_static = $this->application->settings->is_static;
@@ -104,6 +107,7 @@ class General extends Component
$this->is_force_https_enabled = $this->application->settings->is_force_https_enabled;
$this->checkWildCardDomain();
}
public function generateGlobalRandomDomain()
{
// Set wildcard domain based on Global wildcard domain
@@ -115,6 +119,7 @@ class General extends Component
$this->application->save();
$this->emit('success', 'Application settings updated!');
}
public function generateServerRandomDomain()
{
// Set wildcard domain based on Server wildcard domain
@@ -126,6 +131,7 @@ class General extends Component
$this->application->save();
$this->emit('success', 'Application settings updated!');
}
public function submit()
{
try {

View File

@@ -28,6 +28,12 @@ class Heading extends Component
));
$this->application->refresh();
}
public function force_deploy_without_cache()
{
$this->deploy(force_rebuild: true);
}
public function deploy(bool $force_rebuild = false)
{
$this->setDeploymentUuid();
@@ -43,10 +49,13 @@ class Heading extends Component
'environment_name' => $this->parameters['environment_name'],
]);
}
public function force_deploy_without_cache()
protected function setDeploymentUuid()
{
$this->deploy(force_rebuild: true);
$this->deploymentUuid = new Cuid2(7);
$this->parameters['deployment_uuid'] = $this->deploymentUuid;
}
public function stop()
{
remote_process(
@@ -57,9 +66,4 @@ class Heading extends Component
$this->application->save();
$this->application->environment->project->team->notify(new StatusChanged($this->application));
}
protected function setDeploymentUuid()
{
$this->deploymentUuid = new Cuid2(7);
$this->parameters['deployment_uuid'] = $this->deploymentUuid;
}
}

View File

@@ -17,6 +17,7 @@ class Form extends Component
protected $validationAttributes = [
'application.preview_url_template' => 'preview url template',
];
public function resetToDefault()
{
$this->application->preview_url_template = '{{pr_id}}.{{domain}}';
@@ -24,6 +25,7 @@ class Form extends Component
$this->application->save();
$this->generate_real_url();
}
public function generate_real_url()
{
if (data_get($this->application, 'fqdn')) {
@@ -32,10 +34,12 @@ class Form extends Component
$this->preview_url_template = Str::of($this->application->preview_url_template)->replace('{{domain}}', $host);
}
}
public function mount()
{
$this->generate_real_url();
}
public function submit()
{
$this->validate();

View File

@@ -22,6 +22,7 @@ class Previews extends Component
$this->pull_requests = collect();
$this->parameters = getRouteParameters();
}
public function loadStatus($pull_request_id)
{
dispatch(new ContainerStatusJob(
@@ -30,11 +31,7 @@ class Previews extends Component
pull_request_id: $pull_request_id
));
}
protected function setDeploymentUuid()
{
$this->deployment_uuid = new Cuid2(7);
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
}
public function load_prs()
{
try {
@@ -46,6 +43,7 @@ class Previews extends Component
return general_error_handler(err: $e, that: $this);
}
}
public function deploy(int $pull_request_id, string|null $pull_request_html_url = null)
{
try {
@@ -74,6 +72,13 @@ class Previews extends Component
return general_error_handler(err: $e, that: $this);
}
}
protected function setDeploymentUuid()
{
$this->deployment_uuid = new Cuid2(7);
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
}
public function stop(int $pull_request_id)
{
try {
@@ -87,6 +92,7 @@ class Previews extends Component
return general_error_handler(err: $e, that: $this);
}
}
public function previewRefresh()
{
$this->application->previews->each(function ($preview) {

View File

@@ -3,8 +3,8 @@
namespace App\Http\Livewire\Project\Application;
use App\Models\Application;
use Livewire\Component;
use Illuminate\Support\Str;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
class Rollback extends Component
@@ -18,6 +18,7 @@ class Rollback extends Component
{
$this->parameters = getRouteParameters();
}
public function rollbackImage($commit)
{
$deployment_uuid = new Cuid2(7);
@@ -36,6 +37,7 @@ class Rollback extends Component
'environment_name' => $this->parameters['environment_name'],
]);
}
public function loadImages()
{
try {

View File

@@ -21,16 +21,19 @@ class Source extends Component
'application.git_branch' => 'branch',
'application.git_commit_sha' => 'commit sha',
];
public function mount()
{
$this->get_private_keys();
}
private function get_private_keys()
{
$this->private_keys = PrivateKey::whereTeamId(session('currentTeam')->id)->get()->reject(function ($key) {
return $key->id == $this->application->private_key_id;
});
}
public function mount()
{
$this->get_private_keys();
}
public function setPrivateKey(int $private_key_id)
{
$this->application->private_key_id = $private_key_id;
@@ -38,6 +41,7 @@ class Source extends Component
$this->application->refresh();
$this->get_private_keys();
}
public function submit()
{
$this->validate();

View File

@@ -2,10 +2,10 @@
namespace App\Http\Livewire\Project\Database;
use Livewire\Component;
use App\Actions\Database\StartPostgresql;
use App\Jobs\ContainerStatusJob;
use App\Notifications\Application\StatusChanged;
use Livewire\Component;
class Heading extends Component
{
@@ -13,13 +13,16 @@ class Heading extends Component
public array $parameters;
protected $listeners = ['activityFinished'];
public function activityFinished() {
public function activityFinished()
{
$this->database->update([
'started_at' => now(),
]);
$this->emit('refresh');
$this->check_status();
}
public function check_status()
{
dispatch_sync(new ContainerStatusJob(
@@ -28,11 +31,14 @@ class Heading extends Component
));
$this->database->refresh();
}
public function mount()
{
$this->parameters = getRouteParameters();
}
public function stop() {
public function stop()
{
remote_process(
["docker rm -f {$this->database->uuid}"],
$this->database->destination->server
@@ -41,7 +47,9 @@ class Heading extends Component
$this->database->save();
$this->database->environment->project->team->notify(new StatusChanged($this->database));
}
public function start() {
public function start()
{
if ($this->database->type() === 'standalone-postgresql') {
$activity = resolve(StartPostgresql::class)($this->database->destination->server, $this->database);
$this->emit('newMonitorActivity', $activity->id);

View File

@@ -31,10 +31,14 @@ class General extends Component
'database.init_scripts' => 'Init Scripts',
'database.image' => 'Image',
];
public function refresh() {
public function refresh(): void
{
$this->database->refresh();
}
public function submit() {
public function submit()
{
try {
$this->validate();
$this->database->save();

View File

@@ -14,6 +14,7 @@ class DeleteEnvironment extends Component
{
$this->parameters = getRouteParameters();
}
public function delete()
{
$this->validate([

View File

@@ -14,6 +14,7 @@ class DeleteProject extends Component
{
$this->parameters = getRouteParameters();
}
public function delete()
{
$this->validate([

View File

@@ -5,12 +5,9 @@ namespace App\Http\Livewire\Project\New;
use App\Models\Application;
use App\Models\GithubApp;
use App\Models\Project;
use App\Models\Server;
use App\Models\StandaloneDocker;
use App\Models\SwarmDocker;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
class GithubPrivateRepository extends Component
@@ -30,18 +27,14 @@ class GithubPrivateRepository extends Component
public string $selected_branch_name = 'main';
public string $token;
protected int $page = 1;
public $repositories;
public int $total_repositories_count = 0;
public $branches;
public int $total_branches_count = 0;
public int $port = 3000;
public bool $is_static = false;
public string|null $publish_directory = null;
protected int $page = 1;
public function mount()
{
@@ -50,32 +43,7 @@ class GithubPrivateRepository extends Component
$this->repositories = $this->branches = collect();
$this->github_apps = GithubApp::private();
}
protected function loadRepositoryByPage()
{
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/installation/repositories?per_page=100&page={$this->page}");
$json = $response->json();
if ($response->status() !== 200) {
return $this->emit('error', $json['message']);
}
if ($json['total_count'] === 0) {
return;
}
$this->total_repositories_count = $json['total_count'];
$this->repositories = $this->repositories->concat(collect($json['repositories']));
}
protected function loadBranchByPage()
{
ray('Loading page ' . $this->page);
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches?per_page=100&page={$this->page}");
$json = $response->json();
if ($response->status() !== 200) {
return $this->emit('error', $json['message']);
}
$this->total_branches_count = count($json);
$this->branches = $this->branches->concat(collect($json));
}
public function loadRepositories($github_app_id)
{
$this->repositories = collect();
@@ -93,6 +61,22 @@ class GithubPrivateRepository extends Component
$this->selected_repository_id = $this->repositories[0]['id'];
$this->current_step = 'repository';
}
protected function loadRepositoryByPage()
{
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/installation/repositories?per_page=100&page={$this->page}");
$json = $response->json();
if ($response->status() !== 200) {
return $this->emit('error', $json['message']);
}
if ($json['total_count'] === 0) {
return;
}
$this->total_repositories_count = $json['total_count'];
$this->repositories = $this->repositories->concat(collect($json['repositories']));
}
public function loadBranches()
{
$this->selected_repository_owner = $this->repositories->where('id', $this->selected_repository_id)->first()['owner']['login'];
@@ -107,6 +91,20 @@ class GithubPrivateRepository extends Component
}
}
}
protected function loadBranchByPage()
{
ray('Loading page ' . $this->page);
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/repos/{$this->selected_repository_owner}/{$this->selected_repository_repo}/branches?per_page=100&page={$this->page}");
$json = $response->json();
if ($response->status() !== 200) {
return $this->emit('error', $json['message']);
}
$this->total_branches_count = count($json);
$this->branches = $this->branches->concat(collect($json));
}
public function submit()
{
try {
@@ -136,7 +134,7 @@ class GithubPrivateRepository extends Component
'destination_id' => $destination->id,
'destination_type' => $destination_class,
'source_id' => $this->github_app->id,
'source_type' => $this->github_app->getMorphClass()
'source_type' => $this->github_app->getMorphClass()
]);
$application->settings->is_static = $this->is_static;
$application->settings->save();
@@ -150,6 +148,7 @@ class GithubPrivateRepository extends Component
return general_error_handler(err: $e, that: $this);
}
}
public function instantSave()
{
if ($this->is_static) {

View File

@@ -27,14 +27,7 @@ class GithubPrivateRepositoryDeployKey extends Component
public null|string $publish_directory = null;
public string $repository_url;
private object $repository_url_parsed;
public string $branch;
private GithubApp|GitlabApp $git_source;
private string $git_host;
private string $git_repository;
private string $git_branch;
protected $rules = [
'repository_url' => 'required|url',
'branch' => 'required|string',
@@ -49,6 +42,12 @@ class GithubPrivateRepositoryDeployKey extends Component
'is_static' => 'Is static',
'publish_directory' => 'Publish directory',
];
private object $repository_url_parsed;
private GithubApp|GitlabApp $git_source;
private string $git_host;
private string $git_repository;
private string $git_branch;
public function mount()
{
if (isDev()) {
@@ -58,6 +57,7 @@ class GithubPrivateRepositoryDeployKey extends Component
$this->query = request()->query();
$this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->where('id', '!=', 0)->get();
}
public function instantSave()
{
if ($this->is_static) {
@@ -68,30 +68,13 @@ class GithubPrivateRepositoryDeployKey extends Component
$this->publish_directory = null;
}
}
public function setPrivateKey($private_key_id)
{
$this->private_key_id = $private_key_id;
$this->current_step = 'repository';
}
private function get_git_source()
{
$this->repository_url_parsed = Url::fromString($this->repository_url);
$this->git_host = $this->repository_url_parsed->getHost();
$this->git_repository = $this->repository_url_parsed->getSegment(1) . '/' . $this->repository_url_parsed->getSegment(2);
if ($this->branch) {
$this->git_branch = $this->branch;
} else {
$this->git_branch = $this->repository_url_parsed->getSegment(4) ?? 'main';
}
if ($this->git_host == 'github.com') {
$this->git_source = GithubApp::where('name', 'Public GitHub')->first();
} elseif ($this->git_host == 'gitlab.com') {
$this->git_source = GitlabApp::where('name', 'Public GitLab')->first();
} elseif ($this->git_host == 'bitbucket.org') {
// Not supported yet
}
}
public function submit()
{
$this->validate();
@@ -123,7 +106,7 @@ class GithubPrivateRepositoryDeployKey extends Component
'destination_type' => $destination_class,
'private_key_id' => $this->private_key_id,
'source_id' => $this->git_source->id,
'source_type' => $this->git_source->getMorphClass()
'source_type' => $this->git_source->getMorphClass()
];
$application = Application::create($application_init);
$application->settings->is_static = $this->is_static;
@@ -138,4 +121,24 @@ class GithubPrivateRepositoryDeployKey extends Component
return general_error_handler(err: $e, that: $this);
}
}
private function get_git_source()
{
$this->repository_url_parsed = Url::fromString($this->repository_url);
$this->git_host = $this->repository_url_parsed->getHost();
$this->git_repository = $this->repository_url_parsed->getSegment(1) . '/' . $this->repository_url_parsed->getSegment(2);
if ($this->branch) {
$this->git_branch = $this->branch;
} else {
$this->git_branch = $this->repository_url_parsed->getSegment(4) ?? 'main';
}
if ($this->git_host == 'github.com') {
$this->git_source = GithubApp::where('name', 'Public GitHub')->first();
} elseif ($this->git_host == 'gitlab.com') {
$this->git_source = GitlabApp::where('name', 'Public GitLab')->first();
} elseif ($this->git_host == 'bitbucket.org') {
// Not supported yet
}
}
}

View File

@@ -15,13 +15,10 @@ use Spatie\Url\Url;
class PublicGitRepository extends Component
{
public string $repository_url;
private object $repository_url_parsed;
public int $port = 3000;
public string $type;
public $parameters;
public $query;
public bool $branch_found = false;
public string $selected_branch = 'main';
public bool $is_static = false;
@@ -29,11 +26,6 @@ class PublicGitRepository extends Component
public string $git_branch = 'main';
public int $rate_limit_remaining = 0;
public $rate_limit_reset = 0;
private GithubApp|GitlabApp $git_source;
private string $git_host;
private string $git_repository;
protected $rules = [
'repository_url' => 'required|url',
'port' => 'required|numeric',
@@ -46,6 +38,11 @@ class PublicGitRepository extends Component
'is_static' => 'static',
'publish_directory' => 'publish directory',
];
private object $repository_url_parsed;
private GithubApp|GitlabApp $git_source;
private string $git_host;
private string $git_repository;
public function mount()
{
if (isDev()) {
@@ -67,12 +64,7 @@ class PublicGitRepository extends Component
}
$this->emit('success', 'Application settings updated!');
}
private function get_branch()
{
['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = git_api(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}");
$this->rate_limit_reset = Carbon::parse((int)$this->rate_limit_reset)->format('Y-M-d H:i:s');
$this->branch_found = true;
}
public function load_branch()
{
$this->branch_found = false;
@@ -96,6 +88,7 @@ class PublicGitRepository extends Component
}
}
}
private function get_git_source()
{
$this->repository_url_parsed = Url::fromString($this->repository_url);
@@ -111,6 +104,14 @@ class PublicGitRepository extends Component
// Not supported yet
}
}
private function get_branch()
{
['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = git_api(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}");
$this->rate_limit_reset = Carbon::parse((int)$this->rate_limit_reset)->format('Y-M-d H:i:s');
$this->branch_found = true;
}
public function submit()
{
try {

View File

@@ -19,17 +19,20 @@ class Select extends Component
{
$this->parameters = getRouteParameters();
}
public function set_type(string $type)
{
$this->type = $type;
$this->current_step = 'servers';
}
public function set_server(Server $server)
{
$this->server_id = $server->id;
$this->destinations = $server->destinations();
$this->current_step = 'destinations';
}
public function set_destination(string $destination_uuid)
{
$this->destination_uuid = $destination_uuid;
@@ -40,6 +43,7 @@ class Select extends Component
'destination' => $this->destination_uuid,
]);
}
public function load_servers()
{
$this->servers = Server::ownedByCurrentTeam()->get();

View File

@@ -16,6 +16,7 @@ class Danger extends Component
$this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function delete()
{
$destination = $this->resource->destination->getMorphClass()::where('id', $this->resource->destination->id)->first();

View File

@@ -23,10 +23,12 @@ class Add extends Component
'value' => 'value',
'is_build_time' => 'build',
];
public function mount()
{
$this->parameters = getRouteParameters();
}
public function submit()
{
ray('submitting');
@@ -39,6 +41,7 @@ class Add extends Component
]);
$this->clear();
}
public function clear()
{
$this->key = '';

View File

@@ -11,14 +11,17 @@ class All extends Component
public $resource;
public string|null $modalId = null;
protected $listeners = ['refreshEnvs', 'submit'];
public function mount()
{
$this->modalId = new Cuid2(7);
}
public function refreshEnvs()
{
$this->resource->refresh();
}
public function submit($data)
{
try {
@@ -27,16 +30,16 @@ class All extends Component
$this->emit('error', 'Environment variable already exists.');
return;
}
$environment = new EnvironmentVariable();
$environment = new EnvironmentVariable();
$environment->key = $data['key'];
$environment->value = $data['value'];
$environment->is_build_time = $data['is_build_time'];
$environment->is_preview = $data['is_preview'];
if($this->resource->type() === 'application') {
if ($this->resource->type() === 'application') {
$environment->application_id = $this->resource->id;
}
if($this->resource->type() === 'standalone-postgresql') {
if ($this->resource->type() === 'standalone-postgresql') {
$environment->standalone_postgresql_id = $this->resource->id;
}
$environment->save();

View File

@@ -21,17 +21,20 @@ class Show extends Component
'value' => 'value',
'is_build_time' => 'build',
];
public function mount()
{
$this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function submit()
{
$this->validate();
$this->env->save();
$this->emit('success', 'Environment variable updated successfully.');
}
public function delete()
{
$this->env->delete();

View File

@@ -25,6 +25,7 @@ class ResourceLimits extends Component
'resource.limits_cpuset' => 'cpuset',
'resource.limits_cpu_shares' => 'cpu shares',
];
public function submit()
{
try {

View File

@@ -22,10 +22,12 @@ class Add extends Component
'mount_path' => 'mount',
'host_path' => 'host',
];
public function mount()
{
$this->parameters = getRouteParameters();
}
public function submit()
{
$this->validate();
@@ -35,6 +37,7 @@ class Add extends Component
'host_path' => $this->host_path,
]);
}
public function clear()
{
$this->name = '';

View File

@@ -9,10 +9,12 @@ class All extends Component
{
public $resource;
protected $listeners = ['refreshStorages', 'submit'];
public function refreshStorages()
{
$this->resource->refresh();
}
public function submit($data)
{
try {

View File

@@ -19,16 +19,19 @@ class Show extends Component
'mount_path' => 'mount',
'host_path' => 'host',
];
public function mount()
{
$this->modalId = new Cuid2(7);
}
public function submit()
{
$this->validate();
$this->storage->save();
$this->emit('success', 'Storage updated successfully');
}
public function delete()
{
$this->storage->delete();

View File

@@ -2,7 +2,6 @@
namespace App\Http\Livewire;
use App\Enums\ActivityTypes;
use App\Models\Server;
use Livewire\Component;
@@ -20,6 +19,7 @@ class RunCommand extends Component
'server' => 'server',
'command' => 'command',
];
public function mount($servers)
{
$this->servers = $servers;

View File

@@ -5,7 +5,6 @@ namespace App\Http\Livewire\Server;
use App\Actions\Server\InstallDocker;
use App\Models\Server;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
class Form extends Component
{
@@ -34,16 +33,19 @@ class Form extends Component
'server.settings.is_reachable' => 'is reachable',
'server.settings.is_part_of_swarm' => 'is part of swarm'
];
public function mount()
{
$this->wildcard_domain = $this->server->settings->wildcard_domain;
$this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
}
public function installDocker()
{
$activity = resolve(InstallDocker::class)($this->server, session('currentTeam'));
$this->emit('newMonitorActivity', $activity->id);
}
public function validateServer()
{
try {
@@ -59,6 +61,7 @@ class Form extends Component
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
}
}
public function delete()
{
if (!$this->server->isEmpty()) {
@@ -68,6 +71,7 @@ class Form extends Component
$this->server->delete();
redirect()->route('server.all');
}
public function submit()
{
$this->validate();
@@ -88,4 +92,4 @@ class Form extends Component
$this->server->save();
$this->emit('success', 'Server updated successfully.');
}
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Http\Livewire\Server\New;
use App\Models\PrivateKey;
use App\Models\Server;
use Livewire\Component;
@@ -35,19 +34,23 @@ class ByIp extends Component
'user' => 'user',
'port' => 'port',
];
public function mount()
{
$this->name = generate_random_name();
$this->private_key_id = $this->private_keys->first()->id;
}
public function setPrivateKey(string $private_key_id)
{
$this->private_key_id = $private_key_id;
}
public function instantSave()
{
$this->emit('success', 'Application settings updated!');
}
public function submit()
{
$this->validate();

View File

@@ -3,7 +3,6 @@
namespace App\Http\Livewire\Server;
use App\Models\Server;
use Illuminate\Support\Facades\Storage;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
@@ -13,6 +12,16 @@ class PrivateKey extends Component
public $privateKeys;
public $parameters;
public function setPrivateKey($private_key_id)
{
$this->server->update([
'private_key_id' => $private_key_id
]);
refreshPrivateKey($this->server->privateKey);
$this->server->refresh();
$this->checkConnection();
}
public function checkConnection()
{
try {
@@ -27,15 +36,7 @@ class PrivateKey extends Component
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
}
}
public function setPrivateKey($private_key_id)
{
$this->server->update([
'private_key_id' => $private_key_id
]);
refreshPrivateKey($this->server->privateKey);
$this->server->refresh();
$this->checkConnection();
}
public function mount()
{
$this->parameters = getRouteParameters();

View File

@@ -5,7 +5,6 @@ namespace App\Http\Livewire\Server;
use App\Actions\Proxy\CheckConfigurationSync;
use App\Actions\Proxy\SaveConfigurationSync;
use App\Enums\ProxyTypes;
use Illuminate\Support\Str;
use App\Models\Server;
use Livewire\Component;
@@ -17,21 +16,25 @@ class Proxy extends Component
public $proxy_settings = null;
public string|null $redirect_url = null;
protected $listeners = ['proxyStatusUpdated', 'saveConfiguration'=>'submit'];
protected $listeners = ['proxyStatusUpdated', 'saveConfiguration' => 'submit'];
public function mount()
{
$this->redirect_url = $this->server->proxy->redirect_url;
}
public function proxyStatusUpdated()
{
$this->server->refresh();
}
public function change_proxy()
{
$this->server->proxy = null;
$this->server->save();
$this->emit('proxyStatusUpdated');
}
public function select_proxy(string $proxy_type)
{
$this->server->proxy->type = $proxy_type;
@@ -39,6 +42,7 @@ class Proxy extends Component
$this->server->save();
$this->emit('proxyStatusUpdated');
}
public function submit()
{
try {
@@ -53,6 +57,7 @@ class Proxy extends Component
return general_error_handler(err: $e);
}
}
public function reset_proxy_configuration()
{
try {
@@ -61,6 +66,7 @@ class Proxy extends Component
return general_error_handler(err: $e);
}
}
public function load_proxy_configuration()
{
try {
@@ -69,4 +75,4 @@ class Proxy extends Component
return general_error_handler(err: $e);
}
}
}
}

View File

@@ -5,12 +5,12 @@ namespace App\Http\Livewire\Server\Proxy;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Livewire\Component;
use Str;
class Deploy extends Component
{
public Server $server;
public $proxy_settings = null;
public function start_proxy()
{
if (
@@ -22,6 +22,7 @@ class Deploy extends Component
$activity = resolve(StartProxy::class)($this->server);
$this->emit('newMonitorActivity', $activity->id);
}
public function stop()
{
instant_remote_process([
@@ -31,4 +32,4 @@ class Deploy extends Component
$this->server->save();
$this->emit('proxyStatusUpdated');
}
}
}

View File

@@ -9,6 +9,7 @@ use Livewire\Component;
class Status extends Component
{
public Server $server;
public function get_status()
{
dispatch_sync(new ProxyContainerStatusJob(
@@ -17,4 +18,4 @@ class Status extends Component
$this->server->refresh();
$this->emit('proxyStatusUpdated');
}
}
}

View File

@@ -31,6 +31,7 @@ class Configuration extends Component
'settings.public_port_min' => 'Public port min',
'settings.public_port_max' => 'Public port max',
];
public function mount()
{
$this->do_not_track = $this->settings->do_not_track;
@@ -38,6 +39,7 @@ class Configuration extends Component
$this->is_registration_enabled = $this->settings->is_registration_enabled;
$this->next_channel = $this->settings->next_channel;
}
public function instantSave()
{
$this->settings->do_not_track = $this->do_not_track;
@@ -47,6 +49,21 @@ class Configuration extends Component
$this->settings->save();
$this->emit('success', 'Settings updated!');
}
public function submit()
{
$this->resetErrorBag();
if ($this->settings->public_port_min > $this->settings->public_port_max) {
$this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.');
return;
}
$this->validate();
$this->settings->save();
$this->server = Server::findOrFail(0);
$this->setup_instance_fqdn();
$this->emit('success', 'Instance settings updated successfully!');
}
private function setup_instance_fqdn()
{
$file = "$this->dynamic_config_path/coolify.yaml";
@@ -60,35 +77,35 @@ class Configuration extends Component
$schema = $url->getScheme();
$traefik_dynamic_conf = [
'http' =>
[
'routers' =>
[
'coolify-http' =>
[
'entryPoints' => [
0 => 'http',
],
'service' => 'coolify',
'rule' => "Host(`{$host}`)",
],
],
'services' =>
[
'coolify' =>
[
'loadBalancer' =>
'routers' =>
[
'servers' =>
[
0 =>
'coolify-http' =>
[
'url' => 'http://coolify:80',
'entryPoints' => [
0 => 'http',
],
'service' => 'coolify',
'rule' => "Host(`{$host}`)",
],
],
'services' =>
[
'coolify' =>
[
'loadBalancer' =>
[
'servers' =>
[
0 =>
[
'url' => 'http://coolify:80',
],
],
],
],
],
],
],
],
],
];
if ($schema === 'https') {
@@ -110,6 +127,7 @@ class Configuration extends Component
dispatch(new ProxyStartJob($this->server));
}
}
private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file)
{
$yaml = Yaml::dump($traefik_dynamic_conf, 12, 2);
@@ -128,17 +146,4 @@ class Configuration extends Component
ray($yaml);
}
}
public function submit()
{
$this->resetErrorBag();
if ($this->settings->public_port_min > $this->settings->public_port_max) {
$this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.');
return;
}
$this->validate();
$this->settings->save();
$this->server = Server::findOrFail(0);
$this->setup_instance_fqdn();
$this->emit('success', 'Instance settings updated successfully!');
}
}

View File

@@ -4,7 +4,6 @@ namespace App\Http\Livewire\Settings;
use App\Models\InstanceSettings;
use App\Notifications\TransactionalEmails\Test;
use Illuminate\Support\Facades\Notification;
use Livewire\Component;
class Email extends Component
@@ -32,11 +31,23 @@ class Email extends Component
'settings.smtp_username' => 'Username',
'settings.smtp_password' => 'Password',
];
public function mount()
{
$this->decrypt();
$this->emails = auth()->user()->email;
}
private function decrypt()
{
if (data_get($this->settings, 'smtp_password')) {
try {
$this->settings->smtp_password = decrypt($this->settings->smtp_password);
} catch (\Exception $e) {
}
}
}
public function instantSave()
{
try {
@@ -47,20 +58,7 @@ class Email extends Component
$this->validate();
}
}
public function sendTestNotification()
{
$this->settings->notify(new Test($this->emails));
$this->emit('success', 'Test email sent.');
}
private function decrypt()
{
if (data_get($this->settings, 'smtp_password')) {
try {
$this->settings->smtp_password = decrypt($this->settings->smtp_password);
} catch (\Exception $e) {
}
}
}
public function submit()
{
$this->resetErrorBag();
@@ -75,4 +73,10 @@ class Email extends Component
$this->emit('success', 'Transaction email settings updated successfully.');
$this->decrypt();
}
}
public function sendTestNotification()
{
$this->settings->notify(new Test($this->emails));
$this->emit('success', 'Test email sent.');
}
}

View File

@@ -34,12 +34,14 @@ class Change extends Component
'github_app.webhook_secret' => 'nullable',
'github_app.is_system_wide' => 'required|bool',
];
public function mount()
{
$this->webhook_endpoint = $this->ipv4;
$this->parameters = getRouteParameters();
$this->is_system_wide = $this->github_app->is_system_wide;
}
public function submit()
{
try {
@@ -49,6 +51,7 @@ class Change extends Component
return general_error_handler(err: $e, that: $this);
}
}
public function instantSave()
{
}

View File

@@ -19,6 +19,7 @@ class Create extends Component
{
$this->name = generate_random_name();
}
public function createGitHubApp()
{
try {

View File

@@ -8,10 +8,12 @@ use Livewire\Component;
class SwitchTeam extends Component
{
public string $selectedTeamId = 'default';
public function updatedSelectedTeamId()
{
$this->switch_to($this->selectedTeamId);
}
public function switch_to($team_id)
{
if (!auth()->user()->teams->contains($team_id)) {

View File

@@ -18,6 +18,7 @@ class Create extends Component
'name' => 'name',
'description' => 'description',
];
public function submit()
{
$this->validate();

View File

@@ -4,7 +4,6 @@ namespace App\Http\Livewire\Team;
use App\Models\Team;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
class Form extends Component
{
@@ -17,10 +16,12 @@ class Form extends Component
'team.name' => 'name',
'team.description' => 'description',
];
public function mount()
{
$this->team = session('currentTeam');
}
public function submit()
{
$this->validate();

View File

@@ -9,13 +9,15 @@ class Invitations extends Component
{
public $invitations;
protected $listeners = ['refreshInvitations'];
public function refreshInvitations()
{
$this->invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();
}
public function deleteInvitation(int $invitation_id)
{
TeamInvitation::find($invitation_id)->delete();
$this->refreshInvitations();
}
public function refreshInvitations()
{
$this->invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();
}
}

View File

@@ -12,14 +12,17 @@ class InviteLink extends Component
{
public string $email;
public string $role = 'member';
public function mount()
{
$this->email = isDev() ? 'test3@example.com' : '';
}
public function viaEmail()
{
$this->generate_invite_link(isEmail: true);
}
private function generate_invite_link(bool $isEmail = false)
{
try {
@@ -72,8 +75,9 @@ class InviteLink extends Component
return general_error_handler(err: $e, that: $this, customErrorMessage: $error_message);
}
}
public function viaLink()
{
$this->generate_invite_link();
}
}
}

View File

@@ -8,16 +8,19 @@ use Livewire\Component;
class Member extends Component
{
public User $member;
public function makeAdmin()
{
$this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'admin']);
$this->emit('reloadWindow');
}
public function makeReadonly()
{
$this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'member']);
$this->emit('reloadWindow');
}
public function remove()
{
$this->member->teams()->detach(session('currentTeam'));

View File

@@ -2,8 +2,8 @@
namespace App\Http\Livewire\Team\Storage;
use Livewire\Component;
use App\Models\S3Storage;
use Livewire\Component;
class Create extends Component
{
@@ -33,7 +33,9 @@ class Create extends Component
'bucket' => 'Bucket',
'endpoint' => 'Endpoint',
];
public function mount() {
public function mount()
{
if (isDev()) {
$this->name = 'Local MinIO';
$this->description = 'Local MinIO';
@@ -43,15 +45,9 @@ class Create extends Component
$this->endpoint = 'http://coolify-minio:9000';
}
}
private function test_s3_connection() {
try {
$this->storage->testConnection();
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
} catch(\Throwable $th) {
return general_error_handler($th, $this);
}
}
public function submit() {
public function submit()
{
try {
$this->validate();
$this->storage = new S3Storage();
@@ -71,9 +67,19 @@ class Create extends Component
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
$this->storage->save();
return redirect()->route('team.storages.show', $this->storage->uuid);
} catch(\Throwable $th) {
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}
}
}
private function test_s3_connection()
{
try {
$this->storage->testConnection();
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}
}
}

View File

@@ -2,8 +2,8 @@
namespace App\Http\Livewire\Team\Storage;
use Livewire\Component;
use App\Models\S3Storage;
use Livewire\Component;
class Form extends Component
{
@@ -26,22 +26,27 @@ class Form extends Component
'storage.bucket' => 'Bucket',
'storage.endpoint' => 'Endpoint',
];
public function test_s3_connection() {
public function test_s3_connection()
{
try {
$this->storage->testConnection();
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
} catch(\Throwable $th) {
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}
}
public function delete() {
public function delete()
{
try {
$this->storage->delete();
return redirect()->route('team.storages.all');
} catch(\Throwable $th) {
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}
}
public function submit()
{
$this->validate();
@@ -54,4 +59,4 @@ class Form extends Component
return general_error_handler($th, $this);
}
}
}
}

View File

@@ -4,8 +4,8 @@ namespace App\Http\Livewire;
use App\Actions\Server\UpdateCoolify;
use App\Models\InstanceSettings;
use Masmerise\Toaster\Toaster;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
class Upgrade extends Component
{
@@ -27,6 +27,7 @@ class Upgrade extends Component
$this->latestVersion = 'next';
}
}
public function upgrade()
{
try {
@@ -40,4 +41,4 @@ class Upgrade extends Component
return general_error_handler(err: $e, that: $this);
}
}
}
}

View File

@@ -13,7 +13,7 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, string ...$guards): Response
{

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 |