feat: able to download schedule task logs
This commit is contained in:
@@ -25,8 +25,11 @@ class Executions extends Component
|
||||
public ?string $serverTimezone = null;
|
||||
|
||||
public $currentPage = 1;
|
||||
|
||||
public $logsPerPage = 100;
|
||||
|
||||
public $selectedExecution = null;
|
||||
|
||||
public $isPollingActive = false;
|
||||
|
||||
public function getListeners()
|
||||
@@ -74,6 +77,7 @@ class Executions extends Component
|
||||
$this->selectedExecution = null;
|
||||
$this->currentPage = 1;
|
||||
$this->isPollingActive = false;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->selectedKey = $key;
|
||||
@@ -112,15 +116,24 @@ class Executions extends Component
|
||||
}
|
||||
|
||||
$lines = collect(explode("\n", $this->selectedExecution->message));
|
||||
|
||||
return $lines->take($this->currentPage * $this->logsPerPage);
|
||||
}
|
||||
|
||||
public function downloadLogs()
|
||||
{
|
||||
return response()->streamDownload(function () {
|
||||
echo $this->selectedExecution->message;
|
||||
}, 'task-execution-'.$this->selectedExecution->id.'.log');
|
||||
}
|
||||
|
||||
public function hasMoreLogs()
|
||||
{
|
||||
if (! $this->selectedExecution || ! $this->selectedExecution->message) {
|
||||
return false;
|
||||
}
|
||||
$lines = collect(explode("\n", $this->selectedExecution->message));
|
||||
|
||||
return $lines->count() > ($this->currentPage * $this->logsPerPage);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<div class="flex flex-col gap-4"
|
||||
x-data="{
|
||||
<div class="flex flex-col gap-4" x-data="{
|
||||
init() {
|
||||
let interval;
|
||||
$wire.$watch('isPollingActive', value => {
|
||||
@@ -45,15 +44,21 @@
|
||||
@endif
|
||||
@if ($this->logLines->isNotEmpty())
|
||||
<div>
|
||||
<pre class="whitespace-pre-wrap">@foreach($this->logLines as $line){{ $line }}
|
||||
@endforeach</pre>
|
||||
<pre class="whitespace-pre-wrap">
|
||||
@foreach ($this->logLines as $line)
|
||||
{{ $line }}
|
||||
@endforeach
|
||||
</pre>
|
||||
<div class="flex gap-2">
|
||||
@if ($this->hasMoreLogs())
|
||||
<div class="flex justify-center mt-4">
|
||||
<button wire:click="loadMoreLogs" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50">
|
||||
Load More Logs
|
||||
</button>
|
||||
</div>
|
||||
<x-forms.button wire:click.prevent="loadMoreLogs" isHighlighted>
|
||||
Load More
|
||||
</x-forms.button>
|
||||
@endif
|
||||
<x-forms.button wire:click.prevent="downloadLogs" isHighlighted>
|
||||
Download
|
||||
</x-forms.button>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div>No output was recorded for this execution.</div>
|
||||
|
Reference in New Issue
Block a user