mirror of
https://github.com/pelican-dev/panel.git
synced 2026-07-17 04:33:57 +03:00
Compare commits
5 Commits
main
...
boy132/ran
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d7a5ae87c | ||
|
|
2c02dc69e9 | ||
|
|
721eed01f4 | ||
|
|
b54e4a8c7a | ||
|
|
23e08baa17 |
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\RelationManagers;
|
||||
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||
use App\Models\Database;
|
||||
@@ -50,7 +51,7 @@ class DatabasesRelationManager extends RelationManager
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('database')
|
||||
->heading('')
|
||||
->heading(null)
|
||||
->columns([
|
||||
TextColumn::make('database'),
|
||||
TextColumn::make('username')
|
||||
@@ -59,7 +60,7 @@ class DatabasesRelationManager extends RelationManager
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? trans('admin/databasehost.anywhere'). ' ( % )' : $record->remote),
|
||||
TextColumn::make('server.name')
|
||||
->url(fn (Database $database) => route('filament.admin.resources.servers.edit', ['record' => $database->server_id])),
|
||||
->url(fn (Database $database) => user()?->can('update', $database->server) ? EditServer::getUrl(['record' => $database->server]) : null),
|
||||
TextColumn::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
->formatStateUsing(fn ($record) => $record->max_connections ?: trans('server/database.unlimited')),
|
||||
|
||||
@@ -43,12 +43,8 @@ class ListEggs extends ListRecords
|
||||
$defaultEggIcon = 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(public_path($defaultEggIcon)));
|
||||
|
||||
return $table
|
||||
->searchable(true)
|
||||
->defaultPaginationPageOption(25)
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('Id')
|
||||
->hidden(),
|
||||
ImageColumn::make('icon')
|
||||
->label('')
|
||||
->alignCenter()
|
||||
@@ -56,7 +52,7 @@ class ListEggs extends ListRecords
|
||||
->getStateUsing(fn (Egg $record) => $record->icon ?: $defaultEggIcon),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/egg.name'))
|
||||
->description(fn ($record): ?string => (strlen($record->description) > 120) ? substr($record->description, 0, 120).'...' : $record->description)
|
||||
->description(fn ($record) => (strlen($record->description) > 120) ? substr($record->description, 0, 120).'...' : $record->description)
|
||||
->wrap()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Filament\Admin\Resources\Eggs\RelationManagers;
|
||||
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Admin\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Components\Actions\ViewConsoleAction;
|
||||
use App\Models\Server;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -18,27 +22,35 @@ class ServersRelationManager extends RelationManager
|
||||
->recordTitleAttribute('servers')
|
||||
->emptyStateDescription(trans('admin/egg.no_servers'))
|
||||
->emptyStateHeading(trans('admin/egg.no_servers_help'))
|
||||
->searchable(false)
|
||||
->heading(trans('admin/egg.servers'))
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label(trans('admin/server.owner'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->sortable(),
|
||||
->url(fn (Server $server) => user()?->can('update', $server->user) ? EditUser::getUrl(['record' => $server->user]) : null)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/server.name'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.servers.edit', ['record' => $server]))
|
||||
->sortable(),
|
||||
->url(fn (Server $server) => user()?->can('update', $server) ? EditServer::getUrl(['record' => $server]) : null)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('node.name')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.nodes.edit', ['record' => $server->node])),
|
||||
->label(trans('admin/server.node'))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->node) ? EditNode::getUrl(['record' => $server->node]) : null)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('image')
|
||||
->label(trans('admin/server.docker_image')),
|
||||
SelectColumn::make('allocation.id')
|
||||
->label(trans('admin/server.docker_image'))
|
||||
->badge(),
|
||||
TextColumn::make('allocation.address')
|
||||
->label(trans('admin/server.primary_allocation'))
|
||||
->disabled()
|
||||
->options(fn (Server $server) => $server->allocations->take(1)->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||
->placeholder(trans('admin/server.none'))
|
||||
->sortable(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewConsoleAction::make(),
|
||||
EditAction::make()
|
||||
->url(fn (Server $server) => EditServer::getUrl(['record' => $server], panel: 'admin')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ class ListNodes extends ListRecords
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->searchable(false)
|
||||
->checkIfRecordIsSelectableUsing(fn (Node $node) => $node->servers_count <= 0)
|
||||
->columns([
|
||||
TextColumn::make('uuid')
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\Nodes\RelationManagers;
|
||||
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\CreateServer;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Components\Actions\UpdateNodeAllocations;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Node;
|
||||
@@ -11,6 +12,8 @@ use App\Services\Allocations\AssignmentService;
|
||||
use BackedEnum;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
@@ -30,7 +33,7 @@ class AllocationsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'allocations';
|
||||
|
||||
protected static string|BackedEnum|null $icon = TablerIcon::PlugConnected;
|
||||
protected static string|BackedEnum|null $icon = TablerIcon::Network;
|
||||
|
||||
public function setTitle(): string
|
||||
{
|
||||
@@ -46,28 +49,14 @@ class AllocationsRelationManager extends RelationManager
|
||||
->recordTitleAttribute('address')
|
||||
->checkIfRecordIsSelectableUsing(fn (Allocation $allocation) => $allocation->server_id === null)
|
||||
->paginationPageOptions([10, 20, 50, 100, 200, 500])
|
||||
->searchable()
|
||||
->heading('')
|
||||
->heading(null)
|
||||
->selectCurrentPageOnly() //Prevent people from trying to nuke 30,000 ports at once.... -,-
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
TextColumn::make('port')
|
||||
->searchable()
|
||||
->label(trans('admin/node.ports')),
|
||||
TextColumn::make('server.name')
|
||||
->label(trans('admin/node.table.servers'))
|
||||
->icon(TablerIcon::BrandDocker)
|
||||
->visibleFrom('md')
|
||||
->searchable()
|
||||
->url(fn (Allocation $allocation): string => $allocation->server ? route('filament.admin.resources.servers.edit', ['record' => $allocation->server]) : ''),
|
||||
TextInputColumn::make('ip_alias')
|
||||
->searchable()
|
||||
->label(trans('admin/node.table.alias')),
|
||||
TextInputColumn::make('notes')
|
||||
->label(trans('admin/node.table.allocation_notes'))
|
||||
->placeholder(trans('admin/node.table.no_notes')),
|
||||
SelectColumn::make('ip')
|
||||
->options(function (Allocation $allocation) {
|
||||
$ips = Allocation::where('port', $allocation->port)->pluck('ip');
|
||||
@@ -81,15 +70,35 @@ class AllocationsRelationManager extends RelationManager
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->searchable()
|
||||
->sortable()
|
||||
->label(trans('admin/node.table.ip')),
|
||||
TextColumn::make('port')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->label(trans('admin/node.port')),
|
||||
TextInputColumn::make('ip_alias')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->label(trans('admin/node.table.alias'))
|
||||
->placeholder(trans('admin/node.table.no_alias')),
|
||||
TextInputColumn::make('notes')
|
||||
->label(trans('admin/node.table.allocation_notes'))
|
||||
->placeholder(trans('admin/node.table.no_notes')),
|
||||
TextColumn::make('server.name')
|
||||
->label(trans('admin/node.table.servers'))
|
||||
->placeholder(trans('admin/node.table.no_server'))
|
||||
->visibleFrom('md')
|
||||
->searchable()
|
||||
->url(fn (Allocation $allocation) => $allocation->server && user()?->can('update', $allocation->server) ? EditServer::getUrl(['record' => $allocation->server]) : null),
|
||||
])
|
||||
->emptyStateHeading(trans('admin/node.no_allocations'))
|
||||
->recordActions([
|
||||
DeleteAction::make()
|
||||
->visible(fn (Allocation $allocation) => $allocation->server_id === null),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make()
|
||||
->authorize(fn () => user()?->can('update', $this->getOwnerRecord())),
|
||||
Action::make('create new allocation')
|
||||
->label(trans('admin/node.create_allocation'))
|
||||
->tooltip(trans('admin/node.create_allocation'))
|
||||
CreateAction::make()
|
||||
->createAnother(false)
|
||||
->icon(TablerIcon::WorldPlus)
|
||||
->schema(fn () => [
|
||||
Select::make('allocation_ip')
|
||||
@@ -144,6 +153,7 @@ class AllocationsRelationManager extends RelationManager
|
||||
UpdateNodeAllocations::make()
|
||||
->nodeRecord($this->getOwnerRecord())
|
||||
->authorize(fn () => user()?->can('update', $this->getOwnerRecord())),
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,13 @@ namespace App\Filament\Admin\Resources\Nodes\RelationManagers;
|
||||
|
||||
use App\Enums\ServerResourceType;
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\EditEgg;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Admin\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Components\Actions\ViewConsoleAction;
|
||||
use App\Models\Server;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -25,29 +30,27 @@ class ServersRelationManager extends RelationManager
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->searchable(false)
|
||||
->heading('')
|
||||
->heading(null)
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label(trans('admin/node.table.owner'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->user) ? EditUser::getUrl(['record' => $server->user]) : null)
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/node.table.name'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.servers.edit', ['record' => $server]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server) ? EditServer::getUrl(['record' => $server]) : null)
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('egg.name')
|
||||
->label(trans('admin/node.table.egg'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.eggs.edit', ['record' => $server->user]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->egg) ? EditEgg::getUrl(['record' => $server->egg]) : null)
|
||||
->sortable(),
|
||||
SelectColumn::make('allocation.id')
|
||||
->label(trans('admin/node.primary_allocation'))
|
||||
->disabled(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->options(fn (Server $server) => $server->allocations->take(1)->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||
->selectablePlaceholder(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->placeholder(trans('admin/server.none'))
|
||||
->sortable(),
|
||||
->placeholder(trans('admin/server.none')),
|
||||
TextColumn::make('cpu')
|
||||
->label(trans('admin/node.cpu'))
|
||||
->state(fn (Server $server) => $server->formatResource(ServerResourceType::CPULimit)),
|
||||
@@ -61,13 +64,22 @@ class ServersRelationManager extends RelationManager
|
||||
->counts('databases')
|
||||
->label(trans('admin/node.databases'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
TextColumn::make('backups_count')
|
||||
->counts('backups')
|
||||
->label(trans('admin/node.backups'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
])
|
||||
->emptyStateHeading(trans('admin/server.no_servers'));
|
||||
->emptyStateHeading(trans('admin/server.no_servers'))
|
||||
->recordActions([
|
||||
ViewConsoleAction::make(),
|
||||
EditAction::make()
|
||||
->url(fn (Server $server) => EditServer::getUrl(['record' => $server], panel: 'admin')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
namespace App\Filament\Admin\Resources\Servers\Pages;
|
||||
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\EditEgg;
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
|
||||
use App\Filament\Admin\Resources\Servers\ServerResource;
|
||||
use App\Filament\Server\Pages\Console;
|
||||
use App\Filament\Admin\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Components\Actions\ViewConsoleAction;
|
||||
use App\Models\Server;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
@@ -28,12 +30,11 @@ class ListServers extends ListRecords
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->searchable(false)
|
||||
->defaultGroup('node.name')
|
||||
->groups([
|
||||
Group::make('node.name')->getDescriptionFromRecordUsing(fn (Server $server): string => str($server->node->description)->limit(150)),
|
||||
Group::make('user.username')->getDescriptionFromRecordUsing(fn (Server $server): string => $server->user->email),
|
||||
Group::make('egg.name')->getDescriptionFromRecordUsing(fn (Server $server): string => str($server->egg->description)->limit(150)),
|
||||
Group::make('node.name')->getDescriptionFromRecordUsing(fn (Server $server) => str($server->node->description)->limit(150)),
|
||||
Group::make('user.username')->getDescriptionFromRecordUsing(fn (Server $server) => $server->user->email),
|
||||
Group::make('egg.name')->getDescriptionFromRecordUsing(fn (Server $server) => str($server->egg->description)->limit(150)),
|
||||
])
|
||||
->columns([
|
||||
TextColumn::make('condition')
|
||||
@@ -54,19 +55,19 @@ class ListServers extends ListRecords
|
||||
->sortable(),
|
||||
TextColumn::make('node.name')
|
||||
->label(trans('admin/server.node'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.nodes.edit', ['record' => $server->node]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->node) ? EditNode::getUrl(['record' => $server->node]) : null)
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'node.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('egg.name')
|
||||
->label(trans('admin/server.egg'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.eggs.edit', ['record' => $server->egg]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->egg) ? EditEgg::getUrl(['record' => $server->egg]) : null)
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'egg.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('user.username')
|
||||
->label(trans('admin/user.username'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->user) ? EditUser::getUrl(['record' => $server->user]) : null)
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'user.username')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -82,19 +83,23 @@ class ListServers extends ListRecords
|
||||
->label(trans('admin/server.primary_allocation'))
|
||||
->hidden(fn () => user()?->can('update server')) // TODO: update to policy check (fn (Server $server) --> $server is empty)
|
||||
->state(fn (Server $server) => $server->allocation->address ?? trans('admin/server.none')),
|
||||
TextColumn::make('image')->hidden(),
|
||||
TextColumn::make('databases_count')
|
||||
->counts('databases')
|
||||
->label(trans('admin/server.databases'))
|
||||
->numeric()
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
TextColumn::make('backups_count')
|
||||
->counts('backups')
|
||||
->label(trans('admin/server.backups'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('view')
|
||||
->tooltip(trans('admin/server.view'))
|
||||
->icon(TablerIcon::Terminal)
|
||||
->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server))
|
||||
->authorize(fn (Server $server) => user()?->canAccessTenant($server)),
|
||||
ViewConsoleAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Filament\Admin\Resources\Servers\Pages\CreateServer;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Server;
|
||||
use App\Services\Allocations\AssignmentService;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\AssociateAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -19,7 +20,6 @@ use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
@@ -32,21 +32,30 @@ class AllocationsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'allocations';
|
||||
|
||||
protected static string|BackedEnum|null $icon = TablerIcon::Network;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->heading('')
|
||||
->heading(null)
|
||||
->selectCurrentPageOnly()
|
||||
->recordTitleAttribute('address')
|
||||
->recordTitle(fn (Allocation $allocation) => $allocation->address)
|
||||
->inverseRelationship('server')
|
||||
->columns([
|
||||
TextColumn::make('ip')
|
||||
->label(trans('admin/server.ip_address')),
|
||||
->label(trans('admin/server.ip_address'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('port')
|
||||
->label(trans('admin/server.port')),
|
||||
->label(trans('admin/server.port'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextInputColumn::make('ip_alias')
|
||||
->label(trans('admin/server.alias')),
|
||||
->label(trans('admin/server.alias'))
|
||||
->placeholder(trans('admin/server.no_alias'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextInputColumn::make('notes')
|
||||
->label(trans('admin/server.notes'))
|
||||
->placeholder(trans('admin/server.no_notes')),
|
||||
@@ -72,18 +81,26 @@ class AllocationsRelationManager extends RelationManager
|
||||
->emptyStateHeading(trans('admin/server.no_allocations'))
|
||||
->recordActions([
|
||||
Action::make('make-primary')
|
||||
->label(trans('admin/server.make_primary'))
|
||||
->authorize(fn (Allocation $allocation) => user()?->can('update', $allocation))
|
||||
->tooltip(trans('admin/server.make_primary'))
|
||||
->icon(TablerIcon::Star)
|
||||
->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id]) && $this->deselectAllTableRecords())
|
||||
->hidden(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id),
|
||||
Action::make('lock')
|
||||
->label(trans('admin/server.lock'))
|
||||
->authorize(fn (Allocation $allocation) => user()?->can('update', $allocation))
|
||||
->tooltip(trans('admin/server.lock'))
|
||||
->icon(TablerIcon::Lock)
|
||||
->action(fn (Allocation $allocation) => $allocation->update(['is_locked' => true]) && $this->deselectAllTableRecords())
|
||||
->hidden(fn (Allocation $allocation) => $allocation->is_locked),
|
||||
Action::make('unlock')
|
||||
->label(trans('admin/server.unlock'))
|
||||
->authorize(fn (Allocation $allocation) => user()?->can('update', $allocation))
|
||||
->tooltip(trans('admin/server.unlock'))
|
||||
->icon(TablerIcon::LockOpen)
|
||||
->action(fn (Allocation $allocation) => $allocation->update(['is_locked' => false]) && $this->deselectAllTableRecords())
|
||||
->visible(fn (Allocation $allocation) => $allocation->is_locked),
|
||||
DissociateAction::make()
|
||||
->authorize(fn (Allocation $allocation) => user()?->can('update', $allocation))
|
||||
->tooltip(trans('admin/server.remove_allocation'))
|
||||
->after(function (Allocation $allocation) {
|
||||
$allocation->update([
|
||||
'notes' => null,
|
||||
@@ -110,7 +127,7 @@ class AllocationsRelationManager extends RelationManager
|
||||
CreateAction::make()
|
||||
->hiddenLabel()
|
||||
->tooltip(trans('admin/server.create_allocation'))
|
||||
->icon(TablerIcon::Network)
|
||||
->icon(TablerIcon::WorldPlus)
|
||||
->createAnother(false)
|
||||
->schema(fn () => [
|
||||
Select::make('allocation_ip')
|
||||
@@ -163,8 +180,6 @@ class AllocationsRelationManager extends RelationManager
|
||||
])
|
||||
->action(fn (array $data, AssignmentService $service) => $service->handle($this->getOwnerRecord()->node, $data, $this->getOwnerRecord())),
|
||||
AssociateAction::make()
|
||||
->icon(TablerIcon::FilePlus)
|
||||
->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->multiple()
|
||||
->associateAnother(false)
|
||||
->preloadRecordSelect()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Admin\Resources\Servers\RelationManagers;
|
||||
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||
use App\Models\Database;
|
||||
@@ -10,6 +11,7 @@ use App\Models\DatabaseHost;
|
||||
use App\Models\Server;
|
||||
use App\Services\Databases\DatabaseManagementService;
|
||||
use App\Services\Servers\RandomWordService;
|
||||
use BackedEnum;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
@@ -30,6 +32,8 @@ class DatabasesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'databases';
|
||||
|
||||
protected static string|BackedEnum|null $icon = TablerIcon::Database;
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -62,7 +66,7 @@ class DatabasesRelationManager extends RelationManager
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->heading('')
|
||||
->heading(null)
|
||||
->recordTitleAttribute('database')
|
||||
->columns([
|
||||
TextColumn::make('database'),
|
||||
@@ -72,7 +76,7 @@ class DatabasesRelationManager extends RelationManager
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? trans('admin/databasehost.anywhere'). ' ( % )' : $record->remote),
|
||||
TextColumn::make('server.name')
|
||||
->url(fn (Database $database) => route('filament.admin.resources.servers.edit', ['record' => $database->server_id])),
|
||||
->url(fn (Database $database) => user()?->can('update', $database->server) ? EditServer::getUrl(['record' => $database->server]) : null),
|
||||
TextColumn::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
->formatStateUsing(fn ($record) => $record->max_connections ?: trans('admin/databasehost.unlimited')),
|
||||
|
||||
@@ -4,10 +4,15 @@ namespace App\Filament\Admin\Resources\Users\RelationManagers;
|
||||
|
||||
use App\Enums\ServerState;
|
||||
use App\Enums\SuspendAction;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\EditEgg;
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\Components\Actions\ViewConsoleAction;
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use App\Services\Servers\SuspensionService;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -23,7 +28,6 @@ class ServersRelationManager extends RelationManager
|
||||
$user = $this->getOwnerRecord();
|
||||
|
||||
return $table
|
||||
->searchable(false)
|
||||
->heading(trans('admin/user.servers'))
|
||||
->headerActions([
|
||||
Action::make('toggle_suspend')
|
||||
@@ -50,22 +54,20 @@ class ServersRelationManager extends RelationManager
|
||||
}),
|
||||
])
|
||||
->columns([
|
||||
TextColumn::make('uuid')
|
||||
->hidden()
|
||||
->label('UUID')
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/server.name'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.servers.edit', ['record' => $server]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server) ? EditServer::getUrl(['record' => $server]) : null)
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('node.name')
|
||||
->label(trans('admin/server.node'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.nodes.edit', ['record' => $server->node]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->node) ? EditNode::getUrl(['record' => $server->node]) : null)
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('egg.name')
|
||||
->label(trans('admin/server.egg'))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.eggs.edit', ['record' => $server->egg]))
|
||||
->url(fn (Server $server) => user()?->can('update', $server->egg) ? EditEgg::getUrl(['record' => $server->egg]) : null)
|
||||
->searchable()
|
||||
->sortable(),
|
||||
SelectColumn::make('allocation_id')
|
||||
->label(trans('admin/server.primary_allocation'))
|
||||
@@ -83,13 +85,22 @@ class ServersRelationManager extends RelationManager
|
||||
->counts('databases')
|
||||
->label(trans('admin/server.databases'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
TextColumn::make('backups_count')
|
||||
->counts('backups')
|
||||
->label(trans('admin/server.backups'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable()
|
||||
->toggledHiddenByDefault(),
|
||||
])
|
||||
->emptyStateHeading(trans('admin/server.no_servers'));
|
||||
->emptyStateHeading(trans('admin/server.no_servers'))
|
||||
->recordActions([
|
||||
ViewConsoleAction::make(),
|
||||
EditAction::make()
|
||||
->url(fn (Server $server) => EditServer::getUrl(['record' => $server], panel: 'admin')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,12 @@ class UserResource extends Resource
|
||||
->defaultImageUrl(fn (User $user) => Filament::getUserAvatarUrl($user)),
|
||||
TextColumn::make('username')
|
||||
->label(trans('admin/user.username'))
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('email')
|
||||
->label(trans('admin/user.email'))
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
IconColumn::make('mfa_email_enabled')
|
||||
->label(trans('profile.tabs.2fa'))
|
||||
->visibleFrom('lg')
|
||||
|
||||
47
app/Filament/Components/Actions/ViewConsoleAction.php
Normal file
47
app/Filament/Components/Actions/ViewConsoleAction.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Actions;
|
||||
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Filament\Server\Pages\Console;
|
||||
use App\Models\Server;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class ViewConsoleAction extends Action
|
||||
{
|
||||
protected ?Server $server = null;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'view_console';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->tooltip(trans('admin/server.view_console'));
|
||||
|
||||
$this->icon(TablerIcon::Terminal);
|
||||
|
||||
$this->url(fn (?Server $server) => Console::getUrl(panel: 'server', tenant: $this->getServer() ?? $server));
|
||||
|
||||
$this->authorize(fn (?Server $server) => user()?->canAccessTenant($this->getServer() ?? $server));
|
||||
}
|
||||
|
||||
public function server(?Server $server): static
|
||||
{
|
||||
$this->server = $server;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getServer(): ?Server
|
||||
{
|
||||
/** @var ?Server $tenant */
|
||||
$tenant = Filament::getTenant();
|
||||
|
||||
return $this->server ?? $tenant;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,11 @@ use App\Enums\CustomizationKey;
|
||||
use App\Enums\TablerIcon;
|
||||
use App\Livewire\Passkeys;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\AssociateAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DissociateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\View\ActionsIconAlias;
|
||||
use Filament\Actions\ViewAction;
|
||||
@@ -27,6 +30,7 @@ use Filament\Support\Facades\FilamentColor;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Support\Facades\FilamentView;
|
||||
use Filament\Support\View\SupportIconAlias;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\View\TablesIconAlias;
|
||||
use Filament\View\PanelsIconAlias;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
@@ -104,6 +108,8 @@ class FilamentServiceProvider extends ServiceProvider
|
||||
|
||||
Select::configureUsing(fn (Select $select) => $select->native(false));
|
||||
|
||||
SelectColumn::configureUsing(fn (SelectColumn $select) => $select->native(false));
|
||||
|
||||
KeyValue::configureUsing(fn (KeyValue $keyValue) => $keyValue
|
||||
->addAction(function (Action $action) {
|
||||
$action->tooltip(fn () => $action->getLabel());
|
||||
@@ -161,6 +167,18 @@ class FilamentServiceProvider extends ServiceProvider
|
||||
}
|
||||
});
|
||||
|
||||
DeleteBulkAction::configureUsing(function (DeleteBulkAction $action) {
|
||||
$action->icon(TablerIcon::Trash);
|
||||
$action->tooltip(fn () => $action->getLabel());
|
||||
$action->hiddenLabel();
|
||||
$action->iconSize(IconSize::Large);
|
||||
|
||||
if (user()?->getCustomization(CustomizationKey::ButtonStyle)) {
|
||||
$action->iconButton();
|
||||
$action->iconSize(IconSize::ExtraLarge);
|
||||
}
|
||||
});
|
||||
|
||||
CreateAction::configureUsing(function (CreateAction $action) {
|
||||
$action->icon(TablerIcon::Plus);
|
||||
$action->tooltip(fn () => $action->getLabel());
|
||||
@@ -197,6 +215,30 @@ class FilamentServiceProvider extends ServiceProvider
|
||||
}
|
||||
});
|
||||
|
||||
AssociateAction::configureUsing(function (AssociateAction $action) {
|
||||
$action->icon(TablerIcon::Link);
|
||||
$action->tooltip(fn () => $action->getLabel());
|
||||
$action->hiddenLabel();
|
||||
$action->iconSize(IconSize::Large);
|
||||
|
||||
if (user()?->getCustomization(CustomizationKey::ButtonStyle)) {
|
||||
$action->iconButton();
|
||||
$action->iconSize(IconSize::ExtraLarge);
|
||||
}
|
||||
});
|
||||
|
||||
DissociateAction::configureUsing(function (DissociateAction $action) {
|
||||
$action->icon(TablerIcon::Unlink);
|
||||
$action->tooltip(fn () => $action->getLabel());
|
||||
$action->hiddenLabel();
|
||||
$action->iconSize(IconSize::Large);
|
||||
|
||||
if (user()?->getCustomization(CustomizationKey::ButtonStyle)) {
|
||||
$action->iconButton();
|
||||
$action->iconSize(IconSize::ExtraLarge);
|
||||
}
|
||||
});
|
||||
|
||||
Action::configureUsing(function (Action $action) {
|
||||
$action->iconSize(IconSize::Large);
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ return [
|
||||
'owner' => 'Owner',
|
||||
'allocation_notes' => 'Notes',
|
||||
'no_notes' => 'No notes',
|
||||
'no_server' => 'No server',
|
||||
'no_alias' => 'No alias',
|
||||
],
|
||||
'node_info' => 'Node Information',
|
||||
'wings_version' => 'Wings Version',
|
||||
|
||||
@@ -15,6 +15,7 @@ return [
|
||||
'ports' => 'Ports',
|
||||
'alias' => 'Alias',
|
||||
'alias_helper' => 'Optional display name to help you remember what these are.',
|
||||
'no_alias' => 'No Alias',
|
||||
'locked' => 'Locked?',
|
||||
'locked_helper' => 'Users won\'t be able to delete locked allocations',
|
||||
'lock' => 'Lock',
|
||||
@@ -110,7 +111,8 @@ return [
|
||||
'keep_old_variables' => 'Keep old variables if possible?',
|
||||
'create_allocation' => 'Create Allocation',
|
||||
'add_allocation' => 'Add Allocation',
|
||||
'view' => 'View',
|
||||
'remove_allocation' => 'Remove Allocation',
|
||||
'view_console' => 'View Console',
|
||||
'no_log' => 'No Log Available',
|
||||
'select_backups' => 'Select Backups',
|
||||
'warning_backups' => 'Be aware, not transferred backups will be deleted.',
|
||||
|
||||
Reference in New Issue
Block a user