Merge branch 'next' into feat/application-run-command

This commit is contained in:
Stuart Rowlands 2023-12-08 12:06:09 -08:00
commit 08585f7e9a
287 changed files with 1344 additions and 1179 deletions

View File

@ -39,7 +39,7 @@ class PrepareCoolifyTask
public function __invoke(): Activity public function __invoke(): Activity
{ {
$job = new CoolifyTask($this->activity, ignore_errors: $this->remoteProcessArgs->ignore_errors); $job = new CoolifyTask($this->activity, ignore_errors: $this->remoteProcessArgs->ignore_errors, call_event_on_finish: $this->remoteProcessArgs->call_event_on_finish);
dispatch($job); dispatch($job);
$this->activity->refresh(); $this->activity->refresh();
return $this->activity; return $this->activity;

View File

@ -17,10 +17,10 @@ class RunRemoteProcess
public bool $hide_from_output; public bool $hide_from_output;
public bool $is_finished;
public bool $ignore_errors; public bool $ignore_errors;
public $call_event_on_finish = null;
protected $time_start; protected $time_start;
protected $current_time; protected $current_time;
@ -34,7 +34,7 @@ class RunRemoteProcess
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(Activity $activity, bool $hide_from_output = false, bool $is_finished = false, bool $ignore_errors = false) public function __construct(Activity $activity, bool $hide_from_output = false, bool $ignore_errors = false, $call_event_on_finish = null)
{ {
if ($activity->getExtraProperty('type') !== ActivityTypes::INLINE->value) { if ($activity->getExtraProperty('type') !== ActivityTypes::INLINE->value) {
@ -43,8 +43,8 @@ class RunRemoteProcess
$this->activity = $activity; $this->activity = $activity;
$this->hide_from_output = $hide_from_output; $this->hide_from_output = $hide_from_output;
$this->is_finished = $is_finished;
$this->ignore_errors = $ignore_errors; $this->ignore_errors = $ignore_errors;
$this->call_event_on_finish = $call_event_on_finish;
} }
public static function decodeOutput(?Activity $activity = null): string public static function decodeOutput(?Activity $activity = null): string
@ -79,12 +79,18 @@ class RunRemoteProcess
if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) { if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {
$status = ProcessStatus::ERROR; $status = ProcessStatus::ERROR;
} else { } else {
if (($processResult->exitCode() == 0 && $this->is_finished) || $this->activity->properties->get('status') === ProcessStatus::FINISHED->value) { if ($processResult->exitCode() == 0) {
$status = ProcessStatus::FINISHED; $status = ProcessStatus::FINISHED;
} }
if ($processResult->exitCode() != 0 && !$this->ignore_errors) { if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
$status = ProcessStatus::ERROR; $status = ProcessStatus::ERROR;
} }
// if (($processResult->exitCode() == 0 && $this->is_finished) || $this->activity->properties->get('status') === ProcessStatus::FINISHED->value) {
// $status = ProcessStatus::FINISHED;
// }
// if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
// $status = ProcessStatus::ERROR;
// }
} }
$this->activity->properties = $this->activity->properties->merge([ $this->activity->properties = $this->activity->properties->merge([
@ -97,7 +103,15 @@ class RunRemoteProcess
if ($processResult->exitCode() != 0 && !$this->ignore_errors) { if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode()); throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode());
} }
if ($this->call_event_on_finish) {
try {
event(resolve("App\\Events\\$this->call_event_on_finish", [
'userId' => $this->activity->causer_id,
]));
} catch (\Throwable $e) {
ray($e);
}
}
return $processResult; return $processResult;
} }

View File

@ -0,0 +1,42 @@
<?php
namespace App\Actions\Service;
use Lorisleiva\Actions\Concerns\AsAction;
use App\Models\Service;
class DeleteService
{
use AsAction;
public function handle(Service $service)
{
StopService::run($service);
$server = data_get($service, 'server');
$storagesToDelete = collect([]);
$service->environment_variables()->delete();
$commands = [];
foreach ($service->applications()->get() as $application) {
$storages = $application->persistentStorages()->get();
foreach ($storages as $storage) {
$storagesToDelete->push($storage);
}
$application->delete();
}
foreach ($service->databases()->get() as $database) {
$storages = $database->persistentStorages()->get();
foreach ($storages as $storage) {
$storagesToDelete->push($storage);
}
$database->delete();
}
foreach ($storagesToDelete as $storage) {
$commands[] = "docker volume rm -f $storage->name";
}
$commands[] = "docker rm -f $service->uuid";
instant_remote_process($commands, $server, false);
$service->forceDelete();
}
}

View File

@ -16,19 +16,19 @@ class StartService
$commands[] = "cd " . $service->workdir(); $commands[] = "cd " . $service->workdir();
$commands[] = "echo 'Saved configuration files to {$service->workdir()}.'"; $commands[] = "echo 'Saved configuration files to {$service->workdir()}.'";
$commands[] = "echo 'Creating Docker network.'"; $commands[] = "echo 'Creating Docker network.'";
$commands[] = "docker network create --attachable '{$service->uuid}' >/dev/null 2>&1 || true"; $commands[] = "docker network inspect $service->uuid >/dev/null 2>&1 || docker network create --attachable $service->uuid >/dev/null 2>&1 || true";
$commands[] = "echo 'Starting service {$service->name} on {$service->server->name}.'"; $commands[] = "echo 'Starting service $service->name on {$service->server->name}.'";
$commands[] = "echo 'Pulling images.'"; $commands[] = "echo 'Pulling images.'";
$commands[] = "docker compose pull"; $commands[] = "docker compose pull";
$commands[] = "echo 'Starting containers.'"; $commands[] = "echo 'Starting containers.'";
$commands[] = "docker compose up -d --remove-orphans --force-recreate --build"; $commands[] = "docker compose up -d --remove-orphans --force-recreate --build";
$commands[] = "docker network connect $service->uuid coolify-proxy >/dev/null 2>&1 || true"; $commands[] = "docker network connect $service->uuid coolify-proxy >/dev/null 2>&1 || true";
$compose = data_get($service,'docker_compose',[]); $compose = data_get($service, 'docker_compose', []);
$serviceNames = data_get(Yaml::parse($compose),'services',[]); $serviceNames = data_get(Yaml::parse($compose), 'services', []);
foreach($serviceNames as $serviceName => $serviceConfig){ foreach ($serviceNames as $serviceName => $serviceConfig) {
$commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} || true"; $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} || true";
} }
$activity = remote_process($commands, $service->server); $activity = remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged');
return $activity; return $activity;
} }
} }

View File

