Collection of small admin area changes (#604)

* enable tags for nodes

* update icon for cpu column

* disable inline for "force outgoing ip" label

* change label for database hosts resource

* add custom empty state for database hosts & api keys

* add icons to egg tabs

* fix typo

* rename node "Automatic Allocation" to avoid confusion

* run code cleanup

* remove regex for node name

* only check count for application api keys

* replace "New" with "Create"

* change sidebar width to fit "Database Hosts"
This commit is contained in:
Boy132 2024-10-04 01:15:08 +02:00 committed by GitHub
parent 6c205a744d
commit b003404aea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 90 additions and 117 deletions

View File

@ -23,13 +23,6 @@ class ApiKeyResource extends Resource
return false; return false;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -6,6 +6,7 @@ use App\Filament\Resources\ApiKeyResource;
use App\Models\ApiKey; use App\Models\ApiKey;
use Filament\Actions; use Filament\Actions;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction; use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table; use Filament\Tables\Table;
@ -51,13 +52,23 @@ class ListApiKeys extends ListRecords
]) ])
->actions([ ->actions([
DeleteAction::make(), DeleteAction::make(),
])
->emptyStateIcon('tabler-key')
->emptyStateDescription('')
->emptyStateHeading('No API Keys')
->emptyStateActions([
CreateAction::make('create')
->label('Create API Key')
->button(),
]); ]);
} }
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
Actions\CreateAction::make(), Actions\CreateAction::make()
->label('Create API Key')
->hidden(fn () => ApiKey::where('key_type', ApiKey::TYPE_APPLICATION)->count() <= 0),
]; ];
} }
} }

View File

@ -10,7 +10,7 @@ class DatabaseHostResource extends Resource
{ {
protected static ?string $model = DatabaseHost::class; protected static ?string $model = DatabaseHost::class;
protected static ?string $label = 'Databases'; protected static ?string $label = 'Database Host';
protected static ?string $navigationIcon = 'tabler-database'; protected static ?string $navigationIcon = 'tabler-database';
protected static ?string $navigationGroup = 'Advanced'; protected static ?string $navigationGroup = 'Advanced';
@ -20,13 +20,6 @@ class DatabaseHostResource extends Resource
return static::getModel()::count() ?: null; return static::getModel()::count() ?: null;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -4,13 +4,13 @@ namespace App\Filament\Resources\DatabaseHostResource\Pages;
use App\Filament\Resources\DatabaseHostResource; use App\Filament\Resources\DatabaseHostResource;
use App\Services\Databases\Hosts\HostCreationService; use App\Services\Databases\Hosts\HostCreationService;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\CreateRecord;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use PDOException; use PDOException;

View File

@ -7,13 +7,13 @@ use App\Filament\Resources\DatabaseHostResource\RelationManagers\DatabasesRelati
use App\Models\DatabaseHost; use App\Models\DatabaseHost;
use App\Services\Databases\Hosts\HostUpdateService; use App\Services\Databases\Hosts\HostUpdateService;
use Filament\Actions; use Filament\Actions;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\EditRecord;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use PDOException; use PDOException;

View File

@ -3,9 +3,11 @@
namespace App\Filament\Resources\DatabaseHostResource\Pages; namespace App\Filament\Resources\DatabaseHostResource\Pages;
use App\Filament\Resources\DatabaseHostResource; use App\Filament\Resources\DatabaseHostResource;
use App\Models\DatabaseHost;
use Filament\Actions; use Filament\Actions;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\BulkActionGroup; use Filament\Tables\Actions\BulkActionGroup;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteBulkAction; use Filament\Tables\Actions\DeleteBulkAction;
use Filament\Tables\Actions\EditAction; use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
@ -45,13 +47,23 @@ class ListDatabaseHosts extends ListRecords
DeleteBulkAction::make() DeleteBulkAction::make()
->authorize(fn () => auth()->user()->can('delete databasehost')), ->authorize(fn () => auth()->user()->can('delete databasehost')),
]), ]),
])
->emptyStateIcon('tabler-database')
->emptyStateDescription('')
->emptyStateHeading('No Database Hosts')
->emptyStateActions([
CreateAction::make('create')
->label('Create Database Host')
->button(),
]); ]);
} }
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
Actions\CreateAction::make('create')->label('New Database Host'), Actions\CreateAction::make('create')
->label('Create Database Host')
->hidden(fn () => DatabaseHost::count() <= 0),
]; ];
} }
} }

View File

@ -20,13 +20,6 @@ class DatabaseResource extends Resource
return static::getModel()::count() ?: null; return static::getModel()::count() ?: null;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -21,13 +21,6 @@ class EggResource extends Resource
return static::getModel()::count() ?: null; return static::getModel()::count() ?: null;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getGloballySearchableAttributes(): array public static function getGloballySearchableAttributes(): array
{ {
return ['name', 'tags', 'uuid', 'id']; return ['name', 'tags', 'uuid', 'id'];

View File

@ -2,6 +2,7 @@
namespace App\Filament\Resources\EggResource\Pages; namespace App\Filament\Resources\EggResource\Pages;
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
use App\Filament\Resources\EggResource; use App\Filament\Resources\EggResource;
use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Fieldset;
@ -15,10 +16,9 @@ use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Forms\Set; use Filament\Forms\Set;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
use Filament\Forms\Form;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str; use Illuminate\Support\Str;

View File

@ -40,6 +40,7 @@ class EditEgg extends EditRecord
Tabs::make()->tabs([ Tabs::make()->tabs([
Tab::make('Configuration') Tab::make('Configuration')
->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4]) ->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4])
->icon('tabler-egg')
->schema([ ->schema([
TextInput::make('name') TextInput::make('name')
->required() ->required()
@ -80,6 +81,7 @@ class EditEgg extends EditRecord
->helperText('') ->helperText('')
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]), ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]),
Toggle::make('force_outgoing_ip') Toggle::make('force_outgoing_ip')
->inline(false)
->hintIcon('tabler-question-mark') ->hintIcon('tabler-question-mark')
->hintIconTooltip("Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP. ->hintIconTooltip("Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP.
Required for certain games to work properly when the Node has multiple public IP addresses. Required for certain games to work properly when the Node has multiple public IP addresses.
@ -105,9 +107,9 @@ class EditEgg extends EditRecord
->valueLabel('Image URI') ->valueLabel('Image URI')
->helperText('The docker images available to servers using this egg.'), ->helperText('The docker images available to servers using this egg.'),
]), ]),
Tab::make('Process Management') Tab::make('Process Management')
->columns() ->columns()
->icon('tabler-server-cog')
->schema([ ->schema([
Select::make('config_from') Select::make('config_from')
->label('Copy Settings From') ->label('Copy Settings From')
@ -130,6 +132,7 @@ class EditEgg extends EditRecord
]), ]),
Tab::make('Egg Variables') Tab::make('Egg Variables')
->columnSpanFull() ->columnSpanFull()
->icon('tabler-variable')
->schema([ ->schema([
Repeater::make('variables') Repeater::make('variables')
->label('') ->label('')
@ -211,6 +214,7 @@ class EditEgg extends EditRecord
]), ]),
Tab::make('Install Script') Tab::make('Install Script')
->columns(3) ->columns(3)
->icon('tabler-file-download')
->schema([ ->schema([
Select::make('copy_script_from') Select::make('copy_script_from')
->placeholder('None') ->placeholder('None')
@ -230,7 +234,6 @@ class EditEgg extends EditRecord
->language('shell') ->language('shell')
->view('filament.plugins.monaco-editor'), ->view('filament.plugins.monaco-editor'),
]), ]),
])->columnSpanFull()->persistTabInQueryString(), ])->columnSpanFull()->persistTabInQueryString(),
]); ]);
} }

View File

