2023-03-28 22:13:08 +02:00
|
|
|
<?php
|
|
|
|
|
2023-04-25 11:01:56 +02:00
|
|
|
namespace App\Http\Livewire\Project\Application;
|
2023-03-28 22:13:08 +02:00
|
|
|
|
2023-05-03 06:15:45 +01:00
|
|
|
use App\Enums\ActivityTypes;
|
2023-05-31 12:38:36 +02:00
|
|
|
use App\Models\Application;
|
2023-05-23 09:53:24 +02:00
|
|
|
use Illuminate\Support\Facades\Redis;
|
2023-03-28 22:13:08 +02:00
|
|
|
use Livewire\Component;
|
2023-03-31 12:32:07 +01:00
|
|
|
use Spatie\Activitylog\Models\Activity;
|
2023-03-28 22:13:08 +02:00
|
|
|
|
2023-05-24 14:26:50 +02:00
|
|
|
class DeploymentLogs extends Component
|
2023-03-28 22:13:08 +02:00
|
|
|
{
|
2023-05-31 12:38:36 +02:00
|
|
|
public Application $application;
|
2023-03-28 22:13:08 +02:00
|
|
|
public $activity;
|
|
|
|
public $isKeepAliveOn = true;
|
2023-03-31 12:32:07 +01:00
|
|
|
public $deployment_uuid;
|
2023-03-28 22:13:08 +02:00
|
|
|
public function polling()
|
|
|
|
{
|
2023-05-31 14:42:37 +02:00
|
|
|
$this->emit('deploymentFinished');
|
2023-05-23 09:53:24 +02:00
|
|
|
if (is_null($this->activity) && isset($this->deployment_uuid)) {
|
2023-05-03 06:15:45 +01:00
|
|
|
$this->activity = Activity::query()
|
|
|
|
->where('properties->type', '=', ActivityTypes::DEPLOYMENT->value)
|
|
|
|
->where('properties->type_uuid', '=', $this->deployment_uuid)
|
2023-03-31 12:32:07 +01:00
|
|
|
->first();
|
|
|
|
} else {
|
|
|
|
$this->activity?->refresh();
|
|
|
|
}
|
|
|
|
|
2023-05-23 09:53:24 +02:00
|
|
|
if (data_get($this->activity, 'properties.status') == 'finished' || data_get($this->activity, 'properties.status') == 'failed') {
|
2023-03-28 22:13:08 +02:00
|
|
|
$this->isKeepAliveOn = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|