mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
improve filament trans + user profile actions
This commit is contained in:
@@ -44,20 +44,20 @@ class AgentAllowResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('family')->required(),
|
||||
Forms\Components\TextInput::make('start_name')->required(),
|
||||
Forms\Components\TextInput::make('peer_id_start')->required(),
|
||||
Forms\Components\TextInput::make('peer_id_pattern')->required(),
|
||||
Forms\Components\Radio::make('peer_id_matchtype')->options(self::$matchTypes)->required(),
|
||||
Forms\Components\TextInput::make('peer_id_match_num')->integer()->required(),
|
||||
Forms\Components\TextInput::make('agent_start')->required(),
|
||||
Forms\Components\TextInput::make('agent_pattern')->required(),
|
||||
Forms\Components\Radio::make('agent_matchtype')->options(self::$matchTypes)->required(),
|
||||
Forms\Components\TextInput::make('agent_match_num')->required(),
|
||||
Forms\Components\Radio::make('exception')->options(self::$yesOrNo)->required(),
|
||||
Forms\Components\Radio::make('allowhttps')->options(self::$yesOrNo)->required(),
|
||||
Forms\Components\TextInput::make('family')->required()->label(__('label.agent_allow.family')),
|
||||
Forms\Components\TextInput::make('start_name')->required()->label(__('label.agent_allow.start_name')),
|
||||
Forms\Components\TextInput::make('peer_id_start')->required()->label(__('label.agent_allow.peer_id_start')),
|
||||
Forms\Components\TextInput::make('peer_id_pattern')->required()->label(__('label.agent_allow.peer_id_pattern')),
|
||||
Forms\Components\Radio::make('peer_id_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.peer_id_matchtype')),
|
||||
Forms\Components\TextInput::make('peer_id_match_num')->integer()->required()->label(__('label.agent_allow.peer_id_match_num')),
|
||||
Forms\Components\TextInput::make('agent_start')->required()->label(__('label.agent_allow.agent_start')),
|
||||
Forms\Components\TextInput::make('agent_pattern')->required()->label(__('label.agent_allow.agent_pattern')),
|
||||
Forms\Components\Radio::make('agent_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.agent_matchtype')),
|
||||
Forms\Components\TextInput::make('agent_match_num')->required()->label(__('label.agent_allow.agent_match_num')),
|
||||
Forms\Components\Radio::make('exception')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.exception')),
|
||||
Forms\Components\Radio::make('allowhttps')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.allowhttps')),
|
||||
|
||||
Forms\Components\Textarea::make('comment'),
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ class AgentAllowResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('family')->searchable(),
|
||||
Tables\Columns\TextColumn::make('start_name')->searchable(),
|
||||
Tables\Columns\TextColumn::make('peer_id_start'),
|
||||
Tables\Columns\TextColumn::make('agent_start'),
|
||||
Tables\Columns\TextColumn::make('family')->searchable()->label(__('label.agent_allow.family')),
|
||||
Tables\Columns\TextColumn::make('start_name')->searchable()->label(__('label.agent_allow.start_name')),
|
||||
Tables\Columns\TextColumn::make('peer_id_start')->label(__('label.agent_allow.peer_id_start')),
|
||||
Tables\Columns\TextColumn::make('agent_start')->label(__('label.agent_allow.agent_start')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace App\Filament\Resources\System\AgentAllowResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\System\AgentAllowResource;
|
||||
use App\Repositories\AgentAllowRepository;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Forms;
|
||||
|
||||
class ListAgentAllows extends PageList
|
||||
{
|
||||
@@ -15,6 +17,23 @@ class ListAgentAllows extends PageList
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
Actions\Action::make('check')
|
||||
->label(__('admin.resources.agent_allow.check_modal_btn'))
|
||||
->form([
|
||||
Forms\Components\TextInput::make('peer_id')->required(),
|
||||
Forms\Components\TextInput::make('agent')->required(),
|
||||
])
|
||||
->modalHeading(__('admin.resources.agent_allow.check_modal_header'))
|
||||
->action(function ($data) {
|
||||
$agentAllowRep = new AgentAllowRepository();
|
||||
try {
|
||||
$result = $agentAllowRep->checkClient($data['peer_id'], $data['agent']);
|
||||
$this->notify('success', __('admin.resources.agent_allow.check_pass_msg', ['id' => $result->id]));
|
||||
} catch (\Exception $exception) {
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
}
|
||||
})
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ class AgentDenyResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('family_id')->label('Allow family')
|
||||
->relationship('family', 'family')->required(),
|
||||
Forms\Components\TextInput::make('name')->required(),
|
||||
Forms\Components\TextInput::make('peer_id')->required(),
|
||||
Forms\Components\TextInput::make('agent')->required(),
|
||||
Forms\Components\Textarea::make('comment'),
|
||||
->relationship('family', 'family')->required()->label(__('label.agent_allow.family')),
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('peer_id')->required()->label(__('label.agent_deny.peer_id')),
|
||||
Forms\Components\TextInput::make('agent')->required()->label(__('label.agent_deny.agent')),
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ class AgentDenyResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('family.family')->label('Family'),
|
||||
Tables\Columns\TextColumn::make('name')->searchable(),
|
||||
Tables\Columns\TextColumn::make('peer_id')->searchable(),
|
||||
Tables\Columns\TextColumn::make('agent')->searchable(),
|
||||
Tables\Columns\TextColumn::make('family.family')->label(__('label.agent_allow.family')),
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('peer_id')->searchable()->label(__('label.agent_deny.peer_id')),
|
||||
Tables\Columns\TextColumn::make('agent')->searchable()->label(__('label.agent_deny.agent')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\OptionsTrait;
|
||||
use App\Filament\Resources\System\ExamResource\Pages;
|
||||
use App\Filament\Resources\System\ExamResource\RelationManagers;
|
||||
use App\Models\Exam;
|
||||
@@ -16,12 +17,18 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ExamResource extends Resource
|
||||
{
|
||||
use OptionsTrait;
|
||||
|
||||
protected static ?string $model = Exam::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-exclamation';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
const IS_DISCOVERED_OPTIONS = ['0' => 'No', '1' => 'Yes'];
|
||||
|
||||
const STATUS_OPTIONS = ['0' => 'Enabled', '1' => 'Disabled'];
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.exams_list');
|
||||
@@ -38,24 +45,41 @@ class ExamResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Section::make('Base info')->schema([
|
||||
Forms\Components\TextInput::make('name')->required()->columnSpan(['sm' => 2]),
|
||||
Forms\Components\TextInput::make('priority')->columnSpan(['sm' => 2])->helperText('The higher the value, the higher the priority, and when multiple exam match the same user, the one with the highest priority is assigned.'),
|
||||
Forms\Components\Radio::make('status')->options(['0' => 'Enabled', '1' => 'Disabled'])->inline()->columnSpan(['sm' => 2]),
|
||||
Forms\Components\Radio::make('is_discovered')->options(['0' => 'No', '1' => 'Yes'])->label('Discovered')->inline()->columnSpan(['sm' => 2]),
|
||||
Forms\Components\TextInput::make('name')->required()->columnSpan(['sm' => 2])->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('priority')
|
||||
->columnSpan(['sm' => 2])
|
||||
->label(__("label.priority"))
|
||||
->helperText('The higher the value, the higher the priority, and when multiple exam match the same user, the one with the highest priority is assigned.'),
|
||||
Forms\Components\Radio::make('status')
|
||||
->options(self::STATUS_OPTIONS)
|
||||
->inline()
|
||||
->label(__('label.status'))
|
||||
->columnSpan(['sm' => 2]),
|
||||
Forms\Components\Radio::make('is_discovered')
|
||||
->options(self::IS_DISCOVERED_OPTIONS)
|
||||
->label(__('label.exam.is_discovered'))
|
||||
->inline()
|
||||
->columnSpan(['sm' => 2]),
|
||||
])->columns(2),
|
||||
|
||||
Forms\Components\Section::make('Time')->schema([
|
||||
Forms\Components\DateTimePicker::make('begin'),
|
||||
Forms\Components\DateTimePicker::make('end'),
|
||||
Forms\Components\TextInput::make('duration')->integer()->columnSpan(['sm' => 2])
|
||||
Forms\Components\DateTimePicker::make('begin')->label(__('label.begin')),
|
||||
Forms\Components\DateTimePicker::make('end')->label(__('label.begin')),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->integer()
|
||||
->columnSpan(['sm' => 2])
|
||||
->label(__('label.duration'))
|
||||
->helperText('Unit: days. When assign to user, begin and end are used if they are specified. Otherwise begin time is the time at assignment, and the end time is the time at assignment plus the duration.'),
|
||||
])->columns(2),
|
||||
|
||||
Forms\Components\Section::make('Select user')->schema([
|
||||
Forms\Components\CheckboxList::make('filters.classes')->options($userRep->listClass())->columnSpan(['sm' => 2])->columns(4)->label('Classes'),
|
||||
Forms\Components\DateTimePicker::make('filters.register_time_range.0')->label('Register time begin'),
|
||||
Forms\Components\DateTimePicker::make('filters.register_time_range.1')->label('Register time end'),
|
||||
Forms\Components\Toggle::make('filters.donate_status')->label('Donated'),
|
||||
Forms\Components\CheckboxList::make('filters.classes')
|
||||
->options($userRep->listClass())->columnSpan(['sm' => 2])
|
||||
->columns(4)
|
||||
->label(__('label.user.class')),
|
||||
Forms\Components\DateTimePicker::make('filters.register_time_range.0')->label(__("label.exam.register_time_range.begin")),
|
||||
Forms\Components\DateTimePicker::make('filters.register_time_range.1')->label(__("label.exam.register_time_range.end")),
|
||||
Forms\Components\Toggle::make('filters.donate_status')->label(__('label.exam.donated')),
|
||||
])->columns(2),
|
||||
|
||||
|
||||
@@ -68,18 +92,19 @@ class ExamResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
Tables\Columns\TextColumn::make('indexFormatted')->label('Indexes')->html(),
|
||||
Tables\Columns\TextColumn::make('begin'),
|
||||
Tables\Columns\TextColumn::make('end'),
|
||||
Tables\Columns\TextColumn::make('durationText')->label('Duration'),
|
||||
Tables\Columns\TextColumn::make('filterFormatted')->label('Target users')->html(),
|
||||
Tables\Columns\BooleanColumn::make('is_discovered')->label('Discovered'),
|
||||
Tables\Columns\TextColumn::make('priority')->label('Priority'),
|
||||
Tables\Columns\TextColumn::make('statusText')->label('Status'),
|
||||
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('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')),
|
||||
Tables\Columns\TextColumn::make('priority')->label(__('label.priority')),
|
||||
Tables\Columns\TextColumn::make('statusText')->label(__('label.status')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
Tables\Filters\SelectFilter::make('is_discovered')->options(self::IS_DISCOVERED_OPTIONS)->label(__("label.exam.is_discovered")),
|
||||
Tables\Filters\SelectFilter::make('status')->options(self::STATUS_OPTIONS)->label(__("label.status")),
|
||||
])
|
||||
->actions([
|
||||
// Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -35,13 +35,22 @@ class MedalResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required(),
|
||||
Forms\Components\TextInput::make('price')->required()->integer(),
|
||||
Forms\Components\TextInput::make('image_large')->required(),
|
||||
Forms\Components\TextInput::make('image_small')->required(),
|
||||
Forms\Components\Radio::make('get_type')->options(Medal::listGetTypes(true))->inline()->columnSpan(['sm' => 2])->required(),
|
||||
Forms\Components\TextInput::make('duration')->integer()->columnSpan(['sm' => 2])->helperText('Unit: day, if empty, belongs to user forever.'),
|
||||
Forms\Components\Textarea::make('description')->columnSpan(['sm' => 2]),
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('price')->required()->integer()->label(__('label.price')),
|
||||
Forms\Components\TextInput::make('image_large')->required()->label(__('label.medal.image_large')),
|
||||
Forms\Components\TextInput::make('image_small')->required()->label(__('label.medal.image_small')),
|
||||
Forms\Components\Radio::make('get_type')
|
||||
->options(Medal::listGetTypes(true))
|
||||
->inline()
|
||||
->columnSpan(['sm' => 2])
|
||||
->label(__('label.medal.get_type'))
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->integer()
|
||||
->columnSpan(['sm' => 2])
|
||||
->label(__('label.medal.duration'))
|
||||
->helperText(__('label.medal.duration_help')),
|
||||
Forms\Components\Textarea::make('description')->columnSpan(['sm' => 2])->label(__('label.description')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -50,12 +59,12 @@ class MedalResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
Tables\Columns\ImageColumn::make('image_large')->height(120),
|
||||
Tables\Columns\ImageColumn::make('image_small')->height(120),
|
||||
Tables\Columns\TextColumn::make('getTypeText')->label('Get type'),
|
||||
Tables\Columns\TextColumn::make('price'),
|
||||
Tables\Columns\TextColumn::make('duration'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
Tables\Columns\ImageColumn::make('image_large')->height(120)->label(__('label.medal.image_large')),
|
||||
Tables\Columns\ImageColumn::make('image_small')->height(120)->label(__('label.medal.image_small')),
|
||||
Tables\Columns\TextColumn::make('getTypeText')->label('Get type')->label(__('label.medal.get_type')),
|
||||
Tables\Columns\TextColumn::make('price')->label(__('label.price')),
|
||||
Tables\Columns\TextColumn::make('duration')->label(__('label.medal.duration')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user