lasthourcloud/app/Http/Livewire/ActivityMonitor.php
Joao Patricio 00a8c847e9 wip
2023-05-03 06:23:45 +01:00

45 lines
896 B
PHP

<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Spatie\Activitylog\Models\Activity;
class ActivityMonitor extends Component
{
public $activityId;
public $isPollingActive = false;
protected $activity;
protected $listeners = ['newMonitorActivity'];
public function hydrateActivity()
{
$this->activity = Activity::query()
->find($this->activityId);
}
public function newMonitorActivity($activityId)
{
$this->activityId = $activityId;
$this->hydrateActivity();
$this->isPollingActive = true;
}
public function polling()
{
$this->hydrateActivity();
if (data_get($this->activity, 'properties.exitCode') !== null) {
$this->isPollingActive = false;
}
}
public function render()
{
return view('livewire.activity-monitor');
}
}