Update database hosts

This commit is contained in:
notCharles 2024-05-14 19:30:07 -04:00
parent 98ba2c1b8b
commit e9dc6cd32c
2 changed files with 97 additions and 79 deletions

View File

@ -22,21 +22,38 @@ class CreateDatabaseHost extends CreateRecord
{ {
return $form return $form
->schema([ ->schema([
Section::make()->schema([ Section::make()
->columns([
'default' => 2,
'sm' => 3,
'md' => 3,
'lg' => 4,
])
->schema([
Forms\Components\TextInput::make('host') Forms\Components\TextInput::make('host')
->columnSpan(2)
->helperText('The IP address or Domain name that should be used when attempting to connect to this MySQL host from this Panel to create new databases.') ->helperText('The IP address or Domain name that should be used when attempting to connect to this MySQL host from this Panel to create new databases.')
->required() ->required()
->live() ->live(onBlur: true)
->debounce(500)
->afterStateUpdated(fn ($state, Forms\Set $set) => $set('name', $state)) ->afterStateUpdated(fn ($state, Forms\Set $set) => $set('name', $state))
->maxLength(191), ->maxLength(191),
Forms\Components\TextInput::make('port') Forms\Components\TextInput::make('port')
->columnSpan(1)
->helperText('The port that MySQL is running on for this host.') ->helperText('The port that MySQL is running on for this host.')
->required() ->required()
->numeric() ->numeric()
->default(3306) ->default(3306)
->minValue(0) ->minValue(0)
->maxValue(65535), ->maxValue(65535),
Forms\Components\TextInput::make('max_databases')
->label('Max databases')
->helpertext('Blank is unlimited.')
->numeric(),
Forms\Components\TextInput::make('name')
->label('Display Name')
->helperText('A short identifier used to distinguish this location from others. Must be between 1 and 60 characters, for example, us.nyc.lvl3.')
->required()
->maxLength(60),
Forms\Components\TextInput::make('username') Forms\Components\TextInput::make('username')
->helperText('The username of an account that has enough permissions to create new users and databases on the system.') ->helperText('The username of an account that has enough permissions to create new users and databases on the system.')
->required() ->required()
@ -47,22 +64,14 @@ class CreateDatabaseHost extends CreateRecord
->revealable() ->revealable()
->maxLength(191) ->maxLength(191)
->required(), ->required(),
Forms\Components\TextInput::make('name')
->helperText('A short identifier used to distinguish this location from others. Must be between 1 and 60 characters, for example, us.nyc.lvl3.')
->required()
->maxLength(60),
Forms\Components\Select::make('node_id') Forms\Components\Select::make('node_id')
->searchable() ->searchable()
->preload() ->preload()
->helperText('This setting only defaults to this database host when adding a database to a server on the selected node.') ->helperText('This setting only defaults to this database host when adding a database to a server on the selected node.')
->label('Linked Node') ->label('Linked Node')
->relationship('node', 'name'), ->relationship('node', 'name'),
])->columns([
'default' => 1,
'lg' => 2,
]), ]),
]); ]);
} }
protected function mutateFormDataBeforeCreate(array $data): array protected function mutateFormDataBeforeCreate(array $data): array

View File

@ -17,21 +17,37 @@ class EditDatabaseHost extends EditRecord
{ {
return $form return $form
->schema([ ->schema([
Section::make()->schema([ Section::make()
->columns([
'default' => 2,
'sm' => 3,
'md' => 3,
'lg' => 4,
])
->schema([
Forms\Components\TextInput::make('host') Forms\Components\TextInput::make('host')
->columnSpan(2)
->helperText('The IP address or Domain name that should be used when attempting to connect to this MySQL host from this Panel to create new databases.') ->helperText('The IP address or Domain name that should be used when attempting to connect to this MySQL host from this Panel to create new databases.')
->required() ->required()
->live() ->live(onBlur: true)
->debounce(500)
->afterStateUpdated(fn ($state, Forms\Set $set) => $set('name', $state)) ->afterStateUpdated(fn ($state, Forms\Set $set) => $set('name', $state))
->maxLength(191), ->maxLength(191),
Forms\Components\TextInput::make('port') Forms\Components\TextInput::make('port')
->columnSpan(1)
->helperText('The port that MySQL is running on for this host.') ->helperText('The port that MySQL is running on for this host.')
->required() ->required()
->numeric() ->numeric()
->default(3306)
->minValue(0) ->minValue(0)
->maxValue(65535), ->maxValue(65535),
Forms\Components\TextInput::make('max_databases')
->label('Max databases')
->helpertext('Blank is unlimited.')
->numeric(),
Forms\Components\TextInput::make('name')
->label('Display Name')
->helperText('A short identifier used to distinguish this location from others. Must be between 1 and 60 characters, for example, us.nyc.lvl3.')
->required()
->maxLength(60),
Forms\Components\TextInput::make('username') Forms\Components\TextInput::make('username')
->helperText('The username of an account that has enough permissions to create new users and databases on the system.') ->helperText('The username of an account that has enough permissions to create new users and databases on the system.')
->required() ->required()
@ -42,19 +58,12 @@ class EditDatabaseHost extends EditRecord
->revealable() ->revealable()
->maxLength(191) ->maxLength(191)
->required(), ->required(),
Forms\Components\TextInput::make('name')
->helperText('A short identifier used to distinguish this location from others. Must be between 1 and 60 characters, for example, us.nyc.lvl3.')
->required()
->maxLength(60),
Forms\Components\Select::make('node_id') Forms\Components\Select::make('node_id')
->searchable() ->searchable()
->preload() ->preload()
->helperText('This setting only defaults to this database host when adding a database to a server on the selected node.') ->helperText('This setting only defaults to this database host when adding a database to a server on the selected node.')
->label('Linked Node') ->label('Linked Node')
->relationship('node', 'name'), ->relationship('node', 'name'),
])->columns([
'default' => 1,
'lg' => 2,
]), ]),
]); ]);
} }