@ -16,7 +16,7 @@ class ServersRelationManager extends RelationManager
{ {
return $table return $table
->recordTitleAttribute('servers') ->recordTitleAttribute('servers')
->emptyStateDescription('No Servers')->emptyStateHeading('No servers are assigned this egg.') ->emptyStateDescription('No Servers')->emptyStateHeading('No servers are assigned to this Egg.')
->searchable(false) ->searchable(false)
->columns([ ->columns([
TextColumn::make('user.username') TextColumn::make('user.username')

View File

@ -18,13 +18,6 @@ class MountResource extends Resource
return static::getModel()::count() ?: null; return static::getModel()::count() ?: null;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -4,14 +4,14 @@ namespace App\Filament\Resources\MountResource\Pages;
use App\Filament\Resources\MountResource; use App\Filament\Resources\MountResource;
use Filament\Actions; use Filament\Actions;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;
use Filament\Resources\Pages\EditRecord;
use Filament\Forms\Components\Group; use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Resources\Pages\EditRecord;
class EditMount extends EditRecord class EditMount extends EditRecord
{ {

View File

@ -3,8 +3,8 @@
namespace App\Filament\Resources\NodeResource\Pages; namespace App\Filament\Resources\NodeResource\Pages;
use App\Filament\Resources\NodeResource; use App\Filament\Resources\NodeResource;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Grid; use Filament\Forms\Components\Grid;
use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@ -153,7 +153,6 @@ class CreateNode extends CreateRecord
'lg' => 2, 'lg' => 2,
]) ])
->required() ->required()
->regex('/[a-zA-Z0-9_\.\- ]+/')
->helperText('This name is for display only and can be changed later.') ->helperText('This name is for display only and can be changed later.')
->maxLength(100), ->maxLength(100),
@ -220,7 +219,7 @@ class CreateNode extends CreateRecord
ToggleButtons::make('public') ToggleButtons::make('public')
->default(true) ->default(true)
->columnSpan(1) ->columnSpan(1)
->label('Automatic Allocation')->inline() ->label('Use Node for deployment?')->inline()
->options([ ->options([
true => 'Yes', true => 'Yes',
false => 'No', false => 'No',
@ -230,11 +229,7 @@ class CreateNode extends CreateRecord
false => 'danger', false => 'danger',
]), ]),
TagsInput::make('tags') TagsInput::make('tags')
->label('Tags') ->placeholder('Add Tags')
->disabled()
->placeholder('Not Implemented')
->hintIcon('tabler-question-mark')
->hintIconTooltip('Not Implemented')
->columnSpan(2), ->columnSpan(2),
TextInput::make('upload_size') TextInput::make('upload_size')
->label('Upload Limit') ->label('Upload Limit')

View File

@ -182,7 +182,6 @@ class EditNode extends EditRecord
'lg' => 2, 'lg' => 2,
]) ])
->required() ->required()
->regex('/[a-zA-Z0-9_\.\- ]+/')
->helperText('This name is for display only and can be changed later.') ->helperText('This name is for display only and can be changed later.')
->maxLength(100), ->maxLength(100),
@ -235,11 +234,7 @@ class EditNode extends EditRecord
->disabled(), ->disabled(),
TagsInput::make('tags') TagsInput::make('tags')
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]) ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2])
->label('Tags') ->placeholder('Add Tags'),
->disabled()
->placeholder('Not Implemented')
->hintIcon('tabler-question-mark')
->hintIconTooltip('Not Implemented'),
TextInput::make('upload_size') TextInput::make('upload_size')
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 1]) ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 1])
->label('Upload Limit') ->label('Upload Limit')
@ -263,7 +258,7 @@ class EditNode extends EditRecord
->helperText('Display alias for the SFTP address. Leave empty to use the Node FQDN.'), ->helperText('Display alias for the SFTP address. Leave empty to use the Node FQDN.'),
ToggleButtons::make('public') ToggleButtons::make('public')
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3]) ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3])
->label('Automatic Allocation')->inline() ->label('Use Node for deployment?')->inline()
->options([ ->options([
true => 'Yes', true => 'Yes',
false => 'No', false => 'No',

View File

@ -58,7 +58,7 @@ class ListNodes extends ListRecords
->sortable(), ->sortable(),
TextColumn::make('cpu') TextColumn::make('cpu')
->visibleFrom('sm') ->visibleFrom('sm')
->icon('tabler-file') ->icon('tabler-cpu')
->numeric() ->numeric()
->suffix(' %') ->suffix(' %')
->sortable(), ->sortable(),

View File

@ -3,10 +3,10 @@
namespace App\Filament\Resources\NodeResource\RelationManagers; namespace App\Filament\Resources\NodeResource\RelationManagers;
use App\Models\Server; use App\Models\Server;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\SelectColumn; use Filament\Tables\Columns\SelectColumn;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table; use Filament\Tables\Table;
use Filament\Resources\RelationManagers\RelationManager;
class NodesRelationManager extends RelationManager class NodesRelationManager extends RelationManager
{ {

View File

@ -19,13 +19,6 @@ class ServerResource extends Resource
return static::getModel()::count() ?: null; return static::getModel()::count() ?: null;
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -11,6 +11,9 @@ use App\Services\Allocations\AssignmentService;
use App\Services\Servers\RandomWordService; use App\Services\Servers\RandomWordService;
use App\Services\Servers\ServerCreationService; use App\Services\Servers\ServerCreationService;
use App\Services\Users\UserCreationService; use App\Services\Users\UserCreationService;
use Closure;
use Exception;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Component; use Filament\Forms\Components\Component;
@ -26,6 +29,7 @@ use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons; use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Components\Wizard\Step; use Filament\Forms\Components\Wizard\Step;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Get; use Filament\Forms\Get;
@ -33,12 +37,10 @@ use Filament\Forms\Set;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Filament\Forms;
use Filament\Forms\Components\Wizard;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Closure; use LogicException;
class CreateServer extends CreateRecord class CreateServer extends CreateRecord
{ {
@ -633,7 +635,7 @@ class CreateServer extends CreateRecord
'unlimited' => -1, 'unlimited' => -1,
'disabled' => 0, 'disabled' => 0,
'limited' => 128, 'limited' => 128,
default => throw new \LogicException('Invalid state'), default => throw new LogicException('Invalid state'),
}; };
$set('swap', $value); $set('swap', $value);
@ -843,7 +845,7 @@ class CreateServer extends CreateRecord
return !$containsRuleIn; return !$containsRuleIn;
} }
throw new \Exception('Component type not supported: ' . $component::class); throw new Exception('Component type not supported: ' . $component::class);
} }
private function getSelectOptionsFromRules(Get $get): array private function getSelectOptionsFromRules(Get $get): array

View File

@ -2,42 +2,43 @@
namespace App\Filament\Resources\ServerResource\Pages; namespace App\Filament\Resources\ServerResource\Pages;
use App\Enums\ContainerStatus;
use App\Enums\ServerState;
use App\Filament\Resources\ServerResource;
use App\Http\Controllers\Admin\ServersController;
use App\Models\Database; use App\Models\Database;
use App\Models\Egg;
use App\Models\Server;
use App\Models\ServerVariable;
use App\Services\Databases\DatabaseManagementService; use App\Services\Databases\DatabaseManagementService;
use App\Services\Databases\DatabasePasswordService; use App\Services\Databases\DatabasePasswordService;
use App\Services\Servers\RandomWordService;
use App\Services\Servers\ServerDeletionService;
use App\Services\Servers\SuspensionService;
use App\Services\Servers\TransferServerService;
use Closure;
use Exception;
use Filament\Actions;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Grid; use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\Tabs\Tab; use Filament\Forms\Components\Tabs\Tab;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons; use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Form;
use Filament\Forms\Get; use Filament\Forms\Get;
use Filament\Forms\Set; use Filament\Forms\Set;
use LogicException;
use App\Filament\Resources\ServerResource;
use App\Http\Controllers\Admin\ServersController;
use App\Services\Servers\RandomWordService;
use App\Services\Servers\SuspensionService;
use App\Services\Servers\TransferServerService;
use Filament\Actions;
use Filament\Forms;
use App\Enums\ContainerStatus;
use App\Enums\ServerState;
use App\Models\Egg;
use App\Models\Server;
use App\Models\ServerVariable;
use App\Services\Servers\ServerDeletionService;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Form;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord; use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Facades\Validator;
use Closure;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Validator;
use LogicException;
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction; use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
class EditServer extends EditRecord class EditServer extends EditRecord
@ -796,7 +797,7 @@ class EditServer extends EditRecord
return $containsRuleIn; return $containsRuleIn;
} }
throw new \Exception('Component type not supported: ' . $component::class); throw new Exception('Component type not supported: ' . $component::class);
} }
private function getSelectOptionsFromRules(ServerVariable $serverVariable): array private function getSelectOptionsFromRules(ServerVariable $serverVariable): array

