Moar Changes!!

This commit is contained in:
notCharles 2025-08-12 13:45:15 -04:00
parent 68178cd654
commit e02c432a21
8 changed files with 152 additions and 11 deletions

View File

@ -94,7 +94,7 @@ class AllocationResource extends Resource
]) ])
->toolbarActions([ ->toolbarActions([
Action::make('addAllocation') Action::make('addAllocation')
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'tabler-network-off' : 'tabler-network') ->icon(fn () => $server->allocations()->count() >= $server->allocation_limit ? 'tabler-network-off' : 'tabler-network')
->authorize(fn () => auth()->user()->can(Permission::ACTION_ALLOCATION_CREATE, $server)) ->authorize(fn () => auth()->user()->can(Permission::ACTION_ALLOCATION_CREATE, $server))
->tooltip(fn () => $server->allocations()->count() >= $server->allocation_limit ? trans('server/network.limit') : trans('server/network.add')) ->tooltip(fn () => $server->allocations()->count() >= $server->allocation_limit ? trans('server/network.limit') : trans('server/network.add'))

View File

@ -255,7 +255,7 @@ class BackupResource extends Resource
->log(); ->log();
}) })
->visible(fn (Backup $backup) => $backup->status !== BackupStatus::InProgress), ->visible(fn (Backup $backup) => $backup->status !== BackupStatus::InProgress),
])->iconSize(IconSize::ExtraLarge), ])->iconSize(IconSize::Large),
]) ])
->toolbarActions([ ->toolbarActions([
CreateAction::make() CreateAction::make()

View File

@ -141,7 +141,7 @@ class DatabaseResource extends Resource
]) ])
->toolbarActions([ ->toolbarActions([
CreateAction::make('new') CreateAction::make('new')
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon(fn () => $server->databases()->count() >= $server->database_limit ? 'tabler-database-x' : 'tabler-database-plus') ->icon(fn () => $server->databases()->count() >= $server->database_limit ? 'tabler-database-x' : 'tabler-database-plus')
->tooltip(fn () => $server->databases()->count() >= $server->database_limit ? trans('server/database.limit') : trans('server/database.create_database')) ->tooltip(fn () => $server->databases()->count() >= $server->database_limit ? trans('server/database.limit') : trans('server/database.create_database'))
->disabled(fn () => $server->databases()->count() >= $server->database_limit) ->disabled(fn () => $server->databases()->count() >= $server->database_limit)

View File

@ -118,7 +118,7 @@ class EditFiles extends Page
->icon('tabler-x') ->icon('tabler-x')
->url(fn () => ListFiles::getUrl(['path' => dirname($this->path)])), ->url(fn () => ListFiles::getUrl(['path' => dirname($this->path)])),
]) ])
->footerActionsAlignment(Alignment::End) //TODO MISSING PADDING ->footerActionsAlignment(Alignment::End)
->schema([ ->schema([
Select::make('lang') Select::make('lang')
->label(trans('server/file.actions.new_file.syntax')) ->label(trans('server/file.actions.new_file.syntax'))

View File

@ -2,6 +2,8 @@
namespace App\Filament\Server\Resources\FileResource\Pages; namespace App\Filament\Server\Resources\FileResource\Pages;
use App\Exceptions\Repository\FileExistsException;
use App\Livewire\AlertBanner;
use Exception; use Exception;
use App\Facades\Activity; use App\Facades\Activity;
use App\Filament\Server\Resources\FileResource; use App\Filament\Server\Resources\FileResource;
@ -22,17 +24,23 @@ use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction; 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\CodeEditor;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry; 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\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\IconSize; use Filament\Support\Enums\IconSize;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Enums\PaginationMode;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\UploadedFile;
use Illuminate\Routing\Route; 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;
@ -78,10 +86,13 @@ class ListFiles extends ListRecords
$files = File::get($server, $this->path); $files = File::get($server, $this->path);
return $table return $table
->paginated([25, 50]) ->paginated()
->paginationMode(PaginationMode::Simple)
->searchable()
->defaultPaginationPageOption(25) ->defaultPaginationPageOption(25)
->query(fn () => $files->orderByDesc('is_directory')) ->query(fn () => $files->orderByDesc('is_directory'))
->defaultSort('name') ->defaultSort('name')
->deferLoading()
->columns([ ->columns([
TextColumn::make('name') TextColumn::make('name')
->label(trans('server/file.name')) ->label(trans('server/file.name'))
@ -410,6 +421,137 @@ class ListFiles extends ListRecords
->send(); ->send();
}), }),
]), ]),
Action::make('new_file')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->tooltip(trans('server/file.actions.new_file.title'))
->hiddenLabel()->icon('tabler-file-plus')->iconButton()->iconSize(IconSize::ExtraLarge)
->color('primary')
->modalSubmitActionLabel(trans('server/file.actions.new_file.create'))
->action(function ($data) {
$path = join_paths($this->path, $data['name']);
try {
$this->getDaemonFileRepository()->putContent($path, $data['editor'] ?? '');
Activity::event('server:file.write')
->property('file', join_paths($path, $data['name']))
->log();
} catch (FileExistsException) {
AlertBanner::make('file_already_exists')
->title('<code>' . $path . '</code> already exists!')
->danger()
->closable()
->send();
$this->redirect(self::getUrl(['path' => dirname($path)]));
}
})
->schema([
TextInput::make('name')
->label(trans('server/file.actions.new_file.file_name'))
->required(),
CodeEditor::make('editor')
->hiddenLabel(),
]),
Action::make('new_folder')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->hiddenLabel()->icon('tabler-folder-plus')->iconButton()->iconSize(IconSize::ExtraLarge)
->tooltip(trans('server/file.actions.new_folder.title'))
->color('primary')
->action(function ($data) {
try {
$this->getDaemonFileRepository()->createDirectory($data['name'], $this->path);
Activity::event('server:file.create-directory')
->property(['directory' => $this->path, 'name' => $data['name']])
->log();
} catch (FileExistsException) {
$path = join_paths($this->path, $data['name']);
AlertBanner::make('folder_already_exists')
->title('<code>' . $path . '</code> already exists!')
->danger()
->closable()
->send();
$this->redirect(self::getUrl(['path' => dirname($path)]));
}
})
->schema([
TextInput::make('name')
->label(trans('server/file.actions.new_folder.folder_name'))
->required(),
]),
Action::make('upload')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_CREATE, $server))
->hiddenLabel()->icon('tabler-upload')->iconButton()->iconSize(IconSize::ExtraLarge)
->tooltip(trans('server/file.actions.upload.title'))
->color('success')
->action(function ($data) {
if (count($data['files']) > 0 && !isset($data['url'])) {
/** @var UploadedFile $file */
foreach ($data['files'] as $file) {
$this->getDaemonFileRepository()->putContent(join_paths($this->path, $file->getClientOriginalName()), $file->getContent());
Activity::event('server:file.uploaded')
->property('directory', $this->path)
->property('file', $file->getClientOriginalName())
->log();
}
} elseif ($data['url'] !== null) {
$this->getDaemonFileRepository()->pull($data['url'], $this->path);
Activity::event('server:file.pull')
->property('url', $data['url'])
->property('directory', $this->path)
->log();
}
return redirect(ListFiles::getUrl(['path' => $this->path]));
})
->schema([
Tabs::make()
->contained(false)
->schema([
Tab::make(trans('server/file.actions.upload.from_files'))
->live()
->schema([
FileUpload::make('files')
->storeFiles(false)
->previewable(false)
->preserveFilenames()
->maxSize((int) round($server->node->upload_size * (config('panel.use_binary_prefix') ? 1.048576 * 1024 : 1000)))
->multiple(),
]),
Tab::make(trans('server/file.actions.upload.url'))
->live()
->disabled(fn (Get $get) => count($get('files')) > 0)
->schema([
TextInput::make('url')
->label(trans('server/file.actions.upload.url'))
->url(),
]),
]),
]),
Action::make('search')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ, $server))
->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->tooltip(trans('server/file.actions.global_search.title'))
->color('primary')
->icon('tabler-world-search')
->modalHeading(trans('server/file.actions.global_search.title'))
->modalSubmitActionLabel(trans('server/file.actions.global_search.search'))
->schema([
TextInput::make('searchTerm')
->label(trans('server/file.actions.global_search.search_term'))
->placeholder(trans('server/file.actions.global_search.search_term_placeholder'))
->required()
->regex('/^[^*]*\*?[^*]*$/')
->minValue(3),
])
->action(fn ($data) => redirect(SearchFiles::getUrl([
'searchTerm' => $data['searchTerm'],
'path' => $this->path,
]))),
]); ]);
} }

