improve approval notify + add approval_status filter

This commit is contained in:
xiaomlove
2022-06-27 13:22:16 +08:00
parent 1aca20070d
commit f88f0787f9
21 changed files with 153 additions and 32 deletions
@@ -77,7 +77,7 @@ class ExamResource extends Resource
//
])
->actions([
Tables\Actions\EditAction::make(),
// Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
@@ -95,8 +95,8 @@ class ExamResource extends Resource
{
return [
'index' => Pages\ListExams::route('/'),
'create' => Pages\CreateExam::route('/create'),
'edit' => Pages\EditExam::route('/{record}/edit'),
// 'create' => Pages\CreateExam::route('/create'),
// 'edit' => Pages\EditExam::route('/{record}/edit'),
];
}
}
@@ -14,7 +14,7 @@ class ListExams extends PageList
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
// Actions\CreateAction::make(),
];
}
}
@@ -24,6 +24,8 @@ class SettingResource extends Resource
protected static ?string $navigationGroup = 'System';
protected static bool $shouldRegisterNavigation = false;
protected static function getNavigationLabel(): string
{
return __('admin.sidebar.settings');
+5 -4
View File
@@ -32,14 +32,14 @@ class UserResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema(Forms\Components\Card::make()->schema([
->schema([
Forms\Components\TextInput::make('username')->required(),
Forms\Components\TextInput::make('email')->required(),
Forms\Components\TextInput::make('password')->password()->required(),
Forms\Components\TextInput::make('password_confirmation')->password()->required()->same('password'),
Forms\Components\TextInput::make('password')->password()->required()->visibleOn(Pages\CreateUser::class),
Forms\Components\TextInput::make('password_confirmation')->password()->required()->same('password')->visibleOn(Pages\CreateUser::class),
Forms\Components\TextInput::make('id')->integer(),
Forms\Components\Select::make('class')->options(array_column(User::$classes, 'text')),
]));
]);
}
public static function table(Table $table): Table
@@ -90,6 +90,7 @@ class UserResource extends Resource
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
// 'edit' => Pages\EditUser::route('/{record}/edit'),
'view' => Pages\ViewUser::route('/{record}'),
];
}
@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\User\UserResource\Pages;
use App\Filament\Resources\User\UserResource;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewUser extends ViewRecord
{
protected static string $resource = UserResource::class;
}
+2
View File
@@ -12,6 +12,8 @@ class TorrentTrend extends LineChartWidget
{
protected static ?int $sort = 4;
protected static ?string $pollingInterval = null;
protected function getHeading(): ?string
{
return __('dashboard.torrent_trend.page_title');
+2
View File
@@ -14,6 +14,8 @@ class UserTrend extends LineChartWidget
protected static ?int $sort = 3;
protected static ?string $pollingInterval = null;
protected function getHeading(): ?string
{
return __('dashboard.user_trend.page_title');
+15
View File
@@ -221,6 +221,21 @@ class Torrent extends NexusModel
return $fields;
}
public static function listApprovalStatus($onlyKeyValue = false): array
{
$result = self::$approvalStatus;
$keyValue = [];
foreach ($result as $status => &$info) {
$text = nexus_trans("torrent.approval.status_text.$status");
$info['text'] = $text;
$keyValue[$status] = $text;
}
if ($onlyKeyValue) {
return $keyValue;
}
return $result;
}
public function getHrAttribute(): string
{
$hrMode = Setting::get('hr.mode');
+6
View File
@@ -9,6 +9,7 @@ use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Resources\Json\JsonResource;
use Nexus\Nexus;
use Filament\Facades\Filament;
use Illuminate\Contracts\View\View;
class AppServiceProvider extends ServiceProvider
{
@@ -40,5 +41,10 @@ class AppServiceProvider extends ServiceProvider
]);
});
// Filament::registerRenderHook(
// 'content.end',
// fn (): View => view('filament.footer'),
// );
}
}
+9 -7
View File
@@ -473,7 +473,12 @@ class TorrentRepository extends BaseRepository
{
$user = $this->getUser($user);
$torrent = Torrent::query()->findOrFail($params['torrent_id'], ['id', 'banned', 'approval_status', 'visible', 'owner']);
if ($torrent->approval_status == $params['approval_status']) {
$lastLog = TorrentOperationLog::query()
->where('torrent_id', $params['torrent_id'])
->where('uid', $user->id)
->orderBy('id', 'desc')
->first();
if ($torrent->approval_status == $params['approval_status'] && $lastLog && $lastLog->comment == $params['comment']) {
//No change
return $params;
}
@@ -492,12 +497,9 @@ class TorrentRepository extends BaseRepository
} elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_DENY) {
$torrentUpdate['banned'] = 'yes';
$torrentUpdate['visible'] = 'no';
if ($torrent->approval_status != $params['approval_status']) {
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY;
}
if ($torrent->approval_status == Torrent::APPROVAL_STATUS_ALLOW) {
$notifyUser = true;
}
//Deny, record and notify all the time
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY;
$notifyUser = true;
} elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_NONE) {
$torrentUpdate['banned'] = 'no';
$torrentUpdate['visible'] = 'yes';