Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: always have download logs button on scheduled tasks

Andras Bacsai664b718ea3a2
diff --git a/app/Livewire/Project/Shared/ScheduledTask/Executions.php b/app/Livewire/Project/Shared/ScheduledTask/Executions.php
index af86229d24..74eac7132e 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 6afc78a761..c1400f5ec2 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 @@
-<div class="flex flex-col gap-4" x-data="{
+<div class="flex flex-col gap-2" x-data="{
init() {
let interval;
$wire.$watch('isPollingActive', value => {
@@ -23,6 +23,7 @@
'border-red-500' => data_get($execution, 'status') === 'failed',
'border-yellow-500' => data_get($execution, 'status') === 'running',
])>
+
@if (data_get($execution, 'status') === 'running')
<div class="absolute top-2 right-2">
<x-loading />
@@ -34,6 +35,11 @@
Started At: {{ $this->formatDateInServerTimezone(data_get($execution, 'created_at', now())) }}
</div>
</a>
+ @if (strlen($execution->message) > 0)
+ <x-forms.button wire:click.prevent="downloadLogs({{ data_get($execution, 'id') }})">
+ Download Logs
+ </x-forms.button>
+ @endif
@if (data_get($execution, 'id') == $selectedKey)
<div class="p-4 mb-2 bg-gray-100 dark:bg-coolgray-200 rounded">
@if (data_get($execution, 'status') === 'running')
@@ -55,9 +61,7 @@
Load More
</x-forms.button>
@endif
- <x-forms.button wire:click.prevent="downloadLogs" isHighlighted>
- Download
- </x-forms.button>
+
</div>
</div>
@else