mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 15:34:44 +02:00
Fix editing server resources
This commit is contained in:
parent
94f583fef0
commit
fe3bf88ea4
@ -317,120 +317,150 @@ class EditServer extends EditRecord
|
|||||||
'md' => 4,
|
'md' => 4,
|
||||||
'lg' => 4,
|
'lg' => 4,
|
||||||
])
|
])
|
||||||
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\ToggleButtons::make('unlimited_mem')
|
Forms\Components\Grid::make()
|
||||||
->label('Memory')
|
->columns(4)
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
->columnSpanFull()
|
||||||
->inlineLabel()->inline()
|
->schema([
|
||||||
->live()
|
Forms\Components\ToggleButtons::make('unlimited_mem')
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('memory') <= 0)
|
->label('Memory')->inlineLabel()->inline()
|
||||||
->options([
|
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
||||||
true => 'Unlimited',
|
->formatStateUsing(fn (Forms\Get $get) => $get('memory') == 0)
|
||||||
false => 'Limited',
|
->live()
|
||||||
])
|
->options([
|
||||||
->colors([
|
true => 'Unlimited',
|
||||||
true => 'primary',
|
false => 'Limited',
|
||||||
false => 'warning',
|
])
|
||||||
])
|
->colors([
|
||||||
->columnSpan(2),
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('memory')
|
Forms\Components\TextInput::make('memory')
|
||||||
->disabled(fn (Forms\Get $get) => $get('unlimited_mem'))
|
->dehydratedWhenHidden()
|
||||||
->label('Memory Limit')
|
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
|
||||||
->suffix('MB')
|
->label('Memory Limit')->inlineLabel()
|
||||||
->required()
|
->suffix('MB')
|
||||||
->inlineLabel()
|
->required()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
|
]),
|
||||||
|
|
||||||
Forms\Components\ToggleButtons::make('unlimited_disk')
|
Forms\Components\Grid::make()
|
||||||
->label('Disk Space')
|
->columns(4)
|
||||||
->inlineLabel()->inline()
|
->columnSpanFull()
|
||||||
->live()
|
->schema([
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
Forms\Components\ToggleButtons::make('unlimited_disk')
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('disk') <= 0)
|
->label('Disk Space')->inlineLabel()->inline()
|
||||||
->options([
|
->live()
|
||||||
true => 'Unlimited',
|
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
||||||
false => 'Limited',
|
->formatStateUsing(fn (Forms\Get $get) => $get('disk') == 0)
|
||||||
])
|
->options([
|
||||||
->colors([
|
true => 'Unlimited',
|
||||||
true => 'primary',
|
false => 'Limited',
|
||||||
false => 'warning',
|
])
|
||||||
])
|
->colors([
|
||||||
->columnSpan(2),
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('disk')
|
Forms\Components\TextInput::make('disk')
|
||||||
->disabled(fn (Forms\Get $get) => $get('unlimited_disk'))
|
->dehydratedWhenHidden()
|
||||||
->label('Disk Space Limit')
|
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
|
||||||
->suffix('MB')
|
->label('Disk Space Limit')->inlineLabel()
|
||||||
->required()
|
->suffix('MB')
|
||||||
->inlineLabel()
|
->required()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
|
]),
|
||||||
|
|
||||||
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
Forms\Components\Grid::make()
|
||||||
->label('CPU')
|
->columns(4)
|
||||||
->inlineLabel()->inline()
|
->columnSpanFull()
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
->schema([
|
||||||
->live()
|
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('cpu') <= 0)
|
->label('CPU')->inlineLabel()->inline()
|
||||||
->options([
|
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
||||||
true => 'Unlimited',
|
->formatStateUsing(fn (Forms\Get $get) => $get('cpu') == 0)
|
||||||
false => 'Limited',
|
->live()
|
||||||
])
|
->options([
|
||||||
->colors([
|
true => 'Unlimited',
|
||||||
true => 'primary',
|
false => 'Limited',
|
||||||
false => 'warning',
|
])
|
||||||
])
|
->colors([
|
||||||
->columnSpan(2),
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('cpu')
|
Forms\Components\TextInput::make('cpu')
|
||||||
->disabled(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
->dehydratedWhenHidden()
|
||||||
->label('CPU Limit')
|
->hidden(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
||||||
->suffix('%')
|
->label('CPU Limit')->inlineLabel()
|
||||||
->required()
|
->suffix('%')
|
||||||
->inlineLabel()
|
->required()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\Grid::make()
|
||||||
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('swap_support')
|
||||||
|
->live()
|
||||||
|
->label('Enable Swap Memory')->inlineLabel()->inline()
|
||||||
|
->columnSpan(2)
|
||||||
|
->afterStateUpdated(function ($state, Forms\Set $set) {
|
||||||
|
$value = match ($state) {
|
||||||
|
'unlimited' => -1,
|
||||||
|
'disabled' => 0,
|
||||||
|
'limited' => 128,
|
||||||
|
};
|
||||||
|
|
||||||
|
$set('swap', $value);
|
||||||
|
})
|
||||||
|
->formatStateUsing(function (Forms\Get $get) {
|
||||||
|
return match (true) {
|
||||||
|
$get('swap') > 0 => 'limited',
|
||||||
|
$get('swap') == 0 => 'disabled',
|
||||||
|
$get('swap') < 0 => 'unlimited',
|
||||||
|
};
|
||||||
|
})
|
||||||
|
->options([
|
||||||
|
'unlimited' => 'Unlimited',
|
||||||
|
'limited' => 'Limited',
|
||||||
|
'disabled' => 'Disabled',
|
||||||
|
])
|
||||||
|
->colors([
|
||||||
|
'unlimited' => 'primary',
|
||||||
|
'limited' => 'warning',
|
||||||
|
'disabled' => 'danger',
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('swap')
|
||||||
|
->dehydratedWhenHidden()
|
||||||
|
->hidden(fn (Forms\Get $get) => match ($get('swap_support')) {
|
||||||
|
'disabled', 'unlimited', true => true,
|
||||||
|
'limited', false => false,
|
||||||
|
})
|
||||||
|
->label('Swap Memory')->inlineLabel()
|
||||||
|
->suffix('MB')
|
||||||
|
->minValue(-1)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->integer(),
|
||||||
|
]),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('io')
|
Forms\Components\Hidden::make('io')
|
||||||
->helperText('The IO performance relative to other running containers')
|
->helperText('The IO performance relative to other running containers')
|
||||||
->label('Block IO Proportion')
|
->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(),
|
|
||||||
|
|
||||||
Forms\Components\ToggleButtons::make('oom_disabled')
|
Forms\Components\ToggleButtons::make('oom_disabled')
|
||||||
->label('OOM Killer')
|
->label('OOM Killer')->inlineLabel()->inline()
|
||||||
->inline()
|
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->options([
|
->options([
|
||||||
false => 'Disabled',
|
false => 'Disabled',
|
||||||
@ -453,6 +483,7 @@ class EditServer extends EditRecord
|
|||||||
->requiresConfirmation(),
|
->requiresConfirmation(),
|
||||||
Actions\DeleteAction::make('Force Delete')
|
Actions\DeleteAction::make('Force Delete')
|
||||||
->label('Force Delete')
|
->label('Force Delete')
|
||||||
|
->hidden()
|
||||||
->successRedirectUrl(route('filament.admin.resources.servers.index'))
|
->successRedirectUrl(route('filament.admin.resources.servers.index'))
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->after(fn (Server $server) => resolve(ServerDeletionService::class)->withForce()->handle($server))
|
->after(fn (Server $server) => resolve(ServerDeletionService::class)->withForce()->handle($server))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user