diff --git a/config/env/torrents.js b/config/env/torrents.js
index d277f54d..64089e7a 100644
--- a/config/env/torrents.js
+++ b/config/env/torrents.js
@@ -736,6 +736,7 @@ module.exports = {
* @adminUserListPerPage: admin manage users list page settings
* @collectionsListPerPage: movie collections list page settings
* @backupFilesListPerPage: system backup files list page settings
+ * @torrentPeersListPerPage: torrent detail seeder & leecher users list page settings
*/
itemsPerPage: {
topicsPerPage: 10,
@@ -747,7 +748,8 @@ module.exports = {
tracesPerPage: 30,
adminUserListPerPage: 15,
collectionsListPerPage: 6,
- backupFilesListPerPage: 15
+ backupFilesListPerPage: 15,
+ torrentPeersListPerPage: 15
},
/**
diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js
index 9b805231..b74af046 100644
--- a/modules/core/client/app/trans-string-en.js
+++ b/modules/core/client/app/trans-string-en.js
@@ -265,7 +265,7 @@
TAB_TORRENT_INFO: 'Torrent Info',
TAB_USER_SUBTITLE: 'Subtitle Info',
TAB_THUMBS_LIST: 'Thumbs-up',
- TAB_USER_INFO: 'User Info',
+ TAB_USER_INFO: 'Users Info',
TAB_OTHER_TORRENTS: 'Other Torrents',
TAB_MY_PANEL: 'My Pannel',
TAB_ADMIN_PANEL: 'Admin Panel',
diff --git a/modules/core/client/less/mt.less b/modules/core/client/less/mt.less
index edb44729..d3bb7c33 100644
--- a/modules/core/client/less/mt.less
+++ b/modules/core/client/less/mt.less
@@ -873,6 +873,7 @@ body {
.tb-peers {
background-color: #fff;
+ margin-bottom: 10px !important;
thead {
tr {
th {
@@ -889,6 +890,9 @@ body {
}
margin-bottom: 0;
}
+ .pagination {
+ margin: 0 !important;
+ }
}
.tb-other-torrents {
diff --git a/modules/torrents/client/controllers/torrent-info.client.controller.js b/modules/torrents/client/controllers/torrent-info.client.controller.js
index 75b21d3d..c3ef869b 100644
--- a/modules/torrents/client/controllers/torrent-info.client.controller.js
+++ b/modules/torrents/client/controllers/torrent-info.client.controller.js
@@ -130,6 +130,7 @@
vm.rating_vote = res.resource_detail_info.vote_average;
vm.initTabLists();
vm.commentBuildPager();
+ vm.buildPeersPager();
if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInDetail) {
ScrapeService.scrapeTorrent(vm.torrentLocalInfo);
}
@@ -1137,5 +1138,106 @@
}
});
};
+
+ /**
+ * buildPeersPager
+ */
+ vm.buildPeersPager = function () {
+ vm.seederPagedItems = [];
+ vm.leecherPagedItems = [];
+
+ vm.peerItemsPerPage = vm.itemsPerPageConfig.torrentPeersListPerPage;
+
+ vm.currentSeederPage = 1;
+ vm.currentLeecherPage = 1;
+
+ vm.figureOutSeederItemsToDisplay();
+ vm.figureOutLeecherItemsToDisplay();
+ };
+
+ /**
+ * figureOutSeederItemsToDisplay
+ * @param callback
+ */
+ vm.figureOutSeederItemsToDisplay = function (callback) {
+ vm.getSeederUsers(vm.currentSeederPage, function (items) {
+ vm.seederFilterLength = items.total;
+ vm.seederPagedItems = items.rows;
+
+ if (callback) callback();
+ });
+ };
+
+ /**
+ * figureOutLeecherItemsToDisplay
+ * @param callback
+ */
+ vm.figureOutLeecherItemsToDisplay = function (callback) {
+ vm.getLeecherUsers(vm.currentLeecherPage, function (items) {
+ vm.leecherFilterLength = items.total;
+ vm.leecherPagedItems = items.rows;
+
+ if (callback) callback();
+ });
+ };
+
+ /**
+ * getSeederUsers
+ * @param p
+ * @param callback
+ */
+ vm.getSeederUsers = function (p, callback) {
+ TorrentsService.getSeederUsers({
+ torrentId: vm.torrentLocalInfo._id,
+ skip: (p - 1) * vm.peerItemsPerPage,
+ limit: vm.peerItemsPerPage
+ }, function (data) {
+ mtDebug.info(data);
+ callback(data);
+ });
+ };
+
+ /**
+ * getLeecherUsers
+ * @param p
+ * @param callback
+ */
+ vm.getLeecherUsers = function (p, callback) {
+ TorrentsService.getLeecherUsers({
+ torrentId: vm.torrentLocalInfo._id,
+ skip: (p - 1) * vm.peerItemsPerPage,
+ limit: vm.peerItemsPerPage
+ }, function (data) {
+ mtDebug.info(data);
+ callback(data);
+ });
+ };
+
+ /**
+ * seederPageChanged
+ */
+ vm.seederPageChanged = function () {
+ var element = angular.element('#top_of_seeder_list');
+
+ vm.figureOutSeederItemsToDisplay(function () {
+ $timeout(function () {
+ $('html,body').animate({scrollTop: element[0].offsetTop - 60}, 200);
+ }, 10);
+ });
+ };
+
+ /**
+ * seederPageChanged
+ */
+ vm.leecherPageChanged = function () {
+ var element = angular.element('#top_of_leecher_list');
+
+ vm.figureOutLeecherItemsToDisplay(function () {
+ $timeout(function () {
+ $('html,body').animate({scrollTop: element[0].offsetTop - 60}, 200);
+ }, 10);
+ });
+ };
+
}
}());
diff --git a/modules/torrents/client/services/torrents.client.service.js b/modules/torrents/client/services/torrents.client.service.js
index 8b3afa1c..8b20d8a8 100644
--- a/modules/torrents/client/services/torrents.client.service.js
+++ b/modules/torrents/client/services/torrents.client.service.js
@@ -99,6 +99,20 @@
siteInfo: {
method: 'GET',
url: '/api/torrents/siteInfo'
+ },
+ getSeederUsers: {
+ method: 'GET',
+ url: '/api/torrents/:torrentId/seederUsers',
+ params: {
+ torrentId: '@_id'
+ }
+ },
+ getLeecherUsers: {
+ method: 'GET',
+ url: '/api/torrents/:torrentId/leecherUsers',
+ params: {
+ torrentId: '@_id'
+ }
}
});
diff --git a/modules/torrents/client/views/view-torrent.client.view.html b/modules/torrents/client/views/view-torrent.client.view.html
index c5662c37..ff0364f5 100644
--- a/modules/torrents/client/views/view-torrent.client.view.html
+++ b/modules/torrents/client/views/view-torrent.client.view.html
@@ -708,7 +708,7 @@
{{ 'TORRENT_FINISHED_USERS' | translate}}:{{vm.torrentLocalInfo.torrent_finished}}
-
+
- {{ 'TORRENT_SEED_USERS' | translate}}:{{vm.torrentLocalInfo.torrent_seeds}}
@@ -725,15 +725,15 @@
{{ 'TABLE_FIELDS.STARTED' | translate}} |
{{ 'TABLE_FIELDS.ACTIVE' | translate}} |
{{ 'TABLE_FIELDS.CLIENT' | translate}} |
- {{ 'TABLE_FIELDS.CONNECTABLE' | translate}} |
+
-
|
-
+
|
{{item.peer_uploaded | bytes:2}} | {{item.peer_uspeed | bytes:2}}/s |
@@ -743,13 +743,19 @@
{{item.startedat | life}} |
{{item.last_announce_at | life}} |
{{item.user_agent}} |
- {{item.peer_connectable}} |
+
-
+
+
+
- {{ 'TORRENT_LEECHER_USERS' | translate}}:{{vm.torrentLocalInfo.torrent_leechers}}
@@ -766,15 +772,15 @@
{{ 'TABLE_FIELDS.STARTED' | translate}} |
{{ 'TABLE_FIELDS.ACTIVE' | translate}} |
{{ 'TABLE_FIELDS.CLIENT' | translate}} |
- {{ 'TABLE_FIELDS.CONNECTABLE' | translate}} |
+
-
|
-
+
|
{{item.peer_uploaded | bytes:2}} | {{item.peer_uspeed | bytes:2}}/s |
@@ -784,11 +790,17 @@
{{item.startedat | life}} |
{{item.last_announce_at | life}} |
{{item.user_agent}} |
- {{item.peer_connectable}} |
+
+
+
diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js
index c84fd0a9..7dc62fd7 100644
--- a/modules/torrents/server/controllers/torrents.server.controller.js
+++ b/modules/torrents/server/controllers/torrents.server.controller.js
@@ -1440,6 +1440,124 @@ exports.siteInfo = function (req, res) {
});
};
+/**
+ * getSeederUsers
+ * @param req
+ * @param res
+ */
+exports.getSeederUsers = function (req, res) {
+ var skip = 0;
+ var limit = 0;
+
+ if (req.query.skip !== undefined) {
+ skip = parseInt(req.query.skip, 10);
+ }
+ if (req.query.limit !== undefined) {
+ limit = parseInt(req.query.limit, 10);
+ }
+
+ var countSeederUsers = function (callback) {
+ Peer.count({
+ torrent: req.torrent._id,
+ peer_status: PEERSTATE_SEEDER
+ }, function (err, count) {
+ if (err) {
+ callback(err, null);
+ } else {
+ callback(null, count);
+ }
+ });
+
+ };
+
+ var findSeederUsers = function (callback) {
+ Peer.find({
+ torrent: req.torrent._id,
+ peer_status: PEERSTATE_SEEDER
+ })
+ .sort('-peer_uploaded')
+ .populate('user', 'username displayName profileImageURL isVip')
+ .skip(skip)
+ .limit(limit)
+ .exec(function (err, peers) {
+ if (err) {
+ return res.status(422).send({
+ message: errorHandler.getErrorMessage(err)
+ });
+ } else {
+ callback(null, peers);
+ }
+ });
+ };
+
+ async.parallel([countSeederUsers, findSeederUsers], function (err, results) {
+ if (err) {
+ return res.status(422).send(err);
+ } else {
+ res.json({rows: results[1], total: results[0]});
+ }
+ });
+};
+
+/**
+ * getLeecherUsers
+ * @param req
+ * @param res
+ */
+exports.getLeecherUsers = function (req, res) {
+ var skip = 0;
+ var limit = 0;
+
+ if (req.query.skip !== undefined) {
+ skip = parseInt(req.query.skip, 10);
+ }
+ if (req.query.limit !== undefined) {
+ limit = parseInt(req.query.limit, 10);
+ }
+
+ var countSeederUsers = function (callback) {
+ Peer.count({
+ torrent: req.torrent._id,
+ peer_status: PEERSTATE_LEECHER
+ }, function (err, count) {
+ if (err) {
+ callback(err, null);
+ } else {
+ callback(null, count);
+ }
+ });
+
+ };
+
+ var findSeederUsers = function (callback) {
+ Peer.find({
+ torrent: req.torrent._id,
+ peer_status: PEERSTATE_LEECHER
+ })
+ .sort('-peer_uploaded')
+ .populate('user', 'username displayName profileImageURL isVip')
+ .skip(skip)
+ .limit(limit)
+ .exec(function (err, peers) {
+ if (err) {
+ return res.status(422).send({
+ message: errorHandler.getErrorMessage(err)
+ });
+ } else {
+ callback(null, peers);
+ }
+ });
+ };
+
+ async.parallel([countSeederUsers, findSeederUsers], function (err, results) {
+ if (err) {
+ return res.status(422).send(err);
+ } else {
+ res.json({rows: results[1], total: results[0]});
+ }
+ });
+};
+
/**
* Torrent middleware
*/
@@ -1452,7 +1570,7 @@ exports.torrentByID = function (req, res, next, id) {
}
var findTorrents = function (callback) {
- Torrent.findById(id)
+ Torrent.find({_id: id}, {'_peers': 0})
.populate('user', 'username displayName profileImageURL isVip')
.populate('maker', 'name')
.populate('_thumbs.user', 'username displayName profileImageURL isVip uploaded downloaded')
@@ -1474,20 +1592,13 @@ exports.torrentByID = function (req, res, next, id) {
select: 'username displayName profileImageURL isVip'
}
})
- .populate({
- path: '_peers',
- populate: {
- path: 'user',
- select: 'username displayName profileImageURL isVip'
- }
- })
.exec(function (err, torrent) {
if (err) {
callback(err);
} else if (!torrent) {
callback(new Error('No torrent with that id has been found'));
}
- callback(null, torrent);
+ callback(null, torrent[0]);
});
};
diff --git a/modules/torrents/server/policies/torrents.server.policy.js b/modules/torrents/server/policies/torrents.server.policy.js
index 529aa61e..a922453f 100644
--- a/modules/torrents/server/policies/torrents.server.policy.js
+++ b/modules/torrents/server/policies/torrents.server.policy.js
@@ -29,6 +29,8 @@ exports.invokeRolesPolicies = function () {
{resources: '/api/torrents/:torrentId/thumbsUp', permissions: '*'},
{resources: '/api/torrents/:torrentId/rating', permissions: '*'},
{resources: '/api/torrents/:torrentId/scrape', permissions: '*'},
+ {resources: '/api/torrents/:torrentId/seederUsers', permissions: '*'},
+ {resources: '/api/torrents/:torrentId/leecherUsers', permissions: '*'},
{resources: '/api/torrents/:torrentId/toggleHnRStatus', permissions: '*'},
{resources: '/api/torrents/:torrentId/toggleVIPStatus', permissions: '*'},
{resources: '/api/torrents/:torrentId/set/saletype/:saleType', permissions: '*'},
@@ -65,6 +67,8 @@ exports.invokeRolesPolicies = function () {
{resources: '/api/torrents/:torrentId/thumbsUp', permissions: ['put']},
{resources: '/api/torrents/:torrentId/rating', permissions: ['put']},
{resources: '/api/torrents/:torrentId/scrape', permissions: ['get']},
+ {resources: '/api/torrents/:torrentId/seederUsers', permissions: ['get']},
+ {resources: '/api/torrents/:torrentId/leecherUsers', permissions: ['get']},
{resources: '/api/subtitles/:torrentId', permissions: ['post']},
{resources: '/api/subtitles/:torrentId/:subtitleId', permissions: ['get', 'delete']},
@@ -88,6 +92,8 @@ exports.invokeRolesPolicies = function () {
{resources: '/api/tvinfo/:tmdbid/:language', permissions: ['get']},
{resources: '/api/torrents', permissions: ['get']},
{resources: '/api/torrents/:torrentId', permissions: ['get']},
+ {resources: '/api/torrents/:torrentId/seederUsers', permissions: ['get']},
+ {resources: '/api/torrents/:torrentId/leecherUsers', permissions: ['get']},
{resources: '/api/torrents/siteInfo', permissions: ['get']}
]
}
diff --git a/modules/torrents/server/routes/torrents.server.routes.js b/modules/torrents/server/routes/torrents.server.routes.js
index 3ff37070..bda09a91 100644
--- a/modules/torrents/server/routes/torrents.server.routes.js
+++ b/modules/torrents/server/routes/torrents.server.routes.js
@@ -49,6 +49,12 @@ module.exports = function (app) {
app.route('/api/torrents/:torrentId/scrape').all(torrentsPolicy.isAllowed)
.get(torrents.scrape);
+ app.route('/api/torrents/:torrentId/seederUsers').all(torrentsPolicy.isAllowed)
+ .get(torrents.getSeederUsers);
+
+ app.route('/api/torrents/:torrentId/leecherUsers').all(torrentsPolicy.isAllowed)
+ .get(torrents.getLeecherUsers);
+
app.route('/api/torrents/:torrentId/toggleHnRStatus').all(torrentsPolicy.isAllowed)
.put(torrents.toggleHnRStatus);