Files
Virtnet.bond/extensions/Servers/Proxmox/Admin/Resources/LocationResource.php
Joseph.Rawlings f394483daa feat: Update Proxmox extension with various improvements and bug fixes
- Change listStates method to accept nullable integer for limit parameter.
- Modify TechnitiumDns class to return structured error messages on failure.
- Enhance VNC and xterm popup routes with user authorization checks.
- Update backups view to improve loading states and add unique keys for dynamic elements.
- Refactor cloud-init view to ensure proper data binding and improve user experience.
- Add wire:key attributes to various elements in views for better Livewire performance.
- Improve error handling and user feedback in the firewall view.
- Update server overview and statistics views to handle potential null values gracefully.
- Add new migration files to extend database schema with user-set icons and notes for Proxmox nodes.
2026-02-23 17:23:01 -05:00

123 lines
4.8 KiB
PHP

<?php
namespace Paymenter\Extensions\Servers\Proxmox\Admin\Resources;
use Filament\Forms;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Validation\Rules\Unique;
use Paymenter\Extensions\Servers\Proxmox\Admin\Resources\LocationResource\Pages;
use Paymenter\Extensions\Servers\Proxmox\Models\Location;
class LocationResource extends Resource
{
protected static ?string $model = Location::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Proxmox';
protected static ?string $label = 'Location';
protected static ?string $slug = 'proxmox-locations';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->maxLength(255)
->unique(ignoreRecord: true)
->live(onBlur: true),
Forms\Components\Select::make('server_placement')
->label('Server Placement')
->options([
'random' => 'Random Node',
'fill' => 'Fill Nodes (fill each node before moving to the next)',
'least_loaded_server' => 'Least Loaded Node (based on server count)',
'least_loaded_ram' => 'Least Loaded Node (based on RAM)',
'least_loaded_disk' => 'Least Loaded Node (based on disk)',
'least_loaded_cpu' => 'Least Loaded Node (based on CPU)',
])
->default('least_loaded_server')
->helperText('The settings based on CPU, RAM, and disk must be configured in the node settings.')
->required()
->reactive(),
Tabs::make('Tabs')
->persistTabInQueryString()
->columnSpanFull()
->tabs([
Tabs\Tab::make('OS')
->columns(2)
->schema([
Forms\Components\Repeater::make('os')
->relationship('os')
->hiddenLabel()
->disabled(fn (Get $get) => !$get('name'))
->addActionLabel('Add OS')
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->maxLength(255)
->placeholder('Enter the name of the OS'),
Forms\Components\TextInput::make('vm_id')
->label('VM ID')
->required()
->numeric()
->unique(ignoreRecord: true, modifyRuleUsing: function (Unique $rule, Get $get, $record) {
return $rule->where('location_id', $get('../../id'));
})
->placeholder('Enter the VM ID'),
])
->cloneable()
->columns(2)
->columnSpanFull(),
]),
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')->sortable()->searchable(),
Tables\Columns\TextColumn::make('nodes_count')
->label('Nodes')
->sortable()
->searchable()
->counts('nodes')
->formatStateUsing(fn ($state) => $state ?: '0'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'create' => Pages\CreateLocation::route('/create'),
'edit' => Pages\EditLocation::route('/{record}/edit'),
];
}
}