View File

@ -7,8 +7,8 @@ use App\Models\Server;
use App\Services\Allocations\AssignmentService; use App\Services\Allocations\AssignmentService;
use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Set;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Set;
use Filament\Resources\RelationManagers\RelationManager; use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Actions\Action; use Filament\Tables\Actions\Action;
@ -43,8 +43,6 @@ class AllocationsRelationManager extends RelationManager
->recordTitleAttribute('ip') ->recordTitleAttribute('ip')
->recordTitle(fn (Allocation $allocation) => "$allocation->ip:$allocation->port") ->recordTitle(fn (Allocation $allocation) => "$allocation->ip:$allocation->port")
->checkIfRecordIsSelectableUsing(fn (Allocation $record) => $record->id !== $this->getOwnerRecord()->allocation_id) ->checkIfRecordIsSelectableUsing(fn (Allocation $record) => $record->id !== $this->getOwnerRecord()->allocation_id)
// ->actions
// ->groups
->inverseRelationship('server') ->inverseRelationship('server')
->columns([ ->columns([
TextColumn::make('ip')->label('IP'), TextColumn::make('ip')->label('IP'),
@ -63,9 +61,6 @@ class AllocationsRelationManager extends RelationManager
->default(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id) ->default(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id)
->label('Primary'), ->label('Primary'),
]) ])
->filters([
//
])
->actions([ ->actions([
Action::make('make-primary') Action::make('make-primary')
->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id])) ->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id]))