@ -19,6 +19,7 @@ class CoolifyTaskArgs extends Data
public ?Model $model = null, public ?Model $model = null,
public ?string $status = null , public ?string $status = null ,
public bool $ignore_errors = false, public bool $ignore_errors = false,
public $call_event_on_finish = null,
) { ) {
if(is_null($status)){ if(is_null($status)){
$this->status = ProcessStatus::QUEUED->value; $this->status = ProcessStatus::QUEUED->value;

View File

@ -0,0 +1,34 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ServiceStatusChanged implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $userId;
public function __construct($userId = null)
{
if (is_null($userId)) {
$userId = auth()->user()->id ?? null;
}
if (is_null($userId)) {
throw new \Exception("User id is null");
}
$this->userId = $userId;
}
public function broadcastOn(): array
{
return [
new PrivateChannel("custom.{$this->userId}"),
];
}
}

View File

@ -116,7 +116,6 @@ class ProjectController extends Controller
}); });
} }
$service->parse(isNew: true); $service->parse(isNew: true);
return redirect()->route('project.service.configuration', [ return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid, 'service_uuid' => $service->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,

View File

@ -1,41 +0,0 @@
<?php
namespace App\Http\Livewire\Project\Service;
use App\Actions\Service\StartService;
use App\Actions\Service\StopService;
use App\Models\Service;
use Livewire\Component;
class Navbar extends Component
{
public Service $service;
public array $parameters;
public array $query;
protected $listeners = ["checkStatus"];
public function render()
{
return view('livewire.project.service.navbar');
}
public function checkStatus() {
$this->service->refresh();
}
public function deploy()
{
$this->service->parse();
$activity = StartService::run($this->service);
$this->emit('newMonitorActivity', $activity->id);
}
public function stop(bool $forceCleanup = false)
{
StopService::run($this->service);
$this->service->refresh();
if ($forceCleanup) {
$this->emit('success', 'Force cleanup service successfully.');
} else {
$this->emit('success', 'Service stopped successfully.');
}
$this->emit('checkStatus');
}
}

View File

@ -34,7 +34,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
public function __construct(public Server $server) public function __construct(public Server $server)
{ {
if (isDev()) $this->handle(); $this->handle();
} }

View File

@ -21,6 +21,7 @@ class CoolifyTask implements ShouldQueue, ShouldBeEncrypted
public function __construct( public function __construct(
public Activity $activity, public Activity $activity,
public bool $ignore_errors = false, public bool $ignore_errors = false,
public $call_event_on_finish = null
) { ) {
} }
@ -32,6 +33,7 @@ class CoolifyTask implements ShouldQueue, ShouldBeEncrypted
$remote_process = resolve(RunRemoteProcess::class, [ $remote_process = resolve(RunRemoteProcess::class, [
'activity' => $this->activity, 'activity' => $this->activity,
'ignore_errors' => $this->ignore_errors, 'ignore_errors' => $this->ignore_errors,
'call_event_on_finish' => $this->call_event_on_finish
]); ]);
$remote_process(); $remote_process();

View File

@ -4,7 +4,7 @@ namespace App\Jobs;
use App\Actions\Application\StopApplication; use App\Actions\Application\StopApplication;
use App\Actions\Database\StopDatabase; use App\Actions\Database\StopDatabase;
use App\Actions\Service\StopService; use App\Actions\Service\DeleteService;
use App\Models\Application; use App\Models\Application;
use App\Models\Service; use App\Models\Service;
use App\Models\StandaloneMariadb; use App\Models\StandaloneMariadb;
@ -54,11 +54,13 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncrypted
case 'standalone-mariadb': case 'standalone-mariadb':
StopDatabase::run($this->resource); StopDatabase::run($this->resource);
break; break;
case 'service':
StopService::run($this->resource);
break;
} }
if ($this->resource->type() === 'service') {
$this->resource->delete(); $this->resource->delete();
DeleteService::dispatch($this->resource);
} else {
$this->resource->delete();
}
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage()); send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
throw $e; throw $e;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use App\Enums\ProcessStatus; use App\Enums\ProcessStatus;
use Livewire\Component; use Livewire\Component;
@ -8,7 +8,7 @@ use Spatie\Activitylog\Models\Activity;
class ActivityMonitor extends Component class ActivityMonitor extends Component
{ {
public string|null $header = null; public ?string $header = null;
public $activityId; public $activityId;
public $isPollingActive = false; public $isPollingActive = false;
@ -26,31 +26,30 @@ class ActivityMonitor extends Component
public function hydrateActivity() public function hydrateActivity()
{ {
$this->activity = Activity::query() $this->activity = Activity::find($this->activityId);
->find($this->activityId);
} }
public function polling() public function polling()
{ {
$this->hydrateActivity(); $this->hydrateActivity();
$this->setStatus(ProcessStatus::IN_PROGRESS); // $this->setStatus(ProcessStatus::IN_PROGRESS);
$exit_code = data_get($this->activity, 'properties.exitCode'); $exit_code = data_get($this->activity, 'properties.exitCode');
if ($exit_code !== null) { if ($exit_code !== null) {
if ($exit_code === 0) { if ($exit_code === 0) {
$this->setStatus(ProcessStatus::FINISHED); // $this->setStatus(ProcessStatus::FINISHED);
} else { } else {
$this->setStatus(ProcessStatus::ERROR); // $this->setStatus(ProcessStatus::ERROR);
} }
$this->isPollingActive = false; $this->isPollingActive = false;
$this->emit('activityFinished'); $this->dispatch('activityFinished');
} }
} }
protected function setStatus($status) // protected function setStatus($status)
{ // {
$this->activity->properties = $this->activity->properties->merge([ // $this->activity->properties = $this->activity->properties->merge([
'status' => $status, // 'status' => $status,
]); // ]);
$this->activity->save(); // $this->activity->save();
} // }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Boarding; namespace App\Livewire\Boarding;
use App\Actions\Server\InstallDocker; use App\Actions\Server\InstallDocker;
use App\Models\PrivateKey; use App\Models\PrivateKey;
@ -88,7 +88,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
if ($this->selectedServerType === 'localhost') { if ($this->selectedServerType === 'localhost') {
$this->createdServer = Server::find(0); $this->createdServer = Server::find(0);
if (!$this->createdServer) { if (!$this->createdServer) {
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.'); return $this->dispatch('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
} }
$this->serverPublicKey = $this->createdServer->privateKey->publicKey(); $this->serverPublicKey = $this->createdServer->privateKey->publicKey();
return $this->validateServer('localhost'); return $this->validateServer('localhost');
@ -110,7 +110,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
{ {
$this->createdServer = Server::find($this->selectedExistingServer); $this->createdServer = Server::find($this->selectedExistingServer);
if (!$this->createdServer) { if (!$this->createdServer) {
$this->emit('error', 'Server is not found.'); $this->dispatch('error', 'Server is not found.');
$this->currentState = 'private-key'; $this->currentState = 'private-key';
return; return;
} }
@ -173,7 +173,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->privateKey = formatPrivateKey($this->privateKey); $this->privateKey = formatPrivateKey($this->privateKey);
$foundServer = Server::whereIp($this->remoteServerHost)->first(); $foundServer = Server::whereIp($this->remoteServerHost)->first();
if ($foundServer) { if ($foundServer) {
return $this->emit('error', 'IP address is already in use by another team.'); return $this->dispatch('error', 'IP address is already in use by another team.');
} }
$this->createdServer = Server::create([ $this->createdServer = Server::create([
'name' => $this->remoteServerName, 'name' => $this->remoteServerName,
@ -227,8 +227,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
try { try {
$this->dockerInstallationStarted = true; $this->dockerInstallationStarted = true;
$activity = InstallDocker::run($this->createdServer); $activity = InstallDocker::run($this->createdServer);
$this->emit('installDocker'); $this->dispatch('installDocker');
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->dockerInstallationStarted = false; $this->dockerInstallationStarted = false;
return handleError(error: $e, livewire: $this); return handleError(error: $e, livewire: $this);

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use App\Actions\License\CheckResaleLicense; use App\Actions\License\CheckResaleLicense;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
@ -33,11 +33,11 @@ class CheckLicense extends Component
if ($this->settings->resale_license) { if ($this->settings->resale_license) {
try { try {
CheckResaleLicense::run(); CheckResaleLicense::run();
$this->emit('reloadWindow'); $this->dispatch('reloadWindow');
} catch (\Throwable $e) { } catch (\Throwable $e) {
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage()); session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
ray($e->getMessage()); ray($e->getMessage());
return redirect()->to('/settings/license'); return $this->redirect('/settings/license', navigate: true);
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use App\Models\Project; use App\Models\Project;
use App\Models\Server; use App\Models\Server;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Destination; namespace App\Livewire\Destination;
use Livewire\Component; use Livewire\Component;
@ -30,13 +30,13 @@ class Form extends Component
try { try {
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') { if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') {
if ($this->destination->attachedTo()) { if ($this->destination->attachedTo()) {
return $this->emit('error', 'You must delete all resources before deleting this destination.'); return $this->dispatch('error', 'You must delete all resources before deleting this destination.');
} }
instant_remote_process(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false); instant_remote_process(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false);
instant_remote_process(['docker network rm -f ' . $this->destination->network], $this->destination->server); instant_remote_process(['docker network rm -f ' . $this->destination->network], $this->destination->server);
} }
$this->destination->delete(); $this->destination->delete();
return redirect()->route('dashboard'); return $this->redirectRoute('dashboard', navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Destination\New; namespace App\Livewire\Destination\New;
use App\Models\Server; use App\Models\Server;
use App\Models\StandaloneDocker as ModelsStandaloneDocker; use App\Models\StandaloneDocker as ModelsStandaloneDocker;
@ -60,7 +60,7 @@ class StandaloneDocker extends Component
$found = $this->server->standaloneDockers()->where('network', $this->network)->first(); $found = $this->server->standaloneDockers()->where('network', $this->network)->first();
if ($found) { if ($found) {
$this->createNetworkAndAttachToProxy(); $this->createNetworkAndAttachToProxy();
$this->emit('error', 'Network already added to this server.'); $this->dispatch('error', 'Network already added to this server.');
return; return;
} else { } else {
$docker = ModelsStandaloneDocker::create([ $docker = ModelsStandaloneDocker::create([
@ -70,7 +70,7 @@ class StandaloneDocker extends Component
]); ]);
} }
$this->createNetworkAndAttachToProxy(); $this->createNetworkAndAttachToProxy();
return redirect()->route('destination.show', $docker->uuid); return $this->redirectRoute('destination.show', $docker->uuid, navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Destination; namespace App\Livewire\Destination;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -21,7 +21,7 @@ class Show extends Component
return !$alreadyAddedNetworks->contains('network', $network['Name']); return !$alreadyAddedNetworks->contains('network', $network['Name']);
}); });
if ($this->networks->count() === 0) { if ($this->networks->count() === 0) {
$this->emit('success', 'No new networks found.'); $this->dispatch('success', 'No new networks found.');
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Dev; namespace App\Livewire\Dev;
use Livewire\Component; use Livewire\Component;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use DanHarrin\LivewireRateLimiting\WithRateLimiting; use DanHarrin\LivewireRateLimiting\WithRateLimiting;
@ -35,7 +35,7 @@ class ForcePasswordReset extends Component
if ($firstLogin) { if ($firstLogin) {
send_internal_notification('First login for ' . auth()->user()->email); send_internal_notification('First login for ' . auth()->user()->email);
} }
return redirect()->route('dashboard'); return $this->redirectRoute('dashboard', navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use DanHarrin\LivewireRateLimiting\WithRateLimiting; use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
@ -42,7 +42,7 @@ class Help extends Component
); );
$mail->subject("[HELP - {$subscriptionType}]: {$this->subject}"); $mail->subject("[HELP - {$subscriptionType}]: {$this->subject}");
send_user_an_email($mail, auth()->user()?->email, 'hi@coollabs.io'); send_user_an_email($mail, auth()->user()?->email, 'hi@coollabs.io');
$this->emit('success', 'Your message has been sent successfully. <br>We will get in touch with you as soon as possible.'); $this->dispatch('success', 'Your message has been sent successfully. <br>We will get in touch with you as soon as possible.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,9 +1,8 @@
<?php <?php
namespace App\Http\Livewire\Modal; namespace App\Livewire\Modal;
use App\Models\Service; use App\Models\Service;
use Livewire\Component;
use LivewireUI\Modal\ModalComponent; use LivewireUI\Modal\ModalComponent;
class EditCompose extends ModalComponent class EditCompose extends ModalComponent
@ -22,8 +21,8 @@ class EditCompose extends ModalComponent
return view('livewire.modal.edit-compose'); return view('livewire.modal.edit-compose');
} }
public function submit() { public function submit() {
$this->emit('warning', "Saving new docker compose..."); $this->dispatch('warning', "Saving new docker compose...");
$this->emit('saveCompose', $this->service->docker_compose_raw); $this->dispatch('saveCompose', $this->service->docker_compose_raw);
$this->closeModal(); $this->closeModal();
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Notifications; namespace App\Livewire\Notifications;
use App\Models\Team; use App\Models\Team;
use App\Notifications\Test; use App\Notifications\Test;
@ -47,12 +47,12 @@ class DiscordSettings extends Component
{ {
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
} }
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test()); $this->team->notify(new Test());
$this->emit('success', 'Test notification sent.'); $this->dispatch('success', 'Test notification sent.');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Notifications; namespace App\Livewire\Notifications;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\Team; use App\Models\Team;
@ -63,7 +63,7 @@ class EmailSettings extends Component
]); ]);
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved successfully.'); $this->dispatch('success', 'Settings saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -71,7 +71,7 @@ class EmailSettings extends Component
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test($this->emails)); $this->team->notify(new Test($this->emails));
$this->emit('success', 'Test Email sent successfully.'); $this->dispatch('success', 'Test Email sent successfully.');
} }
public function instantSaveInstance() public function instantSaveInstance()
{ {
@ -83,7 +83,7 @@ class EmailSettings extends Component
$this->team->resend_enabled = false; $this->team->resend_enabled = false;
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved successfully.'); $this->dispatch('success', 'Settings saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -113,7 +113,7 @@ class EmailSettings extends Component
{ {
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
} }
public function submit() public function submit()
{ {
@ -131,7 +131,7 @@ class EmailSettings extends Component
]); ]);
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved successfully.'); $this->dispatch('success', 'Settings saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->team->smtp_enabled = false; $this->team->smtp_enabled = false;
return handleError($e, $this); return handleError($e, $this);
@ -148,7 +148,7 @@ class EmailSettings extends Component
]); ]);
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved successfully.'); $this->dispatch('success', 'Settings saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->team->resend_enabled = false; $this->team->resend_enabled = false;
return handleError($e, $this); return handleError($e, $this);
@ -173,7 +173,7 @@ class EmailSettings extends Component
]); ]);
refreshSession(); refreshSession();
$this->team = $team; $this->team = $team;
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
return; return;
} }
if ($settings->resend_enabled) { if ($settings->resend_enabled) {
@ -184,9 +184,9 @@ class EmailSettings extends Component
]); ]);
refreshSession(); refreshSession();
$this->team = $team; $this->team = $team;
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
return; return;
} }
$this->emit('error', 'Instance SMTP/Resend settings are not enabled.'); $this->dispatch('error', 'Instance SMTP/Resend settings are not enabled.');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Notifications; namespace App\Livewire\Notifications;
use App\Models\Team; use App\Models\Team;
use App\Notifications\Test; use App\Notifications\Test;
@ -53,12 +53,12 @@ class TelegramSettings extends Component
{ {
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
} }
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test()); $this->team->notify(new Test());
$this->emit('success', 'Test notification sent.'); $this->dispatch('success', 'Test notification sent.');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\PrivateKey; namespace App\Livewire\PrivateKey;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use Livewire\Component; use Livewire\Component;
@ -35,9 +35,9 @@ class Change extends Component
if ($this->private_key->isEmpty()) { if ($this->private_key->isEmpty()) {
$this->private_key->delete(); $this->private_key->delete();
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get(); currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
return redirect()->route('security.private-key.index'); return $this->redirectRoute('security.private-key.index', navigate: true);
} }
$this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.'); $this->dispatch('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\PrivateKey; namespace App\Livewire\PrivateKey;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use DanHarrin\LivewireRateLimiting\WithRateLimiting; use DanHarrin\LivewireRateLimiting\WithRateLimiting;
@ -67,9 +67,9 @@ class Create extends Component
'team_id' => currentTeam()->id 'team_id' => currentTeam()->id
]); ]);
if ($this->from === 'server') { if ($this->from === 'server') {
return redirect()->route('server.create'); return $this->redirectRoute('server.create', navigate: true);
} }
return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]); return $this->redirectRoute('security.private-key.show', ['private_key_uuid' => $private_key->uuid], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,22 +1,17 @@
<?php <?php
namespace App\Http\Livewire\Profile; namespace App\Livewire\Profile;
use App\Models\User; use Livewire\Attributes\Validate;
use Livewire\Component; use Livewire\Component;
class Form extends Component class Form extends Component
{ {
public int $userId; public int $userId;
public string $name;
public string $email; public string $email;
protected $rules = [ #[Validate('required')]
'name' => 'required', public string $name;
];
protected $validationAttributes = [
'name' => 'name',
];
public function mount() public function mount()
{ {
@ -30,9 +25,11 @@ class Form extends Component
{ {
try { try {
$this->validate(); $this->validate();
User::where('id', $this->userId)->update([ auth()->user()->update([
'name' => $this->name, 'name' => $this->name,
]); ]);
$this->dispatch('success', 'Profile updated successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Project; use App\Models\Project;
use Livewire\Component; use Livewire\Component;
@ -27,7 +27,7 @@ class AddEmpty extends Component
'description' => $this->description, 'description' => $this->description,
'team_id' => currentTeam()->id, 'team_id' => currentTeam()->id,
]); ]);
return redirect()->route('project.show', $project->uuid); return $this->redirectRoute('project.show', $project->uuid, navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Environment; use App\Models\Environment;
use App\Models\Project; use App\Models\Project;
@ -27,10 +27,10 @@ class AddEnvironment extends Component
'project_id' => $this->project->id, 'project_id' => $this->project->id,
]); ]);
return redirect()->route('project.resources', [ return $this->redirectRoute('project.resources', [
'project_uuid' => $this->project->uuid, 'project_uuid' => $this->project->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
]); ], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
handleError($e, $this); handleError($e, $this);
} finally { } finally {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use Livewire\Component; use Livewire\Component;
@ -26,26 +26,26 @@ class Advanced extends Component
if ($this->application->isLogDrainEnabled()) { if ($this->application->isLogDrainEnabled()) {
if (!$this->application->destination->server->isLogDrainEnabled()) { if (!$this->application->destination->server->isLogDrainEnabled()) {
$this->application->settings->is_log_drain_enabled = false; $this->application->settings->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on this server.'); $this->dispatch('error', 'Log drain is not enabled on this server.');
return; return;
} }
} }
if ($this->application->settings->is_force_https_enabled) { if ($this->application->settings->is_force_https_enabled) {
$this->emit('resetDefaultLabels', false); $this->dispatch('resetDefaultLabels', false);
} }
$this->application->settings->save(); $this->application->settings->save();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
} }
public function submit() { public function submit() {
if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) { if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) {
$this->emit('error', 'You cannot set both GPU count and GPU device IDs.'); $this->dispatch('error', 'You cannot set both GPU count and GPU device IDs.');
$this->application->settings->gpu_count = null; $this->application->settings->gpu_count = null;
$this->application->settings->gpu_device_ids = null; $this->application->settings->gpu_device_ids = null;
$this->application->settings->save(); $this->application->settings->save();
return; return;
} }
$this->application->settings->save(); $this->application->settings->save();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
} }
public function render() public function render()
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;
@ -101,7 +101,7 @@ class Command extends Component
$exec = "docker exec {$this->container} {$cmd}"; $exec = "docker exec {$this->container} {$cmd}";
} }
$activity = remote_process([$exec], $this->server, ignore_errors: true); $activity = remote_process([$exec], $this->server, ignore_errors: true);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;
@ -15,15 +15,15 @@ class Configuration extends Component
{ {
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) { if (!$project) {
return redirect()->route('dashboard'); return $this->redirectRoute('dashboard', navigate: true);
} }
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) { if (!$environment) {
return redirect()->route('dashboard'); return $this->redirectRoute('dashboard', navigate: true);
} }
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first(); $application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) { if (!$application) {
return redirect()->route('dashboard'); return $this->redirectRoute('dashboard', navigate: true);
} }
$this->application = $application; $this->application = $application;
$mainServer = $this->application->destination->server; $mainServer = $this->application->destination->server;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\ApplicationDeploymentQueue; use App\Models\ApplicationDeploymentQueue;
use Livewire\Component; use Livewire\Component;
@ -18,7 +18,7 @@ class DeploymentLogs extends Component
public function polling() public function polling()
{ {
$this->emit('deploymentFinished'); $this->dispatch('deploymentFinished');
$this->application_deployment_queue->refresh(); $this->application_deployment_queue->refresh();
if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') { if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') {
$this->isKeepAliveOn = false; $this->isKeepAliveOn = false;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Enums\ApplicationDeploymentStatus; use App\Enums\ApplicationDeploymentStatus;
use App\Models\Application; use App\Models\Application;
@ -35,7 +35,7 @@ class DeploymentNavbar extends Component
$this->application->settings->is_debug_enabled = !$this->application->settings->is_debug_enabled; $this->application->settings->is_debug_enabled = !$this->application->settings->is_debug_enabled;
$this->application->settings->save(); $this->application->settings->save();
$this->is_debug_enabled = $this->application->settings->is_debug_enabled; $this->is_debug_enabled = $this->application->settings->is_debug_enabled;
$this->emit('refreshQueue'); $this->dispatch('refreshQueue');
} }
public function cancel() public function cancel()

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -101,7 +101,7 @@ class General extends Component
try { try {
$this->parsedServices = $this->application->parseCompose(); $this->parsedServices = $this->application->parseCompose();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->emit('error', $e->getMessage()); $this->dispatch('error', $e->getMessage());
} }
$this->parsedServiceDomains = $this->application->docker_compose_domains ? json_decode($this->application->docker_compose_domains, true) : []; $this->parsedServiceDomains = $this->application->docker_compose_domains ? json_decode($this->application->docker_compose_domains, true) : [];
@ -121,7 +121,7 @@ class General extends Component
public function instantSave() public function instantSave()
{ {
$this->application->settings->save(); $this->application->settings->save();
$this->emit('success', 'Settings saved.'); $this->dispatch('success', 'Settings saved.');
$this->application->refresh(); $this->application->refresh();
if ($this->ports_exposes !== $this->application->ports_exposes) { if ($this->ports_exposes !== $this->application->ports_exposes) {
$this->resetDefaultLabels(false); $this->resetDefaultLabels(false);
@ -134,7 +134,7 @@ class General extends Component
return; return;
} }
['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit); ['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit);
$this->emit('success', 'Docker compose file loaded.'); $this->dispatch('success', 'Docker compose file loaded.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->application->docker_compose_location = $this->initialDockerComposeLocation; $this->application->docker_compose_location = $this->initialDockerComposeLocation;
$this->application->docker_compose_pr_location = $this->initialDockerComposePrLocation; $this->application->docker_compose_pr_location = $this->initialDockerComposePrLocation;
@ -151,7 +151,7 @@ class General extends Component
$this->parsedServiceDomains[$serviceName]['domain'] = $domain; $this->parsedServiceDomains[$serviceName]['domain'] = $domain;
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains); $this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
$this->application->save(); $this->application->save();
$this->emit('success', 'Domain generated.'); $this->dispatch('success', 'Domain generated.');
} }
return $domain; return $domain;
} }
@ -196,7 +196,7 @@ class General extends Component
public function updatedApplicationFqdn() public function updatedApplicationFqdn()
{ {
$this->resetDefaultLabels(false); $this->resetDefaultLabels(false);
$this->emit('success', 'Labels reseted to default!'); $this->dispatch('success', 'Labels reseted to default!');
} }
public function submit($showToaster = true) public function submit($showToaster = true)
{ {
@ -220,6 +220,7 @@ class General extends Component
}); });
$this->application->fqdn = $domains->implode(','); $this->application->fqdn = $domains->implode(',');
} }
if (data_get($this->application, 'dockerfile')) { if (data_get($this->application, 'dockerfile')) {
$port = get_port_from_dockerfile($this->application->dockerfile); $port = get_port_from_dockerfile($this->application->dockerfile);
if ($port && !$this->application->ports_exposes) { if ($port && !$this->application->ports_exposes) {
@ -241,7 +242,7 @@ class General extends Component
$this->parsedServices = $this->application->parseCompose(); $this->parsedServices = $this->application->parseCompose();
} }
$this->application->save(); $this->application->save();
$showToaster && $this->emit('success', 'Application settings updated!'); $showToaster && $this->dispatch('success', 'Application settings updated!');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Actions\Application\StopApplication; use App\Actions\Application\StopApplication;
use App\Jobs\ContainerStatusJob; use App\Jobs\ContainerStatusJob;
@ -42,7 +42,7 @@ class Heading extends Component
public function deployNew() public function deployNew()
{ {
if ($this->application->build_pack === 'dockercompose' && is_null($this->application->docker_compose_raw)) { if ($this->application->build_pack === 'dockercompose' && is_null($this->application->docker_compose_raw)) {
$this->emit('error', 'Please load a Compose file first.'); $this->dispatch('error', 'Please load a Compose file first.');
return; return;
} }
$this->setDeploymentUuid(); $this->setDeploymentUuid();
@ -52,17 +52,17 @@ class Heading extends Component
force_rebuild: false, force_rebuild: false,
is_new_deployment: true, is_new_deployment: true,
); );
return redirect()->route('project.application.deployment', [ return $this->redirectRoute('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid, 'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} }
public function deploy(bool $force_rebuild = false) public function deploy(bool $force_rebuild = false)
{ {
if ($this->application->build_pack === 'dockercompose' && is_null($this->application->docker_compose_raw)) { if ($this->application->build_pack === 'dockercompose' && is_null($this->application->docker_compose_raw)) {
$this->emit('error', 'Please load a Compose file first.'); $this->dispatch('error', 'Please load a Compose file first.');
return; return;
} }
$this->setDeploymentUuid(); $this->setDeploymentUuid();
@ -71,12 +71,12 @@ class Heading extends Component
deployment_uuid: $this->deploymentUuid, deployment_uuid: $this->deploymentUuid,
force_rebuild: $force_rebuild, force_rebuild: $force_rebuild,
); );
return redirect()->route('project.application.deployment', [ $this->redirectRoute('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid, 'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} }
protected function setDeploymentUuid() protected function setDeploymentUuid()
@ -101,12 +101,12 @@ class Heading extends Component
restart_only: true, restart_only: true,
is_new_deployment: true, is_new_deployment: true,
); );
return redirect()->route('project.application.deployment', [ return $this->redirectRoute('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid, 'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} }
public function restart() public function restart()
{ {
@ -116,11 +116,11 @@ class Heading extends Component
deployment_uuid: $this->deploymentUuid, deployment_uuid: $this->deploymentUuid,
restart_only: true, restart_only: true,
); );
return redirect()->route('project.application.deployment', [ return $this->redirectRoute('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid, 'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application\Preview; namespace App\Livewire\Project\Application\Preview;
use App\Models\Application; use App\Models\Application;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -46,7 +46,7 @@ class Form extends Component
$this->validate(); $this->validate();
$this->application->preview_url_template = str_replace(' ', '', $this->application->preview_url_template); $this->application->preview_url_template = str_replace(' ', '', $this->application->preview_url_template);
$this->application->save(); $this->application->save();
$this->emit('success', 'Preview url template updated successfully.'); $this->dispatch('success', 'Preview url template updated successfully.');
$this->generate_real_url(); $this->generate_real_url();
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use App\Models\ApplicationPreview; use App\Models\ApplicationPreview;
@ -52,12 +52,12 @@ class Previews extends Component
force_rebuild: true, force_rebuild: true,
pull_request_id: $pull_request_id, pull_request_id: $pull_request_id,
); );
return redirect()->route('project.application.deployment', [ return $this->redirectRoute('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid, 'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -29,13 +29,12 @@ class Rollback extends Component
commit: $commit, commit: $commit,
force_rebuild: false, force_rebuild: false,
); );
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $deployment_uuid, 'deployment_uuid' => $deployment_uuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ], navigate: true);
} }
public function loadImages($showToast = false) public function loadImages($showToast = false)
@ -66,7 +65,7 @@ class Rollback extends Component
]; ];
})->toArray(); })->toArray();
} }
$showToast && $this->emit('success', 'Images loaded.'); $showToast && $this->dispatch('success', 'Images loaded.');
return []; return [];
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Application; namespace App\Livewire\Project\Application;
use App\Models\Application; use App\Models\Application;
use App\Models\PrivateKey; use App\Models\PrivateKey;
@ -49,6 +49,6 @@ class Source extends Component
$this->application->git_commit_sha = 'HEAD'; $this->application->git_commit_sha = 'HEAD';
} }
$this->application->save(); $this->application->save();
$this->emit('success', 'Application source updated!'); $this->dispatch('success', 'Application source updated!');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Environment; use App\Models\Environment;
use App\Models\Project; use App\Models\Project;
@ -148,10 +148,10 @@ class CloneProject extends Component
} }
$newService->parse(); $newService->parse();
} }
return redirect()->route('project.resources', [ return $this->redirectRoute('project.resources', [
'project_uuid' => $newProject->uuid, 'project_uuid' => $newProject->uuid,
'environment_name' => $newEnvironment->name, 'environment_name' => $newEnvironment->name,
]); ], navigate: true);
} catch (\Exception $e) { } catch (\Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use Livewire\Component; use Livewire\Component;
use Spatie\Url\Url; use Spatie\Url\Url;
@ -50,9 +50,9 @@ class BackupEdit extends Component
$url = $url->withoutQueryParameter('selectedBackupId'); $url = $url->withoutQueryParameter('selectedBackupId');
$url = $url->withFragment('backups'); $url = $url->withFragment('backups');
$url = $url->getPath() . "#{$url->getFragment()}"; $url = $url->getPath() . "#{$url->getFragment()}";
return redirect()->to($url); return $this->redirect($url,navigate: true);
} else { } else {
redirect()->route('project.database.backups.all', $this->parameters); return $this->redirectRoute('project.database.backups.all', $this->parameters);
} }
} }
@ -63,9 +63,9 @@ class BackupEdit extends Component
$this->custom_validate(); $this->custom_validate();
$this->backup->save(); $this->backup->save();
$this->backup->refresh(); $this->backup->refresh();
$this->emit('success', 'Backup updated successfully'); $this->dispatch('success', 'Backup updated successfully');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->emit('error', $e->getMessage()); $this->dispatch('error', $e->getMessage());
} }
} }
@ -90,9 +90,9 @@ class BackupEdit extends Component
} }
$this->backup->save(); $this->backup->save();
$this->backup->refresh(); $this->backup->refresh();
$this->emit('success', 'Backup updated successfully'); $this->dispatch('success', 'Backup updated successfully');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->emit('error', $e->getMessage()); $this->dispatch('error', $e->getMessage());
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Livewire\Component; use Livewire\Component;
@ -16,7 +16,7 @@ class BackupExecutions extends Component
{ {
$execution = $this->backup->executions()->where('id', $exeuctionId)->first(); $execution = $this->backup->executions()->where('id', $exeuctionId)->first();
if (is_null($execution)) { if (is_null($execution)) {
$this->emit('error', 'Backup execution not found.'); $this->dispatch('error', 'Backup execution not found.');
return; return;
} }
if ($execution->scheduledDatabaseBackup->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($execution->scheduledDatabaseBackup->database->getMorphClass() === 'App\Models\ServiceDatabase') {
@ -25,15 +25,15 @@ class BackupExecutions extends Component
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server); delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server);
} }
$execution->delete(); $execution->delete();
$this->emit('success', 'Backup deleted successfully.'); $this->dispatch('success', 'Backup deleted successfully.');
$this->emit('refreshBackupExecutions'); $this->dispatch('refreshBackupExecutions');
} }
public function download($exeuctionId) public function download($exeuctionId)
{ {
try { try {
$execution = $this->backup->executions()->where('id', $exeuctionId)->first(); $execution = $this->backup->executions()->where('id', $exeuctionId)->first();
if (is_null($execution)) { if (is_null($execution)) {
$this->emit('error', 'Backup execution not found.'); $this->dispatch('error', 'Backup execution not found.');
return; return;
} }
$filename = data_get($execution, 'filename'); $filename = data_get($execution, 'filename');

View File

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

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledDatabaseBackup;
use Livewire\Component; use Livewire\Component;
@ -35,7 +35,7 @@ class CreateScheduledBackup extends Component
$this->validate(); $this->validate();
$isValid = validate_cron_expression($this->frequency); $isValid = validate_cron_expression($this->frequency);
if (!$isValid) { if (!$isValid) {
$this->emit('error', 'Invalid Cron / Human expression.'); $this->dispatch('error', 'Invalid Cron / Human expression.');
return; return;
} }
$payload = [ $payload = [
@ -57,9 +57,9 @@ class CreateScheduledBackup extends Component
$databaseBackup = ScheduledDatabaseBackup::create($payload); $databaseBackup = ScheduledDatabaseBackup::create($payload);
if ($this->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($this->database->getMorphClass() === 'App\Models\ServiceDatabase') {
$this->emit('refreshScheduledBackups', $databaseBackup->id); $this->dispatch('refreshScheduledBackups', $databaseBackup->id);
} else { } else {
$this->emit('refreshScheduledBackups'); $this->dispatch('refreshScheduledBackups');
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
handleError($e, $this); handleError($e, $this);

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use App\Actions\Database\StartMariadb; use App\Actions\Database\StartMariadb;
use App\Actions\Database\StartMongodb; use App\Actions\Database\StartMongodb;
@ -23,7 +23,7 @@ class Heading extends Component
$this->database->update([ $this->database->update([
'started_at' => now(), 'started_at' => now(),
]); ]);
$this->emit('refresh'); $this->dispatch('refresh');
$this->check_status(); $this->check_status();
} }
@ -50,19 +50,19 @@ class Heading extends Component
{ {
if ($this->database->type() === 'standalone-postgresql') { if ($this->database->type() === 'standalone-postgresql') {
$activity = StartPostgresql::run($this->database); $activity = StartPostgresql::run($this->database);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} else if ($this->database->type() === 'standalone-redis') { } else if ($this->database->type() === 'standalone-redis') {
$activity = StartRedis::run($this->database); $activity = StartRedis::run($this->database);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} else if ($this->database->type() === 'standalone-mongodb') { } else if ($this->database->type() === 'standalone-mongodb') {
$activity = StartMongodb::run($this->database); $activity = StartMongodb::run($this->database);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} else if ($this->database->type() === 'standalone-mysql') { } else if ($this->database->type() === 'standalone-mysql') {
$activity = StartMysql::run($this->database); $activity = StartMysql::run($this->database);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} else if ($this->database->type() === 'standalone-mariadb') { } else if ($this->database->type() === 'standalone-mariadb') {
$activity = StartMariadb::run($this->database); $activity = StartMariadb::run($this->database);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} }
} }
} }

View File

@ -1,7 +1,8 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use Exception;
use Livewire\Component; use Livewire\Component;
class InitScript extends Component class InitScript extends Component
@ -34,7 +35,7 @@ class InitScript extends Component
$this->script['index'] = $this->index; $this->script['index'] = $this->index;
$this->script['content'] = $this->content; $this->script['content'] = $this->content;
$this->script['filename'] = $this->filename; $this->script['filename'] = $this->filename;
$this->emitUp('save_init_script', $this->script); $this->dispatch('save_init_script', $this->script);
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -42,6 +43,6 @@ class InitScript extends Component
public function delete() public function delete()
{ {
$this->emitUp('delete_init_script', $this->script); $this->dispatch('delete_init_script', $this->script);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database\Mariadb; namespace App\Livewire\Project\Database\Mariadb;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -55,12 +55,12 @@ class General extends Component
try { try {
if (!$this->database->destination->server->isLogDrainEnabled()) { if (!$this->database->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -73,7 +73,7 @@ class General extends Component
} }
$this->validate(); $this->validate();
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -82,23 +82,23 @@ class General extends Component
{ {
try { try {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl(); $this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database\Mongodb; namespace App\Livewire\Project\Database\Mongodb;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -54,12 +54,12 @@ class General extends Component
try { try {
if (!$this->database->destination->server->isLogDrainEnabled()) { if (!$this->database->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -75,7 +75,7 @@ class General extends Component
} }
$this->validate(); $this->validate();
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -84,23 +84,23 @@ class General extends Component
{ {
try { try {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl(); $this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database\Mysql; namespace App\Livewire\Project\Database\Mysql;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -56,12 +56,12 @@ class General extends Component
try { try {
if (!$this->database->destination->server->isLogDrainEnabled()) { if (!$this->database->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -74,7 +74,7 @@ class General extends Component
} }
$this->validate(); $this->validate();
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -83,23 +83,23 @@ class General extends Component
{ {
try { try {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl(); $this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database\Postgresql; namespace App\Livewire\Project\Database\Postgresql;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -62,12 +62,12 @@ class General extends Component
try { try {
if (!$this->database->destination->server->isLogDrainEnabled()) { if (!$this->database->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -76,23 +76,23 @@ class General extends Component
{ {
try { try {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl(); $this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
@ -105,7 +105,7 @@ class General extends Component
$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->init_scripts = array_merge($this->database->init_scripts, [$script]);
$this->database->save(); $this->database->save();
$this->emit('success', 'Init script saved successfully.'); $this->dispatch('success', 'Init script saved successfully.');
} }
public function delete_init_script($script) public function delete_init_script($script)
@ -116,7 +116,7 @@ class General extends Component
$this->database->init_scripts = $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->database->save();
$this->refresh(); $this->refresh();
$this->emit('success', 'Init script deleted successfully.'); $this->dispatch('success', 'Init script deleted successfully.');
return; return;
} }
} }
@ -134,7 +134,7 @@ class General extends Component
]); ]);
$found = collect($this->database->init_scripts)->firstWhere('filename', $this->new_filename); $found = collect($this->database->init_scripts)->firstWhere('filename', $this->new_filename);
if ($found) { if ($found) {
$this->emit('error', 'Filename already exists.'); $this->dispatch('error', 'Filename already exists.');
return; return;
} }
if (!isset($this->database->init_scripts)) { if (!isset($this->database->init_scripts)) {
@ -148,7 +148,7 @@ class General extends Component
] ]
]); ]);
$this->database->save(); $this->database->save();
$this->emit('success', 'Init script added successfully.'); $this->dispatch('success', 'Init script added successfully.');
$this->new_content = ''; $this->new_content = '';
$this->new_filename = ''; $this->new_filename = '';
} }
@ -161,7 +161,7 @@ class General extends Component
} }
$this->validate(); $this->validate();
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database\Redis; namespace App\Livewire\Project\Database\Redis;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -48,12 +48,12 @@ class General extends Component
try { try {
if (!$this->database->destination->server->isLogDrainEnabled()) { if (!$this->database->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -66,7 +66,7 @@ class General extends Component
$this->database->redis_conf = null; $this->database->redis_conf = null;
} }
$this->database->save(); $this->database->save();
$this->emit('success', 'Database updated successfully.'); $this->dispatch('success', 'Database updated successfully.');
} catch (Exception $e) { } catch (Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -75,23 +75,23 @@ class General extends Component
{ {
try { try {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl(); $this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use Livewire\Component; use Livewire\Component;
@ -38,7 +38,7 @@ class ScheduledBackups extends Component
public function delete($scheduled_backup_id): void public function delete($scheduled_backup_id): void
{ {
$this->database->scheduledBackups->find($scheduled_backup_id)->delete(); $this->database->scheduledBackups->find($scheduled_backup_id)->delete();
$this->emit('success', 'Scheduled backup deleted successfully.'); $this->dispatch('success', 'Scheduled backup deleted successfully.');
$this->refreshScheduledBackups(); $this->refreshScheduledBackups();
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Environment; use App\Models\Environment;
use Livewire\Component; use Livewire\Component;
@ -23,8 +23,8 @@ class DeleteEnvironment extends Component
$environment = Environment::findOrFail($this->environment_id); $environment = Environment::findOrFail($this->environment_id);
if ($environment->isEmpty()) { if ($environment->isEmpty()) {
$environment->delete(); $environment->delete();
return redirect()->route('project.show', ['project_uuid' => $this->parameters['project_uuid']]); return $this->redirectRoute('project.show', ['project_uuid' => $this->parameters['project_uuid']], navigate: true);
} }
return $this->emit('error', 'Environment has defined resources, please delete them first.'); return $this->dispatch('error', 'Environment has defined resources, please delete them first.');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Project; use App\Models\Project;
use Livewire\Component; use Livewire\Component;
@ -22,9 +22,9 @@ class DeleteProject extends Component
]); ]);
$project = Project::findOrFail($this->project_id); $project = Project::findOrFail($this->project_id);
if ($project->applications->count() > 0) { if ($project->applications->count() > 0) {
return $this->emit('error', 'Project has resources defined, please delete them first.'); return $this->dispatch('error', 'Project has resources defined, please delete them first.');
} }
$project->delete(); $project->delete();
return redirect()->route('projects'); return $this->redirectRoute('projects', navigate: true);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Project; use App\Models\Project;
use Livewire\Component; use Livewire\Component;
@ -18,7 +18,7 @@ class Edit extends Component
$this->validate(); $this->validate();
try { try {
$this->project->save(); $this->project->save();
$this->emit('saved'); $this->dispatch('saved');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\EnvironmentVariable; use App\Models\EnvironmentVariable;
use App\Models\Project; use App\Models\Project;
@ -69,11 +69,12 @@ class DockerCompose extends Component
$service->parse(isNew: true); $service->parse(isNew: true);
return redirect()->route('project.service.configuration', [ return $this->redirectRoute('project.service.configuration', [
'service_uuid' => $service->uuid, 'service_uuid' => $service->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,
]); ]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Application; use App\Models\Application;
use App\Models\Project; use App\Models\Project;
@ -64,12 +64,11 @@ class DockerImage extends Component
'name' => 'docker-image-' . $application->uuid, 'name' => 'docker-image-' . $application->uuid,
'fqdn' => $fqdn 'fqdn' => $fqdn
]); ]);
return $this->redirectRoute('project.application.configuration', [
redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,
]); ], navigate: true);
} }
public function render() public function render()
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Project; use App\Models\Project;
use Livewire\Component; use Livewire\Component;
@ -13,6 +13,6 @@ class EmptyProject extends Component
'name' => generate_random_name(), 'name' => generate_random_name(),
'team_id' => currentTeam()->id, 'team_id' => currentTeam()->id,
]); ]);
return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']); return $this->redirectRoute('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production'], navigate: true);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Application; use App\Models\Application;
use App\Models\GithubApp; use App\Models\GithubApp;
@ -72,7 +72,7 @@ class GithubPrivateRepository extends Component
$response = Http::withToken($this->token)->get("{$this->github_app->api_url}/installation/repositories?per_page=100&page={$this->page}"); $response = Http::withToken($this->token)->get("{$this->github_app->api_url}/installation/repositories?per_page=100&page={$this->page}");
$json = $response->json(); $json = $response->json();
if ($response->status() !== 200) { if ($response->status() !== 200) {
return $this->emit('error', $json['message']); return $this->dispatch('error', $json['message']);
} }
if ($json['total_count'] === 0) { if ($json['total_count'] === 0) {
@ -104,7 +104,7 @@ class GithubPrivateRepository extends Component
$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}"); $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(); $json = $response->json();
if ($response->status() !== 200) { if ($response->status() !== 200) {
return $this->emit('error', $json['message']); return $this->dispatch('error', $json['message']);
} }
$this->total_branches_count = count($json); $this->total_branches_count = count($json);
@ -151,11 +151,11 @@ class GithubPrivateRepository extends Component
$application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid); $application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid);
$application->save(); $application->save();
redirect()->route('project.application.configuration', [ return $this->redirectRoute('project.application.configuration', [
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,
]); ], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -170,6 +170,6 @@ class GithubPrivateRepository extends Component
$this->port = 3000; $this->port = 3000;
$this->publish_directory = null; $this->publish_directory = null;
} }
$this->emit('success', 'Application settings updated!'); $this->dispatch('success', 'Application settings updated!');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Application; use App\Models\Application;
use App\Models\GithubApp; use App\Models\GithubApp;
@ -132,11 +132,11 @@ class GithubPrivateRepositoryDeployKey extends Component
$application->name = generate_random_name($application->uuid); $application->name = generate_random_name($application->uuid);
$application->save(); $application->save();
return redirect()->route('project.application.configuration', [ return $this->redirectRoute('project.application.configuration', [
'project_uuid' => $project->uuid,
'environment_name' => $environment->name,
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
]); 'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Application; use App\Models\Application;
use App\Models\GithubApp; use App\Models\GithubApp;
@ -63,7 +63,7 @@ class PublicGitRepository extends Component
$this->port = 3000; $this->port = 3000;
$this->publish_directory = null; $this->publish_directory = null;
} }
$this->emit('success', 'Application settings updated!'); $this->dispatch('success', 'Application settings updated!');
} }
public function load_any_git() public function load_any_git()
{ {
@ -184,11 +184,11 @@ class PublicGitRepository extends Component
$application->fqdn = $fqdn; $application->fqdn = $fqdn;
$application->save(); $application->save();
return redirect()->route('project.application.configuration', [ return $this->redirectRoute('project.application.configuration', [
'project_uuid' => $project->uuid,
'environment_name' => $environment->name,
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
]); 'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Project; use App\Models\Project;
use App\Models\Server; use App\Models\Server;
@ -47,23 +47,23 @@ class Select extends Component
} }
public function render() public function render()
{ {
if ($this->search) $this->loadServices(); $this->loadServices();
return view('livewire.project.new.select'); return view('livewire.project.new.select');
} }
public function updatedSelectedEnvironment() public function updatedSelectedEnvironment()
{ {
return redirect()->route('project.resources.new', [ return $this->redirectRoute('project.resources.new', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->selectedEnvironment, 'environment_name' => $this->selectedEnvironment,
]); ], navigate: true);
} }
// public function addExistingPostgresql() // public function addExistingPostgresql()
// { // {
// try { // try {
// instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'"); // instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'");
// $this->emit('success', 'Successfully connected to the database.'); // $this->dispatch('success', 'Successfully connected to the database.');
// } catch (\Throwable $e) { // } catch (\Throwable $e) {
// return handleError($e, $this); // return handleError($e, $this);
// } // }
@ -89,7 +89,7 @@ class Select extends Component
$this->services = $this->allServices->filter(function ($service, $key) { $this->services = $this->allServices->filter(function ($service, $key) {
return str_contains(strtolower($key), strtolower($this->search)); return str_contains(strtolower($key), strtolower($this->search));
});; });;
$this->emit('success', 'Successfully loaded services.'); $this->dispatch('success', 'Successfully loaded services.');
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
@ -133,7 +133,7 @@ class Select extends Component
public function setDestination(string $destination_uuid) public function setDestination(string $destination_uuid)
{ {
$this->destination_uuid = $destination_uuid; $this->destination_uuid = $destination_uuid;
redirect()->route('project.resources.new', [ return redirect()->route('project.resources.new', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
'type' => $this->type, 'type' => $this->type,

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\New; namespace App\Livewire\Project\New;
use App\Models\Application; use App\Models\Application;
use App\Models\GithubApp; use App\Models\GithubApp;
@ -70,10 +70,10 @@ CMD ["nginx", "-g", "daemon off;"]
'fqdn' => $fqdn 'fqdn' => $fqdn
]); ]);
redirect()->route('project.application.configuration', [ return $this->redirectRoute('project.application.configuration', [
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,
]); ], navigate: true);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;
use Livewire\Component; use Livewire\Component;
@ -30,18 +30,18 @@ class Application extends Component
{ {
if (!$this->application->service->destination->server->isLogDrainEnabled()) { if (!$this->application->service->destination->server->isLogDrainEnabled()) {
$this->application->is_log_drain_enabled = false; $this->application->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->application->save(); $this->application->save();
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} }
public function delete() public function delete()
{ {
try { try {
$this->application->delete(); $this->application->delete();
$this->emit('success', 'Application deleted successfully.'); $this->dispatch('success', 'Application deleted successfully.');
return redirect()->route('project.service.configuration', $this->parameters); return $this->redirectRoute('project.service.configuration', $this->parameters, navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -56,11 +56,11 @@ class Application extends Component
$this->validate(); $this->validate();
$this->application->save(); $this->application->save();
updateCompose($this->application); updateCompose($this->application);
$this->emit('success', 'Application saved successfully.'); $this->dispatch('success', 'Application saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {
$this->emit('generateDockerCompose'); $this->dispatch('generateDockerCompose');
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Actions\Database\StartDatabaseProxy; use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy; use App\Actions\Database\StopDatabaseProxy;
@ -38,32 +38,32 @@ class Database extends Component
{ {
if (!$this->database->service->destination->server->isLogDrainEnabled()) { if (!$this->database->service->destination->server->isLogDrainEnabled()) {
$this->database->is_log_drain_enabled = false; $this->database->is_log_drain_enabled = false;
$this->emit('error', 'Log drain is not enabled on the server. Please enable it first.'); $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
return; return;
} }
$this->submit(); $this->submit();
$this->emit('success', 'You need to restart the service for the changes to take effect.'); $this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} }
public function instantSave() public function instantSave()
{ {
if ($this->database->is_public && !$this->database->public_port) { if ($this->database->is_public && !$this->database->public_port) {
$this->emit('error', 'Public port is required.'); $this->dispatch('error', 'Public port is required.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
if ($this->database->is_public) { if ($this->database->is_public) {
if (!str($this->database->status)->startsWith('running')) { if (!str($this->database->status)->startsWith('running')) {
$this->emit('error', 'Database must be started to be publicly accessible.'); $this->dispatch('error', 'Database must be started to be publicly accessible.');
$this->database->is_public = false; $this->database->is_public = false;
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getServiceDatabaseUrl(); $this->db_url_public = $this->database->getServiceDatabaseUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->dispatch('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null; $this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->dispatch('success', 'Database is no longer publicly accessible.');
} }
$this->submit(); $this->submit();
} }
@ -77,11 +77,11 @@ class Database extends Component
$this->validate(); $this->validate();
$this->database->save(); $this->database->save();
updateCompose($this->database); updateCompose($this->database);
$this->emit('success', 'Database saved successfully.'); $this->dispatch('success', 'Database saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
ray($e); ray($e);
} finally { } finally {
$this->emit('generateDockerCompose'); $this->dispatch('generateDockerCompose');
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\LocalFileVolume; use App\Models\LocalFileVolume;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;
@ -42,7 +42,7 @@ class FileStorage extends Component
} }
$this->fileStorage->save(); $this->fileStorage->save();
$this->fileStorage->saveStorageOnServer($this->service); $this->fileStorage->saveStorageOnServer($this->service);
$this->emit('success', 'File updated successfully.'); $this->dispatch('success', 'File updated successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->fileStorage->setRawAttributes($original); $this->fileStorage->setRawAttributes($original);
$this->fileStorage->save(); $this->fileStorage->save();

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Jobs\ContainerStatusJob; use App\Jobs\ContainerStatusJob;
use App\Models\Service; use App\Models\Service;
@ -13,7 +13,15 @@ class Index extends Component
public $databases; public $databases;
public array $parameters; public array $parameters;
public array $query; public array $query;
protected $listeners = ["refreshStacks", "checkStatus"]; public function getListeners()
{
$userId = auth()->user()->id;
return [
"echo-private:custom.{$userId},ServiceStatusChanged" => 'checkStatus',
"refreshStacks",
"checkStatus",
];
}
public function render() public function render()
{ {
return view('livewire.project.service.index'); return view('livewire.project.service.index');
@ -28,8 +36,9 @@ class Index extends Component
} }
public function checkStatus() public function checkStatus()
{ {
dispatch(new ContainerStatusJob($this->service->server)); dispatch_sync(new ContainerStatusJob($this->service->server));
$this->refreshStacks(); $this->refreshStacks();
$this->dispatch('serviceStatusChanged');
} }
public function refreshStacks() public function refreshStacks()
{ {

View File

@ -1,14 +1,11 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use Livewire\Component; use Livewire\Component;
class Modal extends Component class Modal extends Component
{ {
public function checkStatus() {
$this->emit('checkStatus');
}
public function render() public function render()
{ {
return view('livewire.project.service.modal'); return view('livewire.project.service.modal');

View File

@ -0,0 +1,70 @@
<?php
namespace App\Livewire\Project\Service;
use App\Actions\Service\StartService;
use App\Actions\Service\StopService;
use App\Events\ServiceStatusChanged;
use App\Jobs\ContainerStatusJob;
use App\Models\Service;
use Livewire\Component;
use Spatie\Activitylog\Models\Activity;
class Navbar extends Component
{
public Service $service;
public array $parameters;
public array $query;
public $isDeploymentProgress = false;
public function checkDeployments()
{
$activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first();
$status = data_get($activity, 'properties.status');
if ($status === 'queued' || $status === 'in_progress') {
$this->isDeploymentProgress = true;
} else {
$this->isDeploymentProgress = false;
}
}
public function getListeners()
{
return [
"serviceStatusChanged"
];
}
public function serviceStatusChanged()
{
$this->service->refresh();
}
public function render()
{
return view('livewire.project.service.navbar');
}
public function checkStatus()
{
$this->service->refresh();
}
public function deploy()
{
$this->checkDeployments();
if ($this->isDeploymentProgress) {
$this->dispatch('error', 'There is a deployment in progress.');
return;
}
$this->service->parse();
$activity = StartService::run($this->service);
$this->dispatch('newMonitorActivity', $activity->id);
}
public function stop(bool $forceCleanup = false)
{
StopService::run($this->service);
$this->service->refresh();
if ($forceCleanup) {
$this->dispatch('success', 'Force cleanup service successfully.');
} else {
$this->dispatch('success', 'Service stopped successfully.');
}
ServiceStatusChanged::dispatch();
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\Service; use App\Models\Service;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use Livewire\Component; use Livewire\Component;
@ -54,9 +54,9 @@ class StackForm extends Component
$this->service->parse(); $this->service->parse();
$this->service->refresh(); $this->service->refresh();
$this->service->saveComposeConfigs(); $this->service->saveComposeConfigs();
$this->emit('refreshStacks'); $this->dispatch('refreshStacks');
$this->emit('refreshEnvs'); $this->dispatch('refreshEnvs');
$this->emit('success', 'Service saved successfully.'); $this->dispatch('success', 'Service saved successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\LocalPersistentVolume; use App\Models\LocalPersistentVolume;
use Livewire\Component; use Livewire\Component;
@ -25,9 +25,9 @@ class Storage extends Component
'resource_type' => $this->resource->getMorphClass(), 'resource_type' => $this->resource->getMorphClass(),
]); ]);
$this->resource->refresh(); $this->resource->refresh();
$this->emit('success', 'Storage added successfully'); $this->dispatch('success', 'Storage added successfully');
$this->emit('clearAddStorage'); $this->dispatch('clearAddStorage');
$this->emit('refreshStorages'); $this->dispatch('refreshStorages');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob; use App\Jobs\DeleteResourceJob;
use Livewire\Component; use Livewire\Component;
@ -22,10 +22,10 @@ class Danger extends Component
{ {
try { try {
DeleteResourceJob::dispatchSync($this->resource); DeleteResourceJob::dispatchSync($this->resource);
return redirect()->route('project.resources', [ return $this->redirectRoute('project.resources', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->parameters['environment_name'] 'environment_name' => $this->parameters['environment_name']
]); ], navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use Livewire\Component; use Livewire\Component;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\EnvironmentVariable; namespace App\Livewire\Project\Shared\EnvironmentVariable;
use Livewire\Component; use Livewire\Component;
@ -33,7 +33,7 @@ class Add extends Component
{ {
$this->validate(); $this->validate();
ray($this->key, $this->value, $this->is_build_time); ray($this->key, $this->value, $this->is_build_time);
$this->emitUp('submit', [ $this->dispatch('saveKey', [
'key' => $this->key, 'key' => $this->key,
'value' => $this->value, 'value' => $this->value,
'is_build_time' => $this->is_build_time, 'is_build_time' => $this->is_build_time,

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\EnvironmentVariable; namespace App\Livewire\Project\Shared\EnvironmentVariable;
use App\Models\EnvironmentVariable; use App\Models\EnvironmentVariable;
use Livewire\Component; use Livewire\Component;
@ -15,7 +15,7 @@ class All extends Component
public ?string $variables = null; public ?string $variables = null;
public ?string $variablesPreview = null; public ?string $variablesPreview = null;
public string $view = 'normal'; public string $view = 'normal';
protected $listeners = ['refreshEnvs', 'submit']; protected $listeners = ['refreshEnvs', 'saveKey' => 'submit'];
public function mount() public function mount()
{ {
@ -106,9 +106,9 @@ class All extends Component
} }
} }
if ($isPreview) { if ($isPreview) {
$this->emit('success', 'Preview environment variables updated successfully.'); $this->dispatch('success', 'Preview environment variables updated successfully.');
} else { } else {
$this->emit('success', 'Environment variables updated successfully.'); $this->dispatch('success', 'Environment variables updated successfully.');
} }
$this->refreshEnvs(); $this->refreshEnvs();
} }
@ -123,7 +123,7 @@ class All extends Component
try { try {
$found = $this->resource->environment_variables()->where('key', $data['key'])->first(); $found = $this->resource->environment_variables()->where('key', $data['key'])->first();
if ($found) { if ($found) {
$this->emit('error', 'Environment variable already exists.'); $this->dispatch('error', 'Environment variable already exists.');
return; return;
} }
$environment = new EnvironmentVariable(); $environment = new EnvironmentVariable();
@ -145,7 +145,7 @@ class All extends Component
} }
$environment->save(); $environment->save();
$this->refreshEnvs(); $this->refreshEnvs();
$this->emit('success', 'Environment variable added successfully.'); $this->dispatch('success', 'Environment variable added successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\EnvironmentVariable; namespace App\Livewire\Project\Shared\EnvironmentVariable;
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable; use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
use Livewire\Component; use Livewire\Component;
@ -49,7 +49,7 @@ class Show extends Component
$this->env->is_shown_once = true; $this->env->is_shown_once = true;
$this->env->save(); $this->env->save();
$this->checkEnvs(); $this->checkEnvs();
$this->emit('refreshEnvs'); $this->dispatch('refreshEnvs');
} }
public function instantSave() public function instantSave()
{ {
@ -59,13 +59,13 @@ class Show extends Component
{ {
$this->validate(); $this->validate();
$this->env->save(); $this->env->save();
$this->emit('success', 'Environment variable updated successfully.'); $this->dispatch('success', 'Environment variable updated successfully.');
$this->emit('refreshEnvs'); $this->dispatch('refreshEnvs');
} }
public function delete() public function delete()
{ {
$this->env->delete(); $this->env->delete();
$this->emit('refreshEnvs'); $this->dispatch('refreshEnvs');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;
@ -10,6 +10,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql; use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql; use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis; use App\Models\StandaloneRedis;
use Illuminate\Support\Sleep;
use Livewire\Component; use Livewire\Component;
class ExecuteContainerCommand extends Component class ExecuteContainerCommand extends Component
@ -23,7 +24,16 @@ class ExecuteContainerCommand extends Component
public string $workDir = ''; public string $workDir = '';
public Server $server; public Server $server;
public $servers = []; public $servers = [];
public function getListeners()
{
return [
"serviceStatusChanged",
];
}
public function serviceStatusChanged()
{
$this->getContainers();
}
protected $rules = [ protected $rules = [
'server' => 'required', 'server' => 'required',
'container' => 'required', 'container' => 'required',
@ -33,8 +43,12 @@ class ExecuteContainerCommand extends Component
public function mount() public function mount()
{ {
$this->containers = collect();
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
$this->getContainers();
}
public function getContainers()
{
$this->containers = collect();
if (data_get($this->parameters, 'application_uuid')) { if (data_get($this->parameters, 'application_uuid')) {
$this->type = 'application'; $this->type = 'application';
$this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail(); $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();
@ -101,7 +115,7 @@ class ExecuteContainerCommand extends Component
$exec = "docker exec {$this->container} {$cmd}"; $exec = "docker exec {$this->container} {$cmd}";
} }
$activity = remote_process([$exec], $this->server, ignore_errors: true); $activity = remote_process([$exec], $this->server, ignore_errors: true);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;
@ -19,7 +19,7 @@ class GetLogs extends Component
{ {
public string $outputs = ''; public string $outputs = '';
public string $errors = ''; public string $errors = '';
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $resource; public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|null $resource = null;
public ServiceApplication|ServiceDatabase|null $servicesubtype = null; public ServiceApplication|ServiceDatabase|null $servicesubtype = null;
public Server $server; public Server $server;
public ?string $container = null; public ?string $container = null;
@ -29,6 +29,7 @@ class GetLogs extends Component
public function mount() public function mount()
{ {
if (!is_null($this->resource)) {
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === 'App\Models\Application') {
$this->showTimeStamps = $this->resource->settings->is_include_timestamps; $this->showTimeStamps = $this->resource->settings->is_include_timestamps;
} else { } else {
@ -39,12 +40,14 @@ class GetLogs extends Component
} }
} }
} }
}
public function doSomethingWithThisChunkOfOutput($output) public function doSomethingWithThisChunkOfOutput($output)
{ {
$this->outputs .= removeAnsiColors($output); $this->outputs .= removeAnsiColors($output);
} }
public function instantSave() public function instantSave()
{ {
if (!is_null($this->resource)) {
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === 'App\Models\Application') {
$this->resource->settings->is_include_timestamps = $this->showTimeStamps; $this->resource->settings->is_include_timestamps = $this->showTimeStamps;
$this->resource->settings->save(); $this->resource->settings->save();
@ -58,6 +61,7 @@ class GetLogs extends Component
} }
} }
} }
}
public function getLogs($refresh = false) public function getLogs($refresh = false)
{ {
if ($this->container) { if ($this->container) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use Livewire\Component; use Livewire\Component;
@ -26,7 +26,7 @@ class HealthChecks extends Component
public function instantSave() public function instantSave()
{ {
$this->resource->save(); $this->resource->save();
$this->emit('success', 'Health check updated.'); $this->dispatch('success', 'Health check updated.');
} }
@ -35,7 +35,7 @@ class HealthChecks extends Component
try { try {
$this->validate(); $this->validate();
$this->resource->save(); $this->resource->save();
$this->emit('success', 'Health check updated.'); $this->dispatch('success', 'Health check updated.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use Livewire\Component; use Livewire\Component;
@ -52,7 +52,7 @@ class ResourceLimits extends Component
} }
$this->validate(); $this->validate();
$this->resource->save(); $this->resource->save();
$this->emit('success', 'Resource limits updated successfully.'); $this->dispatch('success', 'Resource limits updated successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\Storages; namespace App\Livewire\Project\Shared\Storages;
use Livewire\Component; use Livewire\Component;
@ -33,7 +33,7 @@ class Add extends Component
{ {
$this->validate(); $this->validate();
$name = $this->uuid . '-' . $this->name; $name = $this->uuid . '-' . $this->name;
$this->emit('addNewVolume', [ $this->dispatch('addNewVolume', [
'name' => $name, 'name' => $name,
'mount_path' => $this->mount_path, 'mount_path' => $this->mount_path,
'host_path' => $this->host_path, 'host_path' => $this->host_path,

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\Storages; namespace App\Livewire\Project\Shared\Storages;
use App\Models\LocalPersistentVolume; use App\Models\LocalPersistentVolume;
use Livewire\Component; use Livewire\Component;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared\Storages; namespace App\Livewire\Project\Shared\Storages;
use App\Models\LocalPersistentVolume; use App\Models\LocalPersistentVolume;
use Livewire\Component; use Livewire\Component;
@ -33,12 +33,12 @@ class Show extends Component
{ {
$this->validate(); $this->validate();
$this->storage->save(); $this->storage->save();
$this->emit('success', 'Storage updated successfully'); $this->dispatch('success', 'Storage updated successfully');
} }
public function delete() public function delete()
{ {
$this->storage->delete(); $this->storage->delete();
$this->emit('refreshStorages'); $this->dispatch('refreshStorages');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use Livewire\Component; use Livewire\Component;
@ -19,7 +19,7 @@ class Webhooks extends Component
try { try {
$this->validate(); $this->validate();
$this->resource->save(); $this->resource->save();
$this->emit('success','Secret Saved.'); $this->dispatch('success','Secret Saved.');
} catch (\Exception $e) { } catch (\Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Livewire;
use App\Models\Server; use App\Models\Server;
use Livewire\Component; use Livewire\Component;
@ -31,7 +31,7 @@ class RunCommand extends Component
$this->validate(); $this->validate();
try { try {
$activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true); $activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Security; namespace App\Livewire\Security;
use Livewire\Component; use Livewire\Component;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use App\Models\Server; use App\Models\Server;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use Livewire\Component; use Livewire\Component;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component; use Livewire\Component;
@ -15,11 +15,11 @@ class Delete extends Component
try { try {
$this->authorize('delete', $this->server); $this->authorize('delete', $this->server);
if ($this->server->hasDefinedResources()) { if ($this->server->hasDefinedResources()) {
$this->emit('error', 'Server has defined resources. Please delete them first.'); $this->dispatch('error', 'Server has defined resources. Please delete them first.');
return; return;
} }
$this->server->delete(); $this->server->delete();
return redirect()->route('server.all'); return $this->redirectRoute('server.all', navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server\Destination; namespace App\Livewire\Server\Destination;
use App\Models\Server; use App\Models\Server;
use Livewire\Component; use Livewire\Component;
@ -13,9 +13,9 @@ class Show extends Component
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
try { try {
$this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) { if (is_null($this->server)) {
return redirect()->route('server.all'); return $this->redirectRoute('server.all', navigate: true);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use App\Actions\Server\InstallDocker; use App\Actions\Server\InstallDocker;
use App\Models\Server; use App\Models\Server;
@ -44,8 +44,10 @@ class Form extends Component
{ {
$this->wildcard_domain = $this->server->settings->wildcard_domain; $this->wildcard_domain = $this->server->settings->wildcard_domain;
$this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage; $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
if (!$this->server->isFunctional()) {
$this->validateServer(); $this->validateServer();
} }
}
public function serverRefresh($install = true) public function serverRefresh($install = true)
{ {
$this->validateServer($install); $this->validateServer($install);
@ -56,28 +58,28 @@ class Form extends Component
refresh_server_connection($this->server->privateKey); refresh_server_connection($this->server->privateKey);
$this->validateServer(false); $this->validateServer(false);
$this->server->settings->save(); $this->server->settings->save();
$this->emit('success', 'Server updated successfully.'); $this->dispatch('success', 'Server updated successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
} }
public function installDocker() public function installDocker()
{ {
$this->emit('installDocker'); $this->dispatch('installDocker');
$this->dockerInstallationStarted = true; $this->dockerInstallationStarted = true;
$activity = InstallDocker::run($this->server); $activity = InstallDocker::run($this->server);
$this->emit('newMonitorActivity', $activity->id); $this->dispatch('newMonitorActivity', $activity->id);
} }
public function checkLocalhostConnection() public function checkLocalhostConnection()
{ {
$uptime = $this->server->validateConnection(); $uptime = $this->server->validateConnection();
if ($uptime) { if ($uptime) {
$this->emit('success', 'Server is reachable.'); $this->dispatch('success', 'Server is reachable.');
$this->server->settings->is_reachable = true; $this->server->settings->is_reachable = true;
$this->server->settings->is_usable = true; $this->server->settings->is_usable = true;
$this->server->settings->save(); $this->server->settings->save();
} else { } else {
$this->emit('error', 'Server is not reachable. Please check your connection and configuration.'); $this->dispatch('error', 'Server is not reachable. Please check your connection and configuration.');
return; return;
} }
} }
@ -86,24 +88,24 @@ class Form extends Component
try { try {
$uptime = $this->server->validateConnection(); $uptime = $this->server->validateConnection();
if (!$uptime) { if (!$uptime) {
$install && $this->emit('error', 'Server is not reachable. Please check your connection and configuration.'); $install && $this->dispatch('error', 'Server is not reachable. Please check your connection and configuration.');
return; return;
} }
$supported_os_type = $this->server->validateOS(); $supported_os_type = $this->server->validateOS();
if (!$supported_os_type) { if (!$supported_os_type) {
$install && $this->emit('error', 'Server OS type is not supported for automated installation. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://coolify.io/docs/servers#install-docker-engine-manually">documentation</a>.'); $install && $this->dispatch('error', 'Server OS type is not supported for automated installation. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://coolify.io/docs/servers#install-docker-engine-manually">documentation</a>.');
return; return;
} }
$dockerInstalled = $this->server->validateDockerEngine(); $dockerInstalled = $this->server->validateDockerEngine();
if ($dockerInstalled) { if ($dockerInstalled) {
$install && $this->emit('success', 'Docker Engine is installed.<br> Checking version.'); $install && $this->dispatch('success', 'Docker Engine is installed.<br> Checking version.');
} else { } else {
$install && $this->installDocker(); $install && $this->installDocker();
return; return;
} }
$dockerVersion = $this->server->validateDockerEngineVersion(); $dockerVersion = $this->server->validateDockerEngineVersion();
if ($dockerVersion) { if ($dockerVersion) {
$install && $this->emit('success', 'Docker Engine version is 22+.'); $install && $this->dispatch('success', 'Docker Engine version is 22+.');
} else { } else {
$install && $this->installDocker(); $install && $this->installDocker();
return; return;
@ -111,13 +113,13 @@ class Form extends Component
if ($this->server->isSwarm()) { if ($this->server->isSwarm()) {
$swarmInstalled = $this->server->validateDockerSwarm(); $swarmInstalled = $this->server->validateDockerSwarm();
if ($swarmInstalled) { if ($swarmInstalled) {
$install && $this->emit('success', 'Docker Swarm is initiated.'); $install && $this->dispatch('success', 'Docker Swarm is initiated.');
} }
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {
$this->emit('proxyStatusUpdated'); $this->dispatch('proxyStatusUpdated');
} }
} }
@ -135,7 +137,7 @@ class Form extends Component
return $server->id === $this->server->id; return $server->id === $this->server->id;
})->pluck('ip')->toArray(); })->pluck('ip')->toArray();
if (in_array($this->server->ip, $uniqueIPs)) { if (in_array($this->server->ip, $uniqueIPs)) {
$this->emit('error', 'IP address is already in use by another team.'); $this->dispatch('error', 'IP address is already in use by another team.');
return; return;
} }
refresh_server_connection($this->server->privateKey); refresh_server_connection($this->server->privateKey);
@ -143,6 +145,6 @@ class Form extends Component
$this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage; $this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
$this->server->settings->save(); $this->server->settings->save();
$this->server->save(); $this->server->save();
$this->emit('success', 'Server updated successfully.'); $this->dispatch('success', 'Server updated successfully.');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use App\Actions\Server\InstallLogDrain; use App\Actions\Server\InstallLogDrain;
use App\Models\Server; use App\Models\Server;
@ -41,9 +41,9 @@ class LogDrains extends Component
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
try { try {
$server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); $server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($server)) { if (is_null($server)) {
return redirect()->route('server.all'); return $this->redirectRoute('server.all', navigate: true);
} }
$this->server = $server; $this->server = $server;
} catch (\Throwable $e) { } catch (\Throwable $e) {
@ -55,12 +55,12 @@ class LogDrains extends Component
try { try {
InstallLogDrain::run($this->server); InstallLogDrain::run($this->server);
if (!$this->server->isLogDrainEnabled()) { if (!$this->server->isLogDrainEnabled()) {
$this->emit('serverRefresh'); $this->dispatch('serverRefresh');
$this->emit('success', 'Log drain service stopped.'); $this->dispatch('success', 'Log drain service stopped.');
return; return;
} }
$this->emit('serverRefresh'); $this->dispatch('serverRefresh');
$this->emit('success', 'Log drain service started successfully.'); $this->dispatch('success', 'Log drain service started successfully.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -126,7 +126,7 @@ class LogDrains extends Component
]); ]);
} }
$this->server->settings->save(); $this->server->settings->save();
$this->emit('success', 'Settings saved successfully.'); $this->dispatch('success', 'Settings saved successfully.');
return true; return true;
} catch (\Throwable $e) { } catch (\Throwable $e) {
if ($type === 'newrelic') { if ($type === 'newrelic') {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server\New; namespace App\Livewire\Server\New;
use App\Enums\ProxyStatus; use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes; use App\Enums\ProxyTypes;
@ -53,7 +53,7 @@ class ByIp extends Component
public function instantSave() public function instantSave()
{ {
$this->emit('success', 'Application settings updated!'); $this->dispatch('success', 'Application settings updated!');
} }
public function submit() public function submit()
@ -61,7 +61,7 @@ class ByIp extends Component
$this->validate(); $this->validate();
try { try {
if (is_null($this->private_key_id)) { if (is_null($this->private_key_id)) {
return $this->emit('error', 'You must select a private key'); return $this->dispatch('error', 'You must select a private key');
} }
$server = Server::create([ $server = Server::create([
'name' => $this->name, 'name' => $this->name,
@ -79,7 +79,7 @@ class ByIp extends Component
$server->settings->is_swarm_manager = $this->is_swarm_manager; $server->settings->is_swarm_manager = $this->is_swarm_manager;
$server->settings->save(); $server->settings->save();
$server->addInitialNetwork(); $server->addInitialNetwork();
return redirect()->route('server.show', $server->uuid); return $this->redirectRoute('server.show', $server->uuid, navigate: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server\PrivateKey; namespace App\Livewire\Server\PrivateKey;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use App\Models\Server; use App\Models\Server;
@ -17,7 +17,7 @@ class Show extends Component
try { try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) { if (is_null($this->server)) {
return redirect()->route('server.all'); return $this->redirectRoute('server.all', navigate: true);
} }
$this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false); $this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false);
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Livewire\Server; namespace App\Livewire\Server;
use App\Actions\Proxy\CheckConfiguration; use App\Actions\Proxy\CheckConfiguration;
use App\Actions\Proxy\SaveConfiguration; use App\Actions\Proxy\SaveConfiguration;
@ -33,7 +33,7 @@ class Proxy extends Component
{ {
$this->server->proxy = null; $this->server->proxy = null;
$this->server->save(); $this->server->save();
$this->emit('proxyStatusUpdated'); $this->dispatch('proxyStatusUpdated');
} }
public function select_proxy($proxy_type) public function select_proxy($proxy_type)
@ -42,7 +42,7 @@ class Proxy extends Component
$this->server->proxy->set('type', $proxy_type); $this->server->proxy->set('type', $proxy_type);
$this->server->save(); $this->server->save();
$this->selectedProxy = $this->server->proxy->type; $this->selectedProxy = $this->server->proxy->type;
$this->emit('proxyStatusUpdated'); $this->dispatch('proxyStatusUpdated');
} }
public function submit() public function submit()
@ -53,7 +53,7 @@ class Proxy extends Component
$this->server->save(); $this->server->save();
setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server); setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server);
$this->emit('success', 'Proxy configuration saved.'); $this->dispatch('success', 'Proxy configuration saved.');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -73,9 +73,9 @@ class Proxy extends Component
try { try {
$this->proxy_settings = CheckConfiguration::run($this->server); $this->proxy_settings = CheckConfiguration::run($this->server);
if (Str::of($this->proxy_settings)->contains('--api.dashboard=true') && Str::of($this->proxy_settings)->contains('--api.insecure=true')) { if (Str::of($this->proxy_settings)->contains('--api.dashboard=true') && Str::of($this->proxy_settings)->contains('--api.insecure=true')) {
$this->emit('traefikDashboardAvailable', true); $this->dispatch('traefikDashboardAvailable', true);
} else { } else {
$this->emit('traefikDashboardAvailable', false); $this->dispatch('traefikDashboardAvailable', false);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {

Some files were not shown because too many files have changed in this diff Show More