coolify/app/Livewire/Project/Application/Deployment/Show.php

77 lines
2.7 KiB
PHP
Raw Normal View History

2023-04-19 12:42:15 +02:00
<?php
2024-01-07 16:23:41 +01:00
namespace App\Livewire\Project\Application\Deployment;
2023-04-19 12:42:15 +02:00
2024-01-07 16:23:41 +01:00
use App\Models\Application;
2023-05-30 15:52:17 +02:00
use App\Models\ApplicationDeploymentQueue;
2024-01-07 16:23:41 +01:00
use Livewire\Component;
2023-04-19 12:42:15 +02:00
2024-01-07 16:23:41 +01:00
class Show extends Component
2023-04-19 12:42:15 +02:00
{
2024-01-07 16:23:41 +01:00
public Application $application;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public ApplicationDeploymentQueue $application_deployment_queue;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public string $deployment_uuid;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public $isKeepAliveOn = true;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
protected $listeners = ['refreshQueue'];
2024-06-10 22:43:34 +02:00
public function mount()
{
2023-06-15 09:15:41 +02:00
$deploymentUuid = request()->route('deployment_uuid');
2023-04-19 12:42:15 +02:00
2023-08-22 17:44:49 +02:00
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
2024-06-10 22:43:34 +02:00
if (! $project) {
2023-04-25 14:43:35 +02:00
return redirect()->route('dashboard');
2023-04-19 12:42:15 +02:00
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
2024-06-10 22:43:34 +02:00
if (! $environment) {
2023-04-25 14:43:35 +02:00
return redirect()->route('dashboard');
2023-04-19 12:42:15 +02:00
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
2024-06-10 22:43:34 +02:00
if (! $application) {
2023-04-25 14:43:35 +02:00
return redirect()->route('dashboard');
2023-04-19 12:42:15 +02:00
}
2023-06-30 15:57:40 +02:00
// $activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first();
// if (!$activity) {
2024-01-07 16:23:41 +01:00
// return redirect()->route('project.application.deployment.index', [
2023-06-30 15:57:40 +02:00
// 'project_uuid' => $project->uuid,
// 'environment_name' => $environment->name,
// 'application_uuid' => $application->uuid,
// ]);
// }
$application_deployment_queue = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
2024-06-10 22:43:34 +02:00
if (! $application_deployment_queue) {
2024-01-07 16:23:41 +01:00
return redirect()->route('project.application.deployment.index', [
2023-05-30 15:52:17 +02:00
'project_uuid' => $project->uuid,
'environment_name' => $environment->name,
'application_uuid' => $application->uuid,
]);
}
2024-01-07 16:23:41 +01:00
$this->application = $application;
$this->application_deployment_queue = $application_deployment_queue;
$this->deployment_uuid = $deploymentUuid;
}
public function refreshQueue()
{
$this->application_deployment_queue->refresh();
}
public function polling()
{
$this->dispatch('deploymentFinished');
$this->application_deployment_queue->refresh();
if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') {
$this->isKeepAliveOn = false;
}
}
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public function render()
{
return view('livewire.project.application.deployment.show');
2023-04-19 12:42:15 +02:00
}
2023-08-07 22:14:21 +02:00
}