mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-22 03:54:46 +02:00
update edit/create pages
This commit is contained in:
parent
4c43fd1683
commit
03cbdd5bdd
@ -309,66 +309,6 @@ class CreateServer extends CreateRecord
|
|||||||
->inline()
|
->inline()
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('select_image')
|
|
||||||
->label('Docker Image Name')
|
|
||||||
->prefixIcon('tabler-brand-docker')
|
|
||||||
->live()
|
|
||||||
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('image', $state))
|
|
||||||
->options(function ($state, Forms\Get $get, Forms\Set $set) {
|
|
||||||
$egg = Egg::query()->find($get('egg_id'));
|
|
||||||
$images = $egg->docker_images ?? [];
|
|
||||||
|
|
||||||
$currentImage = $get('image');
|
|
||||||
if (!$currentImage && $images) {
|
|
||||||
$defaultImage = collect($images)->first();
|
|
||||||
$set('image', $defaultImage);
|
|
||||||
$set('select_image', $defaultImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_flip($images) + ['ghcr.io/custom-image' => 'Custom Image'];
|
|
||||||
})
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('image')
|
|
||||||
->label('Docker Image')
|
|
||||||
->prefixIcon('tabler-brand-docker')
|
|
||||||
->live()
|
|
||||||
->debounce(500)
|
|
||||||
->afterStateUpdated(function ($state, Forms\Get $get, Forms\Set $set) {
|
|
||||||
$egg = Egg::query()->find($get('egg_id'));
|
|
||||||
$images = $egg->docker_images ?? [];
|
|
||||||
|
|
||||||
if (in_array($state, $images)) {
|
|
||||||
$set('select_image', $state);
|
|
||||||
} else {
|
|
||||||
$set('select_image', 'ghcr.io/custom-image');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->placeholder('Enter a custom Image')
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\TagsInput::make('docker_labels')
|
|
||||||
->label('Docker Labels')
|
|
||||||
->live()
|
|
||||||
->placeholder('Enter custom Docker container labels')
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Textarea::make('startup')
|
Forms\Components\Textarea::make('startup')
|
||||||
->hintIcon('tabler-code')
|
->hintIcon('tabler-code')
|
||||||
->label('Startup Command')
|
->label('Startup Command')
|
||||||
@ -463,7 +403,7 @@ class CreateServer extends CreateRecord
|
|||||||
->columnSpan(2),
|
->columnSpan(2),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Section::make('Resource Management')
|
Forms\Components\Section::make('Environment Management')
|
||||||
->collapsed()
|
->collapsed()
|
||||||
->icon('tabler-server-cog')
|
->icon('tabler-server-cog')
|
||||||
->iconColor('primary')
|
->iconColor('primary')
|
||||||
@ -475,175 +415,190 @@ class CreateServer extends CreateRecord
|
|||||||
])
|
])
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Grid::make()
|
Forms\Components\Fieldset::make('Resource Limits')
|
||||||
->columns(4)
|
->columnSpan([
|
||||||
->columnSpanFull()
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\ToggleButtons::make('unlimited_mem')
|
Forms\Components\Grid::make()
|
||||||
->label('Memory')->inlineLabel()->inline()
|
->columns(4)
|
||||||
->default(true)
|
->columnSpanFull()
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
->schema([
|
||||||
->live()
|
Forms\Components\ToggleButtons::make('unlimited_mem')
|
||||||
->options([
|
->label('Memory')->inlineLabel()->inline()
|
||||||
true => 'Unlimited',
|
->default(true)
|
||||||
false => 'Limited',
|
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
||||||
])
|
->live()
|
||||||
->colors([
|
->options([
|
||||||
true => 'primary',
|
true => 'Unlimited',
|
||||||
false => 'warning',
|
false => 'Limited',
|
||||||
])
|
])
|
||||||
->columnSpan(2),
|
->colors([
|
||||||
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('memory')
|
Forms\Components\TextInput::make('memory')
|
||||||
->dehydratedWhenHidden()
|
->dehydratedWhenHidden()
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
|
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
|
||||||
->label('Memory Limit')->inlineLabel()
|
->label('Memory Limit')->inlineLabel()
|
||||||
->suffix('MiB')
|
->suffix('MiB')
|
||||||
->default(0)
|
->default(0)
|
||||||
->required()
|
->required()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0),
|
->minValue(0),
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
|
||||||
->columns(4)
|
|
||||||
->columnSpanFull()
|
|
||||||
->schema([
|
|
||||||
Forms\Components\ToggleButtons::make('unlimited_disk')
|
|
||||||
->label('Disk Space')->inlineLabel()->inline()
|
|
||||||
->default(true)
|
|
||||||
->live()
|
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
|
||||||
->options([
|
|
||||||
true => 'Unlimited',
|
|
||||||
false => 'Limited',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
true => 'primary',
|
|
||||||
false => 'warning',
|
|
||||||
])
|
|
||||||
->columnSpan(2),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('disk')
|
|
||||||
->dehydratedWhenHidden()
|
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
|
|
||||||
->label('Disk Space Limit')->inlineLabel()
|
|
||||||
->suffix('MiB')
|
|
||||||
->default(0)
|
|
||||||
->required()
|
|
||||||
->columnSpan(2)
|
|
||||||
->numeric()
|
|
||||||
->minValue(0),
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
|
||||||
->columns(4)
|
|
||||||
->columnSpanFull()
|
|
||||||
->schema([
|
|
||||||
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
|
||||||
->label('CPU')->inlineLabel()->inline()
|
|
||||||
->default(true)
|
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
|
||||||
->live()
|
|
||||||
->options([
|
|
||||||
true => 'Unlimited',
|
|
||||||
false => 'Limited',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
true => 'primary',
|
|
||||||
false => 'warning',
|
|
||||||
])
|
|
||||||
->columnSpan(2),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('cpu')
|
|
||||||
->dehydratedWhenHidden()
|
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
|
||||||
->label('CPU Limit')->inlineLabel()
|
|
||||||
->suffix('%')
|
|
||||||
->default(0)
|
|
||||||
->required()
|
|
||||||
->columnSpan(2)
|
|
||||||
->numeric()
|
|
||||||
->minValue(0)
|
|
||||||
->helperText('100% equals one logical thread'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
|
||||||
->columns(4)
|
|
||||||
->columnSpanFull()
|
|
||||||
->schema([
|
|
||||||
Forms\Components\ToggleButtons::make('swap_support')
|
|
||||||
->live()
|
|
||||||
->label('Enable Swap Memory')
|
|
||||||
->inlineLabel()
|
|
||||||
->inline()
|
|
||||||
->columnSpan(2)
|
|
||||||
->default('disabled')
|
|
||||||
->afterStateUpdated(function ($state, Forms\Set $set) {
|
|
||||||
$value = match ($state) {
|
|
||||||
'unlimited' => -1,
|
|
||||||
'disabled' => 0,
|
|
||||||
'limited' => 128,
|
|
||||||
};
|
|
||||||
|
|
||||||
$set('swap', $value);
|
|
||||||
})
|
|
||||||
->options([
|
|
||||||
'unlimited' => 'Unlimited',
|
|
||||||
'limited' => 'Limited',
|
|
||||||
'disabled' => 'Disabled',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
'unlimited' => 'primary',
|
|
||||||
'limited' => 'warning',
|
|
||||||
'disabled' => 'danger',
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('swap')
|
Forms\Components\Grid::make()
|
||||||
->dehydratedWhenHidden()
|
->columns(4)
|
||||||
->hidden(fn (Forms\Get $get) => match ($get('swap_support')) {
|
->columnSpanFull()
|
||||||
'disabled', 'unlimited' => true,
|
->schema([
|
||||||
'limited' => false,
|
Forms\Components\ToggleButtons::make('unlimited_disk')
|
||||||
})
|
->label('Disk Space')->inlineLabel()->inline()
|
||||||
->label('Swap Memory')
|
->default(true)
|
||||||
->default(0)
|
->live()
|
||||||
->suffix('MiB')
|
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
||||||
->minValue(-1)
|
->options([
|
||||||
->columnSpan(2)
|
true => 'Unlimited',
|
||||||
->inlineLabel()
|
false => 'Limited',
|
||||||
->required()
|
])
|
||||||
->integer(),
|
->colors([
|
||||||
]),
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('io')
|
Forms\Components\TextInput::make('disk')
|
||||||
->helperText('The IO performance relative to other running containers')
|
->dehydratedWhenHidden()
|
||||||
->label('Block IO Proportion')
|
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
|
||||||
->default(500),
|
->label('Disk Space Limit')->inlineLabel()
|
||||||
|
->suffix('MiB')
|
||||||
Forms\Components\Grid::make()
|
->default(0)
|
||||||
->columns(4)
|
->required()
|
||||||
->columnSpanFull()
|
->columnSpan(2)
|
||||||
->schema([
|
->numeric()
|
||||||
Forms\Components\ToggleButtons::make('oom_killer')
|
->minValue(0),
|
||||||
->label('OOM Killer')
|
|
||||||
->inlineLabel()->inline()
|
|
||||||
->default(false)
|
|
||||||
->columnSpan(2)
|
|
||||||
->options([
|
|
||||||
false => 'Disabled',
|
|
||||||
true => 'Enabled',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
false => 'success',
|
|
||||||
true => 'danger',
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('oom_disabled_hidden')
|
Forms\Components\Grid::make()
|
||||||
->hidden(),
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
||||||
|
->label('CPU')->inlineLabel()->inline()
|
||||||
|
->default(true)
|
||||||
|
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
||||||
|
->live()
|
||||||
|
->options([
|
||||||
|
true => 'Unlimited',
|
||||||
|
false => 'Limited',
|
||||||
|
])
|
||||||
|
->colors([
|
||||||
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('cpu')
|
||||||
|
->dehydratedWhenHidden()
|
||||||
|
->hidden(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
||||||
|
->label('CPU Limit')->inlineLabel()
|
||||||
|
->suffix('%')
|
||||||
|
->default(0)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2)
|
||||||
|
->numeric()
|
||||||
|
->minValue(0)
|
||||||
|
->helperText('100% equals one CPU core.'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\Grid::make()
|
||||||
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('swap_support')
|
||||||
|
->live()
|
||||||
|
->label('Enable Swap Memory')
|
||||||
|
->inlineLabel()
|
||||||
|
->inline()
|
||||||
|
->columnSpan(2)
|
||||||
|
->default('disabled')
|
||||||
|
->afterStateUpdated(function ($state, Forms\Set $set) {
|
||||||
|
$value = match ($state) {
|
||||||
|
'unlimited' => -1,
|
||||||
|
'disabled' => 0,
|
||||||
|
'limited' => 128,
|
||||||
|
};
|
||||||
|
|
||||||
|
$set('swap', $value);
|
||||||
|
})
|
||||||
|
->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,
|
||||||
|
'limited' => false,
|
||||||
|
})
|
||||||
|
->label('Swap Memory')
|
||||||
|
->default(0)
|
||||||
|
->suffix('MiB')
|
||||||
|
->minValue(-1)
|
||||||
|
->columnSpan(2)
|
||||||
|
->inlineLabel()
|
||||||
|
->required()
|
||||||
|
->integer(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\Hidden::make('io')
|
||||||
|
->helperText('The IO performance relative to other running containers')
|
||||||
|
->label('Block IO Proportion')
|
||||||
|
->default(500),
|
||||||
|
|
||||||
|
Forms\Components\Grid::make()
|
||||||
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('oom_killer')
|
||||||
|
->label('OOM Killer')
|
||||||
|
->inlineLabel()->inline()
|
||||||
|
->default(false)
|
||||||
|
->columnSpan(2)
|
||||||
|
->options([
|
||||||
|
false => 'Disabled',
|
||||||
|
true => 'Enabled',
|
||||||
|
])
|
||||||
|
->colors([
|
||||||
|
false => 'success',
|
||||||
|
true => 'danger',
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('oom_disabled_hidden')
|
||||||
|
->hidden(),
|
||||||
|
]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Fieldset::make('Application Feature Limits')
|
Forms\Components\Fieldset::make('Feature Limits')
|
||||||
->inlineLabel()
|
->inlineLabel()
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
@ -674,6 +629,60 @@ class CreateServer extends CreateRecord
|
|||||||
->numeric()
|
->numeric()
|
||||||
->default(0),
|
->default(0),
|
||||||
]),
|
]),
|
||||||
|
Forms\Components\Fieldset::make('Docker Settings')
|
||||||
|
->columnSpan([
|
||||||
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('select_image')
|
||||||
|
->label('Image Name')
|
||||||
|
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('image', $state))
|
||||||
|
->options(function ($state, Forms\Get $get, Forms\Set $set) {
|
||||||
|
$egg = Egg::query()->find($get('egg_id'));
|
||||||
|
$images = $egg->docker_images ?? [];
|
||||||
|
|
||||||
|
$currentImage = $get('image');
|
||||||
|
if (!$currentImage && $images) {
|
||||||
|
$defaultImage = collect($images)->first();
|
||||||
|
$set('image', $defaultImage);
|
||||||
|
$set('select_image', $defaultImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_flip($images) + ['ghcr.io/custom-image' => 'Custom Image'];
|
||||||
|
})
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('image')
|
||||||
|
->label('Image')
|
||||||
|
->debounce(500)
|
||||||
|
->afterStateUpdated(function ($state, Forms\Get $get, Forms\Set $set) {
|
||||||
|
$egg = Egg::query()->find($get('egg_id'));
|
||||||
|
$images = $egg->docker_images ?? [];
|
||||||
|
|
||||||
|
if (in_array($state, $images)) {
|
||||||
|
$set('select_image', $state);
|
||||||
|
} else {
|
||||||
|
$set('select_image', 'ghcr.io/custom-image');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->placeholder('Enter a custom Image')
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
Forms\Components\TagsInput::make('docker_labels')
|
||||||
|
->label('Labels')
|
||||||
|
->placeholder('Enter custom Docker container labels')
|
||||||
|
->columnSpan(1),
|
||||||
|
]),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -157,60 +157,6 @@ class EditServer extends EditRecord
|
|||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('select_image')
|
|
||||||
->label('Docker Image Name')
|
|
||||||
->prefixIcon('tabler-brand-docker')
|
|
||||||
->live()
|
|
||||||
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('image', $state))
|
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('image'))
|
|
||||||
->options(function ($state, Forms\Get $get) {
|
|
||||||
$egg = Egg::query()->find($get('egg_id'));
|
|
||||||
$images = $egg->docker_images ?? [];
|
|
||||||
|
|
||||||
return ['ghcr.io/custom-image' => 'Custom Image'] + array_flip($images);
|
|
||||||
})
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('image')
|
|
||||||
->label('Docker Image')
|
|
||||||
->prefixIcon('tabler-brand-docker')
|
|
||||||
->live()
|
|
||||||
->debounce(500)
|
|
||||||
->afterStateUpdated(function ($state, Forms\Get $get, Forms\Set $set) {
|
|
||||||
$egg = Egg::query()->find($get('egg_id'));
|
|
||||||
$images = $egg->docker_images ?? [];
|
|
||||||
|
|
||||||
if (in_array($state, $images)) {
|
|
||||||
$set('select_image', $state);
|
|
||||||
} else {
|
|
||||||
$set('select_image', 'ghcr.io/custom-image');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->placeholder('Enter a custom Image')
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\TagsInput::make('docker_labels')
|
|
||||||
->label('Docker Labels')
|
|
||||||
->live()
|
|
||||||
->placeholder('Enter custom Docker container labels')
|
|
||||||
->columnSpan([
|
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 2,
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Textarea::make('startup')
|
Forms\Components\Textarea::make('startup')
|
||||||
->hintIcon('tabler-code')
|
->hintIcon('tabler-code')
|
||||||
->label('Startup Command')
|
->label('Startup Command')
|
||||||
@ -298,7 +244,7 @@ class EditServer extends EditRecord
|
|||||||
->columnSpan(2),
|
->columnSpan(2),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Section::make('Resource Management')
|
Forms\Components\Section::make('Environment Management')
|
||||||
->collapsed()
|
->collapsed()
|
||||||
->icon('tabler-server-cog')
|
->icon('tabler-server-cog')
|
||||||
->iconColor('primary')
|
->iconColor('primary')
|
||||||
@ -310,170 +256,185 @@ class EditServer extends EditRecord
|
|||||||
])
|
])
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Grid::make()
|
Forms\Components\Fieldset::make('Resource Limits')
|
||||||
->columns(4)
|
->columnSpan([
|
||||||
->columnSpanFull()
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\ToggleButtons::make('unlimited_mem')
|
Forms\Components\Grid::make()
|
||||||
->label('Memory')->inlineLabel()->inline()
|
->columns(4)
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
->columnSpanFull()
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('memory') == 0)
|
->schema([
|
||||||
->live()
|
Forms\Components\ToggleButtons::make('unlimited_mem')
|
||||||
->options([
|
->label('Memory')->inlineLabel()->inline()
|
||||||
true => 'Unlimited',
|
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
|
||||||
false => 'Limited',
|
->formatStateUsing(fn (Forms\Get $get) => $get('memory') == 0)
|
||||||
])
|
->live()
|
||||||
->colors([
|
->options([
|
||||||
true => 'primary',
|
true => 'Unlimited',
|
||||||
false => 'warning',
|
false => 'Limited',
|
||||||
])
|
])
|
||||||
->columnSpan(2),
|
->colors([
|
||||||
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('memory')
|
Forms\Components\TextInput::make('memory')
|
||||||
->dehydratedWhenHidden()
|
->dehydratedWhenHidden()
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
|
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
|
||||||
->label('Memory Limit')->inlineLabel()
|
->label('Memory Limit')->inlineLabel()
|
||||||
->suffix('MiB')
|
->suffix('MiB')
|
||||||
->required()
|
->required()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0),
|
->minValue(0),
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
|
||||||
->columns(4)
|
|
||||||
->columnSpanFull()
|
|
||||||
->schema([
|
|
||||||
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')
|
|
||||||
->dehydratedWhenHidden()
|
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
|
|
||||||
->label('Disk Space Limit')->inlineLabel()
|
|
||||||
->suffix('MiB')
|
|
||||||
->required()
|
|
||||||
->columnSpan(2)
|
|
||||||
->numeric()
|
|
||||||
->minValue(0),
|
|
||||||
]),
|
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
|
||||||
->columns(4)
|
|
||||||
->columnSpanFull()
|
|
||||||
->schema([
|
|
||||||
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
|
||||||
->label('CPU')->inlineLabel()->inline()
|
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
|
||||||
->formatStateUsing(fn (Forms\Get $get) => $get('cpu') == 0)
|
|
||||||
->live()
|
|
||||||
->options([
|
|
||||||
true => 'Unlimited',
|
|
||||||
false => 'Limited',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
true => 'primary',
|
|
||||||
false => 'warning',
|
|
||||||
])
|
|
||||||
->columnSpan(2),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('cpu')
|
|
||||||
->dehydratedWhenHidden()
|
|
||||||
->hidden(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
|
||||||
->label('CPU Limit')->inlineLabel()
|
|
||||||
->suffix('%')
|
|
||||||
->required()
|
|
||||||
->columnSpan(2)
|
|
||||||
->numeric()
|
|
||||||
->minValue(0),
|
|
||||||
]),
|
|
||||||
|
|
||||||
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')
|
Forms\Components\Grid::make()
|
||||||
->dehydratedWhenHidden()
|
->columns(4)
|
||||||
->hidden(fn (Forms\Get $get) => match ($get('swap_support')) {
|
->columnSpanFull()
|
||||||
'disabled', 'unlimited', true => true,
|
->schema([
|
||||||
'limited', false => false,
|
Forms\Components\ToggleButtons::make('unlimited_disk')
|
||||||
})
|
->label('Disk Space')->inlineLabel()->inline()
|
||||||
->label('Swap Memory')->inlineLabel()
|
->live()
|
||||||
->suffix('MiB')
|
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
|
||||||
->minValue(-1)
|
->formatStateUsing(fn (Forms\Get $get) => $get('disk') == 0)
|
||||||
->columnSpan(2)
|
->options([
|
||||||
->required()
|
true => 'Unlimited',
|
||||||
->integer(),
|
false => 'Limited',
|
||||||
]),
|
])
|
||||||
|
->colors([
|
||||||
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('io')
|
Forms\Components\TextInput::make('disk')
|
||||||
->helperText('The IO performance relative to other running containers')
|
->dehydratedWhenHidden()
|
||||||
->label('Block IO Proportion'),
|
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
|
||||||
|
->label('Disk Space Limit')->inlineLabel()
|
||||||
Forms\Components\Grid::make()
|
->suffix('MiB')
|
||||||
->columns(4)
|
->required()
|
||||||
->columnSpanFull()
|
->columnSpan(2)
|
||||||
->schema([
|
->numeric()
|
||||||
Forms\Components\ToggleButtons::make('oom_killer')
|
->minValue(0),
|
||||||
->label('OOM Killer')->inlineLabel()->inline()
|
|
||||||
->columnSpan(2)
|
|
||||||
->options([
|
|
||||||
false => 'Disabled',
|
|
||||||
true => 'Enabled',
|
|
||||||
])
|
|
||||||
->colors([
|
|
||||||
false => 'success',
|
|
||||||
true => 'danger',
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('oom_disabled_hidden')
|
Forms\Components\Grid::make()
|
||||||
->hidden(),
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('unlimited_cpu')
|
||||||
|
->label('CPU')->inlineLabel()->inline()
|
||||||
|
->afterStateUpdated(fn (Forms\Set $set) => $set('cpu', 0))
|
||||||
|
->formatStateUsing(fn (Forms\Get $get) => $get('cpu') == 0)
|
||||||
|
->live()
|
||||||
|
->options([
|
||||||
|
true => 'Unlimited',
|
||||||
|
false => 'Limited',
|
||||||
|
])
|
||||||
|
->colors([
|
||||||
|
true => 'primary',
|
||||||
|
false => 'warning',
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('cpu')
|
||||||
|
->dehydratedWhenHidden()
|
||||||
|
->hidden(fn (Forms\Get $get) => $get('unlimited_cpu'))
|
||||||
|
->label('CPU Limit')->inlineLabel()
|
||||||
|
->suffix('%')
|
||||||
|
->required()
|
||||||
|
->columnSpan(2)
|
||||||
|
->numeric()
|
||||||
|
->minValue(0),
|
||||||
|
]),
|
||||||
|
|
||||||
|
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('MiB')
|
||||||
|
->minValue(-1)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->integer(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\Hidden::make('io')
|
||||||
|
->helperText('The IO performance relative to other running containers')
|
||||||
|
->label('Block IO Proportion'),
|
||||||
|
|
||||||
|
Forms\Components\Grid::make()
|
||||||
|
->columns(4)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\ToggleButtons::make('oom_killer')
|
||||||
|
->label('OOM Killer')->inlineLabel()->inline()
|
||||||
|
->columnSpan(2)
|
||||||
|
->options([
|
||||||
|
false => 'Disabled',
|
||||||
|
true => 'Enabled',
|
||||||
|
])
|
||||||
|
->colors([
|
||||||
|
false => 'success',
|
||||||
|
true => 'danger',
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('oom_disabled_hidden')
|
||||||
|
->hidden(),
|
||||||
|
]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Fieldset::make('Application Feature Limits')
|
Forms\Components\Fieldset::make('Feature Limits')
|
||||||
->inlineLabel()
|
->inlineLabel()
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
@ -501,6 +462,60 @@ class EditServer extends EditRecord
|
|||||||
->required()
|
->required()
|
||||||
->numeric(),
|
->numeric(),
|
||||||
]),
|
]),
|
||||||
|
Forms\Components\Fieldset::make('Docker Settings')
|
||||||
|
->columnSpan([
|
||||||
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('select_image')
|
||||||
|
->label('Image Name')
|
||||||
|
->afterStateUpdated(fn (Forms\Set $set, $state) => $set('image', $state))
|
||||||
|
->options(function ($state, Forms\Get $get, Forms\Set $set) {
|
||||||
|
$egg = Egg::query()->find($get('egg_id'));
|
||||||
|
$images = $egg->docker_images ?? [];
|
||||||
|
|
||||||
|
$currentImage = $get('image');
|
||||||
|
if (!$currentImage && $images) {
|
||||||
|
$defaultImage = collect($images)->first();
|
||||||
|
$set('image', $defaultImage);
|
||||||
|
$set('select_image', $defaultImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_flip($images) + ['ghcr.io/custom-image' => 'Custom Image'];
|
||||||
|
})
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('image')
|
||||||
|
->label('Image')
|
||||||
|
->debounce(500)
|
||||||
|
->afterStateUpdated(function ($state, Forms\Get $get, Forms\Set $set) {
|
||||||
|
$egg = Egg::query()->find($get('egg_id'));
|
||||||
|
$images = $egg->docker_images ?? [];
|
||||||
|
|
||||||
|
if (in_array($state, $images)) {
|
||||||
|
$set('select_image', $state);
|
||||||
|
} else {
|
||||||
|
$set('select_image', 'ghcr.io/custom-image');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->placeholder('Enter a custom Image')
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
Forms\Components\TagsInput::make('docker_labels')
|
||||||
|
->label('Labels')
|
||||||
|
->placeholder('Enter custom Docker container labels')
|
||||||
|
->columnSpan(1),
|
||||||
|
]),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user