Pint & Add application features to create page

This commit is contained in:
notCharles 2024-05-09 19:43:46 -04:00
parent 607e186082
commit dfe2e9d629
4 changed files with 111 additions and 101 deletions

View File

@ -31,11 +31,11 @@ class EditNode extends EditRecord
Tabs\Tab::make('Basic Settings')
->icon('tabler-server')
->schema((new CreateNode())->form($form)->getComponents()),
Tabs\Tab::make('Advanced Settings')
->icon('tabler-server-cog')
->schema([
Forms\Components\Placeholder::make('Coming soon!'),
]),
// Tabs\Tab::make('Advanced Settings')
// ->icon('tabler-server-cog')
// ->schema([
// Forms\Components\Placeholder::make('Coming soon!'),
// ]),
Tabs\Tab::make('Configuration')
->icon('tabler-code')
->schema([

View File

@ -353,39 +353,6 @@ class CreateServer extends CreateRecord
'lg' => 3,
]),
Forms\Components\Fieldset::make('Application Feature Limits')
->inlineLabel()
->hiddenOn('create')
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->columns([
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 3,
])
->schema([
Forms\Components\TextInput::make('allocation_limit')
->suffixIcon('tabler-network')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('database_limit')
->suffixIcon('tabler-database')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('backup_limit')
->suffixIcon('tabler-copy-check')
->required()
->numeric()
->default(0),
]),
Forms\Components\Textarea::make('startup')
->hintIcon('tabler-code')
->label('Startup Command')
@ -634,6 +601,10 @@ class CreateServer extends CreateRecord
->label('Block IO Proportion')
->default(500),
Forms\Components\Grid::make()
->columns(4)
->columnSpanFull()
->schema([
Forms\Components\ToggleButtons::make('oom_disabled')
->label('OOM Killer')
->inlineLabel()->inline()
@ -647,6 +618,42 @@ class CreateServer extends CreateRecord
false => 'success',
true => 'danger',
]),
Forms\Components\TextInput::make('oom_disabled_hidden')
->hidden(),
]),
Forms\Components\Fieldset::make('Application Feature Limits')
->inlineLabel()
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->columns([
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 3,
])
->schema([
Forms\Components\TextInput::make('allocation_limit')
->suffixIcon('tabler-network')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('database_limit')
->suffixIcon('tabler-database')
->required()
->numeric()
->default(0),
Forms\Components\TextInput::make('backup_limit')
->suffixIcon('tabler-copy-check')
->required()
->numeric()
->default(0),
]),
]),
]);
}

View File

@ -32,8 +32,7 @@ class EditServer extends EditRecord
])
->schema([
Forms\Components\ToggleButtons::make('docker')
->label('Container Status')
->inlineLabel()
->label('Container Status')->inline()->inlineLabel()
->formatStateUsing(function ($state, Server $server) {
if ($server->node_id === null) {
return 'unknown';
@ -59,13 +58,12 @@ class EditServer extends EditRecord
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->inline(),
]),
Forms\Components\ToggleButtons::make('status')
->label('Server State')
->label('Server State')->inline()->inlineLabel()
->helperText('')
->inlineLabel()
->formatStateUsing(fn ($state) => $state ?? ServerState::Normal)
->options(fn ($state) => collect(ServerState::cases())->filter(fn ($serverState) => $serverState->value === $state)->mapWithKeys(
fn (ServerState $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()]
@ -81,8 +79,7 @@ class EditServer extends EditRecord
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->inline(),
]),
Forms\Components\TextInput::make('external_id')
->maxLength(191)
@ -142,7 +139,7 @@ class EditServer extends EditRecord
->required(),
Forms\Components\ToggleButtons::make('skip_scripts')
->label('Run Egg Install Script?')
->label('Run Egg Install Script?')->inline()
->options([
false => 'Yes',
true => 'Skip',
@ -155,12 +152,11 @@ class EditServer extends EditRecord
false => 'tabler-code',
true => 'tabler-code-off',
])
->inline()
->required(),
Forms\Components\ToggleButtons::make('custom_image')
->live()
->label('Custom Image?')
->label('Custom Image?')->inline()
->formatStateUsing(function ($state, Forms\Get $get) {
if ($state !== null) {
return $state;
@ -181,8 +177,7 @@ class EditServer extends EditRecord
->icons([
false => 'tabler-settings-cancel',
true => 'tabler-settings-check',
])
->inline(),
]),
Forms\Components\TextInput::make('image')
->hidden(fn (Forms\Get $get) => !$get('custom_image'))
@ -213,35 +208,6 @@ class EditServer extends EditRecord
])
->required(),
Forms\Components\Fieldset::make('Application Feature Limits')
->inlineLabel()
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->columns([
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 3,
])
->schema([
Forms\Components\TextInput::make('allocation_limit')
->suffixIcon('tabler-network')
->required()
->numeric(),
Forms\Components\TextInput::make('database_limit')
->suffixIcon('tabler-database')
->required()
->numeric(),
Forms\Components\TextInput::make('backup_limit')
->suffixIcon('tabler-copy-check')
->required()
->numeric(),
]),
Forms\Components\Textarea::make('startup')
->hintIcon('tabler-code')
->label('Startup Command')
@ -459,6 +425,10 @@ class EditServer extends EditRecord
->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_disabled')
->label('OOM Killer')->inlineLabel()->inline()
->columnSpan(2)
@ -470,6 +440,39 @@ class EditServer extends EditRecord
false => 'success',
true => 'danger',
]),
Forms\Components\TextInput::make('oom_disabled_hidden')
->hidden(),
]),
Forms\Components\Fieldset::make('Application Feature Limits')
->inlineLabel()
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->columns([
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 3,
])
->schema([
Forms\Components\TextInput::make('allocation_limit')
->suffixIcon('tabler-network')
->required()
->numeric(),
Forms\Components\TextInput::make('database_limit')
->suffixIcon('tabler-database')
->required()
->numeric(),
Forms\Components\TextInput::make('backup_limit')
->suffixIcon('tabler-copy-check')
->required()
->numeric(),
]),
]),
]);
}