View File

@ -21,13 +21,14 @@ use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\Tabs; use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Tabs\Tab; use Filament\Forms\Components\Tabs\Tab;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Get; use Filament\Forms\Get;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Illuminate\Validation\Rules\Password; use Illuminate\Validation\Rules\Password;
@ -273,7 +274,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
]; ];
} }
protected function handleRecordUpdate($record, $data): \Illuminate\Database\Eloquent\Model protected function handleRecordUpdate($record, $data): Model
{ {
if ($token = $data['2facode'] ?? null) { if ($token = $data['2facode'] ?? null) {
/** @var ToggleTwoFactorService $service */ /** @var ToggleTwoFactorService $service */

View File

@ -6,11 +6,11 @@ use App\Enums\ServerState;
use App\Models\Server; use App\Models\Server;
use App\Models\User; use App\Models\User;
use App\Services\Servers\SuspensionService; use App\Services\Servers\SuspensionService;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Actions;
use Filament\Tables\Columns\SelectColumn; use Filament\Tables\Columns\SelectColumn;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table; use Filament\Tables\Table;
use Filament\Tables\Actions;
use Filament\Resources\RelationManagers\RelationManager;
class ServersRelationManager extends RelationManager class ServersRelationManager extends RelationManager
{ {

View File

@ -5,12 +5,12 @@ namespace App\Models;
use App\Exceptions\Service\HasActiveServersException; use App\Exceptions\Service\HasActiveServersException;
use App\Repositories\Daemon\DaemonConfigurationRepository; use App\Repositories\Daemon\DaemonConfigurationRepository;
use Exception; use Exception;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
/** /**
* @property int $id * @property int $id
@ -75,11 +75,11 @@ class Node extends Model
'disk_overallocate', 'cpu', 'cpu_overallocate', 'disk_overallocate', 'cpu', 'cpu_overallocate',
'upload_size', 'daemon_base', 'upload_size', 'daemon_base',
'daemon_sftp', 'daemon_sftp_alias', 'daemon_listen', 'daemon_sftp', 'daemon_sftp_alias', 'daemon_listen',
'description', 'maintenance_mode', 'description', 'maintenance_mode', 'tags',
]; ];
public static array $validationRules = [ public static array $validationRules = [
'name' => 'required|regex:/^([\w .-]{1,100})$/', 'name' => 'required|string|min:1|max:100',
'description' => 'string|nullable', 'description' => 'string|nullable',
'public' => 'boolean', 'public' => 'boolean',
'fqdn' => 'required|string', 'fqdn' => 'required|string',

View File

@ -24,7 +24,7 @@ class AdminPanelProvider extends PanelProvider
public function boot() public function boot()
{ {
FilamentAsset::registerCssVariables([ FilamentAsset::registerCssVariables([
'sidebar-width' => '14rem !important', 'sidebar-width' => '16rem !important',
]); ]);
} }