diff --git a/app/Livewire/Project/Shared/ScheduledTask/Executions.php b/app/Livewire/Project/Shared/ScheduledTask/Executions.php index af86229d2..74eac7132 100644 --- a/app/Livewire/Project/Shared/ScheduledTask/Executions.php +++ b/app/Livewire/Project/Shared/ScheduledTask/Executions.php @@ -120,11 +120,16 @@ class Executions extends Component return $lines->take($this->currentPage * $this->logsPerPage); } - public function downloadLogs() + public function downloadLogs(int $executionId) { - return response()->streamDownload(function () { - echo $this->selectedExecution->message; - }, 'task-execution-'.$this->selectedExecution->id.'.log'); + $execution = $this->executions->firstWhere('id', $executionId); + if (! $execution) { + return; + } + + return response()->streamDownload(function () use ($execution) { + echo $execution->message; + }, 'task-execution-'.$execution->id.'.log'); } public function hasMoreLogs() diff --git a/resources/views/livewire/project/shared/scheduled-task/executions.blade.php b/resources/views/livewire/project/shared/scheduled-task/executions.blade.php index 6afc78a76..c1400f5ec 100644 --- a/resources/views/livewire/project/shared/scheduled-task/executions.blade.php +++ b/resources/views/livewire/project/shared/scheduled-task/executions.blade.php @@ -1,4 +1,4 @@ -
@@ -34,6 +35,11 @@ Started At: {{ $this->formatDateInServerTimezone(data_get($execution, 'created_at', now())) }}
+ @if (strlen($execution->message) > 0) + + Download Logs + + @endif @if (data_get($execution, 'id') == $selectedKey)
@if (data_get($execution, 'status') === 'running') @@ -55,9 +61,7 @@ Load More @endif - - Download - +
@else