View File

@ -49,7 +49,7 @@ class EditSchedule extends EditRecord
{ {
return [ return [
DeleteAction::make() DeleteAction::make()
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon('tabler-trash') ->icon('tabler-trash')
->tooltip(trans('server/schedule.delete')) ->tooltip(trans('server/schedule.delete'))
->after(function ($record) { ->after(function ($record) {
@ -58,15 +58,15 @@ class EditSchedule extends EditRecord
->log(); ->log();
}), }),
ExportScheduleAction::make() ExportScheduleAction::make()
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon('tabler-download') ->icon('tabler-download')
->tooltip(trans('server/schedule.export')), ->tooltip(trans('server/schedule.export')),
$this->getSaveFormAction()->formId('form') $this->getSaveFormAction()->formId('form')
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon('tabler-device-floppy') ->icon('tabler-device-floppy')
->tooltip(trans('server/schedule.save')), ->tooltip(trans('server/schedule.save')),
$this->getCancelFormAction()->formId('form') $this->getCancelFormAction()->formId('form')
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon('tabler-cancel') ->icon('tabler-cancel')
->tooltip(trans('server/schedule.cancel')), ->tooltip(trans('server/schedule.cancel')),
]; ];

View File

@ -43,7 +43,7 @@ class ViewSchedule extends ViewRecord
$this->fillForm(); $this->fillForm();
}), }),
EditAction::make() EditAction::make()
->hiddenLabel()->iconButton()->iconSize(IconSize::Large) ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
->icon('tabler-calendar-code') ->icon('tabler-calendar-code')
->tooltip(trans('server/schedule.edit')), ->tooltip(trans('server/schedule.edit')),
]; ];

View File

@ -119,7 +119,6 @@ class UserResource extends Resource
return $table return $table
->paginated(false) ->paginated(false)
// ->searchable(false) TODO toolbarActions do not render without the search bar :/
->columns([ ->columns([
ImageColumn::make('picture') ImageColumn::make('picture')
->visibleFrom('lg') ->visibleFrom('lg')