Skip to content

Commit

Permalink
add own column class for node health
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Dec 12, 2024
1 parent d6f814b commit 1d7f7c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 2 additions & 4 deletions app/Filament/Admin/Resources/NodeResource/Pages/ListNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Filament\Admin\Resources\NodeResource\Pages;

use App\Filament\Admin\Resources\NodeResource;
use App\Filament\Components\Tables\Columns\NodeHealthColumn;
use App\Models\Node;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
Expand All @@ -27,10 +28,7 @@ public function table(Table $table): Table
->label('UUID')
->searchable()
->hidden(),
IconColumn::make('health')
->alignCenter()
->state(fn (Node $node) => $node)
->view('livewire.columns.version-column'),
NodeHealthColumn::make('health'),
TextColumn::make('name')
->icon('tabler-server-2')
->sortable()
Expand Down
17 changes: 17 additions & 0 deletions app/Filament/Components/Tables/Columns/NodeHealthColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Filament\Components\Tables\Columns;

use Filament\Tables\Columns\IconColumn;

class NodeHealthColumn extends IconColumn
{
protected string $view = 'livewire.columns.version-column';

protected function setUp(): void
{
parent::setUp();

$this->alignCenter();
}
}
4 changes: 2 additions & 2 deletions resources/views/livewire/columns/version-column.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@php
use Filament\Tables\Columns\IconColumn\IconColumnSize;
$node = $getState();
$size = $getSize($state) ?? IconColumnSize::Large;
$node = $getRecord();
$size = $getSize($node) ?? IconColumnSize::Large;
$sizeClasses = match ($size) {
IconColumnSize::ExtraSmall, 'xs' => 'fi-ta-icon-item-size-xs h-3 w-3',
Expand Down

0 comments on commit 1d7f7c6

Please sign in to comment.