mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-15 20:02:25 +01:00
add torrents list view pagination
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
*/
|
||||
vm.getMovieTopInfo = function () {
|
||||
vm.moviesInfo = TorrentsService.query({
|
||||
limit: 8
|
||||
limit: 16
|
||||
}, function (items) {
|
||||
vm.movieTopList = items;
|
||||
}, function (err) {
|
||||
|
||||
@@ -388,4 +388,10 @@
|
||||
color: @brand-danger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.torrent-list {
|
||||
.pagination-div {
|
||||
border-top: 2px solid lighten(@gray-base, 70%)
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@
|
||||
.controller('TorrentsInfoController', TorrentsInfoController);
|
||||
|
||||
TorrentsInfoController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'Notification', 'TorrentsService',
|
||||
'MeanTorrentConfig', 'DownloadService', '$sce', '$filter', 'CommentsService', 'ModalConfirmService', 'marked', 'Upload', '$timeout', '$uiViewScroll',
|
||||
'MeanTorrentConfig', 'DownloadService', '$sce', '$filter', 'CommentsService', 'ModalConfirmService', 'marked', 'Upload', '$timeout',
|
||||
'SubtitlesService'];
|
||||
|
||||
function TorrentsInfoController($scope, $state, $stateParams, $translate, Authentication, Notification, TorrentsService, MeanTorrentConfig,
|
||||
DownloadService, $sce, $filter, CommentsService, ModalConfirmService, marked, Upload, $timeout, SubtitlesService,
|
||||
$uiViewScroll) {
|
||||
DownloadService, $sce, $filter, CommentsService, ModalConfirmService, marked, Upload, $timeout, SubtitlesService) {
|
||||
var vm = this;
|
||||
vm.user = Authentication.user;
|
||||
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
|
||||
vm.searchTags = [];
|
||||
vm.searchKey = '';
|
||||
vm.currPageNumber = 1;
|
||||
vm.topNumber = 6;
|
||||
vm.pageNumber = 50;
|
||||
vm.releaseYear = undefined;
|
||||
vm.topItems = 6;
|
||||
|
||||
vm.torrentTabs = [];
|
||||
|
||||
@@ -31,14 +29,40 @@
|
||||
$state.go('authentication.signin');
|
||||
}
|
||||
|
||||
//page init
|
||||
vm.torrentBuildPager = torrentBuildPager;
|
||||
vm.torrentFigureOutItemsToDisplay = torrentFigureOutItemsToDisplay;
|
||||
vm.torrentPageChanged = torrentPageChanged;
|
||||
|
||||
function torrentBuildPager() {
|
||||
vm.torrentPagedItems = [];
|
||||
vm.torrentItemsPerPage = 8;
|
||||
vm.torrentCurrentPage = 1;
|
||||
vm.torrentFigureOutItemsToDisplay();
|
||||
}
|
||||
|
||||
function torrentFigureOutItemsToDisplay() {
|
||||
vm.getMoviePageInfo(vm.torrentCurrentPage, function (items) {
|
||||
vm.torrentFilterLength = items.total;
|
||||
vm.torrentPagedItems = items.rows;
|
||||
});
|
||||
}
|
||||
|
||||
function torrentPageChanged() {
|
||||
var element = angular.element('#top_of_torrent_list');
|
||||
|
||||
vm.torrentFigureOutItemsToDisplay();
|
||||
window.scrollTo(0, element[0].offsetTop - 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* getMovieTopInfo
|
||||
*/
|
||||
vm.getMovieTopInfo = function () {
|
||||
TorrentsService.query({
|
||||
limit: vm.topNumber
|
||||
TorrentsService.get({
|
||||
limit: vm.topItems
|
||||
}, function (items) {
|
||||
vm.movieTopInfo = items;
|
||||
vm.movieTopInfo = items.rows;
|
||||
}, function (err) {
|
||||
Notification.error({
|
||||
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TOP_MOVIE_INFO_ERROR')
|
||||
@@ -68,7 +92,7 @@
|
||||
});
|
||||
}
|
||||
e.blur();
|
||||
vm.getMoviePageInfo(1);
|
||||
vm.torrentBuildPager();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,7 +108,7 @@
|
||||
} else {
|
||||
vm.searchTags.splice(vm.searchTags.indexOf(n), 1);
|
||||
}
|
||||
vm.getMoviePageInfo(1);
|
||||
vm.torrentBuildPager();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -93,7 +117,7 @@
|
||||
*/
|
||||
vm.onKeysKeyDown = function (evt) {
|
||||
if (evt.keyCode === 13) {
|
||||
vm.getMoviePageInfo(1);
|
||||
vm.torrentBuildPager();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -101,31 +125,30 @@
|
||||
* getMoviePageInfo
|
||||
* @param p: page number
|
||||
*/
|
||||
vm.getMoviePageInfo = function (p) {
|
||||
vm.currPageNumber = p;
|
||||
|
||||
vm.getMoviePageInfo = function (p, callback) {
|
||||
//if searchKey or searchTags has value, the skip=0
|
||||
var skip = vm.topNumber;
|
||||
if (vm.searchKey.trim().length > 0 || vm.searchTags.length > 0) {
|
||||
var skip = vm.topItems;
|
||||
if (vm.searchKey.trim().length > 0 || vm.searchTags.length > 0 || vm.releaseYear) {
|
||||
skip = 0;
|
||||
}
|
||||
|
||||
TorrentsService.query({
|
||||
skip: (p - 1) * vm.pageNumber + 0,
|
||||
limit: p * vm.pageNumber,
|
||||
keys: vm.searchKey,
|
||||
TorrentsService.get({
|
||||
skip: (p - 1) * vm.torrentItemsPerPage + 0, //skip
|
||||
limit: vm.torrentItemsPerPage,
|
||||
keys: vm.searchKey.trim(),
|
||||
torrent_status: 'reviewed',
|
||||
torrent_type: 'movie',
|
||||
torrent_release: vm.releaseYear,
|
||||
torrent_tags: vm.searchTags
|
||||
}, function (items) {
|
||||
vm.moviePageInfo = items;
|
||||
if (items.length === 0) {
|
||||
Notification.error({
|
||||
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('MOVIE_PAGE_INFO_EMPTY')
|
||||
});
|
||||
} else {
|
||||
callback(items);
|
||||
console.log(items);
|
||||
}
|
||||
console.log(items);
|
||||
}, function (err) {
|
||||
Notification.error({
|
||||
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('MOVIE_PAGE_INFO_ERROR')
|
||||
@@ -170,7 +193,7 @@
|
||||
vm.searchTags = [];
|
||||
$('.btn-tag').removeClass('btn-success').addClass('btn-default');
|
||||
|
||||
vm.getMoviePageInfo(1);
|
||||
vm.torrentBuildPager();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -193,7 +216,7 @@
|
||||
} else {
|
||||
vm.releaseYear = y;
|
||||
}
|
||||
vm.getMoviePageInfo(1);
|
||||
vm.torrentBuildPager();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<section class="container padding-top-10" ng-controller="TorrentsController as vm" ng-init="vm.getMovieTopInfo();vm.getMoviePageInfo(1);">
|
||||
<section class="container padding-top-10" ng-controller="TorrentsController as vm" ng-init="vm.getMovieTopInfo();vm.torrentBuildPager();">
|
||||
<div class="row">
|
||||
<div ng-repeat="item in vm.movieTopInfo">
|
||||
<div data-ng-if="$index != 0 && $index % 3 == 0" class="clearfix visible-sm-block"></div>
|
||||
<div data-ng-if="$index != 0 && $index % 6 == 0" class="clearfix visible-md-block visible-lg-block"></div>
|
||||
<div class="col-sm-4 col-md-2">
|
||||
<div class="thumbnail torrent-post-info" ng-click="vm.openTorrentInfo(item._id);">
|
||||
<img ng-src="{{vm.tmdbConfig.poster_img_base_url}}{{item.torrent_img}}" alt="{{item.torrent_title}}"
|
||||
@@ -97,43 +99,44 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tb-v-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'TABLE_FIELDS.INFO' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="torrent-list-info" ng-repeat="item in vm.moviePageInfo" ng-click="vm.openTorrentInfo(item._id);">
|
||||
<td class="col-md-7 td-text-overflow">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img class="media-object" ng-src="{{vm.tmdbConfig.poster_list_base_url}}{{item.torrent_img}}" alt="...">
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h5 class="media-heading">{{item.torrent_original_title}}
|
||||
<span ng-show="item.torrent_original_title!=item.torrent_title"> / {{item.torrent_title}}</span>
|
||||
<div class="torrent-list" id="top_of_torrent_list">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tb-v-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'TABLE_FIELDS.INFO' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
|
||||
<th>{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="torrent-list-info" ng-repeat="item in vm.torrentPagedItems" ng-click="vm.openTorrentInfo(item._id);">
|
||||
<td class="col-md-7 td-text-overflow">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img class="media-object" ng-src="{{vm.tmdbConfig.poster_list_base_url}}{{item.torrent_img}}" alt="...">
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h5 class="media-heading">{{item.torrent_original_title}}
|
||||
<span ng-show="item.torrent_original_title!=item.torrent_title"> / {{item.torrent_title}}</span>
|
||||
<span class="label label-download text-uppercase"
|
||||
title="{{ 'TITLE_ALT.DOWNLOAD_TORRENT' | translate}}"
|
||||
ng-click="vm.downloadTorrent(item._id); $event.stopPropagation();">
|
||||
title="{{ 'TITLE_ALT.DOWNLOAD_TORRENT' | translate}}"
|
||||
ng-click="vm.downloadTorrent(item._id); $event.stopPropagation();">
|
||||
<i class="glyphicon glyphicon-arrow-right"></i> {{ 'CA_DOWNLOAD' | translate}}
|
||||
</span>
|
||||
</h5>
|
||||
</h5>
|
||||
|
||||
<div class="list-all-genres">
|
||||
<span class="genres-item" ng-repeat="t in item.torrent_genres">{{t}}</span>
|
||||
</div>
|
||||
<div class="list-all-genres">
|
||||
<span class="genres-item" ng-repeat="t in item.torrent_genres">{{t}}</span>
|
||||
</div>
|
||||
|
||||
<div class="text-long">{{item.torrent_filename | filename}}</div>
|
||||
<div class="text-long">{{item.torrent_filename | filename}}</div>
|
||||
|
||||
<div class="list-all-tags">
|
||||
<!--<span class="label label-success text-uppercase">{{ item.torrent_type}}</span>-->
|
||||
<div class="list-all-tags">
|
||||
<!--<span class="label label-success text-uppercase">{{ item.torrent_type}}</span>-->
|
||||
<span class="label label-warning" ng-click="vm.onReleaseClicked(item.torrent_release); $event.stopPropagation();">
|
||||
{{ item.torrent_release}}
|
||||
</span>
|
||||
@@ -143,35 +146,41 @@
|
||||
{{ 'RESOURCESTAGS.' + vm.getTagTitle(t) + '.' + t | translate}}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle text-center">
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle text-center">
|
||||
<span title="{{ 'TITLE_ALT.IMDB_VOTES' | translate}}"
|
||||
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes | number : 1}}</span>
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.createdat | life}}</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.torrent_size | bytes:2}}</td>
|
||||
<td class="col-md-1 td-v-middle list-user-info">
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.SEEDS' | translate}}">
|
||||
<span class="glyphicon glyphicon-arrow-up torrent-up"></span>
|
||||
{{item.torrent_seeds}}
|
||||
</p>
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.createdat | life}}</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.torrent_size | bytes:2}}</td>
|
||||
<td class="col-md-1 td-v-middle list-user-info">
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.SEEDS' | translate}}">
|
||||
<span class="glyphicon glyphicon-arrow-up torrent-up"></span>
|
||||
{{item.torrent_seeds}}
|
||||
</p>
|
||||
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.LEECHERS' | translate}}">
|
||||
<span class="glyphicon glyphicon-arrow-down torrent-down"></span>
|
||||
{{item.torrent_leechers}}
|
||||
</p>
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.LEECHERS' | translate}}">
|
||||
<span class="glyphicon glyphicon-arrow-down torrent-down"></span>
|
||||
{{item.torrent_leechers}}
|
||||
</p>
|
||||
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.FINISHED' | translate}}">
|
||||
<span class="glyphicon glyphicon-ok torrent-finished"></span>
|
||||
{{item.torrent_finished}}
|
||||
</p>
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.user.displayName}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="no-margin-p" title="{{ 'TITLE_ALT.FINISHED' | translate}}">
|
||||
<span class="glyphicon glyphicon-ok torrent-finished"></span>
|
||||
{{item.torrent_finished}}
|
||||
</p>
|
||||
</td>
|
||||
<td class="col-md-1 td-v-middle">{{item.user.displayName}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination-div">
|
||||
<uib-pagination boundary-links="true" max-size="8" items-per-page="vm.torrentItemsPerPage" total-items="vm.torrentFilterLength"
|
||||
ng-model="vm.torrentCurrentPage" ng-change="vm.torrentPageChanged()"></uib-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -393,20 +393,41 @@ exports.list = function (req, res) {
|
||||
|
||||
console.log(JSON.stringify(condition));
|
||||
|
||||
Torrent.find(condition)
|
||||
.sort('-createdat')
|
||||
.populate('user', 'displayName')
|
||||
.skip(skip)
|
||||
.limit(limit)
|
||||
.exec(function (err, torrents) {
|
||||
|
||||
var countQuery = function (callback) {
|
||||
Torrent.count(condition, function (err, count) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
callback(err, null);
|
||||
} else {
|
||||
res.json(torrents);
|
||||
callback(null, count);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var findQuery = function (callback) {
|
||||
Torrent.find(condition)
|
||||
.sort('-createdat')
|
||||
.populate('user', 'displayName')
|
||||
.skip(skip)
|
||||
.limit(limit)
|
||||
.exec(function (err, torrents) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
callback(null, torrents);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
async.parallel([countQuery, findQuery], function (err, results) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: 'Torrents query error'
|
||||
});
|
||||
} else {
|
||||
res.json({rows: results[1], total: results[0]});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user