fix: add Cache import, convert DiagnosticResult to array for Livewire

This commit is contained in:
root
2026-05-21 17:27:40 +02:00
parent 17f543e7c9
commit c53d1bca45
2 changed files with 18 additions and 11 deletions
@@ -11,6 +11,7 @@ use App\Models\Miscellaneous\WebsitePermission;
use App\Models\StaffActivity; use App\Models\StaffActivity;
use App\Services\AutoDetectService; use App\Services\AutoDetectService;
use App\Services\CatalogService; use App\Services\CatalogService;
use App\Services\Diagnostics\DiagnosticResult;
use App\Services\Diagnostics\DiagnosticRunner; use App\Services\Diagnostics\DiagnosticRunner;
use App\Services\GitHubService; use App\Services\GitHubService;
use App\Services\RconService; use App\Services\RconService;
@@ -1072,7 +1073,12 @@ final class Commandocentrum extends Page implements HasForms
private function runDiagnostics(): void private function runDiagnostics(): void
{ {
$runner = app(DiagnosticRunner::class); $runner = app(DiagnosticRunner::class);
$this->diagnostics = $runner->runAll(); $this->diagnostics = array_map(fn (DiagnosticResult $r) => [
'name' => $r->name,
'status' => $r->status,
'message' => $r->message,
'fix' => $r->fix,
], $runner->runAll());
} }
private function renderDiagnostics(): HtmlString private function renderDiagnostics(): HtmlString
@@ -1081,9 +1087,9 @@ final class Commandocentrum extends Page implements HasForms
$this->runDiagnostics(); $this->runDiagnostics();
} }
$errors = array_filter($this->diagnostics, fn ($r) => $r->status === 'error'); $errors = array_filter($this->diagnostics, fn ($r) => $r['status'] === 'error');
$warnings = array_filter($this->diagnostics, fn ($r) => $r->status === 'warning'); $warnings = array_filter($this->diagnostics, fn ($r) => $r['status'] === 'warning');
$ok = array_filter($this->diagnostics, fn ($r) => $r->status === 'ok'); $ok = array_filter($this->diagnostics, fn ($r) => $r['status'] === 'ok');
$errorCount = count($errors); $errorCount = count($errors);
$warningCount = count($warnings); $warningCount = count($warnings);
@@ -1120,21 +1126,21 @@ final class Commandocentrum extends Page implements HasForms
if ($errorCount > 0 || $warningCount > 0) { if ($errorCount > 0 || $warningCount > 0) {
$html .= '<div style="display:flex;flex-direction:column;gap:8px;">'; $html .= '<div style="display:flex;flex-direction:column;gap:8px;">';
foreach ($this->diagnostics as $result) { foreach ($this->diagnostics as $result) {
if ($result->status === 'ok') { if ($result['status'] === 'ok') {
continue; continue;
} }
$color = $result->status === 'error' ? '#ef4444' : '#f59e0b'; $color = $result['status'] === 'error' ? '#ef4444' : '#f59e0b';
$icon = $result->status === 'error' $icon = $result['status'] === 'error'
? '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="' . $color . '" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>' ? '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="' . $color . '" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'
: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="' . $color . '" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>'; : '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="' . $color . '" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>';
$html .= '<div style="background:#fff;border:1px solid ' . $color . '30;border-radius:10px;padding:14px 16px;display:flex;align-items:flex-start;gap:12px;">'; $html .= '<div style="background:#fff;border:1px solid ' . $color . '30;border-radius:10px;padding:14px 16px;display:flex;align-items:flex-start;gap:12px;">';
$html .= '<div style="flex-shrink:0;margin-top:2px;">' . $icon . '</div>'; $html .= '<div style="flex-shrink:0;margin-top:2px;">' . $icon . '</div>';
$html .= '<div style="flex:1;">'; $html .= '<div style="flex:1;">';
$html .= '<div style="font-weight:600;color:#1e293b;font-size:14px;">' . e($result->name) . '</div>'; $html .= '<div style="font-weight:600;color:#1e293b;font-size:14px;">' . e($result['name']) . '</div>';
$html .= '<div style="color:#64748b;font-size:13px;margin-top:2px;">' . e($result->message) . '</div>'; $html .= '<div style="color:#64748b;font-size:13px;margin-top:2px;">' . e($result['message']) . '</div>';
if ($result->fix) { if ($result['fix']) {
$html .= '<div style="background:#f8fafc;border-radius:6px;padding:8px 12px;margin-top:8px;font-size:12px;color:#475569;font-family:monospace;">💡 ' . e($result->fix) . '</div>'; $html .= '<div style="background:#f8fafc;border-radius:6px;padding:8px 12px;margin-top:8px;font-size:12px;color:#475569;font-family:monospace;">💡 ' . e($result['fix']) . '</div>';
} }
$html .= '</div></div>'; $html .= '</div></div>';
} }
@@ -2,6 +2,7 @@
namespace App\Services\Diagnostics; namespace App\Services\Diagnostics;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
class SystemDiagnostic class SystemDiagnostic