mailwolt/app/Livewire/Ui/Dashboard/DomainsPanel.php

70 lines
2.2 KiB
PHP

<?php
namespace App\Livewire\Ui\Dashboard;
use Livewire\Component;
class DomainsPanel extends Component
{
public array $domains = [
['name'=>'mail.example.com', 'status'=>'1:249 ausstehend', 'icon'=>'ph-envelope-simple', 'cert_days'=>8],
['name'=>'beispiel.de', 'status'=>'834 gesendet', 'icon'=>'ph-globe', 'cert_days'=>24],
['name'=>'user.test', 'status'=>'Ohne Aktivität', 'icon'=>'ph-at', 'cert_days'=>3],
];
protected function certBadge(?int $days): array
{
if ($days === null) {
return [
'class' => 'bg-white/8 text-white/50 border-white/10',
'icon' => 'ph-shield-warning-duotone',
'label' => '—',
'title' => 'Gültigkeit unbekannt',
];
}
if ($days <= 5) {
return [
'class' => 'bg-rose-500/10 text-rose-300 border-rose-400/30',
'icon' => 'ph-shield-x-duotone',
'label' => $days.'d',
'title' => "Zertifikat sehr kritisch (≤5 Tage)",
];
}
if ($days <= 20) {
return [
'class' => 'bg-amber-400/10 text-amber-300 border-amber-300/30',
'icon' => 'ph-shield-warning-duotone',
'label' => $days.'d',
'title' => "Zertifikat bald fällig (≤20 Tage)",
];
}
return [
'class' => 'bg-emerald-500/10 text-emerald-300 border-emerald-400/30',
'icon' => 'ph-shield-check-duotone',
'label' => $days.'d',
'title' => "Zertifikat ok (>20 Tage)",
];
}
public function getDomainsWithBadgesProperty(): array
{
return array_map(function ($d) {
$b = $this->certBadge($d['cert_days'] ?? null);
return $d + [
'cert_class' => $b['class'],
'cert_icon' => $b['icon'],
'cert_label' => $b['label'],
'cert_title' => $b['title'],
];
}, $this->domains);
}
public function render()
{
return view('livewire.ui.dashboard.domains-panel');
}
}