diff --git a/app/Livewire/ActivityMonitor.php b/app/Livewire/ActivityMonitor.php index 1a819f1c0..398fdeb0d 100644 --- a/app/Livewire/ActivityMonitor.php +++ b/app/Livewire/ActivityMonitor.php @@ -14,6 +14,8 @@ class ActivityMonitor extends Component public $eventToDispatch = 'activityFinished'; + public $eventData = null; + public $isPollingActive = false; public bool $fullHeight = false; @@ -26,10 +28,11 @@ class ActivityMonitor extends Component protected $listeners = ['activityMonitor' => 'newMonitorActivity']; - public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished') + public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished', $eventData = null) { $this->activityId = $activityId; $this->eventToDispatch = $eventToDispatch; + $this->eventData = $eventData; $this->hydrateActivity(); @@ -55,7 +58,11 @@ class ActivityMonitor extends Component if ($user) { $teamId = $user->currentTeam()->id; if (! self::$eventDispatched) { - $this->eventToDispatch::dispatch($teamId); + if (filled($this->eventData)) { + $this->eventToDispatch::dispatch($teamId, $this->eventData); + } else { + $this->eventToDispatch::dispatch($teamId); + } self::$eventDispatched = true; } } @@ -63,7 +70,11 @@ class ActivityMonitor extends Component return; } if (! self::$eventDispatched) { - $this->dispatch($this->eventToDispatch); + if (filled($this->eventData)) { + $this->dispatch($this->eventToDispatch, $this->eventData); + } else { + $this->dispatch($this->eventToDispatch); + } self::$eventDispatched = true; } } diff --git a/app/Livewire/NewActivityMonitor.php b/app/Livewire/NewActivityMonitor.php deleted file mode 100644 index a9334e710..000000000 --- a/app/Livewire/NewActivityMonitor.php +++ /dev/null @@ -1,74 +0,0 @@ - 'newMonitorActivity']; - - public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished', $eventData = null) - { - $this->activityId = $activityId; - $this->eventToDispatch = $eventToDispatch; - $this->eventData = $eventData; - - $this->hydrateActivity(); - - $this->isPollingActive = true; - } - - public function hydrateActivity() - { - $this->activity = Activity::find($this->activityId); - } - - public function polling() - { - $this->hydrateActivity(); - // $this->setStatus(ProcessStatus::IN_PROGRESS); - $exit_code = data_get($this->activity, 'properties.exitCode'); - if ($exit_code !== null) { - // if ($exit_code === 0) { - // // $this->setStatus(ProcessStatus::FINISHED); - // } else { - // // $this->setStatus(ProcessStatus::ERROR); - // } - $this->isPollingActive = false; - if ($this->eventToDispatch !== null) { - if (str($this->eventToDispatch)->startsWith('App\\Events\\')) { - $causer_id = data_get($this->activity, 'causer_id'); - $user = User::find($causer_id); - if ($user) { - foreach ($user->teams as $team) { - $teamId = $team->id; - $this->eventToDispatch::dispatch($teamId); - } - } - - return; - } - if (! is_null($this->eventData)) { - $this->dispatch($this->eventToDispatch, $this->eventData); - } else { - $this->dispatch($this->eventToDispatch); - } - } - } - } -} diff --git a/app/Livewire/Server/ValidateAndInstall.php b/app/Livewire/Server/ValidateAndInstall.php index ba8fd9d4f..459b50b91 100644 --- a/app/Livewire/Server/ValidateAndInstall.php +++ b/app/Livewire/Server/ValidateAndInstall.php @@ -106,7 +106,8 @@ class ValidateAndInstall extends Component if ($this->number_of_tries <= $this->max_tries) { $activity = $this->server->installDocker(); $this->number_of_tries++; - $this->dispatch('newActivityMonitor', $activity->id, 'init', $this->number_of_tries); + // $this->dispatch('newActivityMonitor', $activity->id, 'init', $this->number_of_tries); + $this->dispatch('activityMonitor', $activity->id, 'init', $this->number_of_tries); } return; diff --git a/resources/views/livewire/new-activity-monitor.blade.php b/resources/views/livewire/new-activity-monitor.blade.php deleted file mode 100644 index 6bd1f82ca..000000000 --- a/resources/views/livewire/new-activity-monitor.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -@php use App\Actions\CoolifyTask\RunRemoteProcess; @endphp -
- @if ($this->activity) - @if (isset($header)) -
- {{ $header }} - @if ($isPollingActive) - - @endif -
- @endif -
- -
{{ RunRemoteProcess::decodeOutput($this->activity) }}
-
- @endif -
diff --git a/resources/views/livewire/server/validate-and-install.blade.php b/resources/views/livewire/server/validate-and-install.blade.php index b7d86a4ca..b57e0425a 100644 --- a/resources/views/livewire/server/validate-and-install.blade.php +++ b/resources/views/livewire/server/validate-and-install.blade.php @@ -120,7 +120,7 @@ @endif @endif - + @isset($error)
{!! $error !!}
@endisset