From 561febabb6b282c7a59a7aa466a99ad441a5da9b Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 02:23:17 -0500 Subject: [PATCH 01/19] (Update) Helper JS Add support for user history table filters. Went JS visibility based to avoid an extra ajax call. --- resources/js/unit3d/helper.js | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/resources/js/unit3d/helper.js b/resources/js/unit3d/helper.js index 7b8d4572ab..600d979715 100644 --- a/resources/js/unit3d/helper.js +++ b/resources/js/unit3d/helper.js @@ -1,3 +1,55 @@ +class historyFilterBuilder { + constructor() { + this.filter = ''; + } + set(filter) { + this.filter = filter; + } + get() { + return this.filter; + } + handle() { + $('.historyFiltered').each(function() { + var filter = historyFilter.get(); + if(filter == 'active' && (!$(this).attr('active') || $(this).attr('active') != 1)) { + $(this).hide(); + return; + } + if(filter == 'seeding' && (!$(this).attr('seeding') || $(this).attr('seeding') != 1)) { + $(this).hide(); + return; + } + if(filter == 'prewarned' && (!$(this).attr('prewarned') || $(this).attr('prewarned') != 1)) { + $(this).hide(); + return; + } + if(filter == 'hr' && (!$(this).attr('hr') || $(this).attr('hr') != 1)) { + $(this).hide(); + return; + } + if(filter == 'immune' && (!$(this).attr('immune') || $(this).attr('immune') != 1)) { + $(this).hide(); + return; + } + $(this).show(); + }); + } + init() { + $('.historyFilter').each(function() { + $(this).off('click'); + $(this).on('click', function(e) { + var filter = $(this).attr('filter'); + e.preventDefault(); + $('.historyList').each(function() { + $(this).removeClass('active'); + }); + $('#'+filter).addClass('active'); + historyFilter.set(filter); + historyFilter.handle(); + }); + }); + } +} class facetedSearchBuilder { constructor() { this.lazyloader = ''; @@ -446,6 +498,9 @@ $(document).ready(function () { var facetedType = document.getElementById('facetedSearch').getAttribute('type'); facetedSearch.init(facetedType); } + if(document.getElementById('historyFilter')) { + historyFilter.init(); + } torrentBookmark.update(); }); $(document).on('click', '.pagination a', function (e) { @@ -468,6 +523,7 @@ $(document).on('click', '.pagination a', function (e) { }); const facetedSearch = new facetedSearchBuilder(); const torrentBookmark = new torrentBookmarkBuilder(); +const historyFilter = new historyFilterBuilder(); var facetedSearchXHR = null; var torrentBookmarkXHR = null; From 006c2fece9a73011bada98fa07ee61478354271e Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 02:23:49 -0500 Subject: [PATCH 02/19] (Update) Torrent English Lang File Case fixes. --- resources/lang/en/torrent.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/lang/en/torrent.php b/resources/lang/en/torrent.php index 507d8a3150..06da50a26d 100644 --- a/resources/lang/en/torrent.php +++ b/resources/lang/en/torrent.php @@ -34,21 +34,21 @@ 'created_at' => 'Created at', 'credited' => 'Credited', 'current' => 'Current', - 'current-filters' => 'Current filters', - 'currently-leeching' => 'Currently leeching', - 'currently-seeding' => 'Currently seeding', - 'dead-torrent' => 'Dead torrent', - 'dead-torrents' => 'Dead torrents', - 'delete-bookmark' => 'Delete this bookmark', + 'current-filters' => 'Current Filters', + 'currently-leeching' => 'Currently Leeching', + 'currently-seeding' => 'Currently Seeding', + 'dead-torrent' => 'Dead Torrent', + 'dead-torrents' => 'Dead Torrents', + 'delete-bookmark' => 'Delete This Bookmark', 'description' => 'Description', 'discounts' => 'Discounts', 'double-upload' => 'Double upload', 'download-all' => 'Download All', 'download-check' => 'Download check', 'downloaded' => 'Downloaded', - 'dying-torrent' => 'Dying torrent', - 'dying-torrents' => 'Dying torrents', - 'encode-settings' => 'Encode settings', + 'dying-torrent' => 'Dying Torrent', + 'dying-torrents' => 'Dying Torrents', + 'encode-settings' => 'Encode Settings', 'estimated-ratio' => 'Estimated Ratio after Download', 'failed' => 'Failed', 'feature' => 'Feature', From 4179e4e527995c8fb1f89a996e8cd253a5d4e6e3 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 02:24:18 -0500 Subject: [PATCH 03/19] (Update) User English Lang File Case fixes. --- resources/lang/en/user.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/resources/lang/en/user.php b/resources/lang/en/user.php index 55617b5199..d6562a230e 100644 --- a/resources/lang/en/user.php +++ b/resources/lang/en/user.php @@ -12,7 +12,7 @@ 'account-settings' => 'Account Settings', 'achievements' => 'Achievements', 'active' => 'Active', - 'active-table' => 'My active table', + 'active-table' => 'My Active Table', 'active-torrents' => 'Active torrents', 'active-warning' => 'Active Warning', 'active-warnings' => 'Active Warnings', @@ -60,10 +60,10 @@ 'follow' => 'Follow', 'followers' => 'Followers', 'formats-are-supported' => ':formats are supported', - 'forum-signature' => 'Forum signature', + 'forum-signature' => 'Forum Signature', 'gift-given' => 'Gift Given', 'gift-received' => 'Gift Received', - 'history-table' => 'My history table', + 'history-table' => 'My History Table', 'hit-n-runs' => 'Hit and Runs', 'hit-n-runs-count' => 'Hit and Run Count (All Time)', 'hit-n-runs-history' => 'Torrent Hit and Runs History', @@ -85,7 +85,7 @@ 'member-since' => 'Member since', 'members-desc' => 'List of users registered on :title with all groups. Find an user now.', 'moderated-by' => 'Moderated by :mod on', - 'my-bonus-points' => 'My bonus points', + 'my-bonus-points' => 'My Bonus Points', 'my-bookmarks' => 'My Bookmarks', 'my-fl-tokens' => 'My FL tokens', 'my-profile' => 'My Profile', @@ -117,27 +117,27 @@ 'tips-given' => 'Tips Given', 'tips-received' => 'Tips Received', 'title' => 'Title', - 'top-bankers' => 'Top bankers', - 'top-downloaders-data' => 'Top downloaders (data)', - 'top-leechers' => 'Top leechers', - 'top-seeders' => 'Top seeders', - 'top-seedtime' => 'Top seedtime', - 'top-uploaders-data' => 'Top uploaders (data)', - 'top-uploaders-torrents' => 'Top uploaders (torrents)', + 'top-bankers' => 'Top Bankers', + 'top-downloaders-data' => 'Top Downloaders (Data)', + 'top-leechers' => 'Top Leechers', + 'top-seeders' => 'Top Seeders', + 'top-seedtime' => 'Top Seedtime', + 'top-uploaders-data' => 'Top Uploaders (data)', + 'top-uploaders-torrents' => 'Top Uploaders (torrents)', 'topics' => 'Forum Topics Made', 'torrent-comments' => 'Torrent Comments Made', - 'torrents-history' => 'Torrents history', - 'total-download' => 'Total download', - 'total-downloads' => 'Total downloads', - 'total-leeching' => 'Total leeching', - 'total-seeding' => 'Total seeding', + 'torrents-history' => 'Torrents History', + 'total-download' => 'Total Download', + 'total-downloads' => 'Total Downloads', + 'total-leeching' => 'Total Leeching', + 'total-seeding' => 'Total Seeding', 'total-seedtime-all' => 'Total Seedtime (All Torrents)', - 'total-upload' => 'Total upload', - 'total-uploads' => 'Total uploads', + 'total-upload' => 'Total Upload', + 'total-uploads' => 'Total Uploads', 'unban' => 'Unban User', 'unfollow' => 'Unfollow', 'unlocked' => 'Unlocked', - 'unlocked-achievements' => 'Unlocked achievements', + 'unlocked-achievements' => 'Unlocked Achievements', 'upload-bon' => 'Upload Added From BON Store', 'upload-recorded' => 'Recorded Upload', 'upload-true' => 'True Upload', From 5057659e0b74834ffb5aa1906a62c409faa14bf4 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 02:25:08 -0500 Subject: [PATCH 04/19] (Update) User History Table View Add JS filters to history. --- resources/views/user/history.blade.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/resources/views/user/history.blade.php b/resources/views/user/history.blade.php index c47a1c91e2..a6e9f86c25 100644 --- a/resources/views/user/history.blade.php +++ b/resources/views/user/history.blade.php @@ -29,11 +29,20 @@ class="l-breadcrumb-item-link"> @lang('user.history-table') - @lang('torrent.download-all') @lang('torrent.torrent') + @lang('torrent.download-all') @lang('torrent.torrents') +
+
@@ -55,7 +64,7 @@ class="l-breadcrumb-item-link"> @foreach ($history as $his) - +
{{ $his->torrent->name }} From 731828af9ebe8da0763c62d1f2c996e912fa0f3e Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:05:16 -0500 Subject: [PATCH 05/19] (Update) UserController faceted filtering for history. TODO: faceted filtering for other user views. --- app/Http/Controllers/UserController.php | 80 +++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 39ca734f07..72fbf6560a 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -670,6 +670,86 @@ public function myActive($username, $id) return view('user.active', ['user' => $user, 'active' => $active]); } + /** + * Uses Input's To Put Together A Filtered View. + * + * @param \Illuminate\Http\Request $request + * @param $username + * @param $id + * + * @return array + */ + public function myFilter(Request $request, $username, $id) + { + $user = User::findOrFail($id); + abort_unless(auth()->user()->group->is_modo || auth()->user()->id == $user->id, 403); + + if($request->has('view') && $request->input('view') == 'history') { + $his_upl = History::where('user_id', '=', $id)->sum('actual_uploaded'); + $his_upl_cre = History::where('user_id', '=', $id)->sum('uploaded'); + $his_downl = History::where('user_id', '=', $id)->sum('actual_downloaded'); + $his_downl_cre = History::where('user_id', '=', $id)->sum('downloaded'); + $history = History::with(['torrent' => function ($query) { + $query->withAnyStatus(); + }])->leftJoin('torrents as torrents', 'torrents.info_hash', '=', 'history.info_hash'); + + $order = null; + $sorting = null; + if ($request->has('sorting') && $request->input('sorting') != null) { + $sorting = $request->input('sorting'); + } + if ($request->has('direction') && $request->input('direction') != null) { + $order = $request->input('direction'); + } + if (! $sorting || $sorting == null || ! $order || $order == null) { + $sorting = 'created_at'; + $order = 'desc'; + // $order = 'asc'; + } + if ($order == 'asc') { + $direction = 1; + } else { + $direction = 2; + } + + if($request->has('completed') && $request->input('completed') != null) { + $history->where('completed_at','>',0); + } + + if($request->has('active') && $request->input('active') != null) { + $history->where('active','=',1); + } + + if($request->has('seeding') && $request->input('seeding') != null) { + $history->where('seeder','=',1); + } + + if($request->has('prewarned') && $request->input('prewarned') != null) { + $history->where('prewarn','=',1); + } + + if($request->has('hr') && $request->input('hr') != null) { + $history->where('hitrun','=',1); + } + + if($request->has('immune') && $request->input('immune') != null) { + $history->where('immune','=',1); + } + + $table = $history->where('history.user_id', '=', $user->id)->orderBy('torrents.'.$sorting, $order)->paginate(50); + + return view('user.filters', [ + 'user' => $user, + 'history' => $table, + 'his_upl' => $his_upl, + 'his_upl_cre' => $his_upl_cre, + 'his_downl' => $his_downl, + 'his_downl_cre' => $his_downl_cre, + ])->render(); + } + return false; + } + /** * Get A Users History Table. * From f6448abcc03f06cbfbeb6220ff4c382ee1e6d07a Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:14:49 -0500 Subject: [PATCH 06/19] (Update) UserController Fix sortable. --- app/Http/Controllers/UserController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 72fbf6560a..9d77dca90b 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -736,7 +736,12 @@ public function myFilter(Request $request, $username, $id) $history->where('immune','=',1); } - $table = $history->where('history.user_id', '=', $user->id)->orderBy('torrents.'.$sorting, $order)->paginate(50); + if($sorting != "name") { + $table = $history->where('history.user_id', '=', $user->id)->orderBy('history.' . $sorting, $order)->paginate(50); + } + else { + $table = $history->where('history.user_id', '=', $user->id)->orderBy('torrents.' . $sorting, $order)->paginate(50); + } return view('user.filters', [ 'user' => $user, From 3580b345fd043ed6d1581930908ebe7b3c8ca34c Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:15:23 -0500 Subject: [PATCH 07/19] (Update) Helper JS Add ajax for user filters. --- resources/js/unit3d/helper.js | 133 +++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 36 deletions(-) diff --git a/resources/js/unit3d/helper.js b/resources/js/unit3d/helper.js index 600d979715..6cf4c5e1e1 100644 --- a/resources/js/unit3d/helper.js +++ b/resources/js/unit3d/helper.js @@ -1,6 +1,9 @@ -class historyFilterBuilder { +class userFilterBuilder { constructor() { + this.csrf = document.querySelector("meta[name='csrf-token']").getAttribute("content"); + this.api = ''; this.filter = ''; + this.view = 'history'; } set(filter) { this.filter = filter; @@ -8,44 +11,96 @@ class historyFilterBuilder { get() { return this.filter; } - handle() { - $('.historyFiltered').each(function() { - var filter = historyFilter.get(); - if(filter == 'active' && (!$(this).attr('active') || $(this).attr('active') != 1)) { - $(this).hide(); - return; + handle(page,nav) { + + var userId = $('#userFilter').attr('userId'); + var userName = $('#userFilter').attr('userName'); + + var active = (function () { + if ($("#active").is(":checked")) { + return $("#active").val(); } - if(filter == 'seeding' && (!$(this).attr('seeding') || $(this).attr('seeding') != 1)) { - $(this).hide(); - return; + })(); + + var seeding = (function () { + if ($("#seeding").is(":checked")) { + return $("#seeding").val(); } - if(filter == 'prewarned' && (!$(this).attr('prewarned') || $(this).attr('prewarned') != 1)) { - $(this).hide(); - return; + })(); + + var prewarned = (function () { + if ($("#prewarned").is(":checked")) { + return $("#prewarned").val(); } - if(filter == 'hr' && (!$(this).attr('hr') || $(this).attr('hr') != 1)) { - $(this).hide(); - return; + })(); + + var hr = (function () { + if ($("#hr").is(":checked")) { + return $("#hr").val(); } - if(filter == 'immune' && (!$(this).attr('immune') || $(this).attr('immune') != 1)) { - $(this).hide(); - return; + })(); + + var immune = (function () { + if ($("#immune").is(":checked")) { + return $("#immune").val(); + } + })(); + + var completed = (function () { + if ($("#completed").is(":checked")) { + return $("#completed").val(); + } + })(); + + var sorting = $("#sorting").val(); + var direction = $("#direction").val(); + + if(userFilterXHR != null) { + userFilterXHR.abort(); + } + userFilterXHR = $.ajax({ + url: '/'+userName+'.'+userId+'/userFilters', + data: { + _token: this.csrf, + page: page, + active: active, + sorting: sorting, + direction: direction, + seeding: seeding, + prewarned: prewarned, + completed: completed, + hr: hr, + immune: immune, + view: this.view, + }, + type: 'post', + beforeSend: function () { + $("#userFilter").html('') + } + }).done(function (e) { + $data = $(e); + $("#userFilter").html($data); + if (page) { + $("#filterHeader")[0].scrollIntoView(); } - $(this).show(); + if (!nav) { + if (window.history && window.history.replaceState) { + window.history.replaceState(null, null, ' '); + } + } + userFilterXHR = null; }); } init() { - $('.historyFilter').each(function() { - $(this).off('click'); - $(this).on('click', function(e) { - var filter = $(this).attr('filter'); - e.preventDefault(); - $('.historyList').each(function() { - $(this).removeClass('active'); - }); - $('#'+filter).addClass('active'); - historyFilter.set(filter); - historyFilter.handle(); + $('.userFilter').each(function() { + if($(this).attr('trigger')) { + var trigger = $(this).attr('trigger'); + } else { + var trigger = 'click'; + } + $(this).off(trigger); + $(this).on(trigger, function(e) { + userFilter.handle(); }); }); } @@ -498,13 +553,13 @@ $(document).ready(function () { var facetedType = document.getElementById('facetedSearch').getAttribute('type'); facetedSearch.init(facetedType); } - if(document.getElementById('historyFilter')) { - historyFilter.init(); + if(document.getElementById('userFilter')) { + userFilter.init(); } torrentBookmark.update(); }); $(document).on('click', '.pagination a', function (e) { - if(!document.getElementById('facetedSearch')) return; + if(!document.getElementById('facetedSearch') && !document.getElementById('userFilter')) return; e.preventDefault(); var sub = null; if (window.location.hash && window.location.hash.substring) { @@ -519,12 +574,18 @@ $(document).on('click', '.pagination a', function (e) { if (window.history && window.history.pushState) { window.history.pushState("", "", url); } - facetedSearch.show(page,true); + if(document.getElementById('facetedSearch')) { + facetedSearch.show(page, true); + } + if(document.getElementById('userFilter')) { + userFilter.handle(page, true); + } }); const facetedSearch = new facetedSearchBuilder(); const torrentBookmark = new torrentBookmarkBuilder(); -const historyFilter = new historyFilterBuilder(); +const userFilter = new userFilterBuilder(); +var userFilterXHR = null; var facetedSearchXHR = null; var torrentBookmarkXHR = null; From b4d12625e3143f95f93d41ae1afd29dd730e34ca Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:15:51 -0500 Subject: [PATCH 08/19] (Add) User Filters Blade Only for history. --- resources/views/user/filters.blade.php | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 resources/views/user/filters.blade.php diff --git a/resources/views/user/filters.blade.php b/resources/views/user/filters.blade.php new file mode 100644 index 0000000000..cacd6ee362 --- /dev/null +++ b/resources/views/user/filters.blade.php @@ -0,0 +1,82 @@ +
+ +
+ +
@lang('user.torrents-history')
+ + + + + + + + + + + + + + + + + @foreach ($history as $his) + + + + @if ($his->active == 1) + @else + @endif + @if ($his->seeder == 1) + @else + @endif + + + @if ($his->seedtime < config('hitrun.seedtime')) + + @else + + @endif + + + + @if ($his->prewarn == 1) + + @else + + @endif + @if ($his->hitrun == 1) + + @else + + @endif + @if ($his->immune == 1) + + @else + + @endif + + @endforeach + +
@lang('torrent.name')@lang('torrent.agent')@lang('common.active')@lang('torrent.seeder')@lang('torrent.uploaded')@lang('torrent.downloaded')@lang('torrent.seedtime')@lang('torrent.created_at')@lang('torrent.updated_at')@lang('torrent.completed_at')@lang('torrent.prewarn')@lang('torrent.hitrun')@lang('torrent.immune')
+ + {{ $his->torrent->name }} + + + {{ $his->agent ? $his->agent : trans('common.unknown') }} + @lang('common.yes')@lang('common.no')@lang('common.yes')@lang('common.no') + {{ App\Helpers\StringHelper::formatBytes($his->actual_uploaded , 2) }} + {{ App\Helpers\StringHelper::formatBytes($his->uploaded , 2) }} + + {{ App\Helpers\StringHelper::formatBytes($his->actual_downloaded , 2) }} + {{ App\Helpers\StringHelper::formatBytes($his->downloaded , 2) }} + + {{ App\Helpers\StringHelper::timeElapsed($his->seedtime) }} + + {{ App\Helpers\StringHelper::timeElapsed($his->seedtime) }} + {{ $his->created_at->diffForHumans() }}{{ $his->updated_at->diffForHumans() }}{{ $his->completed_at ? $his->completed_at->diffForHumans() : "N/A"}}
+
+ {{ $history->appends(request()->except('page'))->render() }} +
+
\ No newline at end of file From 09b89ff145d68680934e6db286a2cf748e7b2cc1 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:16:39 -0500 Subject: [PATCH 09/19] (Update) User History View Switch to ajax. Go filter style. --- resources/views/user/history.blade.php | 139 +++++++++++++++++++------ 1 file changed, 107 insertions(+), 32 deletions(-) diff --git a/resources/views/user/history.blade.php b/resources/views/user/history.blade.php index a6e9f86c25..f00516a342 100644 --- a/resources/views/user/history.blade.php +++ b/resources/views/user/history.blade.php @@ -15,56 +15,129 @@ class="l-breadcrumb-item-link"> @section('content')
- @lang('user.total-download'): +
+
+ +
+ @lang('user.total-download'): {{ App\Helpers\StringHelper::formatBytes($his_downl,2) }} {{ App\Helpers\StringHelper::formatBytes($his_downl_cre,2) }} - @lang('user.total-upload'): + @lang('user.total-upload'): {{ App\Helpers\StringHelper::formatBytes($his_upl,2) }} {{ App\Helpers\StringHelper::formatBytes($his_upl_cre,2) }} -

- @lang('user.history-table') - - - @lang('torrent.download-all') @lang('torrent.torrents') +

+
+
+
+

+ @lang('user.history-table') +

+
+
+
+ +
-
@lang('user.torrents-history')
- - - - - - - - - - - - - + + + + + + + + + + + + + - + @foreach ($history as $his) - +
@sortablelink('name', trans('torrent.name'))@sortablelink('agent', trans('torrent.agent'))@sortablelink('active', trans('common.active'))@sortablelink('seeder', trans('torrent.seeder'))@sortablelink('uploaded', trans('torrent.uploaded'))@sortablelink('downloaded', trans('torrent.downloaded'))@sortablelink('seedtime', trans('torrent.seedtime'))@sortablelink('created_at', trans('torrent.created_at'))@sortablelink('updated_at', trans('torrent.updated_at'))@sortablelink('completed_at', trans('torrent.completed_at'))@sortablelink('prewarn', trans('torrent.prewarn'))@sortablelink('hitrun', trans('torrent.hitrun'))@sortablelink('immune', trans('torrent.immune'))@lang('torrent.name')@lang('torrent.agent')@lang('common.active')@lang('torrent.seeder')@lang('torrent.uploaded')@lang('torrent.downloaded')@lang('torrent.seedtime')@lang('torrent.created_at')@lang('torrent.updated_at')@lang('torrent.completed_at')@lang('torrent.prewarn')@lang('torrent.hitrun')@lang('torrent.immune')
{{ $his->torrent->name }} @@ -125,4 +198,6 @@ class="l-breadcrumb-item-link"> + + @endsection From 299b3d8b182d89784bf4af39dd163671e3869529 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 05:17:07 -0500 Subject: [PATCH 10/19] (Update) Web Routes support for user filters. --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 72040720fc..0419059697 100755 --- a/routes/web.php +++ b/routes/web.php @@ -248,6 +248,7 @@ Route::get('/{username}.{id}/myuploads', 'UserController@myUploads')->name('myuploads'); Route::get('/{username}.{id}/myactive', 'UserController@myActive')->name('myactive'); Route::get('/{username}.{id}/myhistory', 'UserController@myHistory')->name('myhistory'); + Route::post('/{username}.{id}/userFilters', 'UserController@myFilter')->name('myfilter'); Route::post('/{username}.{id}/myuploadssearch', 'UserController@myUploadsSearch')->name('myuploadssearch'); Route::get('/{username}.{id}/downloadHistoryTorrents', 'UserController@downloadHistoryTorrents')->name('download_history_torrents'); Route::get('/{username}.{id}/myresurrections', 'UserController@myResurrections')->name('myResurrections'); From 95d56b16cc6d2180badf014de9365cc1ef07e32a Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Sat, 19 Jan 2019 13:21:41 +0000 Subject: [PATCH 11/19] Apply fixes from StyleCI --- app/Http/Controllers/UserController.php | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9d77dca90b..88e88cc7ed 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -684,7 +684,7 @@ public function myFilter(Request $request, $username, $id) $user = User::findOrFail($id); abort_unless(auth()->user()->group->is_modo || auth()->user()->id == $user->id, 403); - if($request->has('view') && $request->input('view') == 'history') { + if ($request->has('view') && $request->input('view') == 'history') { $his_upl = History::where('user_id', '=', $id)->sum('actual_uploaded'); $his_upl_cre = History::where('user_id', '=', $id)->sum('uploaded'); $his_downl = History::where('user_id', '=', $id)->sum('actual_downloaded'); @@ -712,35 +712,34 @@ public function myFilter(Request $request, $username, $id) $direction = 2; } - if($request->has('completed') && $request->input('completed') != null) { - $history->where('completed_at','>',0); + if ($request->has('completed') && $request->input('completed') != null) { + $history->where('completed_at', '>', 0); } - if($request->has('active') && $request->input('active') != null) { - $history->where('active','=',1); + if ($request->has('active') && $request->input('active') != null) { + $history->where('active', '=', 1); } - if($request->has('seeding') && $request->input('seeding') != null) { - $history->where('seeder','=',1); + if ($request->has('seeding') && $request->input('seeding') != null) { + $history->where('seeder', '=', 1); } - if($request->has('prewarned') && $request->input('prewarned') != null) { - $history->where('prewarn','=',1); + if ($request->has('prewarned') && $request->input('prewarned') != null) { + $history->where('prewarn', '=', 1); } - if($request->has('hr') && $request->input('hr') != null) { - $history->where('hitrun','=',1); + if ($request->has('hr') && $request->input('hr') != null) { + $history->where('hitrun', '=', 1); } - if($request->has('immune') && $request->input('immune') != null) { - $history->where('immune','=',1); + if ($request->has('immune') && $request->input('immune') != null) { + $history->where('immune', '=', 1); } - if($sorting != "name") { - $table = $history->where('history.user_id', '=', $user->id)->orderBy('history.' . $sorting, $order)->paginate(50); - } - else { - $table = $history->where('history.user_id', '=', $user->id)->orderBy('torrents.' . $sorting, $order)->paginate(50); + if ($sorting != 'name') { + $table = $history->where('history.user_id', '=', $user->id)->orderBy('history.'.$sorting, $order)->paginate(50); + } else { + $table = $history->where('history.user_id', '=', $user->id)->orderBy('torrents.'.$sorting, $order)->paginate(50); } return view('user.filters', [ @@ -752,6 +751,7 @@ public function myFilter(Request $request, $username, $id) 'his_downl_cre' => $his_downl_cre, ])->render(); } + return false; } From 4d1e4d2f216c8dd9c5538fe663d8421391b31247 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:49:22 -0500 Subject: [PATCH 12/19] (Update) TorrentController Handle new activity filters. --- app/Http/Controllers/TorrentController.php | 77 +++++++++++++++++++--- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 3d57b812a1..072dc50394 100755 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -322,10 +322,30 @@ public function faceted(Request $request, Torrent $torrent) $repository = $this->faceted; $personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first(); $collection = null; + $seedling = null; + $notdownloaded = null; + $downloaded = null; + $leeching = null; + $idling = null; if ($request->has('view') && $request->input('view') == 'group') { $collection = 1; } + if($request->has('seeding') && $request->input('seeding') != null) { + $seedling = 1; + } + if($request->has('notdownloaded') && $request->input('notdownloaded') != null) { + $notdownloaded = 1; + } + if($request->has('downloaded') && $request->input('downloaded') != null) { + $downloaded = 1; + } + if($request->has('leeching') && $request->input('leeching') != null) { + $leeching = 1; + } + if($request->has('idling') && $request->input('idling') != null) { + $idling = 1; + } $search = $request->input('search'); $description = $request->input('description'); @@ -481,17 +501,53 @@ public function faceted(Request $request, Torrent $torrent) $torrent->where('torrentsl.seeders', '=', $dead); } } else { - $torrent = $torrent->with(['user', 'category'])->withCount(['thanks', 'comments']); + + if($seedling == 1 || $notdownloaded == 1 || $downloaded == 1 || $leeching == 1 || $idling == 1) { + + $torrent = $torrent->distinct()->select('torrents.id')->selectRaw('historyl.seeder as seeding,torrents.*,torrents.user_id as creator')->with(['uploader','category'])->withCount(['thanks', 'comments'])->leftJoin('history as historyl', 'torrents.info_hash', '=', 'historyl.info_hash'); + + $torrent->orWhere(function ($query) use($user,$seedling,$notdownloaded,$downloaded,$leeching,$idling) { + if($seedling == 1) { + $query->orWhere(function ($query) use ($user){ + $query->where('historyl.user_id', '=', $user->id)->where('historyl.seeder', '=', '1'); + }); + } + if($notdownloaded == 1) { + $query->orWhere(function ($query) use ($user){ + $query->whereRaw('historyl.id is null'); + }); + } + if($downloaded == 1) { + $query->orWhere(function ($query) use ($user){ + $query->where('historyl.user_id', '=', $user->id)->whereRaw('(historyl.seeder = ? OR historyl.completed_at is not null)',[1]); + }); + } + if($leeching == 1) { + $query->orWhere(function ($query) use ($user){ + $query->where('historyl.user_id', '=', $user->id)->whereRaw('(historyl.active = ? AND (historyl.completed_at is null OR historyl.seeder = 0))',[1]); + }); + } + if($idling == 1) { + $query->orWhere(function ($query) use ($user){ + $query->where('historyl.user_id', '=', $user->id)->whereRaw('(historyl.active = ? AND (historyl.completed_at is null OR historyl.seeder = ?))',[0,1]); + }); + } + }); + + } + else { + $torrent = $torrent->distinct()->select('torrents.id')->selectRaw('historyl.seeder as seeding,torrents.*,torrents.user_id as creator')->with(['uploader','category'])->withCount(['thanks', 'comments'])->leftJoin('history as historyl', 'torrents.info_hash', '=', 'historyl.info_hash'); + } if ($request->has('search') && $request->input('search') != null) { $torrent->where(function ($query) use ($search) { - $query->where('name', 'like', $search); + $query->where('torrents.name', 'like', $search); }); } if ($request->has('description') && $request->input('description') != null) { $torrent->where(function ($query) use ($description) { - $query->where('description', 'like', $description)->orWhere('mediainfo', 'like', $description); + $query->where('torrents.description', 'like', $description)->orWhere('mediainfo', 'like', $description); }); } @@ -500,7 +556,7 @@ public function faceted(Request $request, Torrent $torrent) if (null === $match) { return ['result' => [], 'count' => 0]; } - $torrent->where('user_id', '=', $match->id)->where('anon', '=', 0); + $torrent->where('torrents.user_id', '=', $match->id)->where('anon', '=', 0); } if ($request->has('imdb') && $request->input('imdb') != null) { @@ -529,7 +585,7 @@ public function faceted(Request $request, Torrent $torrent) if ($request->has('genres') && $request->input('genres') != null) { $genreID = TagTorrent::distinct()->select('torrent_id')->whereIn('tag_name', $genres)->get(); - $torrent->whereIn('id', $genreID); + $torrent->whereIn('torrents.id', $genreID); } if ($request->has('freeleech') && $request->input('freeleech') != null) { @@ -561,16 +617,17 @@ public function faceted(Request $request, Torrent $torrent) } if ($request->has('alive') && $request->input('alive') != null) { - $torrent->where('seeders', '>=', $alive); + $torrent->where('torrents.seeders', '>=', $alive); } if ($request->has('dying') && $request->input('dying') != null) { - $torrent->where('seeders', '=', $dying)->where('times_completed', '>=', 3); + $torrent->where('torrents.seeders', '=', $dying)->where('times_completed', '>=', 3); } if ($request->has('dead') && $request->input('dead') != null) { - $torrent->where('seeders', '=', $dead); + $torrent->where('torrents.seeders', '=', $dead); } + } if ($request->has('qty')) { @@ -601,7 +658,7 @@ public function faceted(Request $request, Torrent $torrent) } $totals = []; $counts = []; - $launcher = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->whereIn('imdb', $fed)->orderBy($sorting, $order); + $launcher = Torrent::with(['uploader', 'category'])->withCount(['thanks', 'comments'])->whereIn('imdb', $fed)->orderBy($sorting, $order); foreach ($launcher->cursor() as $chunk) { if ($chunk->imdb) { if (! array_key_exists($chunk->imdb, $totals)) { @@ -650,7 +707,7 @@ public function faceted(Request $request, Torrent $torrent) $torrents = null; } } else { - $torrents = $torrent->orderBy('sticky', 'desc')->orderBy($sorting, $order)->paginate($qty); + $torrents = $torrent->orderBy('torrents.sticky', 'desc')->orderBy('torrents.'.$sorting, $order)->paginate($qty); } if ($collection == 1 && is_array($torrents)) { $client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb')); From 2d969e2d82bb723f671989edb5ed3847aea72358 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:52:36 -0500 Subject: [PATCH 13/19] (Update) Torrent Model Establish relationship with an uploader on a torrent. --- app/Torrent.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Torrent.php b/app/Torrent.php index 0671d193ea..54ce1df89f 100755 --- a/app/Torrent.php +++ b/app/Torrent.php @@ -56,6 +56,19 @@ public function user() ]); } + /** + * Belongs To A Uploader. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function uploader() + { + return $this->belongsTo(User::class, 'creator')->withDefault([ + 'username' => 'System', + 'id' => '1', + ]); + } + /** * Belongs To A Category. * From a1a2e2bb9c24bc91fc7b75aae6dc6b849db75463 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:53:13 -0500 Subject: [PATCH 14/19] (Update) Helper JS Support additional search fields for torrent. --- resources/js/unit3d/helper.js | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/resources/js/unit3d/helper.js b/resources/js/unit3d/helper.js index 6cf4c5e1e1..7ada5dd7fd 100644 --- a/resources/js/unit3d/helper.js +++ b/resources/js/unit3d/helper.js @@ -3,6 +3,7 @@ class userFilterBuilder { this.csrf = document.querySelector("meta[name='csrf-token']").getAttribute("content"); this.api = ''; this.filter = ''; + this.start = 0; this.view = 'history'; } set(filter) { @@ -11,6 +12,9 @@ class userFilterBuilder { get() { return this.filter; } + force() { + this.handle(this.start,true); + } handle(page,nav) { var userId = $('#userFilter').attr('userId'); @@ -103,6 +107,15 @@ class userFilterBuilder { userFilter.handle(); }); }); + + var page = 0; + if (window.location.hash && window.location.hash.indexOf('page')) { + page = parseInt(window.location.hash.split('/')[1]); + } + if (page && page > 0) { + this.start = page; + this.force(); + } } } class facetedSearchBuilder { @@ -161,6 +174,26 @@ class facetedSearchBuilder { var types = []; var genres = []; var qty = $("#qty").val(); + var notdownloaded = (function () { + if ($("#notdownloaded").is(":checked")) { + return $("#notdownloaded").val(); + } + })(); + var downloaded = (function () { + if ($("#downloaded").is(":checked")) { + return $("#downloaded").val(); + } + })(); + var idling = (function () { + if ($("#idling").is(":checked")) { + return $("#idling").val(); + } + })(); + var leeching = (function () { + if ($("#leeching").is(":checked")) { + return $("#leeching").val(); + } + })(); var freeleech = (function () { if ($("#freeleech").is(":checked")) { return $("#freeleech").val(); @@ -176,6 +209,11 @@ class facetedSearchBuilder { return $("#featured").val(); } })(); + var seeding = (function () { + if ($("#seeding").is(":checked")) { + return $("#seeding").val(); + } + })(); var stream = (function () { if ($("#stream").is(":checked")) { return $("#stream").val(); @@ -288,6 +326,11 @@ class facetedSearchBuilder { uploader: uploader, imdb: imdb, tvdb: tvdb, + notdownloaded: notdownloaded, + downloaded: downloaded, + idling: idling, + leeching: leeching, + seeding: seeding, view: this.view, tmdb: tmdb, mal: mal, From 9cff51004f21d5437e60d6b67f93a7f653976639 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:53:36 -0500 Subject: [PATCH 15/19] (Update) Torrent English Lang Pack dumped from torrent views. --- resources/lang/en/torrent.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/lang/en/torrent.php b/resources/lang/en/torrent.php index 06da50a26d..a38772ad84 100644 --- a/resources/lang/en/torrent.php +++ b/resources/lang/en/torrent.php @@ -5,6 +5,7 @@ * |-------------------------------------------------------------------------- */ return [ + 'activity' => 'Activity', 'age' => 'Age', 'agent' => 'Agent', 'alive' => 'Alive', @@ -71,6 +72,9 @@ 'grouping-categories-desc' => 'What category would you like to group?', 'grouping-results' => 'Grouping Results', 'groupings-view' => 'Groupings View', + 'have-downloaded' => 'Downloaded', + 'have-not-completed' => 'Not Completed', + 'have-not-downloaded' => 'Not Downloaded', 'health' => 'Health', 'history' => 'History', 'hitrun' => 'H&R?', @@ -90,6 +94,7 @@ 'legendary-seeder' => 'Legendary seeder', 'legendary-torrent' => 'Legendary torrent', 'list' => 'List', + 'me' => 'Me', 'media-info' => 'MediaInfo', 'media-info-parser' => 'MediaInfo Parser', 'media-info-paste' => 'Paste MediaInfo dump here', @@ -103,6 +108,7 @@ 'no-privileges' => 'You are not able to download this file - please check below for more info', 'no-privileges-desc' => 'Please solve the failed results above for download button to appear', 'not-completed' => 'Started Downloading But Never Completed', + 'not-downloaded' => 'Not Downloaded', 'old-torrent' => 'Old torrent', 'optional' => 'Optional', 'original-output' => 'Show / Hide original output', From bd0cee04d4ec09436264f53868121b4d7981f8ef Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:54:43 -0500 Subject: [PATCH 16/19] (Update) Torrent Results Refer to uploader and not user. --- resources/views/torrent/results.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/torrent/results.blade.php b/resources/views/torrent/results.blade.php index 7acfe679c7..5f7efa8707 100644 --- a/resources/views/torrent/results.blade.php +++ b/resources/views/torrent/results.blade.php @@ -131,17 +131,17 @@ class="torrent-poster-img-small show-poster" alt="@lang('torrent.poster')"> @if ($torrent->anon == 1) @lang('common.anonymous') - @if ($user->id == $torrent->user->id || $user->group->is_modo) - - ({{ $torrent->user->username }}) + @if ($user->id == $torrent->uploader->id || $user->group->is_modo) + + ({{ $torrent->uploader->username }}) @endif @else - - {{ $torrent->user->username }} + + {{ $torrent->uploader->username }} @endif From fd0a74c6cc4cd5931bda50c09ace23d589df33a4 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 19 Jan 2019 17:55:13 -0500 Subject: [PATCH 17/19] (Update) Torrent List View Add new filter methods (activity). --- resources/views/torrent/torrents.blade.php | 85 +++++++++++++++------- 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/resources/views/torrent/torrents.blade.php b/resources/views/torrent/torrents.blade.php index 6f4b76353a..f94a3989c1 100644 --- a/resources/views/torrent/torrents.blade.php +++ b/resources/views/torrent/torrents.blade.php @@ -30,7 +30,7 @@
-
+
@@ -41,32 +41,32 @@
-