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

View File

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