Fix Container/Server Status + Mobile Styling

This commit is contained in:
notCharles 2024-04-22 18:03:34 -04:00
parent 65bfda1034
commit 2f82229048

View File

@ -43,7 +43,7 @@ class ServerResource extends Resource
Forms\Components\ToggleButtons::make('docker') Forms\Components\ToggleButtons::make('docker')
->label('Container Status') ->label('Container Status')
->hiddenOn('create') ->hiddenOn('create')
->disableOptionWhen(fn ($state, $value) => $state !== $value) ->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';
@ -55,8 +55,8 @@ class ServerResource extends Resource
return $details['state'] ?? 'unknown'; return $details['state'] ?? 'unknown';
}) })
->options(collect(ContainerStatus::cases())->mapWithKeys( ->options(fn ($state) => collect(ContainerStatus::cases())->filter(fn ($containerStatus) => $containerStatus->value === $state)->mapWithKeys(
fn (ContainerStatus $status) => [$status->value => str($status->value)->ucwords()] fn (ContainerStatus $state) => [$state->value => str($state->value)->replace('_', ' ')->ucwords()]
)) ))
->colors(collect(ContainerStatus::cases())->mapWithKeys( ->colors(collect(ContainerStatus::cases())->mapWithKeys(
fn (ContainerStatus $status) => [$status->value => $status->color()] fn (ContainerStatus $status) => [$status->value => $status->color()]
@ -64,17 +64,21 @@ class ServerResource extends Resource
->icons(collect(ContainerStatus::cases())->mapWithKeys( ->icons(collect(ContainerStatus::cases())->mapWithKeys(
fn (ContainerStatus $status) => [$status->value => $status->icon()] fn (ContainerStatus $status) => [$status->value => $status->icon()]
)) ))
->grouped() ->columnSpan([
->columnSpanFull() 'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->inline(), ->inline(),
Forms\Components\ToggleButtons::make('status') Forms\Components\ToggleButtons::make('status')
->label('Server State') ->label('Server State')
->helperText('') ->helperText('')
->hiddenOn('create') ->hiddenOn('create')
->disableOptionWhen(fn ($state, $value) => $state !== $value) ->inlineLabel()
->formatStateUsing(fn ($state) => $state ?? ServerState::Normal) ->formatStateUsing(fn ($state) => $state ?? ServerState::Normal)
->options(collect(ServerState::cases())->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()]
)) ))
->colors(collect(ServerState::cases())->mapWithKeys( ->colors(collect(ServerState::cases())->mapWithKeys(
@ -83,8 +87,12 @@ class ServerResource extends Resource
->icons(collect(ServerState::cases())->mapWithKeys( ->icons(collect(ServerState::cases())->mapWithKeys(
fn (ServerState $state) => [$state->value => $state->icon()] fn (ServerState $state) => [$state->value => $state->icon()]
)) ))
->grouped() ->columnSpan([
->columnSpanFull() 'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->inline(), ->inline(),
Forms\Components\TextInput::make('external_id') Forms\Components\TextInput::make('external_id')
@ -420,7 +428,18 @@ class ServerResource extends Resource
Forms\Components\Fieldset::make('Application Feature Limits') Forms\Components\Fieldset::make('Application Feature Limits')
->inlineLabel() ->inlineLabel()
->hiddenOn('create') ->hiddenOn('create')
->columns(3) ->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->columns([
'default' => 1,
'sm' => 2,
'md' => 3,
'lg' => 3,
])
->schema([ ->schema([
Forms\Components\TextInput::make('allocation_limit') Forms\Components\TextInput::make('allocation_limit')
->suffixIcon('tabler-network') ->suffixIcon('tabler-network')