mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-28 09:14:44 +02:00
Update Server Resources, remove defaults
This commit is contained in:
parent
4ebc67aab0
commit
d42fc88535
@ -111,7 +111,6 @@ class EditServer extends EditRecord
|
||||
|
||||
Forms\Components\Select::make('owner_id')
|
||||
->prefixIcon('tabler-user')
|
||||
->default(auth()->user()->id)
|
||||
->label('Owner')
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
@ -126,7 +125,6 @@ class EditServer extends EditRecord
|
||||
|
||||
Forms\Components\Textarea::make('description')
|
||||
->hidden()
|
||||
->default('')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
|
||||
@ -146,7 +144,6 @@ class EditServer extends EditRecord
|
||||
|
||||
Forms\Components\ToggleButtons::make('skip_scripts')
|
||||
->label('Run Egg Install Script?')
|
||||
->default(false)
|
||||
->options([
|
||||
false => 'Yes',
|
||||
true => 'Skip',
|
||||
@ -165,7 +162,6 @@ class EditServer extends EditRecord
|
||||
Forms\Components\ToggleButtons::make('custom_image')
|
||||
->live()
|
||||
->label('Custom Image?')
|
||||
->default(false)
|
||||
->formatStateUsing(function ($state, Forms\Get $get) {
|
||||
if ($state !== null) {
|
||||
return $state;
|
||||
@ -242,18 +238,15 @@ class EditServer extends EditRecord
|
||||
Forms\Components\TextInput::make('allocation_limit')
|
||||
->suffixIcon('tabler-network')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
->numeric(),
|
||||
Forms\Components\TextInput::make('database_limit')
|
||||
->suffixIcon('tabler-database')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
->numeric(),
|
||||
Forms\Components\TextInput::make('backup_limit')
|
||||
->suffixIcon('tabler-copy-check')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
->numeric(),
|
||||
]),
|
||||
|
||||
Forms\Components\Textarea::make('startup')
|
||||
@ -274,7 +267,7 @@ class EditServer extends EditRecord
|
||||
);
|
||||
}),
|
||||
|
||||
Forms\Components\Hidden::make('start_on_completion')->default(true),
|
||||
Forms\Components\Hidden::make('start_on_completion'),
|
||||
|
||||
Forms\Components\Section::make('Egg Variables')
|
||||
->icon('tabler-eggs')
|
||||
@ -325,58 +318,127 @@ class EditServer extends EditRecord
|
||||
->collapsed()
|
||||
->icon('tabler-server-cog')
|
||||
->iconColor('primary')
|
||||
->columns(2)
|
||||
->columnSpan(([
|
||||
->columns([
|
||||
'default' => 2,
|
||||
'sm' => 4,
|
||||
'md' => 4,
|
||||
'lg' => 6,
|
||||
]))
|
||||
'lg' => 4,
|
||||
])
|
||||
->schema([
|
||||
Forms\Components\ToggleButtons::make('unlimited_mem')
|
||||
->label('Memory')
|
||||
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
||||
->inlineLabel()->inline()
|
||||
->live()
|
||||
->formatStateUsing(fn (Forms\Get $get) => $get('memory') <= 0)
|
||||
->options([
|
||||
true => 'Unlimited',
|
||||
false => 'Limited',
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
Forms\Components\TextInput::make('memory')
|
||||
->default(0)
|
||||
->label('Allocated Memory')
|
||||
->disabled(fn (Forms\Get $get) => $get('unlimited_mem'))
|
||||
->label('Memory Limit')
|
||||
->suffix('MB')
|
||||
->required()
|
||||
->inlineLabel()
|
||||
->columnSpan(2)
|
||||
->numeric(),
|
||||
|
||||
Forms\Components\TextInput::make('swap')
|
||||
->default(0)
|
||||
->label('Swap Memory')
|
||||
->suffix('MB')
|
||||
->helperText('0 disables swap and -1 allows unlimited swap')
|
||||
->minValue(-1)
|
||||
->required()
|
||||
->numeric(),
|
||||
Forms\Components\ToggleButtons::make('unlimited_disk')
|
||||
->label('Disk Space')
|
||||
->inlineLabel()->inline()
|
||||
->live()
|
||||
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
||||
->formatStateUsing(fn (Forms\Get $get) => $get('disk') <= 0)
|
||||
->options([
|
||||
true => 'Unlimited',
|
||||
false => 'Limited',
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
Forms\Components\TextInput::make('disk')
|
||||
->default(0)
|
||||
->disabled(fn (Forms\Get $get) => $get('unlimited_disk'))
|
||||
->label('Disk Space Limit')
|
||||
->suffix('MB')
|
||||
->required()
|
||||
->inlineLabel()
|
||||
->columnSpan(2)
|
||||
->numeric(),
|
||||
|
||||
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
||||
->label('CPU')
|
||||
->inlineLabel()->inline()
|
||||
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
||||
->live()
|
||||
->formatStateUsing(fn (Forms\Get $get) => $get('cpu') <= 0)
|
||||
->options([
|
||||
true => 'Unlimited',
|
||||
false => 'Limited',
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
Forms\Components\TextInput::make('cpu')
|
||||
->default(0)
|
||||
->disabled(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
||||
->label('CPU Limit')
|
||||
->suffix('%')
|
||||
->required()
|
||||
->inlineLabel()
|
||||
->columnSpan(2)
|
||||
->numeric(),
|
||||
|
||||
Forms\Components\Hidden::make('io')
|
||||
->helperText('The IO performance relative to other running containers')
|
||||
->label('Block IO Proportion')
|
||||
->required(),
|
||||
// ->numeric()
|
||||
// ->minValue(0)
|
||||
// ->maxValue(1000)
|
||||
// ->step(10)
|
||||
|
||||
Forms\Components\ToggleButtons::make('swap_support')
|
||||
->label('Enable Swap Memory')
|
||||
->columnSpan(2)
|
||||
->inlineLabel()->inline()
|
||||
->formatStateUsing(fn (Forms\Get $get) => $get('swap') <= 0)
|
||||
->options([
|
||||
'unlimited' => 'Unlimited',
|
||||
'limited' => 'Limited',
|
||||
'disabled' => 'Disabled',
|
||||
])
|
||||
->colors([
|
||||
'unlimited' => 'primary',
|
||||
'limited' => 'warning',
|
||||
'disabled' => 'danger',
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('swap')
|
||||
->disabled(fn (Forms\Get $get) => $get('swap_support'))
|
||||
->label('Swap Memory')
|
||||
->suffix('MB')
|
||||
->minValue(-1)
|
||||
->columnSpan(2)
|
||||
->inlineLabel()
|
||||
->required()
|
||||
// ->numeric()
|
||||
// ->minValue(0)
|
||||
// ->maxValue(1000)
|
||||
// ->step(10)
|
||||
->default(0),
|
||||
->numeric(),
|
||||
|
||||
Forms\Components\ToggleButtons::make('oom_disabled')
|
||||
->label('OOM Killer')
|
||||
->inline()
|
||||
->default(false)
|
||||
->columnSpan(2)
|
||||
->options([
|
||||
false => 'Disabled',
|
||||
true => 'Enabled',
|
||||
@ -384,18 +446,14 @@ class EditServer extends EditRecord
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'danger',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-sword-off',
|
||||
true => 'tabler-sword',
|
||||
])
|
||||
->required(),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
$this->getSaveFormAction(),
|
||||
Actions\DeleteAction::make('Force Delete')
|
||||
->label('Force Delete')
|
||||
->successRedirectUrl(route('filament.admin.resources.servers.index'))
|
||||
@ -408,6 +466,11 @@ class EditServer extends EditRecord
|
||||
->after(fn (Server $server) => resolve(ServerDeletionService::class)->handle($server))
|
||||
->requiresConfirmation(),
|
||||
];
|
||||
|
||||
}
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
|
Loading…
x
Reference in New Issue
Block a user