Files
Scheduler/app/Livewire/BotLogs.php
Oskar-Mikael 1565df568d
All checks were successful
Deploy App / deploy (push) Successful in 11s
Fix job dispatch and show log output
2025-09-04 17:38:30 +02:00

54 lines
1.5 KiB
PHP

<?php
namespace App\Livewire;
use App\Models\BotLog;
use Illuminate\Support\Facades\Auth;
use Jantinnerezo\LivewireAlert\Facades\LivewireAlert;
use Livewire\Component;
use Livewire\WithoutUrlPagination;
use Livewire\WithPagination;
class BotLogs extends Component
{
use WithPagination;
use WithoutUrlPagination;
public function showError(int $logId): void
{
$log = BotLog::find($logId);
if ($log) {
LivewireAlert::title('Error Details')
->html("<pre class='whitespace-pre-wrap break-words'>{$log->error}</pre>")
->warning()
->timer(null)
->withCancelButton('Close')
->show();
}
}
public function showOutput(int $logId): void
{
$log = BotLog::find($logId);
if ($log) {
$output = $log->output ?? 'No output';
LivewireAlert::title('Output Details')
->html("<pre class='text-left rounded p-4 bg-gray-200 whitespace-pre-wrap break-words'><code>{$output}</code</pre>")
->info()
->timer(null)
->withCancelButton('Close')
->show();
}
}
public function render()
{
return view('livewire.bot-logs', [
'logs' => BotLog::whereHas('bot', fn($q) => $q->where('user_id', Auth::id()))
->orderBy('created_at', 'desc')
->latest()
->paginate(10),
]);
}
}