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

77 lines
2.7 KiB
PHP
Raw Normal View History

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