2023-03-28 20:13:08 +00:00
|
|
|
<?php
|
|
|
|
|
2023-04-25 09:01:56 +00:00
|
|
|
namespace App\Http\Livewire\Project\Application;
|
2023-03-28 20:13:08 +00:00
|
|
|
|
|
|
|
use Livewire\Component;
|
2023-03-31 11:32:07 +00:00
|
|
|
use Spatie\Activitylog\Models\Activity;
|
2023-03-28 20:13:08 +00:00
|
|
|
|
2023-04-25 09:01:56 +00:00
|
|
|
class PollDeployment extends Component
|
2023-03-28 20:13:08 +00:00
|
|
|
{
|
|
|
|
public $activity;
|
|
|
|
public $isKeepAliveOn = true;
|
2023-03-31 11:32:07 +00:00
|
|
|
public $deployment_uuid;
|
2023-03-29 10:27:02 +00:00
|
|
|
|
2023-03-28 20:13:08 +00:00
|
|
|
public function polling()
|
|
|
|
{
|
2023-03-31 11:32:07 +00:00
|
|
|
if ( is_null($this->activity) && isset($this->deployment_uuid)) {
|
|
|
|
$this->activity = Activity::where('properties->deployment_uuid', '=', $this->deployment_uuid)
|
|
|
|
->first();
|
|
|
|
} else {
|
|
|
|
$this->activity?->refresh();
|
|
|
|
}
|
|
|
|
|
2023-03-31 16:26:38 +00:00
|
|
|
if (data_get($this->activity, 'properties.status') == 'finished' || data_get($this->activity, 'properties.status') == 'failed' ) {
|
2023-03-28 20:13:08 +00:00
|
|
|
$this->isKeepAliveOn = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|