refactor: extract action classes, add Blade components, reduce Commandocentrum

- Create EmulatorControlAction and NitroControlAction classes
- Extract business logic from Commandocentrum controller methods
- Add Blade components for status cards, diagnostics, and summary cards
- Replace shell_exec with file_get_contents in config reading
- Remove duplicate methods and unused code
- Commandocentrum reduced from 2033 to 1780 lines
This commit is contained in:
root
2026-05-19 20:57:31 +02:00
parent 976b990a8a
commit cbe189fd96
6 changed files with 364 additions and 294 deletions
@@ -0,0 +1,65 @@
@props(['diagnostics'])
@php
$errors = array_filter($diagnostics, fn ($r) => $r->status === 'error');
$warnings = array_filter($diagnostics, fn ($r) => $r->status === 'warning');
$ok = array_filter($diagnostics, fn ($r) => $r->status === 'ok');
$errorCount = count($errors);
$warningCount = count($warnings);
$okCount = count($ok);
$overallStatus = $errorCount > 0 ? 'error' : ($warningCount > 0 ? 'warning' : 'ok');
$overallColor = match ($overallStatus) {
'error' => '#ef4444',
'warning' => '#f59e0b',
default => '#22c55e',
};
$overallLabel = match ($overallStatus) {
'error' => 'Kritieke Problemen',
'warning' => 'Waarschuwingen',
default => 'Gezond',
};
@endphp
<div style="display:flex;flex-direction:column;gap:16px;">
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px;">
<x-filament-components::commandocentrum.summary-card label="Gezond" :count="$okCount" color="#22c55e" icon="check" />
<x-filament-components::commandocentrum.summary-card label="Waarschuwingen" :count="$warningCount" color="#f59e0b" icon="warning" />
<x-filament-components::commandocentrum.summary-card label="Fouten" :count="$errorCount" color="#ef4444" icon="error" />
</div>
<div style="background:{{ $overallColor }}15;border:1px solid {{ $overallColor }}30;border-radius:12px;padding:16px;display:flex;align-items:center;gap:12px;">
<div style="width:12px;height:12px;border-radius:50%;background:{{ $overallColor }};"></div>
<span style="font-weight:700;color:{{ $overallColor }};font-size:16px;">Systeem Status: {{ $overallLabel }}</span>
</div>
@if ($errorCount > 0 || $warningCount > 0)
<div style="display:flex;flex-direction:column;gap:8px;">
@foreach ($diagnostics as $result)
@if ($result->status === 'ok')
@continue
@endif
@php
$color = $result->status === 'error' ? '#ef4444' : '#f59e0b';
@endphp
<div style="background:#fff;border:1px solid {{ $color }}30;border-radius:10px;padding:14px 16px;display:flex;align-items:flex-start;gap:12px;">
<div style="flex-shrink:0;margin-top:2px;">
@if ($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>
@else
<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>
@endif
</div>
<div style="flex:1;">
<div style="font-weight:600;color:#1e293b;font-size:14px;">{{ $result->name }}</div>
<div style="color:#64748b;font-size:13px;margin-top:2px;">{{ $result->message }}</div>
@if ($result->fix)
<div style="background:#f8fafc;border-radius:6px;padding:8px 12px;margin-top:8px;font-size:12px;color:#475569;font-family:monospace;">💡 {{ $result->fix }}</div>
@endif
</div>
</div>
@endforeach
</div>
@endif
</div>