mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
Merge branch 'php8' into section
This commit is contained in:
@@ -85,7 +85,7 @@ class ExamResource extends Resource
|
||||
|
||||
Forms\Components\Section::make(__('label.exam.section_time'))->schema([
|
||||
Forms\Components\DateTimePicker::make('begin')->label(__('label.begin')),
|
||||
Forms\Components\DateTimePicker::make('end')->label(__('label.begin')),
|
||||
Forms\Components\DateTimePicker::make('end')->label(__('label.end')),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->integer()
|
||||
->columnSpan(['sm' => 2])
|
||||
@@ -118,7 +118,7 @@ class ExamResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('indexFormatted')->label(__('label.exam.index_formatted'))->html(),
|
||||
Tables\Columns\TextColumn::make('begin')->label(__('label.begin')),
|
||||
Tables\Columns\TextColumn::make('end')->label(__('label.begin')),
|
||||
Tables\Columns\TextColumn::make('end')->label(__('label.end')),
|
||||
Tables\Columns\TextColumn::make('durationText')->label(__('label.duration')),
|
||||
Tables\Columns\TextColumn::make('filterFormatted')->label(__('label.exam.filter_formatted'))->html(),
|
||||
Tables\Columns\BooleanColumn::make('is_discovered')->label(__('label.exam.is_discovered')),
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\Resources\System\PluginResource\Pages;
|
||||
use App\Filament\Resources\System\PluginResource\RelationManagers;
|
||||
use App\Models\Plugin;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class PluginResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Plugin::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-plus-circle';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 99;
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.plugin');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('package_name')->label(__('label.plugin.package_name')),
|
||||
Forms\Components\TextInput::make('remote_url')->label(__('label.plugin.remote_url')),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('package_name')->label(__('plugin.labels.package_name')),
|
||||
Tables\Columns\TextColumn::make('remote_url')->label(__('plugin.labels.remote_url')),
|
||||
Tables\Columns\TextColumn::make('installed_version')->label(__('plugin.labels.installed_version')),
|
||||
Tables\Columns\TextColumn::make('statusText')->label(__('label.status')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions(self::getActions())
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManagePlugins::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
private static function getActions()
|
||||
{
|
||||
$actions = [];
|
||||
$actions[] = Tables\Actions\EditAction::make();
|
||||
$actions[] = self::buildInstallAction();
|
||||
$actions[] = self::buildUpdateAction();
|
||||
$actions[] = Tables\Actions\DeleteAction::make('delete')
|
||||
->hidden(fn ($record) => $record->status == Plugin::STATUS_NOT_INSTALLED)
|
||||
->using(function ($record) {
|
||||
$record->update(['status' => Plugin::STATUS_PRE_DELETE]);
|
||||
});
|
||||
return $actions;
|
||||
}
|
||||
|
||||
private static function buildInstallAction()
|
||||
{
|
||||
return Tables\Actions\Action::make('install')
|
||||
->label(__('plugin.actions.install'))
|
||||
->icon('heroicon-o-arrow-down')
|
||||
->requiresConfirmation()
|
||||
->hidden(fn ($record) => $record->status == Plugin::STATUS_NORMAL)
|
||||
->action(function ($record) {
|
||||
$record->update(['status' => Plugin::STATUS_PRE_INSTALL]);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
private static function buildUpdateAction()
|
||||
{
|
||||
return Tables\Actions\Action::make('update')
|
||||
->label(__('plugin.actions.update'))
|
||||
->icon('heroicon-o-arrow-up')
|
||||
->requiresConfirmation()
|
||||
->hidden(fn ($record) => in_array($record->status, [Plugin::STATUS_NOT_INSTALLED, Plugin::STATUS_PRE_UPDATE]))
|
||||
->action(function ($record) {
|
||||
$record->update(['status' => Plugin::STATUS_PRE_UPDATE]);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\PluginResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\PluginResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManagePlugins extends ManageRecords
|
||||
{
|
||||
protected static string $resource = PluginResource::class;
|
||||
|
||||
protected ?string $maxContentWidth = 'full';
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
use PhpIP\IP;
|
||||
|
||||
class SeedBoxRecordResource extends Resource
|
||||
{
|
||||
@@ -55,12 +56,23 @@ class SeedBoxRecordResource extends Resource
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('typeText')->label(__('label.seed_box_record.type')),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('operator')->label(__('label.seed_box_record.operator'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
|
||||
Tables\Columns\TextColumn::make('ip')
|
||||
->label(__('label.seed_box_record.ip'))
|
||||
->searchable()
|
||||
->searchable(true, function (Builder $query, $search) {
|
||||
try {
|
||||
$ip = IP::create($search);
|
||||
$ipNumeric = $ip->numeric();
|
||||
return $query->orWhere(function (Builder $query) use ($ipNumeric) {
|
||||
return $query->where('ip_begin_numeric', '<=', $ipNumeric)->where('ip_end_numeric', '>=', $ipNumeric);
|
||||
});
|
||||
} catch (\Exception $exception) {
|
||||
do_log("Invalid IP: $search, error: " . $exception->getMessage());
|
||||
}
|
||||
})
|
||||
->formatStateUsing(fn ($record) => $record->ip ?: sprintf('%s ~ %s', $record->ip_begin, $record->ip_end)),
|
||||
Tables\Columns\TextColumn::make('comment')->label(__('label.comment')),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
@@ -73,6 +85,16 @@ class SeedBoxRecordResource extends Resource
|
||||
->label(__('label.seed_box_record.status')),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('uid')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('uid')
|
||||
->label('UID')
|
||||
->placeholder('UID')
|
||||
,
|
||||
])->query(function (Builder $query, array $data) {
|
||||
return $query->when($data['uid'], fn (Builder $query, $uid) => $query->where("uid", $uid));
|
||||
})
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('type')->options(SeedBoxRecord::listTypes('text'))->label(__('label.seed_box_record.type')),
|
||||
Tables\Filters\SelectFilter::make('status')->options(SeedBoxRecord::listStatus('text'))->label(__('label.seed_box_record.status')),
|
||||
])
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Filament\OptionsTrait;
|
||||
use App\Filament\Resources\System\SettingResource;
|
||||
use App\Models\HitAndRun;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Tag;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\ComponentContainer;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
@@ -58,9 +59,6 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
$data = [];
|
||||
foreach ($formData as $prefix => $parts) {
|
||||
foreach ($parts as $name => $value) {
|
||||
if (is_null($value)) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($name, $notAutoloadNames)) {
|
||||
$autoload = 'no';
|
||||
} else {
|
||||
@@ -78,6 +76,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
}
|
||||
}
|
||||
Setting::query()->upsert($data, ['name'], ['value']);
|
||||
do_action("nexus_setting_update");
|
||||
clear_setting_cache();
|
||||
Filament::notify('success', __('filament::resources/pages/edit-record.messages.saved'), true);
|
||||
}
|
||||
@@ -87,13 +86,9 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
$tabs = [];
|
||||
$tabs[] = Forms\Components\Tabs\Tab::make(__('label.setting.hr.tab_header'))
|
||||
->id('hr')
|
||||
->schema([
|
||||
Forms\Components\Radio::make('hr.mode')->options(HitAndRun::listModes(true))->inline(true)->label(__('label.setting.hr.mode')),
|
||||
Forms\Components\TextInput::make('hr.inspect_time')->helperText(__('label.setting.hr.inspect_time_help'))->label(__('label.setting.hr.inspect_time'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.seed_time_minimum')->helperText(__('label.setting.hr.seed_time_minimum_help'))->label(__('label.setting.hr.seed_time_minimum'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
|
||||
])->columns(2);
|
||||
->schema($this->getHitAndRunSchema())
|
||||
->columns(2)
|
||||
;
|
||||
|
||||
$tabs[] = Forms\Components\Tabs\Tab::make(__('label.setting.backup.tab_header'))
|
||||
->id('backup')
|
||||
@@ -117,6 +112,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
Forms\Components\TextInput::make('seed_box.not_seed_box_max_speed')->label(__('label.setting.seed_box.not_seed_box_max_speed'))->helperText(__('label.setting.seed_box.not_seed_box_max_speed_help'))->integer(),
|
||||
Forms\Components\Radio::make('seed_box.no_promotion')->options(self::$yesOrNo)->inline(true)->label(__('label.setting.seed_box.no_promotion'))->helperText(__('label.setting.seed_box.no_promotion_help')),
|
||||
Forms\Components\TextInput::make('seed_box.max_uploaded')->label(__('label.setting.seed_box.max_uploaded'))->helperText(__('label.setting.seed_box.max_uploaded_help'))->integer(),
|
||||
Forms\Components\TextInput::make('seed_box.max_uploaded_duration')->label(__('label.setting.seed_box.max_uploaded_duration'))->helperText(__('label.setting.seed_box.max_uploaded_duration_help'))->integer(),
|
||||
])->columns(2);
|
||||
|
||||
$tabs[] = Forms\Components\Tabs\Tab::make(__('label.setting.system.tab_header'))
|
||||
@@ -137,4 +133,16 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
private function getHitAndRunSchema()
|
||||
{
|
||||
$default = [
|
||||
Forms\Components\Radio::make('hr.mode')->options(HitAndRun::listModes(true))->inline(true)->label(__('label.setting.hr.mode')),
|
||||
Forms\Components\TextInput::make('hr.inspect_time')->helperText(__('label.setting.hr.inspect_time_help'))->label(__('label.setting.hr.inspect_time'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.seed_time_minimum')->helperText(__('label.setting.hr.seed_time_minimum_help'))->label(__('label.setting.hr.seed_time_minimum'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
|
||||
];
|
||||
return apply_filter("hit_and_run_setting_schema", $default);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class UsernameChangeLogResource extends Resource
|
||||
{
|
||||
@@ -50,13 +51,30 @@ class UsernameChangeLogResource extends Resource
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->searchable()->label(__('label.username')),
|
||||
Tables\Columns\TextColumn::make('username_old')->searchable()->label(__('username-change-log.labels.username_old')),
|
||||
Tables\Columns\TextColumn::make('username_new')->searchable()->label(__('username-change-log.labels.username_new')),
|
||||
Tables\Columns\TextColumn::make('operator')->searchable()->label(__('label.operator')),
|
||||
Tables\Columns\TextColumn::make('username_new')
|
||||
->searchable()
|
||||
->label(__('username-change-log.labels.username_new'))
|
||||
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->uid, false, true, true, true)))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('operator')
|
||||
->searchable()
|
||||
->label(__('label.operator'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at'))->formatStateUsing(fn ($state) => format_datetime($state)),
|
||||
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('uid')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('uid')
|
||||
->label('UID')
|
||||
->placeholder('UID')
|
||||
,
|
||||
])->query(function (Builder $query, array $data) {
|
||||
return $query->when($data['uid'], fn (Builder $query, $uid) => $query->where("uid", $uid));
|
||||
})
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('change_type')->options(UsernameChangeLog::listChangeType())->label(__('username-change-log.labels.change_type')),
|
||||
])
|
||||
->actions([
|
||||
|
||||
+2
-3
@@ -2,14 +2,13 @@
|
||||
|
||||
namespace App\Filament\Resources\System\UsernameChangeLogResource\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\System\UsernameChangeLogResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageUsernameChangeLogs extends ManageRecords
|
||||
class ManageUsernameChangeLogs extends PageListSingle
|
||||
{
|
||||
protected ?string $maxContentWidth = 'full';
|
||||
|
||||
protected static string $resource = UsernameChangeLogResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
|
||||
Reference in New Issue
Block a user