improve searchbox extra

This commit is contained in:
xiaomlove
2022-11-05 01:08:04 +08:00
parent 7b65d84752
commit 8dd2880e76
16 changed files with 96 additions and 71 deletions
+10 -2
View File
@@ -33,6 +33,7 @@ use App\Repositories\ToolRepository;
use App\Repositories\TorrentRepository; use App\Repositories\TorrentRepository;
use App\Repositories\UserRepository; use App\Repositories\UserRepository;
use Carbon\Carbon; use Carbon\Carbon;
use Filament\Notifications\Notification;
use GeoIp2\Database\Reader; use GeoIp2\Database\Reader;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Encryption\Encrypter; use Illuminate\Encryption\Encrypter;
@@ -90,8 +91,15 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
$columnInfo = NexusDB::getMysqlColumnInfo('searchbox', 'section_name'); // Notification::make()
dd($columnInfo); // ->success()
// ->title('Test Test')
// ->send()
// ;
$key = 'sbsb';
$r = session()->push($key, [1,2,3]);
$r = session()->get($key);
dd($r);
} }
@@ -40,7 +40,7 @@ class CategoryResource extends Resource
return $form return $form
->schema([ ->schema([
Forms\Components\Select::make('mode') Forms\Components\Select::make('mode')
->options(SearchBox::query()->pluck('name', 'id')->toArray()) ->options(SearchBox::listModeOptions())
->label(__('label.search_box.label')) ->label(__('label.search_box.label'))
->required() ->required()
, ,
@@ -84,6 +84,7 @@ class IconResource extends Resource
]) ])
->actions([ ->actions([
Tables\Actions\EditAction::make(), Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
]) ])
->bulkActions([ ->bulkActions([
Tables\Actions\DeleteBulkAction::make(), Tables\Actions\DeleteBulkAction::make(),
@@ -44,7 +44,7 @@ class SecondIconResource extends Resource
$specialMode = Setting::get('main.specialcat'); $specialMode = Setting::get('main.specialcat');
$torrentTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($torrentMode); $torrentTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($torrentMode);
$specialTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($specialMode); $specialTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($specialMode);
$modeOptions = SearchBox::query()->whereIn('id', [$torrentMode, $specialMode])->pluck('name', 'id')->toArray(); $modeOptions = SearchBox::listModeOptions();
return $form return $form
->schema([ ->schema([
Forms\Components\TextInput::make('name') Forms\Components\TextInput::make('name')
@@ -52,12 +52,6 @@ class SecondIconResource extends Resource
->required() ->required()
->helperText(__('label.second_icon.name_help')) ->helperText(__('label.second_icon.name_help'))
, ,
Forms\Components\Select::make('mode')
->label(__('label.search_box.label'))
->options($modeOptions)
->required()
->reactive()
,
Forms\Components\TextInput::make('image') Forms\Components\TextInput::make('image')
->label(__('label.second_icon.image')) ->label(__('label.second_icon.image'))
->required() ->required()
@@ -79,6 +73,11 @@ class SecondIconResource extends Resource
->columns(4) ->columns(4)
->hidden(fn (\Closure $get) => $get('mode') != $specialMode) ->hidden(fn (\Closure $get) => $get('mode') != $specialMode)
, ,
Forms\Components\Select::make('mode')
->options($modeOptions)
->label(__('label.search_box.taxonomy.mode'))
->helperText(__('label.search_box.taxonomy.mode_help'))
,
]); ]);
} }
@@ -109,6 +108,7 @@ class SecondIconResource extends Resource
]) ])
->actions([ ->actions([
Tables\Actions\EditAction::make(), Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
]) ])
->bulkActions([ ->bulkActions([
Tables\Actions\DeleteBulkAction::make(), Tables\Actions\DeleteBulkAction::make(),
@@ -87,6 +87,12 @@ class SectionResource extends Resource
->label(__('label.search_box.custom_fields_display')) ->label(__('label.search_box.custom_fields_display'))
->helperText(__('label.search_box.custom_fields_display_help')) ->helperText(__('label.search_box.custom_fields_display_help'))
, ,
Forms\Components\CheckboxList::make('other')
->options(SearchBox::listExtraText())
->columns(2)
->label(__('label.search_box.other'))
,
Forms\Components\Section::make(__('label.search_box.section_name')) Forms\Components\Section::make(__('label.search_box.section_name'))
->schema($sectionNameLocalSchema) ->schema($sectionNameLocalSchema)
->columns(count($sectionNameLocalSchema)) ->columns(count($sectionNameLocalSchema))
@@ -28,4 +28,15 @@ class EditSection extends EditRecord
clear_search_box_cache($this->record->id); clear_search_box_cache($this->record->id);
} }
protected function mutateFormDataBeforeFill(array $data): array
{
foreach (SearchBox::$extras as $field => $text) {
if (!empty($data['extra'][$field])) {
$data['other'][] = $field;
}
unset($data['extra'][$field]);
}
return $data;
}
} }
@@ -21,4 +21,5 @@ class EditTag extends EditRecord
{ {
return $this->getResource()::getUrl('index'); return $this->getResource()::getUrl('index');
} }
} }
@@ -15,20 +15,24 @@ class TrackerController extends Controller
} }
/** /**
* @deprecated
* @param Request $request * @param Request $request
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function announce(Request $request): \Illuminate\Http\Response public function announce(Request $request): \Illuminate\Http\Response
{ {
throw new \RuntimeException("Deprecated! Reference to: https://nexusphp.org/2022/07/18/tracker-url-recommend-to-use-old-announce-php/");
return $this->repository->announce($request); return $this->repository->announce($request);
} }
/** /**
* @deprecated
* @param Request $request * @param Request $request
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function scrape(Request $request): \Illuminate\Http\Response public function scrape(Request $request): \Illuminate\Http\Response
{ {
throw new \RuntimeException("Deprecated! Reference to: https://nexusphp.org/2022/07/18/tracker-url-recommend-to-use-old-announce-php/");
return $this->repository->scrape($request); return $this->repository->scrape($request);
} }
} }
+4 -1
View File
@@ -45,6 +45,10 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\Platform::class, \App\Http\Middleware\Platform::class,
], ],
'filament' => [
\Illuminate\Session\Middleware\StartSession::class,
\Filament\Http\Middleware\Authenticate::class,
],
]; ];
/** /**
@@ -58,7 +62,6 @@ class Kernel extends HttpKernel
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.nexus' => \App\Http\Middleware\NexusAuth::class, 'auth.nexus' => \App\Http\Middleware\NexusAuth::class,
'auth.filament' => \Filament\Http\Middleware\Authenticate::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+28 -5
View File
@@ -11,6 +11,8 @@ class SearchBox extends NexusModel
{ {
private static array $instances = []; private static array $instances = [];
private static array $modeOptions = [];
protected $table = 'searchbox'; protected $table = 'searchbox';
protected $fillable = [ protected $fillable = [
@@ -18,7 +20,8 @@ class SearchBox extends NexusModel
'showsource', 'showmedium', 'showcodec', 'showstandard', 'showprocessing', 'showteam', 'showaudiocodec', 'showsource', 'showmedium', 'showcodec', 'showstandard', 'showprocessing', 'showteam', 'showaudiocodec',
'custom_fields', 'custom_fields_display_name', 'custom_fields_display', 'custom_fields', 'custom_fields_display_name', 'custom_fields_display',
'extra->' . self::EXTRA_TAXONOMY_LABELS, 'extra->' . self::EXTRA_TAXONOMY_LABELS,
'extra->' . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST 'extra->' . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST,
'extra->' . self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST,
]; ];
protected $casts = [ protected $casts = [
@@ -55,27 +58,36 @@ class SearchBox extends NexusModel
self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST => ['text' => 'Display seed box icon on torrent list'], self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST => ['text' => 'Display seed box icon on torrent list'],
]; ];
public static function listExtraText(): array public static function listExtraText($fullName = false): array
{ {
$result = []; $result = [];
foreach (self::$extras as $extra => $info) { foreach (self::$extras as $field => $info) {
$result[$extra] = nexus_trans("searchbox.extras.$extra"); if ($fullName) {
$name = "extra[$field]";
} else {
$name = $field;
}
$result[$name] = nexus_trans("searchbox.extras.$field");
} }
return $result; return $result;
} }
public static function formatTaxonomyExtra(array $data): array public static function formatTaxonomyExtra(array $data): array
{ {
do_log("data: " . json_encode($data));
foreach (self::$taxonomies as $field => $table) { foreach (self::$taxonomies as $field => $table) {
$data["show{$field}"] = 0; $data["show{$field}"] = 0;
foreach ($data['extra'][self::EXTRA_TAXONOMY_LABELS] ?? [] as $item) { foreach ($data['extra'][self::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
if ($field == $item['torrent_field']) { if ($field == $item['torrent_field']) {
$data["show{$field}"] = 1; $data["show{$field}"] = 1;
// $data["extra->" . self::EXTRA_TAXONOMY_LABELS][] = $item;
} }
} }
} }
$data["extra->" . self::EXTRA_TAXONOMY_LABELS] = $data['extra'][self::EXTRA_TAXONOMY_LABELS]; $data["extra->" . self::EXTRA_TAXONOMY_LABELS] = $data['extra'][self::EXTRA_TAXONOMY_LABELS];
$other = $data['other'] ?? [];
$data["extra->" . self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST] = in_array(self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST, $other) ? 1 : 0;
$data["extra->" . self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST] = in_array(self::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST, $other) ? 1 : 0;
return $data; return $data;
} }
@@ -137,6 +149,17 @@ class SearchBox extends NexusModel
})->get(); })->get();
} }
public static function listModeOptions(): array
{
if (!empty(self::$modeOptions)) {
return self::$modeOptions;
}
self::$modeOptions = SearchBox::query()
->pluck('name', 'id')
->toArray();
return self::$modeOptions;
}
public function getCustomFieldsAttribute($value): array public function getCustomFieldsAttribute($value): array
{ {
if (!is_array($value)) { if (!is_array($value)) {
+1 -1
View File
@@ -81,8 +81,8 @@ return [
| |
*/ */
'middleware_group' => 'auth.filament',
// 'middleware_group' => 'web', // 'middleware_group' => 'web',
'middleware_group' => 'filament',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
-51
View File
@@ -1,51 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Dark mode
|--------------------------------------------------------------------------
|
| By enabling this setting, your notifications will be ready for Tailwind's
| Dark Mode feature.
|
| https://tailwindcss.com/docs/dark-mode
|
*/
'dark_mode' => false,
/*
|--------------------------------------------------------------------------
| Database notifications
|--------------------------------------------------------------------------
|
| By enabling this feature, your users are able to open a slide-over within
| the app to view their database notifications.
|
*/
'database' => [
'enabled' => false,
'trigger' => null,
'polling_interval' => '30s',
],
/*
|--------------------------------------------------------------------------
| Layout
|--------------------------------------------------------------------------
|
| This is the configuration for the general layout of notifications.
|
*/
'layout' => [
'alignment' => [
'horizontal' => 'right',
'vertical' => 'top',
],
],
];
+1
View File
@@ -679,6 +679,7 @@ elseif($action == 'add')
} }
elseif($action == 'submit') elseif($action == 'submit')
{ {
die("This method is deprecated! This method is no longer available in 1.8, it does not save data correctly, please go to the management system!");
$dbtablename=return_category_db_table_name($type); $dbtablename=return_category_db_table_name($type);
if ($_POST['isedit']){ if ($_POST['isedit']){
$id = intval($_POST['id'] ?? 0); $id = intval($_POST['id'] ?? 0);
+9 -1
View File
@@ -150,7 +150,14 @@ return [
'approval_status' => 'Approval status', 'approval_status' => 'Approval status',
'pos_state' => 'Pos state', 'pos_state' => 'Pos state',
'sp_state' => 'Promotion', 'sp_state' => 'Promotion',
'visible' => 'Visible', 'visible' => 'Active',
'source' => 'Source',
'codec' => 'Codec',
'audiocodec' => 'Audio codec',
'medium' => 'Medium',
'team' => 'Team',
'processing' => 'Processing',
'standard' => 'Standard',
'picktype' => 'Recommend', 'picktype' => 'Recommend',
'promotion_time_type' => 'Promotion type time', 'promotion_time_type' => 'Promotion type time',
'hr' => 'H&R', 'hr' => 'H&R',
@@ -254,6 +261,7 @@ return [
then it's label<%artist.label%>it's value<%artist.value%>", then it's label<%artist.label%>it's value<%artist.value%>",
'category' => 'Category', 'category' => 'Category',
'torrent_field_duplicate' => 'Torrent table field::field cannot be reused!', 'torrent_field_duplicate' => 'Torrent table field::field cannot be reused!',
'other' => 'Other',
'taxonomy' => [ 'taxonomy' => [
'name' => 'Name', 'name' => 'Name',
'sort_index' => 'Sort', 'sort_index' => 'Sort',
+2
View File
@@ -114,6 +114,7 @@ return [
], ],
'exam' => [ 'exam' => [
'label' => '考核', 'label' => '考核',
'is_done' => '是否完成',
'is_discovered' => '自动发现', 'is_discovered' => '自动发现',
'register_time_range' => [ 'register_time_range' => [
'begin' => '注册时间开始', 'begin' => '注册时间开始',
@@ -262,6 +263,7 @@ return [
'custom_fields_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>', 'custom_fields_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>',
'category' => '分类', 'category' => '分类',
'torrent_field_duplicate' => '种子表字段::field 不能重复使用!', 'torrent_field_duplicate' => '种子表字段::field 不能重复使用!',
'other' => '其他',
'taxonomy' => [ 'taxonomy' => [
'name' => '名称', 'name' => '名称',
'sort_index' => '排序', 'sort_index' => '排序',
+10 -2
View File
@@ -143,14 +143,21 @@ return [
'owner' => '發布者', 'owner' => '發布者',
'size' => '大小', 'size' => '大小',
'ttl' => '存活時間', 'ttl' => '存活時間',
'seeders' => '做', 'seeders' => '做',
'leechers' => '下', 'leechers' => '下',
'times_completed' => '完成次數', 'times_completed' => '完成次數',
'category' => '類型', 'category' => '類型',
'approval_status' => '審核狀態', 'approval_status' => '審核狀態',
'pos_state' => '置頂', 'pos_state' => '置頂',
'sp_state' => '優惠', 'sp_state' => '優惠',
'visible' => '活種', 'visible' => '活種',
'source' => '來源',
'codec' => '編碼',
'audiocodec' => '音頻編碼',
'medium' => '媒介',
'team' => '製作組',
'processing' => '處理',
'standard' => '分辨率',
'picktype' => '推薦', 'picktype' => '推薦',
'promotion_time_type' => '優惠時間類型', 'promotion_time_type' => '優惠時間類型',
'hr' => 'H&R', 'hr' => 'H&R',
@@ -252,6 +259,7 @@ return [
'custom_fields_display_help' => '使用特殊的標簽代表字段的名稱和值,如某字段其 Name 為 artist,則它的名稱為:<%artist.label%>,它的值為:<%artist.value%>', 'custom_fields_display_help' => '使用特殊的標簽代表字段的名稱和值,如某字段其 Name 為 artist,則它的名稱為:<%artist.label%>,它的值為:<%artist.value%>',
'category' => '分類', 'category' => '分類',
'torrent_field_duplicate' => '種子表字段::field 不能重復使用!', 'torrent_field_duplicate' => '種子表字段::field 不能重復使用!',
'other' => '其他',
'taxonomy' => [ 'taxonomy' => [
'name' => '名稱', 'name' => '名稱',
'sort_index' => '排序', 'sort_index' => '排序',