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

71 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;
public ApplicationDeploymentQueue $application_deployment_queue;
public string $deployment_uuid;
public $isKeepAliveOn = true;
protected $listeners = ['refreshQueue'];
2024-01-07 15:23:41 +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();
2023-04-19 10:42:15 +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']);
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();
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();
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;
}
}
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
}