Update database view
This commit is contained in:
parent
00dda7dbe4
commit
0cd03e95f4
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\DatabaseHostResource\RelationManagers;
|
namespace App\Filament\Resources\DatabaseHostResource\RelationManagers;
|
||||||
|
|
||||||
|
use App\Models\Database;
|
||||||
|
use App\Models\DatabaseHost;
|
||||||
|
use App\Services\Databases\DatabasePasswordService;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\RelationManagers\RelationManager;
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
@ -12,21 +16,32 @@ class DatabasesRelationManager extends RelationManager
|
|||||||
{
|
{
|
||||||
protected static string $relationship = 'databases';
|
protected static string $relationship = 'databases';
|
||||||
|
|
||||||
|
protected $listeners = ['refresh'=>'refreshForm'];
|
||||||
|
|
||||||
public function form(Form $form): Form
|
public function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('database')->columnSpanFull(),
|
Forms\Components\TextInput::make('database')->columnSpanFull(),
|
||||||
Forms\Components\TextInput::make('username'),
|
Forms\Components\TextInput::make('username'),
|
||||||
Forms\Components\TextInput::make('password')->default('Soon™'),
|
Forms\Components\TextInput::make('password')
|
||||||
|
->hintAction(
|
||||||
|
Action::make('rotate')
|
||||||
|
->icon('tabler-refresh')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->action(fn (DatabasePasswordService $service, Database $db) => $service->handle($db))
|
||||||
|
)
|
||||||
|
->formatStateUsing(fn (Database $database) => decrypt($database->password)),
|
||||||
Forms\Components\TextInput::make('remote')->label('Connections From'),
|
Forms\Components\TextInput::make('remote')->label('Connections From'),
|
||||||
Forms\Components\TextInput::make('max_connections'),
|
Forms\Components\TextInput::make('max_connections'),
|
||||||
Forms\Components\TextInput::make('JDBC')->label('JDBC Connection String')->columnSpanFull()->default('Soon™'),
|
Forms\Components\TextInput::make('JDBC')
|
||||||
|
->label('JDBC Connection String')
|
||||||
|
->columnSpanFull()
|
||||||
|
->formatStateUsing(fn (Forms\Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode(decrypt($database->password)) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')),
|
||||||
Forms\Components\TextInput::make('created_at'),
|
Forms\Components\TextInput::make('created_at'),
|
||||||
Forms\Components\TextInput::make('updated_at'),
|
Forms\Components\TextInput::make('updated_at'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
@ -36,8 +51,7 @@ class DatabasesRelationManager extends RelationManager
|
|||||||
Tables\Columns\TextColumn::make('username'),
|
Tables\Columns\TextColumn::make('username'),
|
||||||
//Tables\Columns\TextColumn::make('password'),
|
//Tables\Columns\TextColumn::make('password'),
|
||||||
Tables\Columns\TextColumn::make('remote'),
|
Tables\Columns\TextColumn::make('remote'),
|
||||||
Tables\Columns\TextColumn::make('server_id')
|
Tables\Columns\TextColumn::make('server.name'),
|
||||||
->label('Belongs To'),
|
|
||||||
// TODO ->url(route('filament.admin.resources.servers.edit', ['record', ''])),
|
// TODO ->url(route('filament.admin.resources.servers.edit', ['record', ''])),
|
||||||
Tables\Columns\TextColumn::make('max_connections'),
|
Tables\Columns\TextColumn::make('max_connections'),
|
||||||
Tables\Columns\TextColumn::make('created_at'),
|
Tables\Columns\TextColumn::make('created_at'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user