@@ -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;
|
||||||
|
@@ -17,24 +17,24 @@ 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;
|
||||||
|
|
||||||
protected $last_write_at = 0;
|
protected $last_write_at = 0;
|
||||||
|
|
||||||
protected $throttle_interval_ms = 500;
|
protected $throttle_interval_ms = 200;
|
||||||
|
|
||||||
protected int $counter = 1;
|
protected int $counter = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -74,17 +74,29 @@ class RunRemoteProcess
|
|||||||
$this->time_start = hrtime(true);
|
$this->time_start = hrtime(true);
|
||||||
|
|
||||||
$status = ProcessStatus::IN_PROGRESS;
|
$status = ProcessStatus::IN_PROGRESS;
|
||||||
$processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...));
|
$timeout = config('constants.ssh.command_timeout');
|
||||||
|
$process = Process::timeout($timeout)->start($this->getCommand(), $this->handleOutput(...));
|
||||||
|
$this->activity->properties = $this->activity->properties->merge([
|
||||||
|
'process_id' => $process->id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$processResult = $process->wait();
|
||||||
|
// $processResult = Process::timeout($timeout)->run($this->getCommand(), $this->handleOutput(...));
|
||||||
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 +109,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +137,6 @@ class RunRemoteProcess
|
|||||||
}
|
}
|
||||||
$this->current_time = $this->elapsedTime();
|
$this->current_time = $this->elapsedTime();
|
||||||
$this->activity->description = $this->encodeOutput($type, $output);
|
$this->activity->description = $this->encodeOutput($type, $output);
|
||||||
|
|
||||||
if ($this->isAfterLastThrottle()) {
|
if ($this->isAfterLastThrottle()) {
|
||||||
// Let's write to database.
|
// Let's write to database.
|
||||||
DB::transaction(function () {
|
DB::transaction(function () {
|
||||||
|
@@ -105,7 +105,7 @@ class StartMariadb
|
|||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
||||||
$this->commands[] = "echo '{$database->name} started.'";
|
$this->commands[] = "echo '{$database->name} started.'";
|
||||||
return remote_process($this->commands, $database->destination->server);
|
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
|
@@ -121,7 +121,7 @@ class StartMongodb
|
|||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
||||||
$this->commands[] = "echo '{$database->name} started.'";
|
$this->commands[] = "echo '{$database->name} started.'";
|
||||||
return remote_process($this->commands, $database->destination->server);
|
return remote_process($this->commands, $database->destination->server,callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
|
@@ -105,7 +105,7 @@ class StartMysql
|
|||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
||||||
$this->commands[] = "echo '{$database->name} started.'";
|
$this->commands[] = "echo '{$database->name} started.'";
|
||||||
return remote_process($this->commands, $database->destination->server);
|
return remote_process($this->commands, $database->destination->server,callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
|
@@ -131,7 +131,7 @@ class StartPostgresql
|
|||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
||||||
$this->commands[] = "echo '{$database->name} started.'";
|
$this->commands[] = "echo '{$database->name} started.'";
|
||||||
return remote_process($this->commands, $database->destination->server);
|
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
|
@@ -115,7 +115,7 @@ class StartRedis
|
|||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";
|
||||||
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
|
||||||
$this->commands[] = "echo '{$database->name} started.'";
|
$this->commands[] = "echo '{$database->name} started.'";
|
||||||
return remote_process($this->commands, $database->destination->server);
|
return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_local_persistent_volumes()
|
private function generate_local_persistent_volumes()
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Actions\Database;
|
namespace App\Actions\Database;
|
||||||
|
|
||||||
|
use App\Events\DatabaseStatusChanged;
|
||||||
use App\Models\StandaloneMariadb;
|
use App\Models\StandaloneMariadb;
|
||||||
use App\Models\StandaloneMongodb;
|
use App\Models\StandaloneMongodb;
|
||||||
use App\Models\StandaloneMysql;
|
use App\Models\StandaloneMysql;
|
||||||
|
42
app/Actions/Service/DeleteService.php
Normal file
42
app/Actions/Service/DeleteService.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,11 @@ class CoolifyTaskArgs extends Data
|
|||||||
public string $command,
|
public string $command,
|
||||||
public string $type,
|
public string $type,
|
||||||
public ?string $type_uuid = null,
|
public ?string $type_uuid = null,
|
||||||
|
public ?int $process_id = null,
|
||||||
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;
|
||||||
|
@@ -8,5 +8,6 @@ enum ProcessStatus: string
|
|||||||
case IN_PROGRESS = 'in_progress';
|
case IN_PROGRESS = 'in_progress';
|
||||||
case FINISHED = 'finished';
|
case FINISHED = 'finished';
|
||||||
case ERROR = 'error';
|
case ERROR = 'error';
|
||||||
|
case KILLED = 'killed';
|
||||||
case CANCELLED = 'cancelled';
|
case CANCELLED = 'cancelled';
|
||||||
}
|
}
|
||||||
|
34
app/Events/ApplicationStatusChanged.php
Normal file
34
app/Events/ApplicationStatusChanged.php
Normal 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 ApplicationStatusChanged implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
public $teamId;
|
||||||
|
public function __construct($teamId = null)
|
||||||
|
{
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
$teamId = auth()->user()->currentTeam()->id ?? null;
|
||||||
|
}
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
throw new \Exception("Team id is null");
|
||||||
|
}
|
||||||
|
$this->teamId = $teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel("team.{$this->teamId}"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
34
app/Events/BackupCreated.php
Normal file
34
app/Events/BackupCreated.php
Normal 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 BackupCreated implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
public $teamId;
|
||||||
|
public function __construct($teamId = null)
|
||||||
|
{
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
$teamId = auth()->user()->currentTeam()->id ?? null;
|
||||||
|
}
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
throw new \Exception("Team id is null");
|
||||||
|
}
|
||||||
|
$this->teamId = $teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel("team.{$this->teamId}"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
34
app/Events/DatabaseStatusChanged.php
Normal file
34
app/Events/DatabaseStatusChanged.php
Normal 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 DatabaseStatusChanged 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("user.{$this->userId}"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
34
app/Events/ServiceStatusChanged.php
Normal file
34
app/Events/ServiceStatusChanged.php
Normal 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("user.{$this->userId}"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -22,7 +22,7 @@ class TestEvent implements ShouldBroadcast
|
|||||||
public function broadcastOn(): array
|
public function broadcastOn(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new PrivateChannel("custom.{$this->teamId}"),
|
new PrivateChannel("team.{$this->teamId}"),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,10 @@ class Controller extends BaseController
|
|||||||
if (isInstanceAdmin()) {
|
if (isInstanceAdmin()) {
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
$database = StandalonePostgresql::whereName('coolify-db')->first();
|
$database = StandalonePostgresql::whereName('coolify-db')->first();
|
||||||
|
if ($database->status !== 'running') {
|
||||||
|
$database->status = 'running';
|
||||||
|
$database->save();
|
||||||
|
}
|
||||||
if ($database) {
|
if ($database) {
|
||||||
$s3s = S3Storage::whereTeamId(0)->get();
|
$s3s = S3Storage::whereTeamId(0)->get();
|
||||||
}
|
}
|
||||||
|
@@ -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,
|
||||||
|
@@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire\Project\Application;
|
|
||||||
|
|
||||||
use App\Models\Application;
|
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\Service;
|
|
||||||
use App\Models\StandaloneMariadb;
|
|
||||||
use App\Models\StandaloneMongodb;
|
|
||||||
use App\Models\StandaloneMysql;
|
|
||||||
use App\Models\StandalonePostgresql;
|
|
||||||
use App\Models\StandaloneRedis;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Command extends Component
|
|
||||||
{
|
|
||||||
public string $command;
|
|
||||||
public string $container;
|
|
||||||
public $containers;
|
|
||||||
public $parameters;
|
|
||||||
public $resource;
|
|
||||||
public string $type;
|
|
||||||
public string $workDir = '';
|
|
||||||
public Server $server;
|
|
||||||
public $servers = [];
|
|
||||||
|
|
||||||
protected $rules = [
|
|
||||||
'server' => 'required',
|
|
||||||
'container' => 'required',
|
|
||||||
'command' => 'required',
|
|
||||||
'workDir' => 'nullable',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->containers = collect();
|
|
||||||
$this->parameters = get_route_parameters();
|
|
||||||
if (data_get($this->parameters, 'application_uuid')) {
|
|
||||||
$this->type = 'application';
|
|
||||||
$this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();
|
|
||||||
$this->server = $this->resource->destination->server;
|
|
||||||
$containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, 0);
|
|
||||||
if ($containers->count() > 0) {
|
|
||||||
$containers->each(function ($container) {
|
|
||||||
$this->containers->push(str_replace('/', '', $container['Names']));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (data_get($this->parameters, 'database_uuid')) {
|
|
||||||
$this->type = 'database';
|
|
||||||
$resource = StandalonePostgresql::where('uuid', $this->parameters['database_uuid'])->first();
|
|
||||||
if (is_null($resource)) {
|
|
||||||
$resource = StandaloneRedis::where('uuid', $this->parameters['database_uuid'])->first();
|
|
||||||
if (is_null($resource)) {
|
|
||||||
$resource = StandaloneMongodb::where('uuid', $this->parameters['database_uuid'])->first();
|
|
||||||
if (is_null($resource)) {
|
|
||||||
$resource = StandaloneMysql::where('uuid', $this->parameters['database_uuid'])->first();
|
|
||||||
if (is_null($resource)) {
|
|
||||||
$resource = StandaloneMariadb::where('uuid', $this->parameters['database_uuid'])->first();
|
|
||||||
if (is_null($resource)) {
|
|
||||||
abort(404);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->resource = $resource;
|
|
||||||
$this->server = $this->resource->destination->server;
|
|
||||||
$this->container = $this->resource->uuid;
|
|
||||||
$this->containers->push($this->container);
|
|
||||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
|
||||||
$this->type = 'service';
|
|
||||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
|
||||||
$this->resource->applications()->get()->each(function ($application) {
|
|
||||||
if (str(data_get($application, 'status'))->contains('running')) {
|
|
||||||
$this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$this->resource->databases()->get()->each(function ($database) {
|
|
||||||
if (str(data_get($database, 'status'))->contains('running')) {
|
|
||||||
$this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->server = $this->resource->server;
|
|
||||||
}
|
|
||||||
if ($this->containers->count() > 1) {
|
|
||||||
$this->container = $this->containers->first();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function runCommand()
|
|
||||||
{
|
|
||||||
$this->validate();
|
|
||||||
try {
|
|
||||||
if (!empty($this->workDir)) {
|
|
||||||
$exec = "docker exec -w {$this->workDir} {$this->container} {$this->command}";
|
|
||||||
} else {
|
|
||||||
$exec = "docker exec {$this->container} {$this->command}";
|
|
||||||
}
|
|
||||||
$activity = remote_process([$exec], $this->server, ignore_errors: true);
|
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.project.shared.execute-container-command');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire\Project\Shared;
|
|
||||||
|
|
||||||
use App\Jobs\DeleteResourceJob;
|
|
||||||
use Livewire\Component;
|
|
||||||
use Visus\Cuid2\Cuid2;
|
|
||||||
|
|
||||||
class Danger extends Component
|
|
||||||
{
|
|
||||||
public $resource;
|
|
||||||
public array $parameters;
|
|
||||||
public ?string $modalId = null;
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->modalId = new Cuid2(7);
|
|
||||||
$this->parameters = get_route_parameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
DeleteResourceJob::dispatchSync($this->resource);
|
|
||||||
return redirect()->route('project.resources', [
|
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
|
||||||
'environment_name' => $this->parameters['environment_name']
|
|
||||||
]);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -4,6 +4,7 @@ namespace App\Jobs;
|
|||||||
|
|
||||||
use App\Enums\ApplicationDeploymentStatus;
|
use App\Enums\ApplicationDeploymentStatus;
|
||||||
use App\Enums\ProxyTypes;
|
use App\Enums\ProxyTypes;
|
||||||
|
use App\Events\ApplicationStatusChanged;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
use App\Models\ApplicationDeploymentQueue;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
@@ -266,6 +267,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
"ignore_errors" => true,
|
"ignore_errors" => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
ApplicationStatusChanged::dispatch(data_get($this->application,'environment.project.team.id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function push_to_docker_registry()
|
private function push_to_docker_registry()
|
||||||
@@ -451,6 +453,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d > {$this->workdir}{$this->docker_compose_location}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d > {$this->workdir}{$this->docker_compose_location}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
$this->save_environment_variables();
|
$this->save_environment_variables();
|
||||||
|
// Build new container to limit downtime.
|
||||||
|
$this->build_by_compose_file();
|
||||||
$this->stop_running_container(force: true);
|
$this->stop_running_container(force: true);
|
||||||
|
|
||||||
$networkId = $this->application->uuid;
|
$networkId = $this->application->uuid;
|
||||||
@@ -1243,6 +1247,28 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function build_by_compose_file() {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Pulling & building required images.");
|
||||||
|
if ($this->application->build_pack === 'dockerimage') {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
|
||||||
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} build"), "hidden" => true],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if ($this->docker_compose_location) {
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} build"), "hidden" => true],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->application_deployment_queue->addLogEntry("New images built.");
|
||||||
|
}
|
||||||
|
|
||||||
private function start_by_compose_file()
|
private function start_by_compose_file()
|
||||||
{
|
{
|
||||||
if ($this->application->build_pack === 'dockerimage') {
|
if ($this->application->build_pack === 'dockerimage') {
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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();
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
use App\Actions\Database\StopDatabase;
|
use App\Actions\Database\StopDatabase;
|
||||||
|
use App\Events\BackupCreated;
|
||||||
use App\Models\S3Storage;
|
use App\Models\S3Storage;
|
||||||
use App\Models\ScheduledDatabaseBackup;
|
use App\Models\ScheduledDatabaseBackup;
|
||||||
use App\Models\ScheduledDatabaseBackupExecution;
|
use App\Models\ScheduledDatabaseBackupExecution;
|
||||||
@@ -74,6 +75,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
BackupCreated::dispatch($this->team->id);
|
||||||
// Check if team is exists
|
// Check if team is exists
|
||||||
if (is_null($this->team)) {
|
if (is_null($this->team)) {
|
||||||
$this->backup->update(['status' => 'failed']);
|
$this->backup->update(['status' => 'failed']);
|
||||||
@@ -307,6 +309,8 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage());
|
send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage());
|
||||||
throw $e;
|
throw $e;
|
||||||
|
} finally {
|
||||||
|
BackupCreated::dispatch($this->team->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function backup_standalone_mongodb(string $databaseWithCollections): void
|
private function backup_standalone_mongodb(string $databaseWithCollections): void
|
||||||
|
@@ -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;
|
|
||||||
}
|
}
|
||||||
$this->resource->delete();
|
if ($this->resource->type() === 'service') {
|
||||||
|
$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;
|
||||||
|
@@ -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();
|
||||||
}
|
// }
|
||||||
}
|
}
|
@@ -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);
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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;
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Livewire\Dev;
|
namespace App\Livewire\Dev;
|
||||||
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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 {
|
@@ -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 {
|
@@ -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()
|
||||||
{
|
{
|
@@ -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;
|
@@ -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;
|
@@ -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()
|
@@ -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;
|
@@ -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 {
|
@@ -1,8 +1,9 @@
|
|||||||
<?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\Events\ApplicationStatusChanged;
|
||||||
use App\Jobs\ContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Jobs\ServerStatusJob;
|
use App\Jobs\ServerStatusJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
@@ -15,13 +16,19 @@ class Heading extends Component
|
|||||||
public array $parameters;
|
public array $parameters;
|
||||||
|
|
||||||
protected string $deploymentUuid;
|
protected string $deploymentUuid;
|
||||||
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$teamId = auth()->user()->currentTeam()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'check_status',
|
||||||
|
];
|
||||||
|
}
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function check_status()
|
public function check_status($showNotification = false)
|
||||||
{
|
{
|
||||||
if ($this->application->destination->server->isFunctional()) {
|
if ($this->application->destination->server->isFunctional()) {
|
||||||
dispatch(new ContainerStatusJob($this->application->destination->server));
|
dispatch(new ContainerStatusJob($this->application->destination->server));
|
||||||
@@ -32,6 +39,7 @@ class Heading extends Component
|
|||||||
} else {
|
} else {
|
||||||
dispatch(new ServerStatusJob($this->application->destination->server));
|
dispatch(new ServerStatusJob($this->application->destination->server));
|
||||||
}
|
}
|
||||||
|
if ($showNotification) $this->dispatch('success', 'Application status updated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function force_deploy_without_cache()
|
public function force_deploy_without_cache()
|
||||||
@@ -42,7 +50,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 +60,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 +79,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 +109,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 +124,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
@@ -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!');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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;
|
||||||
@@ -10,13 +10,21 @@ class BackupExecutions extends Component
|
|||||||
public $backup;
|
public $backup;
|
||||||
public $executions;
|
public $executions;
|
||||||
public $setDeletableBackup;
|
public $setDeletableBackup;
|
||||||
protected $listeners = ['refreshBackupExecutions', 'deleteBackup'];
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$userId = auth()->user()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:team.{$userId},BackupCreated" => 'refreshBackupExecutions',
|
||||||
|
"refreshBackupExecutions",
|
||||||
|
"deleteBackup"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function deleteBackup($exeuctionId)
|
public function deleteBackup($exeuctionId)
|
||||||
{
|
{
|
||||||
$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 +33,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');
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
@@ -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;
|
||||||
@@ -8,6 +8,7 @@ use App\Actions\Database\StartMysql;
|
|||||||
use App\Actions\Database\StartPostgresql;
|
use App\Actions\Database\StartPostgresql;
|
||||||
use App\Actions\Database\StartRedis;
|
use App\Actions\Database\StartRedis;
|
||||||
use App\Actions\Database\StopDatabase;
|
use App\Actions\Database\StopDatabase;
|
||||||
|
use App\Events\DatabaseStatusChanged;
|
||||||
use App\Jobs\ContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -16,21 +17,28 @@ class Heading extends Component
|
|||||||
public $database;
|
public $database;
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
|
|
||||||
protected $listeners = ['activityFinished'];
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$userId = auth()->user()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:user.{$userId},DatabaseStatusChanged" => 'activityFinished',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function activityFinished()
|
public function activityFinished()
|
||||||
{
|
{
|
||||||
$this->database->update([
|
$this->database->update([
|
||||||
'started_at' => now(),
|
'started_at' => now(),
|
||||||
]);
|
]);
|
||||||
$this->emit('refresh');
|
$this->dispatch('refresh');
|
||||||
$this->check_status();
|
$this->check_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function check_status()
|
public function check_status($showNotification = false)
|
||||||
{
|
{
|
||||||
dispatch_sync(new ContainerStatusJob($this->database->destination->server));
|
dispatch_sync(new ContainerStatusJob($this->database->destination->server));
|
||||||
$this->database->refresh();
|
$this->database->refresh();
|
||||||
|
if ($showNotification) $this->dispatch('success', 'Database status updated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -50,19 +58,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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) {
|
@@ -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) {
|
@@ -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) {
|
@@ -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);
|
||||||
}
|
}
|
@@ -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) {
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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()
|
||||||
{
|
{
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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!');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
@@ -109,9 +109,6 @@ class Select extends Component
|
|||||||
if (count($this->servers) === 1) {
|
if (count($this->servers) === 1) {
|
||||||
$server = $this->servers->first();
|
$server = $this->servers->first();
|
||||||
$this->setServer($server);
|
$this->setServer($server);
|
||||||
if (count($server->destinations()) === 1) {
|
|
||||||
$this->setDestination($server->destinations()->first()->uuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!is_null($this->server)) {
|
if (!is_null($this->server)) {
|
||||||
$foundServer = $this->servers->where('id', $this->server)->first();
|
$foundServer = $this->servers->where('id', $this->server)->first();
|
||||||
@@ -133,7 +130,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,
|
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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();
|
@@ -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:user.{$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()
|
||||||
{
|
{
|
@@ -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');
|
72
app/Livewire/Project/Service/Navbar.php
Normal file
72
app/Livewire/Project/Service/Navbar.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?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 check_status($showNotification = false)
|
||||||
|
{
|
||||||
|
dispatch_sync(new ContainerStatusJob($this->service->destination->server));
|
||||||
|
$this->service->refresh();
|
||||||
|
if ($showNotification) $this->dispatch('success', 'Service status updated.');
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
@@ -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);
|
||||||
}
|
}
|
@@ -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);
|
||||||
}
|
}
|
36
app/Livewire/Project/Shared/Danger.php
Normal file
36
app/Livewire/Project/Shared/Danger.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Shared;
|
||||||
|
|
||||||
|
use App\Jobs\DeleteResourceJob;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
|
class Danger extends Component
|
||||||
|
{
|
||||||
|
public $resource;
|
||||||
|
public $projectUuid;
|
||||||
|
public $environmentName;
|
||||||
|
public ?string $modalId = null;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->modalId = new Cuid2(7);
|
||||||
|
$parameters = get_route_parameters();
|
||||||
|
$this->projectUuid = $parameters['project_uuid'];
|
||||||
|
$this->environmentName = $parameters['environment_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DeleteResourceJob::dispatchSync($this->resource);
|
||||||
|
return $this->redirectRoute('project.resources', [
|
||||||
|
'project_uuid' => $this->projectUuid,
|
||||||
|
'environment_name' => $this->environmentName
|
||||||
|
], navigate: true);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Livewire\Project\Shared;
|
namespace App\Livewire\Project\Shared;
|
||||||
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
@@ -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,
|
@@ -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);
|
||||||
}
|
}
|
@@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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();
|
||||||
@@ -66,7 +80,9 @@ class ExecuteContainerCommand extends Component
|
|||||||
$this->resource = $resource;
|
$this->resource = $resource;
|
||||||
$this->server = $this->resource->destination->server;
|
$this->server = $this->resource->destination->server;
|
||||||
$this->container = $this->resource->uuid;
|
$this->container = $this->resource->uuid;
|
||||||
$this->containers->push($this->container);
|
if (str(data_get($this,'resource.status'))->startsWith('running')) {
|
||||||
|
$this->containers->push($this->container);
|
||||||
|
}
|
||||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||||
$this->type = 'service';
|
$this->type = 'service';
|
||||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||||
@@ -92,13 +108,16 @@ class ExecuteContainerCommand extends Component
|
|||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
try {
|
try {
|
||||||
|
// Wrap command to prevent escaped execution in the host.
|
||||||
|
$cmd = 'sh -c "' . str_replace('"', '\"', $this->command) . '"';
|
||||||
|
|
||||||
if (!empty($this->workDir)) {
|
if (!empty($this->workDir)) {
|
||||||
$exec = "docker exec -w {$this->workDir} {$this->container} {$this->command}";
|
$exec = "docker exec -w {$this->workDir} {$this->container} {$cmd}";
|
||||||
} else {
|
} else {
|
||||||
$exec = "docker exec {$this->container} {$this->command}";
|
$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);
|
||||||
}
|
}
|
@@ -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,13 +29,15 @@ class GetLogs extends Component
|
|||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
if (!is_null($this->resource)) {
|
||||||
$this->showTimeStamps = $this->resource->settings->is_include_timestamps;
|
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||||
} else {
|
$this->showTimeStamps = $this->resource->settings->is_include_timestamps;
|
||||||
if ($this->servicesubtype) {
|
|
||||||
$this->showTimeStamps = $this->servicesubtype->is_include_timestamps;
|
|
||||||
} else {
|
} else {
|
||||||
$this->showTimeStamps = $this->resource->is_include_timestamps;
|
if ($this->servicesubtype) {
|
||||||
|
$this->showTimeStamps = $this->servicesubtype->is_include_timestamps;
|
||||||
|
} else {
|
||||||
|
$this->showTimeStamps = $this->resource->is_include_timestamps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,21 +47,30 @@ class GetLogs extends Component
|
|||||||
}
|
}
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
if (!is_null($this->resource)) {
|
||||||
$this->resource->settings->is_include_timestamps = $this->showTimeStamps;
|
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||||
$this->resource->settings->save();
|
$this->resource->settings->is_include_timestamps = $this->showTimeStamps;
|
||||||
} else {
|
$this->resource->settings->save();
|
||||||
if ($this->servicesubtype) {
|
}
|
||||||
$this->servicesubtype->is_include_timestamps = $this->showTimeStamps;
|
if ($this->resource->getMorphClass() === 'App\Models\Service') {
|
||||||
$this->servicesubtype->save();
|
$serviceName = str($this->container)->beforeLast('-')->value();
|
||||||
} else {
|
$subType = $this->resource->applications()->where('name', $serviceName)->first();
|
||||||
$this->resource->is_include_timestamps = $this->showTimeStamps;
|
if ($subType) {
|
||||||
$this->resource->save();
|
$subType->is_include_timestamps = $this->showTimeStamps;
|
||||||
|
$subType->save();
|
||||||
|
} else {
|
||||||
|
$subType = $this->resource->databases()->where('name', $serviceName)->first();
|
||||||
|
if ($subType) {
|
||||||
|
$subType->is_include_timestamps = $this->showTimeStamps;
|
||||||
|
$subType->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getLogs($refresh = false)
|
public function getLogs($refresh = false)
|
||||||
{
|
{
|
||||||
|
if (!$refresh && $this->resource->getMorphClass() === 'App\Models\Service') return;
|
||||||
if ($this->container) {
|
if ($this->container) {
|
||||||
if ($this->showTimeStamps) {
|
if ($this->showTimeStamps) {
|
||||||
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");
|
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");
|
@@ -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);
|
||||||
}
|
}
|
@@ -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;
|
||||||
@@ -62,17 +62,24 @@ class Logs extends Component
|
|||||||
$this->status = $this->resource->status;
|
$this->status = $this->resource->status;
|
||||||
$this->server = $this->resource->destination->server;
|
$this->server = $this->resource->destination->server;
|
||||||
$this->container = $this->resource->uuid;
|
$this->container = $this->resource->uuid;
|
||||||
|
if (str(data_get($this,'resource.status'))->startsWith('running')) {
|
||||||
|
$this->containers->push($this->container);
|
||||||
|
}
|
||||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||||
$this->type = 'service';
|
$this->type = 'service';
|
||||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||||
$service_name = data_get($this->parameters, 'service_name');
|
$this->resource->applications()->get()->each(function ($application) {
|
||||||
$this->serviceSubType = $this->resource->applications()->where('name', $service_name)->first();
|
if (str(data_get($application, 'status'))->contains('running')) {
|
||||||
if (!$this->serviceSubType) {
|
$this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||||
$this->serviceSubType = $this->resource->databases()->where('name', $service_name)->first();
|
}
|
||||||
}
|
});
|
||||||
$this->status = $this->resource->status;
|
$this->resource->databases()->get()->each(function ($database) {
|
||||||
|
if (str(data_get($database, 'status'))->contains('running')) {
|
||||||
|
$this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$this->server = $this->resource->server;
|
$this->server = $this->resource->server;
|
||||||
$this->container = data_get($this->parameters, 'service_name') . '-' . $this->resource->uuid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@@ -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);
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user