mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-27 22:47:23 +08:00
migration script
# Conflicts: # app/Filament/Resources/Torrent/AnnounceLogResource.php
This commit is contained in:
@@ -2,6 +2,17 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Actions\ViewAction;
|
||||
use App\Filament\Resources\Torrent\AnnounceLogResource\Pages\ListAnnounceLogs;
|
||||
use App\Filament\Resources\Torrent\AnnounceLogResource\Pages;
|
||||
use App\Filament\Resources\Torrent\AnnounceLogResource\RelationManagers;
|
||||
use App\Models\AnnounceLog;
|
||||
@@ -15,18 +26,15 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Infolists;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Infolists\Components\Tabs;
|
||||
use Filament\Infolists\Components\Fieldset;
|
||||
|
||||
|
||||
class AnnounceLogResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AnnounceLog::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
@@ -48,78 +56,78 @@ class AnnounceLogResource extends Resource
|
||||
return Setting::getIsRecordAnnounceLog() && config('clickhouse.connection.host') != '';
|
||||
}
|
||||
|
||||
public static function infolist(Infolist $infolist): Infolist
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $infolist
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tabs\Tab::make(__('announce-log.tab_primary'))
|
||||
Tab::make(__('announce-log.tab_primary'))
|
||||
->schema([
|
||||
Fieldset::make(__('announce-log.fieldset_basic'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('timestamp')->label(__('announce-log.timestamp')),
|
||||
Infolists\Components\TextEntry::make('user_id')->label(__('announce-log.user_id'))->copyable(),
|
||||
Infolists\Components\TextEntry::make('torrent_id')->label(__('announce-log.torrent_id'))->copyable(),
|
||||
Infolists\Components\TextEntry::make('torrent_size')->label(__('announce-log.torrent_size'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('seeder_count')->label(__('announce-log.seeder_count')),
|
||||
Infolists\Components\TextEntry::make('leecher_count')->label(__('announce-log.leecher_count')),
|
||||
Infolists\Components\TextEntry::make('promotion_state')->label(__('announce-log.promotion_state'))->formatStateUsing(fn($state) => Torrent::$promotionTypes[$state]['text'] ?? ''),
|
||||
Infolists\Components\TextEntry::make('promotion_state_desc')->label(__('announce-log.promotion_state_desc')),
|
||||
Infolists\Components\TextEntry::make('event')->label(__('announce-log.event')),
|
||||
Infolists\Components\TextEntry::make('left')->label(__('announce-log.left'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('announce_time')->label(__('announce-log.announce_time')),
|
||||
Infolists\Components\TextEntry::make('speed')->label(__('announce-log.speed'))->formatStateUsing(fn($state) => mksize($state) . "/s"),
|
||||
TextEntry::make('timestamp')->label(__('announce-log.timestamp')),
|
||||
TextEntry::make('user_id')->label(__('announce-log.user_id'))->copyable(),
|
||||
TextEntry::make('torrent_id')->label(__('announce-log.torrent_id'))->copyable(),
|
||||
TextEntry::make('torrent_size')->label(__('announce-log.torrent_size'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('seeder_count')->label(__('announce-log.seeder_count')),
|
||||
TextEntry::make('leecher_count')->label(__('announce-log.leecher_count')),
|
||||
TextEntry::make('promotion_state')->label(__('announce-log.promotion_state'))->formatStateUsing(fn($state) => Torrent::$promotionTypes[$state]['text'] ?? ''),
|
||||
TextEntry::make('promotion_state_desc')->label(__('announce-log.promotion_state_desc')),
|
||||
TextEntry::make('event')->label(__('announce-log.event')),
|
||||
TextEntry::make('left')->label(__('announce-log.left'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('announce_time')->label(__('announce-log.announce_time')),
|
||||
TextEntry::make('speed')->label(__('announce-log.speed'))->formatStateUsing(fn($state) => mksize($state) . "/s"),
|
||||
])->columns(4),
|
||||
|
||||
Fieldset::make(__('announce-log.fieldset_uploaded'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('uploaded_offset')->label(__('announce-log.uploaded_offset'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('uploaded_total_last')->label(__('announce-log.uploaded_total_last'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('uploaded_total')->label(__('announce-log.uploaded_total'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('uploaded_increment')->label(__('announce-log.uploaded_increment'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('up_factor')->label(__('announce-log.up_factor')),
|
||||
Infolists\Components\TextEntry::make('up_factor_desc')->label(__('announce-log.up_factor_desc')),
|
||||
Infolists\Components\TextEntry::make('uploaded_increment_for_user')->label(__('announce-log.uploaded_increment_for_user'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('uploaded_offset')->label(__('announce-log.uploaded_offset'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('uploaded_total_last')->label(__('announce-log.uploaded_total_last'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('uploaded_total')->label(__('announce-log.uploaded_total'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('uploaded_increment')->label(__('announce-log.uploaded_increment'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('up_factor')->label(__('announce-log.up_factor')),
|
||||
TextEntry::make('up_factor_desc')->label(__('announce-log.up_factor_desc')),
|
||||
TextEntry::make('uploaded_increment_for_user')->label(__('announce-log.uploaded_increment_for_user'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
])->columns(4),
|
||||
|
||||
Fieldset::make(__('announce-log.fieldset_downloaded'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('downloaded_offset')->label(__('announce-log.downloaded_offset'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('downloaded_total_last')->label(__('announce-log.downloaded_total_last'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('downloaded_total')->label(__('announce-log.downloaded_total'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('downloaded_increment')->label(__('announce-log.downloaded_increment'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
Infolists\Components\TextEntry::make('down_factor')->label(__('announce-log.down_factor')),
|
||||
Infolists\Components\TextEntry::make('down_factor_desc')->label(__('announce-log.down_factor_desc')),
|
||||
Infolists\Components\TextEntry::make('downloaded_increment_for_user')->label(__('announce-log.downloaded_increment_for_user'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('downloaded_offset')->label(__('announce-log.downloaded_offset'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('downloaded_total_last')->label(__('announce-log.downloaded_total_last'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('downloaded_total')->label(__('announce-log.downloaded_total'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('downloaded_increment')->label(__('announce-log.downloaded_increment'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
TextEntry::make('down_factor')->label(__('announce-log.down_factor')),
|
||||
TextEntry::make('down_factor_desc')->label(__('announce-log.down_factor_desc')),
|
||||
TextEntry::make('downloaded_increment_for_user')->label(__('announce-log.downloaded_increment_for_user'))->formatStateUsing(fn($state) => mksize($state)),
|
||||
])->columns(4),
|
||||
]),
|
||||
Tabs\Tab::make(__('announce-log.tab_secondary'))
|
||||
Tab::make(__('announce-log.tab_secondary'))
|
||||
->schema([
|
||||
Fieldset::make(__('announce-log.fieldset_client'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('port')->label(__('announce-log.port')),
|
||||
Infolists\Components\TextEntry::make('agent')->label(__('announce-log.agent')),
|
||||
Infolists\Components\TextEntry::make('peer_id')->label(__('announce-log.peer_id'))->copyable(),
|
||||
Infolists\Components\TextEntry::make('client_select')->label(__('announce-log.client_select')),
|
||||
TextEntry::make('port')->label(__('announce-log.port')),
|
||||
TextEntry::make('agent')->label(__('announce-log.agent')),
|
||||
TextEntry::make('peer_id')->label(__('announce-log.peer_id'))->copyable(),
|
||||
TextEntry::make('client_select')->label(__('announce-log.client_select')),
|
||||
])->columns(4),
|
||||
Fieldset::make(__('announce-log.fieldset_location'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('ip')->label(__('announce-log.ip'))->copyable()->limit(25),
|
||||
Infolists\Components\TextEntry::make('ipv4')->label(__('announce-log.ipv4'))->copyable(),
|
||||
Infolists\Components\TextEntry::make('ipv6')->label(__('announce-log.ipv6'))->copyable()->limit(25),
|
||||
Infolists\Components\TextEntry::make('continent')->label(__('announce-log.continent')),
|
||||
Infolists\Components\TextEntry::make('country')->label(__('announce-log.country')),
|
||||
Infolists\Components\TextEntry::make('city')->label(__('announce-log.city')),
|
||||
TextEntry::make('ip')->label(__('announce-log.ip'))->copyable()->limit(25),
|
||||
TextEntry::make('ipv4')->label(__('announce-log.ipv4'))->copyable(),
|
||||
TextEntry::make('ipv6')->label(__('announce-log.ipv6'))->copyable()->limit(25),
|
||||
TextEntry::make('continent')->label(__('announce-log.continent')),
|
||||
TextEntry::make('country')->label(__('announce-log.country')),
|
||||
TextEntry::make('city')->label(__('announce-log.city')),
|
||||
|
||||
])->columns(4),
|
||||
Fieldset::make(__('announce-log.fieldset_request'))
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('scheme')->label(__('announce-log.scheme')),
|
||||
Infolists\Components\TextEntry::make('host')->label(__('announce-log.host')),
|
||||
Infolists\Components\TextEntry::make('path')->label(__('announce-log.path')),
|
||||
Infolists\Components\TextEntry::make('request_id')->label(__('announce-log.request_id'))->copyable()->limit(25),
|
||||
Infolists\Components\TextEntry::make('batch_no')->label(__('announce-log.batch_no'))->copyable(),
|
||||
TextEntry::make('scheme')->label(__('announce-log.scheme')),
|
||||
TextEntry::make('host')->label(__('announce-log.host')),
|
||||
TextEntry::make('path')->label(__('announce-log.path')),
|
||||
TextEntry::make('request_id')->label(__('announce-log.request_id'))->copyable()->limit(25),
|
||||
TextEntry::make('batch_no')->label(__('announce-log.batch_no'))->copyable(),
|
||||
|
||||
])->columns(4),
|
||||
]),
|
||||
@@ -131,93 +139,93 @@ class AnnounceLogResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('timestamp')->label(__('announce-log.timestamp'))->sortable(),
|
||||
Tables\Columns\TextColumn::make('user_id')->label(__('announce-log.user_id')),
|
||||
Tables\Columns\TextColumn::make('torrent_id')->label(__('announce-log.torrent_id')),
|
||||
Tables\Columns\TextColumn::make('peer_id')->label(__('announce-log.peer_id')),
|
||||
Tables\Columns\TextColumn::make('torrent_size')
|
||||
TextColumn::make('timestamp')->label(__('announce-log.timestamp'))->sortable(),
|
||||
TextColumn::make('user_id')->label(__('announce-log.user_id')),
|
||||
TextColumn::make('torrent_id')->label(__('announce-log.torrent_id')),
|
||||
TextColumn::make('peer_id')->label(__('announce-log.peer_id')),
|
||||
TextColumn::make('torrent_size')
|
||||
->label(__('announce-log.torrent_size'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('uploaded_total')
|
||||
TextColumn::make('uploaded_total')
|
||||
->label(__('announce-log.uploaded_total'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('uploaded_increment')
|
||||
TextColumn::make('uploaded_increment')
|
||||
->label(__('announce-log.uploaded_increment'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('downloaded_total')
|
||||
TextColumn::make('downloaded_total')
|
||||
->label(__('announce-log.downloaded_total'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('downloaded_increment')
|
||||
TextColumn::make('downloaded_increment')
|
||||
->label(__('announce-log.downloaded_increment'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('left')
|
||||
TextColumn::make('left')
|
||||
->label(__('announce-log.left'))
|
||||
->formatStateUsing(fn ($state): string => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('announce_time')
|
||||
TextColumn::make('announce_time')
|
||||
->label(__('announce-log.announce_time'))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('event')->label(__('announce-log.event')),
|
||||
Tables\Columns\TextColumn::make('ip')->label('IP'),
|
||||
TextColumn::make('event')->label(__('announce-log.event')),
|
||||
TextColumn::make('ip')->label('IP'),
|
||||
// Tables\Columns\TextColumn::make('agent')->label(__('announce-log.agent')),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('user_id')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('user_id')
|
||||
Filter::make('user_id')
|
||||
->schema([
|
||||
TextInput::make('user_id')
|
||||
->label(__('announce-log.user_id'))
|
||||
->numeric()
|
||||
->minValue(1)
|
||||
,
|
||||
])
|
||||
,
|
||||
Tables\Filters\Filter::make('torrent_id')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('torrent_id')
|
||||
Filter::make('torrent_id')
|
||||
->schema([
|
||||
TextInput::make('torrent_id')
|
||||
->label(__('announce-log.torrent_id'))
|
||||
->numeric()
|
||||
->minValue(1)
|
||||
,
|
||||
])
|
||||
,
|
||||
Tables\Filters\Filter::make('peer_id')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('peer_id')
|
||||
Filter::make('peer_id')
|
||||
->schema([
|
||||
TextInput::make('peer_id')
|
||||
->label(__('announce-log.peer_id'))
|
||||
,
|
||||
])
|
||||
,
|
||||
Tables\Filters\Filter::make('ip')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('ip')
|
||||
Filter::make('ip')
|
||||
->schema([
|
||||
TextInput::make('ip')
|
||||
->label('IP')
|
||||
,
|
||||
])
|
||||
,
|
||||
Tables\Filters\Filter::make('event')
|
||||
->form([
|
||||
Forms\Components\Select::make('event')
|
||||
Filter::make('event')
|
||||
->schema([
|
||||
Select::make('event')
|
||||
->label(__('announce-log.event'))
|
||||
->options(AnnounceLog::listEvents())
|
||||
,
|
||||
])
|
||||
,
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make()->modalWidth('5xl'),
|
||||
->recordActions([
|
||||
ViewAction::make()->modalWidth('5xl'),
|
||||
])
|
||||
->bulkActions([
|
||||
->toolbarActions([
|
||||
// Tables\Actions\BulkActionGroup::make([
|
||||
// Tables\Actions\DeleteBulkAction::make(),
|
||||
// ]),
|
||||
@@ -234,7 +242,7 @@ class AnnounceLogResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAnnounceLogs::route('/'),
|
||||
'index' => ListAnnounceLogs::route('/'),
|
||||
// 'create' => Pages\CreateAnnounceLog::route('/create'),
|
||||
// 'edit' => Pages\EditAnnounceLog::route('/{record}/edit'),
|
||||
];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent\AnnounceLogResource\Pages;
|
||||
|
||||
use Filament\Actions\DeleteAction;
|
||||
use App\Filament\Resources\Torrent\AnnounceLogResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
@@ -13,7 +14,7 @@ class EditAnnounceLog extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,23 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use App\Filament\Resources\Torrent\TagResource\Pages\ListTags;
|
||||
use App\Filament\Resources\Torrent\TagResource\Pages\CreateTag;
|
||||
use App\Filament\Resources\Torrent\TagResource\Pages\EditTag;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use App\Filament\Resources\Torrent\TagResource\Pages;
|
||||
use App\Filament\Resources\Torrent\TagResource\RelationManagers;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\Tag;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -18,9 +29,9 @@ class TagResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Tag::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-tag';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-tag';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
@@ -34,24 +45,24 @@ class TagResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('color')->required()->label(__('label.tag.color')),
|
||||
Forms\Components\TextInput::make('font_color')->required()->label(__('label.tag.font_color')),
|
||||
Forms\Components\TextInput::make('font_size')->required()->label(__('label.tag.font_size')),
|
||||
Forms\Components\TextInput::make('margin')->required()->label(__('label.tag.margin')),
|
||||
Forms\Components\TextInput::make('padding')->required()->label(__('label.tag.padding')),
|
||||
Forms\Components\TextInput::make('border_radius')->required()->label(__('label.tag.border_radius')),
|
||||
Forms\Components\TextInput::make('priority')->integer()->required()->label(__('label.priority'))->default(0),
|
||||
Forms\Components\Select::make('mode')
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')->required()->label(__('label.name')),
|
||||
TextInput::make('color')->required()->label(__('label.tag.color')),
|
||||
TextInput::make('font_color')->required()->label(__('label.tag.font_color')),
|
||||
TextInput::make('font_size')->required()->label(__('label.tag.font_size')),
|
||||
TextInput::make('margin')->required()->label(__('label.tag.margin')),
|
||||
TextInput::make('padding')->required()->label(__('label.tag.padding')),
|
||||
TextInput::make('border_radius')->required()->label(__('label.tag.border_radius')),
|
||||
TextInput::make('priority')->integer()->required()->label(__('label.priority'))->default(0),
|
||||
Select::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.taxonomy.mode'))
|
||||
->helperText(__('label.search_box.taxonomy.mode_help'))
|
||||
,
|
||||
Forms\Components\Textarea::make('description')->label(__('label.description')),
|
||||
Textarea::make('description')->label(__('label.description')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -59,26 +70,26 @@ class TagResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('search_box.name')
|
||||
TextColumn::make('id'),
|
||||
TextColumn::make('search_box.name')
|
||||
->label(__('label.search_box.label'))
|
||||
->formatStateUsing(fn ($record) => $record->search_box->name ?? 'All')
|
||||
,
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('color')->label(__('label.tag.color')),
|
||||
Tables\Columns\TextColumn::make('font_color')->label(__('label.tag.font_color')),
|
||||
Tables\Columns\TextColumn::make('font_size')->label(__('label.tag.font_size')),
|
||||
Tables\Columns\TextColumn::make('margin')->label(__('label.tag.margin')),
|
||||
Tables\Columns\TextColumn::make('padding')->label(__('label.tag.padding')),
|
||||
Tables\Columns\TextColumn::make('border_radius')->label(__('label.tag.border_radius')),
|
||||
Tables\Columns\TextColumn::make('priority')->label(__('label.priority'))->sortable(),
|
||||
Tables\Columns\TextColumn::make('torrents_count')->label(__('label.tag.torrents_count')),
|
||||
Tables\Columns\TextColumn::make('torrents_sum_size')->label(__('label.tag.torrents_sum_size'))->formatStateUsing(fn ($state) => mksize($state)),
|
||||
TextColumn::make('name')->label(__('label.name'))->searchable(),
|
||||
TextColumn::make('color')->label(__('label.tag.color')),
|
||||
TextColumn::make('font_color')->label(__('label.tag.font_color')),
|
||||
TextColumn::make('font_size')->label(__('label.tag.font_size')),
|
||||
TextColumn::make('margin')->label(__('label.tag.margin')),
|
||||
TextColumn::make('padding')->label(__('label.tag.padding')),
|
||||
TextColumn::make('border_radius')->label(__('label.tag.border_radius')),
|
||||
TextColumn::make('priority')->label(__('label.priority'))->sortable(),
|
||||
TextColumn::make('torrents_count')->label(__('label.tag.torrents_count')),
|
||||
TextColumn::make('torrents_sum_size')->label(__('label.tag.torrents_sum_size'))->formatStateUsing(fn ($state) => mksize($state)),
|
||||
// Tables\Columns\TextColumn::make('updated_at')->dateTime()->label(__('label.updated_at')),
|
||||
])
|
||||
->defaultSort('priority', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('mode')
|
||||
SelectFilter::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.taxonomy.mode'))
|
||||
->query(function (Builder $query, array $data) {
|
||||
@@ -90,9 +101,9 @@ class TagResource extends Resource
|
||||
})
|
||||
,
|
||||
])
|
||||
->actions(self::getActions())
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
->recordActions(self::getActions())
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -106,22 +117,22 @@ class TagResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTags::route('/'),
|
||||
'create' => Pages\CreateTag::route('/create'),
|
||||
'edit' => Pages\EditTag::route('/{record}/edit'),
|
||||
'index' => ListTags::route('/'),
|
||||
'create' => CreateTag::route('/create'),
|
||||
'edit' => EditTag::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
private static function getActions(): array
|
||||
{
|
||||
$actions = [];
|
||||
$actions[] = Tables\Actions\Action::make('detach_torrents')
|
||||
$actions[] = Action::make('detach_torrents')
|
||||
->label(__('admin.resources.tag.detach_torrents'))
|
||||
->requiresConfirmation()
|
||||
->action(function ($record) {
|
||||
$record->torrent_tags()->delete();
|
||||
});
|
||||
$actions[] = Tables\Actions\EditAction::make();
|
||||
$actions[] = EditAction::make();
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TagResource\Pages;
|
||||
|
||||
use Filament\Actions\DeleteAction;
|
||||
use App\Filament\Resources\Torrent\TagResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
@@ -13,7 +14,7 @@ class EditTag extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TagResource\Pages;
|
||||
|
||||
use Filament\Actions\CreateAction;
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Torrent\TagResource;
|
||||
use App\Models\Tag;
|
||||
@@ -16,7 +17,7 @@ class ListTags extends PageList
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use App\Filament\Resources\Torrent\TorrentDenyReasonResource\Pages\ManageTorrentDenyReasons;
|
||||
use App\Filament\Resources\Torrent\TorrentDenyReasonResource\Pages;
|
||||
use App\Filament\Resources\Torrent\TorrentDenyReasonResource\RelationManagers;
|
||||
use App\Models\TorrentDenyReason;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -17,9 +23,9 @@ class TorrentDenyReasonResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TorrentDenyReason::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-no-symbol';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-no-symbol';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
@@ -33,12 +39,12 @@ class TorrentDenyReasonResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('priority')->integer()->label(__('label.priority'))->default(0),
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')->required()->label(__('label.name')),
|
||||
TextInput::make('priority')->integer()->label(__('label.priority'))->default(0),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
@@ -46,28 +52,28 @@ class TorrentDenyReasonResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('priority')->label(__('label.priority'))->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at')),
|
||||
TextColumn::make('id'),
|
||||
TextColumn::make('name')->label(__('label.name')),
|
||||
TextColumn::make('priority')->label(__('label.priority'))->sortable(),
|
||||
TextColumn::make('created_at')->label(__('label.created_at')),
|
||||
])
|
||||
->defaultSort('priority', 'desc')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManageTorrentDenyReasons::route('/'),
|
||||
'index' => ManageTorrentDenyReasons::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -2,20 +2,22 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TorrentDenyReasonResource\Pages;
|
||||
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Actions\CreateAction;
|
||||
use App\Filament\Resources\Torrent\TorrentDenyReasonResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageTorrentDenyReasons extends ManageRecords
|
||||
{
|
||||
protected ?string $maxContentWidth = 'full';
|
||||
protected Width|string|null $maxContentWidth = 'full';
|
||||
|
||||
protected static string $resource = TorrentDenyReasonResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use App\Filament\Resources\Torrent\TorrentOperationLogResource\Pages\ManageTorrentOperationLogs;
|
||||
use App\Filament\Resources\Torrent\TorrentOperationLogResource\Pages;
|
||||
use App\Filament\Resources\Torrent\TorrentOperationLogResource\RelationManagers;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\TorrentOperationLog;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -18,9 +23,9 @@ class TorrentOperationLogResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TorrentOperationLog::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
@@ -34,10 +39,10 @@ class TorrentOperationLogResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
@@ -46,58 +51,58 @@ class TorrentOperationLogResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('user.username')
|
||||
TextColumn::make('id')->sortable(),
|
||||
TextColumn::make('user.username')
|
||||
->formatStateUsing(fn ($record) => username_for_admin($record->uid))
|
||||
->label(__('label.user.label'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('torrent.name')
|
||||
TextColumn::make('torrent.name')
|
||||
->formatStateUsing(fn ($record) => torrent_name_for_admin($record->torrent))
|
||||
->label(__('label.torrent.label'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('action_type_text')
|
||||
TextColumn::make('action_type_text')
|
||||
->label(__('torrent-operation-log.fields.action_type'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('comment')
|
||||
TextColumn::make('comment')
|
||||
->label(__('label.comment'))
|
||||
,
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
TextColumn::make('created_at')
|
||||
->formatStateUsing(fn ($state) => format_datetime($state))
|
||||
->label(__('label.created_at'))
|
||||
,
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('uid')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('uid')
|
||||
Filter::make('uid')
|
||||
->schema([
|
||||
TextInput::make('uid')
|
||||
->placeholder('UID')
|
||||
,
|
||||
])->query(function (Builder $query, array $data) {
|
||||
return $query->when($data['uid'], fn (Builder $query, $value) => $query->where("uid", $value));
|
||||
})
|
||||
,
|
||||
Tables\Filters\Filter::make('torrent_id')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('torrent_id')
|
||||
Filter::make('torrent_id')
|
||||
->schema([
|
||||
TextInput::make('torrent_id')
|
||||
->placeholder('Torrent ID')
|
||||
,
|
||||
])->query(function (Builder $query, array $data) {
|
||||
return $query->when($data['torrent_id'], fn (Builder $query, $value) => $query->where("torrent_id", $value));
|
||||
})
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('action_type')
|
||||
SelectFilter::make('action_type')
|
||||
->options(TorrentOperationLog::listStaticProps(TorrentOperationLog::$actionTypes, 'torrent.operation_log.%s.type_text', true))
|
||||
->label(__('torrent-operation-log.fields.action_type'))
|
||||
->multiple()
|
||||
,
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
// Tables\Actions\EditAction::make(),
|
||||
// Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
->toolbarActions([
|
||||
// Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
@@ -105,7 +110,7 @@ class TorrentOperationLogResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManageTorrentOperationLogs::route('/'),
|
||||
'index' => ManageTorrentOperationLogs::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,28 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\BadgeColumn;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\Pages\ListTorrents;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\Pages\CreateTorrent;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\Pages\EditTorrent;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Exception;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use App\Filament\OptionsTrait;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\RelationManagers;
|
||||
@@ -19,7 +41,6 @@ use Elasticsearch\Endpoints\Search;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -39,9 +60,9 @@ class TorrentResource extends Resource
|
||||
|
||||
protected static ?string $model = Torrent::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
@@ -57,10 +78,10 @@ class TorrentResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
@@ -78,45 +99,45 @@ class TorrentResource extends Resource
|
||||
$showApproval = self::shouldShowApproval();
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('basic_category.name')->label(__('label.torrent.category')),
|
||||
Tables\Columns\TextColumn::make('name')->formatStateUsing(fn ($record) => torrent_name_for_admin($record, true))
|
||||
TextColumn::make('id')->sortable(),
|
||||
TextColumn::make('basic_category.name')->label(__('label.torrent.category')),
|
||||
TextColumn::make('name')->formatStateUsing(fn ($record) => torrent_name_for_admin($record, true))
|
||||
->label(__('label.name'))
|
||||
->searchable(query: function (Builder $query, string $search) {
|
||||
return $query->where("name", "like", "%{$search}%")->orWhere("small_descr", "like", "%{$search}%");
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('posStateText')->label(__('label.torrent.pos_state')),
|
||||
Tables\Columns\TextColumn::make('spStateText')->label(__('label.torrent.sp_state')),
|
||||
Tables\Columns\TextColumn::make('pickInfoText')
|
||||
TextColumn::make('posStateText')->label(__('label.torrent.pos_state')),
|
||||
TextColumn::make('spStateText')->label(__('label.torrent.sp_state')),
|
||||
TextColumn::make('pickInfoText')
|
||||
->label(__('label.torrent.picktype'))
|
||||
->formatStateUsing(fn ($record) => $record->pickInfo['text'])
|
||||
,
|
||||
Tables\Columns\IconColumn::make('hr')
|
||||
IconColumn::make('hr')
|
||||
->label(__('label.torrent.hr'))
|
||||
->boolean()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('size')
|
||||
TextColumn::make('size')
|
||||
->label(__('label.torrent.size'))
|
||||
->formatStateUsing(fn ($state) => mksize($state))
|
||||
->sortable()
|
||||
,
|
||||
Tables\Columns\TextColumn::make('seeders')->label(__('label.torrent.seeders'))->sortable(),
|
||||
Tables\Columns\TextColumn::make('leechers')->label(__('label.torrent.leechers'))->sortable(),
|
||||
Tables\Columns\BadgeColumn::make('approval_status')
|
||||
TextColumn::make('seeders')->label(__('label.torrent.seeders'))->sortable(),
|
||||
TextColumn::make('leechers')->label(__('label.torrent.leechers'))->sortable(),
|
||||
BadgeColumn::make('approval_status')
|
||||
->visible($showApproval)
|
||||
->label(__('label.torrent.approval_status'))
|
||||
->colors(array_flip(Torrent::listApprovalStatus(true, 'badge_color')))
|
||||
->formatStateUsing(fn ($record) => $record->approvalStatusText),
|
||||
Tables\Columns\TextColumn::make('added')->label(__('label.added'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('user.username')
|
||||
TextColumn::make('added')->label(__('label.added'))->dateTime(),
|
||||
TextColumn::make('user.username')
|
||||
->label(__('label.torrent.owner'))
|
||||
->formatStateUsing(fn ($record) => username_for_admin($record->owner))
|
||||
,
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters(self::getFilters())
|
||||
->actions(self::getActions())
|
||||
->bulkActions(self::getBulkActions())
|
||||
->recordActions(self::getActions())
|
||||
->toolbarActions(self::getBulkActions())
|
||||
;
|
||||
|
||||
}
|
||||
@@ -136,9 +157,9 @@ class TorrentResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTorrents::route('/'),
|
||||
'create' => Pages\CreateTorrent::route('/create'),
|
||||
'edit' => Pages\EditTorrent::route('/{record}/edit'),
|
||||
'index' => ListTorrents::route('/'),
|
||||
'create' => CreateTorrent::route('/create'),
|
||||
'edit' => EditTorrent::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -147,15 +168,15 @@ class TorrentResource extends Resource
|
||||
$user = Auth::user();
|
||||
$actions = [];
|
||||
if (user_can('torrentsticky')) {
|
||||
$actions[] = Tables\Actions\BulkAction::make('posState')
|
||||
$actions[] = BulkAction::make('posState')
|
||||
->label(__('admin.resources.torrent.bulk_action_pos_state'))
|
||||
->form([
|
||||
Forms\Components\Select::make('pos_state')
|
||||
Select::make('pos_state')
|
||||
->label(__('label.torrent.pos_state'))
|
||||
->options(Torrent::listPosStates(true))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\DateTimePicker::make('pos_state_until')
|
||||
DateTimePicker::make('pos_state_until')
|
||||
->label(__('label.deadline'))
|
||||
,
|
||||
])
|
||||
@@ -165,7 +186,7 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->setPosState($idArr, $data['pos_state'], $data['pos_state_until']);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
@@ -174,20 +195,20 @@ class TorrentResource extends Resource
|
||||
}
|
||||
|
||||
if (user_can('torrentonpromotion')) {
|
||||
$actions[] = Tables\Actions\BulkAction::make('sp_state')
|
||||
$actions[] = BulkAction::make('sp_state')
|
||||
->label(__('admin.resources.torrent.bulk_action_sp_state'))
|
||||
->form([
|
||||
Forms\Components\Select::make('sp_state')
|
||||
Select::make('sp_state')
|
||||
->label(__('label.torrent.sp_state'))
|
||||
->options(Torrent::listPromotionTypes(true))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\Select::make('promotion_time_type')
|
||||
Select::make('promotion_time_type')
|
||||
->label(__('label.torrent.promotion_time_type'))
|
||||
->options(Torrent::listPromotionTimeTypes(true))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\DateTimePicker::make('promotion_until')
|
||||
DateTimePicker::make('promotion_until')
|
||||
->label(__('label.deadline'))
|
||||
,
|
||||
])
|
||||
@@ -197,7 +218,7 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->setSpState($idArr, $data['sp_state'], $data['promotion_time_type'], $data['promotion_until']);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', $exception->getMessage());
|
||||
}
|
||||
@@ -206,10 +227,10 @@ class TorrentResource extends Resource
|
||||
}
|
||||
|
||||
if (user_can('torrentmanage') && ($user->picker == 'yes' || $user->class >= User::CLASS_SYSOP)) {
|
||||
$actions[] = Tables\Actions\BulkAction::make('recommend')
|
||||
$actions[] = BulkAction::make('recommend')
|
||||
->label(__('admin.resources.torrent.bulk_action_recommend'))
|
||||
->form([
|
||||
Forms\Components\Radio::make('picktype')
|
||||
Radio::make('picktype')
|
||||
->label(__('admin.resources.torrent.bulk_action_recommend'))
|
||||
->inline()
|
||||
->options(Torrent::listPickInfo(true))
|
||||
@@ -225,7 +246,7 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->setPickType($idArr, $data['picktype']);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
@@ -234,7 +255,7 @@ class TorrentResource extends Resource
|
||||
}
|
||||
|
||||
if (user_can('torrentmanage')) {
|
||||
$actions[] = Tables\Actions\BulkAction::make('remove_tag')
|
||||
$actions[] = BulkAction::make('remove_tag')
|
||||
->label(__('admin.resources.torrent.bulk_action_remove_tag'))
|
||||
->requiresConfirmation()
|
||||
->icon('heroicon-o-minus-circle')
|
||||
@@ -243,18 +264,18 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->syncTags($idArr);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
})
|
||||
->deselectRecordsAfterCompletion();
|
||||
|
||||
$actions[] = Tables\Actions\BulkAction::make('attach_tag')
|
||||
$actions[] = BulkAction::make('attach_tag')
|
||||
->label(__('admin.resources.torrent.bulk_action_attach_tag'))
|
||||
->form([
|
||||
Forms\Components\Checkbox::make('remove')->label(__('admin.resources.torrent.bulk_action_attach_tag_remove_old')),
|
||||
Forms\Components\CheckboxList::make('tags')
|
||||
Checkbox::make('remove')->label(__('admin.resources.torrent.bulk_action_attach_tag_remove_old')),
|
||||
CheckboxList::make('tags')
|
||||
->label(__('label.tag.label'))
|
||||
->columns(4)
|
||||
->options(TagRepository::createBasicQuery()->pluck('name', 'id')->toArray())
|
||||
@@ -270,17 +291,17 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->syncTags($idArr, $data['tags'], $data['remove'] ?? false);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
})
|
||||
->deselectRecordsAfterCompletion();
|
||||
|
||||
$actions[] = Tables\Actions\BulkAction::make('hr')
|
||||
$actions[] = BulkAction::make('hr')
|
||||
->label(__('admin.resources.torrent.bulk_action_hr'))
|
||||
->form([
|
||||
Forms\Components\Radio::make('hr')
|
||||
Radio::make('hr')
|
||||
->label(__('admin.resources.torrent.bulk_action_hr'))
|
||||
->inline()
|
||||
->options(self::getYesNoOptions())
|
||||
@@ -296,7 +317,7 @@ class TorrentResource extends Resource
|
||||
try {
|
||||
$torrentRep = new TorrentRepository();
|
||||
$torrentRep->setHr($idArr, $data['hr']);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
}
|
||||
@@ -306,7 +327,7 @@ class TorrentResource extends Resource
|
||||
// $actions[] = self::getBulkActionChangeCategory();
|
||||
|
||||
if (user_can('torrent-delete')) {
|
||||
$actions[] = Tables\Actions\DeleteBulkAction::make('bulk-delete')->using(function (Collection $records) {
|
||||
$actions[] = DeleteBulkAction::make('bulk-delete')->using(function (Collection $records) {
|
||||
deletetorrent($records->pluck('id')->toArray());
|
||||
});
|
||||
}
|
||||
@@ -317,43 +338,43 @@ class TorrentResource extends Resource
|
||||
{
|
||||
$actions = [];
|
||||
if (self::shouldShowApproval() && user_can('torrent-approval')) {
|
||||
$actions[] = Tables\Actions\Action::make('approval')
|
||||
$actions[] = \Filament\Actions\Action::make('approval')
|
||||
->label(__('admin.resources.torrent.action_approval'))
|
||||
->form([
|
||||
Forms\Components\Radio::make('approval_status')
|
||||
->schema([
|
||||
Radio::make('approval_status')
|
||||
->label(__('label.torrent.approval_status'))
|
||||
->inline()
|
||||
->required()
|
||||
->options(Torrent::listApprovalStatus(true))
|
||||
,
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
Textarea::make('comment')->label(__('label.comment')),
|
||||
])
|
||||
->action(function (Torrent $record, array $data) {
|
||||
$torrentRep = new TorrentRepository();
|
||||
try {
|
||||
$data['torrent_id'] = $record->id;
|
||||
$torrentRep->approval(Auth::user(), $data);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage(), 'error');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if (user_can('torrent-delete')) {
|
||||
$actions[] = Tables\Actions\DeleteAction::make('delete')->using(function ($record) {
|
||||
$actions[] = DeleteAction::make('delete')->using(function ($record) {
|
||||
deletetorrent($record->id);
|
||||
});
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
private static function getBulkActionChangeCategory(): Tables\Actions\BulkAction
|
||||
private static function getBulkActionChangeCategory(): BulkAction
|
||||
{
|
||||
$searchBoxRep = new SearchBoxRepository();
|
||||
return Tables\Actions\BulkAction::make('changeCategory')
|
||||
return BulkAction::make('changeCategory')
|
||||
->label(__('admin.resources.torrent.bulk_action_change_category'))
|
||||
->form([
|
||||
Forms\Components\Select::make('section_id')
|
||||
Select::make('section_id')
|
||||
->label(__('searchbox.section'))
|
||||
->helperText(new HtmlString(__('admin.resources.torrent.bulk_action_change_category_section_help')))
|
||||
->options(function() {
|
||||
@@ -369,12 +390,12 @@ class TorrentResource extends Resource
|
||||
->required()
|
||||
,
|
||||
$searchBoxRep->buildSearchBoxFormSchema(SearchBox::getBrowseSearchBox(), 'section_info')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
->hidden(function (Get $get) {
|
||||
return $get('section_id') != SearchBox::getBrowseMode();
|
||||
})
|
||||
,
|
||||
$searchBoxRep->buildSearchBoxFormSchema(SearchBox::getSpecialSearchBox(), 'section_info')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
->hidden(function (Get $get) {
|
||||
return $get('section_id') != SearchBox::getSpecialMode();
|
||||
})
|
||||
,
|
||||
@@ -385,7 +406,7 @@ class TorrentResource extends Resource
|
||||
$newSectionId = $data['section_id'];
|
||||
try {
|
||||
$torrentRep->changeCategory($records, $newSectionId, $data['section_info']['section'][$newSectionId]);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
do_log($exception->getMessage(), 'error');
|
||||
}
|
||||
});
|
||||
@@ -400,9 +421,9 @@ class TorrentResource extends Resource
|
||||
private static function getFilters()
|
||||
{
|
||||
$filters = [
|
||||
Tables\Filters\Filter::make('owner')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('owner')
|
||||
Filter::make('owner')
|
||||
->schema([
|
||||
TextInput::make('owner')
|
||||
->label(__('label.torrent.owner'))
|
||||
->placeholder('UID')
|
||||
,
|
||||
@@ -411,60 +432,60 @@ class TorrentResource extends Resource
|
||||
})
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('visible')
|
||||
SelectFilter::make('visible')
|
||||
->options(self::$yesOrNo)
|
||||
->label(__('label.torrent.visible'))
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('hr')
|
||||
SelectFilter::make('hr')
|
||||
->options(self::getYesNoOptions())
|
||||
->label(__('label.torrent.hr'))
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('pos_state')
|
||||
SelectFilter::make('pos_state')
|
||||
->options(Torrent::listPosStates(true))
|
||||
->label(__('label.torrent.pos_state'))
|
||||
->multiple()
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('sp_state')
|
||||
SelectFilter::make('sp_state')
|
||||
->options(Torrent::listPromotionTypes(true))
|
||||
->label(__('label.torrent.sp_state'))
|
||||
->multiple()
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('picktype')
|
||||
SelectFilter::make('picktype')
|
||||
->options(Torrent::listPickInfo(true))
|
||||
->label(__('label.torrent.picktype'))
|
||||
->multiple()
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('approval_status')
|
||||
SelectFilter::make('approval_status')
|
||||
->options(Torrent::listApprovalStatus(true))
|
||||
->label(__('label.torrent.approval_status'))
|
||||
->multiple()
|
||||
,
|
||||
|
||||
Tables\Filters\SelectFilter::make('tags')
|
||||
SelectFilter::make('tags')
|
||||
->relationship('tags', 'name')
|
||||
->label(__('label.tag.label'))
|
||||
->multiple()
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('category')
|
||||
SelectFilter::make('category')
|
||||
->options(Category::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.torrent.category'))
|
||||
->multiple()
|
||||
,
|
||||
];
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $tableModel) {
|
||||
$filters[] = Tables\Filters\SelectFilter::make($torrentField)
|
||||
$filters[] = SelectFilter::make($torrentField)
|
||||
->options(NexusDB::table($tableModel['table'])->orderBy('sort_index')->orderBy('id')->pluck('name', 'id'))
|
||||
->multiple()
|
||||
;
|
||||
}
|
||||
|
||||
$filters[] = Tables\Filters\Filter::make('added_begin')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('added_begin')
|
||||
$filters[] = Filter::make('added_begin')
|
||||
->schema([
|
||||
DatePicker::make('added_begin')
|
||||
->maxDate(now())
|
||||
->label(__('label.torrent.added_begin'))
|
||||
,
|
||||
@@ -472,9 +493,9 @@ class TorrentResource extends Resource
|
||||
return $query->when($data['added_begin'], fn (Builder $query, $value) => $query->where("added", '>=', $value));
|
||||
})
|
||||
;
|
||||
$filters[] = Tables\Filters\Filter::make('added_end')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('added_end')
|
||||
$filters[] = Filter::make('added_end')
|
||||
->schema([
|
||||
DatePicker::make('added_end')
|
||||
->maxDate(now())
|
||||
->label(__('label.torrent.added_end'))
|
||||
,
|
||||
@@ -482,9 +503,9 @@ class TorrentResource extends Resource
|
||||
return $query->when($data['added_end'], fn (Builder $query, $value) => $query->where("added", '<=', $value));
|
||||
})
|
||||
;
|
||||
$filters[] = Tables\Filters\Filter::make('size_begin')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('size_begin')
|
||||
$filters[] = Filter::make('size_begin')
|
||||
->schema([
|
||||
TextInput::make('size_begin')
|
||||
->numeric()
|
||||
->placeholder('GB')
|
||||
->label(__('label.torrent.size_begin'))
|
||||
@@ -493,9 +514,9 @@ class TorrentResource extends Resource
|
||||
return $query->when($data['size_begin'], fn (Builder $query, $value) => $query->where("size", '>=', $value * 1024 * 1024 * 1024));
|
||||
})
|
||||
;
|
||||
$filters[] = Tables\Filters\Filter::make('size_end')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('size_end')
|
||||
$filters[] = Filter::make('size_end')
|
||||
->schema([
|
||||
TextInput::make('size_end')
|
||||
->numeric()
|
||||
->placeholder('GB')
|
||||
->label(__('label.torrent.size_end'))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
|
||||
use Filament\Actions\DeleteAction;
|
||||
use App\Filament\Resources\Torrent\TorrentResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
@@ -13,7 +14,7 @@ class EditTorrent extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user