This commit is contained in:
notCharles 2025-04-30 18:46:07 -04:00
parent 1ba9a1dab3
commit 7b12f8cb04
30 changed files with 113 additions and 108 deletions

View File

@ -10,8 +10,8 @@ use App\Repositories\Daemon\DaemonPowerRepository;
use Closure; use Closure;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
@ -37,6 +37,9 @@ class GSLToken extends FeatureProvider
return 'gsltoken'; return 'gsltoken';
} }
/**
* @throws \Exception
*/
public function getAction(): Action public function getAction(): Action
{ {
/** @var Server $server */ /** @var Server $server */
@ -50,9 +53,9 @@ class GSLToken extends FeatureProvider
->modalHeading('Invalid GSL token') ->modalHeading('Invalid GSL token')
->modalDescription('It seems like your Gameserver Login Token (GSL token) is invalid or has expired.') ->modalDescription('It seems like your Gameserver Login Token (GSL token) is invalid or has expired.')
->modalSubmitActionLabel('Update GSL Token') ->modalSubmitActionLabel('Update GSL Token')
->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server)) ->disabledSchema(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
->form([ ->schema([
Placeholder::make('java') TextEntry::make('java')
->label('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it ->label('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it
completely.'), completely.'),
TextInput::make('gsltoken') TextInput::make('gsltoken')

View File

@ -48,7 +48,7 @@ class JavaVersion extends FeatureProvider
->modalDescription('This server is currently running an unsupported version of Java and cannot be started.') ->modalDescription('This server is currently running an unsupported version of Java and cannot be started.')
->modalSubmitActionLabel('Update Docker Image') ->modalSubmitActionLabel('Update Docker Image')
->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server)) ->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
->form([ ->schema([
Placeholder::make('java') Placeholder::make('java')
->label('Please select a supported version from the list below to continue starting the server.'), ->label('Please select a supported version from the list below to continue starting the server.'),
Select::make('image') Select::make('image')

View File

@ -91,7 +91,7 @@ class DatabaseHostResource extends Resource
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema
{ {
return $schema return $schema
->schema([ ->components([
Section::make() Section::make()
->columnSpanFull() ->columnSpanFull()
->columns([ ->columns([

View File

@ -48,7 +48,7 @@ class EditNode extends EditRecord
public function form(Schema $schema): Schema public function form(Schema $schema): Schema
{ {
return $schema->schema([ return $schema->components([
Tabs::make('Tabs') Tabs::make('Tabs')
->columns([ ->columns([
'default' => 2, 'default' => 2,

View File

@ -110,7 +110,7 @@ class RoleResource extends Resource
return $schema return $schema
->columns(1) ->columns(1)
->schema([ ->components([
TextInput::make('name') TextInput::make('name')
->label(trans('admin/role.name')) ->label(trans('admin/role.name'))
->required() ->required()

View File

@ -76,7 +76,7 @@ class EditServer extends EditRecord
public function form(Schema $schema): Schema public function form(Schema $schema): Schema
{ {
return $schema return $schema
->schema([ ->components([
Tabs::make('Tabs') Tabs::make('Tabs')
->persistTabInQueryString() ->persistTabInQueryString()
->columns([ ->columns([

View File

@ -105,7 +105,7 @@ class UserResource extends Resource
{ {
return $schema return $schema
->columns(['default' => 1, 'lg' => 3]) ->columns(['default' => 1, 'lg' => 3])
->schema([ ->components([
TextInput::make('username') TextInput::make('username')
->label(trans('admin/user.username')) ->label(trans('admin/user.username'))
->alphaNum() ->alphaNum()

View File

@ -40,7 +40,7 @@ class Settings extends ServerFormPage
'md' => 4, 'md' => 4,
'lg' => 6, 'lg' => 6,
]) ])
->schema([ ->components([
Section::make('Server Information') Section::make('Server Information')
->columns([ ->columns([
'default' => 1, 'default' => 1,

View File

@ -42,7 +42,7 @@ class Startup extends ServerFormPage
'md' => 4, 'md' => 4,
'lg' => 6, 'lg' => 6,
]) ])
->schema([ ->components([
Hidden::make('previewing') Hidden::make('previewing')
->default(false), ->default(false),
Textarea::make('startup') Textarea::make('startup')

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources\FileResource\Pages; namespace App\Filament\Server\Resources\FileResource\Pages;
//use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
use App\Enums\EditorLanguages; use App\Enums\EditorLanguages;
use App\Facades\Activity; use App\Facades\Activity;
use App\Filament\Server\Resources\FileResource; use App\Filament\Server\Resources\FileResource;
@ -11,27 +12,25 @@ use App\Models\Server;
use App\Repositories\Daemon\DaemonFileRepository; use App\Repositories\Daemon\DaemonFileRepository;
use App\Filament\Components\Tables\Columns\BytesColumn; use App\Filament\Components\Tables\Columns\BytesColumn;
use App\Filament\Components\Tables\Columns\DateTimeColumn; use App\Filament\Components\Tables\Columns\DateTimeColumn;
use Filament\Actions\Action as HeaderAction; use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\BulkAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\FileUpload;
use Filament\Infolists\Components\TextEntry;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Utilities\Get; use Filament\Infolists\Components\TextEntry;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Panel; use Filament\Panel;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\PageRegistration; use Filament\Resources\Pages\PageRegistration;
use Filament\Actions\Action; use Filament\Schemas\Components\Tabs;
use Filament\Actions\ActionGroup; use Filament\Schemas\Components\Tabs\Tab;
use Filament\Actions\BulkAction; use Filament\Schemas\Components\Utilities\Get;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
@ -40,7 +39,6 @@ use Illuminate\Routing\Route;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Route as RouteFacade; use Illuminate\Support\Facades\Route as RouteFacade;
use Livewire\Attributes\Locked; use Livewire\Attributes\Locked;
use Filament\Forms\Components\RichEditor;
class ListFiles extends ListRecords class ListFiles extends ListRecords
{ {
@ -75,6 +73,9 @@ class ListFiles extends ListRecords
return $breadcrumbs; return $breadcrumbs;
} }
/**
* @throws \Exception
*/
public function table(Table $table): Table public function table(Table $table): Table
{ {
/** @var Server $server */ /** @var Server $server */
@ -333,20 +334,20 @@ class ListFiles extends ListRecords
->log(); ->log();
}), }),
]) ])
$location = rtrim($data['location'], '/');
])
->action(function (Collection $files, $data) {
->content(fn (Get $get) => resolve_path('./' . join_paths($this->path, $get('location') ?? ''))),
Placeholder::make('new_location')
->live(),
->required()
->hint('Enter the new directory, relative to the current directory.')
->label('Directory')
->form([
TextInput::make('location')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->groupedBulkActions([ ->groupedBulkActions([
BulkAction::make('move') BulkAction::make('move')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->schema([
TextInput::make('location')
->label('Directory')
->hint('Enter the new directory, relative to the current directory.')
->required()
->live(),
TextEntry::make('new_location')
->state(fn (Get $get) => resolve_path('./' . join_paths($this->path, $get('location') ?? ''))),
])
->action(function (Collection $files, $data) {
$location = rtrim($data['location'], '/');
$files = $files->map(fn ($file) => ['to' => join_paths($location, $file['name']), 'from' => $file['name']])->toArray(); $files = $files->map(fn ($file) => ['to' => join_paths($location, $file['name']), 'from' => $file['name']])->toArray();
$this->getDaemonFileRepository()->renameFiles($this->path, $files); $this->getDaemonFileRepository()->renameFiles($this->path, $files);
@ -356,21 +357,21 @@ class ListFiles extends ListRecords
->property('files', $files) ->property('files', $files)
->log(); ->log();
$files = $files->map(fn ($file) => $file['name'])->toArray();
->action(function ($data, Collection $files) {
])
->suffix('.tar.gz'),
->placeholder(fn () => 'archive-' . str(Carbon::now()->toRfc3339String())->replace(':', '')->before('+0000') . 'Z')
->label('Archive name')
->form([
TextInput::make('name')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_ARCHIVE, $server))
BulkAction::make('archive')
->success()
->title(count($files) . ' Files were moved to ' . resolve_path(join_paths($this->path, $location)))
Notification::make() Notification::make()
}), ->title(count($files) . ' Files were moved to ' . resolve_path(join_paths($this->path, $location)))
->success()
->send(); ->send();
}),
BulkAction::make('archive')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_ARCHIVE, $server))
->schema([
TextInput::make('name')
->label('Archive name')
->placeholder(fn () => 'archive-' . str(Carbon::now()->toRfc3339String())->replace(':', '')->before('+0000') . 'Z')
->suffix('.tar.gz'),
])
->action(function ($data, Collection $files) {
$files = $files->map(fn ($file) => $file['name'])->toArray();
$archive = $this->getDaemonFileRepository()->compressFiles($this->path, $files, $data['name']); $archive = $this->getDaemonFileRepository()->compressFiles($this->path, $files, $data['name']);
@ -413,7 +414,7 @@ class ListFiles extends ListRecords
$server = Filament::getTenant(); $server = Filament::getTenant();
return [ return [
HeaderAction::make('new_file') Action::make('new_file')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server)) ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->label('New File') ->label('New File')
->color('gray') ->color('gray')
@ -439,12 +440,12 @@ class ListFiles extends ListRecords
->selectablePlaceholder(false) ->selectablePlaceholder(false)
->afterStateUpdated(fn ($state) => $this->dispatch('setLanguage', lang: $state)) ->afterStateUpdated(fn ($state) => $this->dispatch('setLanguage', lang: $state))
->default(EditorLanguages::plaintext->value), ->default(EditorLanguages::plaintext->value),
RichEditor::make('editor') // MonacoEditor::make('editor')
->label(''), // ->label('')
// ->view('filament.plugins.monaco-editor') // ->view('filament.plugins.monaco-editor')
// ->language(fn (Get $get) => $get('lang') ?? 'plaintext'), // ->language(fn (Get $get) => $get('lang') ?? 'plaintext'),
]), ]),
HeaderAction::make('new_folder') Action::make('new_folder')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server)) ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->label('New Folder') ->label('New Folder')
->color('gray') ->color('gray')
@ -460,7 +461,7 @@ class ListFiles extends ListRecords
->label('Folder Name') ->label('Folder Name')
->required(), ->required(),
]), ]),
HeaderAction::make('upload') Action::make('upload')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server)) ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->label('Upload') ->label('Upload')
->action(function ($data) { ->action(function ($data) {
@ -509,7 +510,7 @@ class ListFiles extends ListRecords
]), ]),
]), ]),
]), ]),
HeaderAction::make('search') Action::make('search')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ, $server)) ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ, $server))
->label('Global Search') ->label('Global Search')
->modalSubmitActionLabel('Search') ->modalSubmitActionLabel('Search')

53
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "e8fa9e5978e5f6f11a110124a4994051", "content-hash": "f51b79ee140902eca3032c03f5feca08",
"packages": [ "packages": [
{ {
"name": "amphp/amp", "name": "amphp/amp",
@ -936,16 +936,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.343.0", "version": "3.343.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "8750298282f7f6f3fc65e43ae37a64bfc055100a" "reference": "b24383b59b0fc039cecffe0bd7453ae514b22ed5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/8750298282f7f6f3fc65e43ae37a64bfc055100a", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/b24383b59b0fc039cecffe0bd7453ae514b22ed5",
"reference": "8750298282f7f6f3fc65e43ae37a64bfc055100a", "reference": "b24383b59b0fc039cecffe0bd7453ae514b22ed5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1027,9 +1027,9 @@
"support": { "support": {
"forum": "https://github.com/aws/aws-sdk-php/discussions", "forum": "https://github.com/aws/aws-sdk-php/discussions",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.343.0" "source": "https://github.com/aws/aws-sdk-php/tree/3.343.1"
}, },
"time": "2025-04-29T18:04:08+00:00" "time": "2025-04-30T18:21:17+00:00"
}, },
{ {
"name": "blade-ui-kit/blade-heroicons", "name": "blade-ui-kit/blade-heroicons",
@ -3638,16 +3638,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v12.11.0", "version": "v12.11.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "050b2dfeaf6fff9e08e84b355822636492fb45f4" "reference": "bd0d62bd9c5196728e428cd695d89ec8640daac1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/050b2dfeaf6fff9e08e84b355822636492fb45f4", "url": "https://api.github.com/repos/laravel/framework/zipball/bd0d62bd9c5196728e428cd695d89ec8640daac1",
"reference": "050b2dfeaf6fff9e08e84b355822636492fb45f4", "reference": "bd0d62bd9c5196728e428cd695d89ec8640daac1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3849,7 +3849,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2025-04-29T20:18:16+00:00" "time": "2025-04-30T13:48:39+00:00"
}, },
{ {
"name": "laravel/helpers", "name": "laravel/helpers",
@ -7049,16 +7049,16 @@
}, },
{ {
"name": "predis/predis", "name": "predis/predis",
"version": "v2.3.0", "version": "v2.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/predis/predis.git", "url": "https://github.com/predis/predis.git",
"reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9" "reference": "f49e13ee3a2a825631562aa0223ac922ec5d058b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/predis/predis/zipball/bac46bfdb78cd6e9c7926c697012aae740cb9ec9", "url": "https://api.github.com/repos/predis/predis/zipball/f49e13ee3a2a825631562aa0223ac922ec5d058b",
"reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9", "reference": "f49e13ee3a2a825631562aa0223ac922ec5d058b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7067,6 +7067,7 @@
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.3", "friendsofphp/php-cs-fixer": "^3.3",
"phpstan/phpstan": "^1.9", "phpstan/phpstan": "^1.9",
"phpunit/phpcov": "^6.0 || ^8.0",
"phpunit/phpunit": "^8.0 || ^9.4" "phpunit/phpunit": "^8.0 || ^9.4"
}, },
"suggest": { "suggest": {
@ -7089,7 +7090,7 @@
"role": "Maintainer" "role": "Maintainer"
} }
], ],
"description": "A flexible and feature-complete Redis client for PHP.", "description": "A flexible and feature-complete Redis/Valkey client for PHP.",
"homepage": "http://github.com/predis/predis", "homepage": "http://github.com/predis/predis",
"keywords": [ "keywords": [
"nosql", "nosql",
@ -7098,7 +7099,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/predis/predis/issues", "issues": "https://github.com/predis/predis/issues",
"source": "https://github.com/predis/predis/tree/v2.3.0" "source": "https://github.com/predis/predis/tree/v2.4.0"
}, },
"funding": [ "funding": [
{ {
@ -7106,7 +7107,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-11-21T20:00:02+00:00" "time": "2025-04-30T15:16:02+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",
@ -12976,16 +12977,16 @@
}, },
{ {
"name": "hamcrest/hamcrest-php", "name": "hamcrest/hamcrest-php",
"version": "v2.1.0", "version": "v2.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/hamcrest/hamcrest-php.git", "url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "99ec86beb7da3604d57cd3ca3699d2853f53018d" "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/99ec86beb7da3604d57cd3ca3699d2853f53018d", "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487",
"reference": "99ec86beb7da3604d57cd3ca3699d2853f53018d", "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -13021,9 +13022,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/hamcrest/hamcrest-php/issues", "issues": "https://github.com/hamcrest/hamcrest-php/issues",
"source": "https://github.com/hamcrest/hamcrest-php/tree/v2.1.0" "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.1.1"
}, },
"time": "2025-04-29T18:09:42+00:00" "time": "2025-04-30T06:54:44+00:00"
}, },
{ {
"name": "iamcal/sql-parser", "name": "iamcal/sql-parser",
@ -16148,5 +16149,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.2" "php": "8.2"
}, },
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }