Files
panel-pelican-dev/app/Filament/Resources/NodeResource.php

158 lines
5.7 KiB
PHP
Raw Normal View History

2024-03-24 01:48:03 -04:00
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\NodeResource\Pages;
use App\Models\Node;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
class NodeResource extends Resource
{
protected static ?string $model = Node::class;
2024-03-30 02:15:56 -04:00
protected static ?string $navigationIcon = 'tabler-server-2';
2024-03-24 01:48:03 -04:00
protected static ?string $recordTitleAttribute = 'name';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Toggle::make('behind_proxy')
2024-03-24 14:42:36 -04:00
->helperText('If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.')
2024-03-24 01:48:03 -04:00
->required(),
Forms\Components\TextInput::make('memory')
->required()
->numeric(),
Forms\Components\TextInput::make('memory_overallocate')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('disk')
->required()
->numeric(),
Forms\Components\TextInput::make('disk_overallocate')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('upload_size')
->required()
2024-03-24 14:42:36 -04:00
->integer()
2024-03-24 01:48:03 -04:00
->default(100),
Forms\Components\TextInput::make('daemonListen')
->required()
2024-03-24 14:42:36 -04:00
->integer()
->label('Daemon Port')
2024-03-24 01:48:03 -04:00
->default(8080),
Forms\Components\TextInput::make('daemonSFTP')
->required()
2024-03-24 14:42:36 -04:00
->integer()
->label('Daemon SFTP Port')
2024-03-24 01:48:03 -04:00
->default(2022),
Forms\Components\TextInput::make('daemonBase')
->required()
->maxLength(191)
->default('/home/daemon-files'),
2024-03-24 14:42:36 -04:00
Forms\Components\ToggleButtons::make('public')
->label('Node Visibility')
->inline()
->default(true)
->helperText('By setting a node to private you will be denying the ability to auto-deploy to this node.')
->options([
true => 'Public',
false => 'Private',
])
->colors([
true => 'warning',
false => 'danger',
])
->icons([
2024-03-30 02:15:56 -04:00
true => 'tabler-eye-check',
false => 'tabler-eye-cancel',
2024-03-24 14:42:36 -04:00
]),
2024-03-24 01:48:03 -04:00
]);
}
public static function table(Table $table): Table
{
return $table
2024-04-09 18:45:31 -04:00
->searchable(false)
2024-03-24 01:48:03 -04:00
->columns([
Tables\Columns\TextColumn::make('uuid')
->label('UUID')
2024-03-24 14:42:36 -04:00
->searchable()
->hidden(),
Tables\Columns\IconColumn::make('health')
->alignCenter()
2024-03-27 00:07:21 -04:00
->state(fn (Node $node) => $node)
->view('livewire.columns.version-column'),
2024-03-24 01:48:03 -04:00
Tables\Columns\TextColumn::make('name')
2024-03-30 20:31:36 -04:00
->icon('tabler-server-2')
2024-04-09 18:45:31 -04:00
->sortable()
2024-03-24 01:48:03 -04:00
->searchable(),
Tables\Columns\TextColumn::make('fqdn')
2024-03-26 20:52:56 -04:00
->label('Address')
2024-03-30 20:31:36 -04:00
->icon('tabler-network')
2024-04-09 18:45:31 -04:00
->sortable()
2024-03-24 01:48:03 -04:00
->searchable(),
Tables\Columns\TextColumn::make('memory')
2024-03-30 20:31:36 -04:00
->icon('tabler-device-desktop-analytics')
2024-03-24 01:48:03 -04:00
->numeric()
2024-04-01 12:33:16 -04:00
->suffix(' GB')
->formatStateUsing(fn ($state) => number_format($state / 1000, 2))
2024-03-24 01:48:03 -04:00
->sortable(),
Tables\Columns\TextColumn::make('disk')
2024-03-30 20:31:36 -04:00
->icon('tabler-file')
2024-03-24 01:48:03 -04:00
->numeric()
2024-04-01 12:33:16 -04:00
->suffix(' GB')
->formatStateUsing(fn ($state) => number_format($state / 1000, 2))
2024-03-24 01:48:03 -04:00
->sortable(),
2024-03-24 14:42:36 -04:00
Tables\Columns\IconColumn::make('scheme')
->label('SSL')
2024-03-30 02:15:56 -04:00
->trueIcon('tabler-lock')
->falseIcon('tabler-lock-open-off')
2024-03-24 14:42:36 -04:00
->state(fn (Node $node) => $node->scheme === 'https'),
Tables\Columns\IconColumn::make('public')
2024-03-30 02:15:56 -04:00
->trueIcon('tabler-eye-check')
2024-04-09 18:45:31 -04:00
->falseIcon('tabler-eye-cancel'),
2024-03-24 14:42:36 -04:00
Tables\Columns\TextColumn::make('servers_count')
->counts('servers')
->label('Servers')
2024-03-24 01:48:03 -04:00
->sortable()
2024-04-09 18:45:31 -04:00
->icon('tabler-brand-docker'),
2024-03-24 01:48:03 -04:00
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListNodes::route('/'),
'create' => Pages\CreateNode::route('/create'),
'edit' => Pages\EditNode::route('/{record}/edit'),
];
}
}