mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +02:00
Add missing Database
address field (#1049)
* Add address field to display `host:port` to enduser on `ListDatabases` & `EditServer` * Add `CopyAction` to `EditServer` * Update databaseHost `display_name_help`
This commit is contained in:
parent
1fdc428f3e
commit
d438e29154
@ -664,11 +664,17 @@ class EditServer extends EditRecord
|
||||
->helperText(fn (Server $server) => $server->databases->isNotEmpty() ? '' : trans('admin/server.no_databases'))
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('host')
|
||||
->label(trans('admin/databasehost.table.host'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->address())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->columnSpan(1),
|
||||
TextInput::make('database')
|
||||
->columnSpan(2)
|
||||
->label(trans('admin/server.name'))
|
||||
->label(trans('admin/databasehost.table.database'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->database)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintAction(
|
||||
Action::make('Delete')
|
||||
->label(trans('filament-actions::delete.single.modal.actions.delete.label'))
|
||||
@ -689,6 +695,7 @@ class EditServer extends EditRecord
|
||||
->label(trans('admin/databasehost.table.username'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->username)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->columnSpan(1),
|
||||
TextInput::make('password')
|
||||
->label(trans('admin/databasehost.table.password'))
|
||||
@ -697,6 +704,7 @@ class EditServer extends EditRecord
|
||||
->revealable()
|
||||
->columnSpan(1)
|
||||
->hintAction(RotateDatabasePasswordAction::make())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->formatStateUsing(fn (Database $database) => $database->password),
|
||||
TextInput::make('remote')
|
||||
->disabled()
|
||||
@ -714,7 +722,8 @@ class EditServer extends EditRecord
|
||||
->revealable()
|
||||
->label(trans('admin/databasehost.table.connection_string'))
|
||||
->columnSpan(2)
|
||||
->formatStateUsing(fn (Database $record) => $record->jdbc),
|
||||
->formatStateUsing(fn (Database $record) => $record->jdbc)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
])
|
||||
->relationship('databases')
|
||||
->deletable(false)
|
||||
|
@ -35,8 +35,10 @@ class ListDatabases extends ListRecords
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('host')
|
||||
->formatStateUsing(fn (Database $database) => $database->address())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
TextInput::make('database')
|
||||
->columnSpanFull()
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
TextInput::make('username')
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
@ -67,6 +69,9 @@ class ListDatabases extends ListRecords
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('host')
|
||||
->state(fn (Database $database) => $database->address())
|
||||
->badge(),
|
||||
TextColumn::make('database'),
|
||||
TextColumn::make('username'),
|
||||
TextColumn::make('remote'),
|
||||
|
@ -87,10 +87,15 @@ class Database extends Model implements Validatable
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
public function address(): string
|
||||
{
|
||||
return $this->host->name . ':' . $this->host->port;
|
||||
}
|
||||
|
||||
protected function jdbc(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => 'jdbc:mysql://' . $this->username . ':' . urlencode($this->password) . '@' . $this->host->host . ':' . $this->host->port . '/' . $this->database,
|
||||
get: fn () => 'jdbc:mysql://' . $this->username . ':' . urlencode($this->password) . '@' . $this->address() . '/' . $this->database,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ return [
|
||||
'model_label' => 'Database Host',
|
||||
'model_label_plural' => 'Database Hosts',
|
||||
'table' => [
|
||||
'database' => 'Database',
|
||||
'name' => 'Name',
|
||||
'host' => 'Host',
|
||||
'port' => 'Port',
|
||||
@ -25,7 +26,7 @@ return [
|
||||
'max_database' => 'Max Databases',
|
||||
'max_databases_help' => 'The maximum number of databases that can be created on this host. If the limit is reached, no new databases can be created on this host. Blank is unlimited.',
|
||||
'display_name' => 'Display Name',
|
||||
'display_name_help' => 'A short identifier used to distinguish this host from others. Must be between 1 and 60 characters, for example, us.nyc.lvl3.',
|
||||
'display_name_help' => 'The IP address or Domain name that should be shown to the enduser.',
|
||||
'username' => 'Username',
|
||||
'username_help' => 'The username of an account that has enough permissions to create new users and databases on the system.',
|
||||
'password' => 'Password',
|
||||
|
Loading…
x
Reference in New Issue
Block a user