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') Tabs\Tab::make('Basic Settings')
->icon('tabler-server') ->icon('tabler-server')
->schema((new CreateNode())->form($form)->getComponents()), ->schema((new CreateNode())->form($form)->getComponents()),
Tabs\Tab::make('Advanced Settings') // Tabs\Tab::make('Advanced Settings')
->icon('tabler-server-cog') // ->icon('tabler-server-cog')
->schema([ // ->schema([
Forms\Components\Placeholder::make('Coming soon!'), // Forms\Components\Placeholder::make('Coming soon!'),
]), // ]),
Tabs\Tab::make('Configuration') Tabs\Tab::make('Configuration')
->icon('tabler-code') ->icon('tabler-code')
->schema([ ->schema([

View File

@ -353,39 +353,6 @@ class CreateServer extends CreateRecord
'lg' => 3, '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') Forms\Components\Textarea::make('startup')
->hintIcon('tabler-code') ->hintIcon('tabler-code')
->label('Startup Command') ->label('Startup Command')
@ -634,18 +601,58 @@ class CreateServer extends CreateRecord
->label('Block IO Proportion') ->label('Block IO Proportion')
->default(500), ->default(500),
Forms\Components\ToggleButtons::make('oom_disabled') Forms\Components\Grid::make()
->label('OOM Killer') ->columns(4)
->inlineLabel()->inline() ->columnSpanFull()
->default(false) ->schema([
->columnSpan(2) Forms\Components\ToggleButtons::make('oom_disabled')
->options([ ->label('OOM Killer')
false => 'Disabled', ->inlineLabel()->inline()
true => 'Enabled', ->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')
->inlineLabel()
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
]) ])
->colors([ ->columns([
false => 'success', 'default' => 1,
true => 'danger', '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([ ->schema([
Forms\Components\ToggleButtons::make('docker') Forms\Components\ToggleButtons::make('docker')
->label('Container Status') ->label('Container Status')->inline()->inlineLabel()
->inlineLabel()
->formatStateUsing(function ($state, Server $server) { ->formatStateUsing(function ($state, Server $server) {
if ($server->node_id === null) { if ($server->node_id === null) {
return 'unknown'; return 'unknown';
@ -59,13 +58,12 @@ class EditServer extends EditRecord
'sm' => 2, 'sm' => 2,
'md' => 2, 'md' => 2,
'lg' => 3, 'lg' => 3,
]) ]),
->inline(),
Forms\Components\ToggleButtons::make('status') Forms\Components\ToggleButtons::make('status')
->label('Server State') ->label('Server State')->inline()->inlineLabel()
->helperText('') ->helperText('')
->inlineLabel()
->formatStateUsing(fn ($state) => $state ?? ServerState::Normal) ->formatStateUsing(fn ($state) => $state ?? ServerState::Normal)
->options(fn ($state) => collect(ServerState::cases())->filter(fn ($serverState) => $serverState->value === $state)->mapWithKeys( ->options(fn ($state) => collect(ServerState::cases())->filter(fn ($serverState) => $serverState->value === $state)->mapWithKeys(
fn (ServerState $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()] fn (ServerState $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()]
@ -81,8 +79,7 @@ class EditServer extends EditRecord
'sm' => 2, 'sm' => 2,
'md' => 2, 'md' => 2,
'lg' => 3, 'lg' => 3,
]) ]),
->inline(),
Forms\Components\TextInput::make('external_id') Forms\Components\TextInput::make('external_id')
->maxLength(191) ->maxLength(191)
@ -142,7 +139,7 @@ class EditServer extends EditRecord
->required(), ->required(),
Forms\Components\ToggleButtons::make('skip_scripts') Forms\Components\ToggleButtons::make('skip_scripts')
->label('Run Egg Install Script?') ->label('Run Egg Install Script?')->inline()
->options([ ->options([
false => 'Yes', false => 'Yes',
true => 'Skip', true => 'Skip',
@ -155,12 +152,11 @@ class EditServer extends EditRecord
false => 'tabler-code', false => 'tabler-code',
true => 'tabler-code-off', true => 'tabler-code-off',
]) ])
->inline()
->required(), ->required(),
Forms\Components\ToggleButtons::make('custom_image') Forms\Components\ToggleButtons::make('custom_image')
->live() ->live()
->label('Custom Image?') ->label('Custom Image?')->inline()
->formatStateUsing(function ($state, Forms\Get $get) { ->formatStateUsing(function ($state, Forms\Get $get) {
if ($state !== null) { if ($state !== null) {
return $state; return $state;
@ -181,8 +177,7 @@ class EditServer extends EditRecord
->icons([ ->icons([
false => 'tabler-settings-cancel', false => 'tabler-settings-cancel',
true => 'tabler-settings-check', true => 'tabler-settings-check',
]) ]),
->inline(),
Forms\Components\TextInput::make('image') Forms\Components\TextInput::make('image')
->hidden(fn (Forms\Get $get) => !$get('custom_image')) ->hidden(fn (Forms\Get $get) => !$get('custom_image'))
@ -213,35 +208,6 @@ class EditServer extends EditRecord
]) ])
->required(), ->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') Forms\Components\Textarea::make('startup')
->hintIcon('tabler-code') ->hintIcon('tabler-code')
->label('Startup Command') ->label('Startup Command')
@ -459,16 +425,53 @@ class EditServer extends EditRecord
->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'),
Forms\Components\ToggleButtons::make('oom_disabled') Forms\Components\Grid::make()
->label('OOM Killer')->inlineLabel()->inline() ->columns(4)
->columnSpan(2) ->columnSpanFull()
->options([ ->schema([
false => 'Disabled', Forms\Components\ToggleButtons::make('oom_disabled')
true => 'Enabled', ->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')
->inlineLabel()
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
]) ])
->colors([ ->columns([
false => 'success', 'default' => 1,
true => 'danger', '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(),
]), ]),
]), ]),
]); ]);

View File

@ -52,7 +52,7 @@ class AdminPanelProvider extends PanelProvider
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters') ->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters')
->pages([ ->pages([
// Pages\Dashboard::class, // Pages\Dashboard::class,
]) ])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')