mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-22 10:54:44 +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')
|
||||||
@ -474,6 +414,20 @@ class CreateServer extends CreateRecord
|
|||||||
'lg' => 4,
|
'lg' => 4,
|
||||||
])
|
])
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Fieldset::make('Resource Limits')
|
||||||
|
->columnSpan([
|
||||||
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Grid::make()
|
Forms\Components\Grid::make()
|
||||||
->columns(4)
|
->columns(4)
|
||||||
@ -566,7 +520,7 @@ class CreateServer extends CreateRecord
|
|||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->numeric()
|
->numeric()
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->helperText('100% equals one logical thread'),
|
->helperText('100% equals one CPU core.'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Grid::make()
|
Forms\Components\Grid::make()
|
||||||
@ -642,8 +596,9 @@ class CreateServer extends CreateRecord
|
|||||||
Forms\Components\TextInput::make('oom_disabled_hidden')
|
Forms\Components\TextInput::make('oom_disabled_hidden')
|
||||||
->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')
|
||||||
@ -309,6 +255,20 @@ class EditServer extends EditRecord
|
|||||||
'lg' => 4,
|
'lg' => 4,
|
||||||
])
|
])
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Fieldset::make('Resource Limits')
|
||||||
|
->columnSpan([
|
||||||
|
'default' => 2,
|
||||||
|
'sm' => 4,
|
||||||
|
'md' => 4,
|
||||||
|
'lg' => 6,
|
||||||
|
])
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'sm' => 2,
|
||||||
|
'md' => 3,
|
||||||
|
'lg' => 3,
|
||||||
|
])
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Grid::make()
|
Forms\Components\Grid::make()
|
||||||
->columns(4)
|
->columns(4)
|
||||||
@ -472,8 +432,9 @@ class EditServer extends EditRecord
|
|||||||
Forms\Components\TextInput::make('oom_disabled_hidden')
|
Forms\Components\TextInput::make('oom_disabled_hidden')
|
||||||
->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