Files
panel/app/Livewire/NodeSystemInformation.php

55 lines
1.7 KiB
PHP
Raw Normal View History

2024-03-27 00:07:21 -04:00
<?php
namespace App\Livewire;
2026-01-27 11:36:07 +01:00
use App\Enums\TablerIcon;
2024-03-27 00:07:21 -04:00
use App\Models\Node;
use Filament\Support\Enums\IconSize;
use Filament\Tables\View\Components\Columns\IconColumnComponent\IconComponent;
use Illuminate\View\ComponentAttributeBag;
use Livewire\Attributes\Locked;
2024-03-27 00:07:21 -04:00
use Livewire\Component;
use function Filament\Support\generate_icon_html;
2024-03-27 00:07:21 -04:00
class NodeSystemInformation extends Component
{
#[Locked]
2024-03-27 00:07:21 -04:00
public Node $node;
2024-10-19 18:29:44 -04:00
public function render(): string
2024-03-27 00:07:21 -04:00
{
$systemInformation = $this->node->systemInformation();
$exception = $systemInformation['exception'] ?? null;
$version = $systemInformation['version'] ?? null;
if ($exception) {
$this->js('console.error("' . $exception . '");');
}
$tooltip = $exception ? 'Error connecting to node!<br>Check browser console for details.' : $version;
2026-01-27 11:36:07 +01:00
$icon = $exception ? TablerIcon::HeartOff : TablerIcon::Heartbeat;
$color = $exception ? 'danger' : 'success';
return generate_icon_html($icon, attributes: (new ComponentAttributeBag())
->merge([
'x-tooltip' => '{
content: "' . $tooltip . '",
theme: $store.theme,
allowHTML: true,
placement: "bottom",
}',
], escape: false)
->color(IconComponent::class, $color), size: IconSize::Large)
->toHtml();
2024-03-27 00:07:21 -04:00
}
2024-10-19 21:00:11 -04:00
public function placeholder(): string
2024-03-27 00:07:21 -04:00
{
2026-01-27 11:36:07 +01:00
return generate_icon_html(TablerIcon::HeartQuestion, attributes: (new ComponentAttributeBag())
->color(IconComponent::class, 'warning'), size: IconSize::Large)
->toHtml();
2024-03-27 00:07:21 -04:00
}
}