mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-04 12:18:22 +02:00
Merge branch 'master' of https://github.com/taobataoma/meanTorrent
* 'master' of https://github.com/taobataoma/meanTorrent: feat(torrents): show torrent joined collections and albums in detail page
This commit is contained in:
@@ -77,8 +77,16 @@
|
||||
albumId: '@_id'
|
||||
},
|
||||
interceptor: {response: removeCache}
|
||||
},
|
||||
getTorrentAlbums: {
|
||||
method: 'GET',
|
||||
url: '/api/albums/torrent/:torrentId',
|
||||
isArray: true,
|
||||
params: {
|
||||
torrentId: '@torrentId'
|
||||
},
|
||||
cache: albumsCache
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return album;
|
||||
|
||||
@@ -249,6 +249,21 @@ exports.list = function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getTorrentAlbums
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.getTorrentAlbums = function (req, res) {
|
||||
Album.find({
|
||||
torrents: {$in: [req.torrent._id]}
|
||||
}, function (err, albums) {
|
||||
if (albums) {
|
||||
res.json(albums);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Album middleware
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ exports.invokeRolesPolicies = function () {
|
||||
roles: ['admin', 'oper'],
|
||||
allows: [
|
||||
{resources: '/api/albums', permissions: '*'},
|
||||
{resources: '/api/albums/torrent/:torrentId', permissions: '*'},
|
||||
{resources: '/api/albums/:albumId', permissions: '*'},
|
||||
{resources: '/api/albums/:albumId/insert/:torrentId', permissions: '*'},
|
||||
{resources: '/api/albums/:albumId/remove/:torrentId', permissions: '*'},
|
||||
@@ -29,6 +30,7 @@ exports.invokeRolesPolicies = function () {
|
||||
roles: ['user'],
|
||||
allows: [
|
||||
{resources: '/api/albums', permissions: ['get']},
|
||||
{resources: '/api/albums/torrent/:torrentId', permissions: ['get']},
|
||||
{resources: '/api/albums/:albumId', permissions: ['get']}
|
||||
]
|
||||
},
|
||||
@@ -36,6 +38,7 @@ exports.invokeRolesPolicies = function () {
|
||||
roles: ['guest'],
|
||||
allows: [
|
||||
{resources: '/api/albums', permissions: ['get']},
|
||||
{resources: '/api/albums/torrent/:torrentId', permissions: ['get']},
|
||||
{resources: '/api/albums/:albumId', permissions: ['get']}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ module.exports = function (app) {
|
||||
.get(albums.list)
|
||||
.post(albums.create);
|
||||
|
||||
app.route('/api/albums/torrent/:torrentId').all(albumsPolicy.isAllowed)
|
||||
.get(albums.getTorrentAlbums);
|
||||
|
||||
app.route('/api/albums/:albumId').all(albumsPolicy.isAllowed)
|
||||
.get(albums.read)
|
||||
.put(albums.update)
|
||||
|
||||
@@ -84,8 +84,16 @@
|
||||
rlevel: '@rlevel'
|
||||
},
|
||||
interceptor: {response: removeCache}
|
||||
},
|
||||
getTorrentCollections: {
|
||||
method: 'GET',
|
||||
url: '/api/collections/torrent/:torrentId',
|
||||
isArray: true,
|
||||
params: {
|
||||
torrentId: '@torrentId'
|
||||
},
|
||||
cache: collectionsCache
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return collection;
|
||||
|
||||
@@ -12,6 +12,7 @@ var path = require('path'),
|
||||
Maker = mongoose.model('Maker'),
|
||||
Torrent = mongoose.model('Torrent'),
|
||||
Collection = mongoose.model('Collection'),
|
||||
objectId = require('mongodb').ObjectId,
|
||||
async = require('async'),
|
||||
tmdb = require('moviedb')(config.meanTorrentConfig.tmdbConfig.key),
|
||||
traceLogCreate = require(path.resolve('./config/lib/tracelog')).create,
|
||||
@@ -301,6 +302,21 @@ exports.list = function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getTorrentCollections
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.getTorrentCollections = function (req, res) {
|
||||
Collection.find({
|
||||
torrents: {$in: [req.torrent._id]}
|
||||
}, function (err, coll) {
|
||||
if (coll) {
|
||||
res.json(coll);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Collection middleware
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ exports.invokeRolesPolicies = function () {
|
||||
{resources: '/api/search/collection/:language', permissions: '*'},
|
||||
{resources: '/api/collectionInfo/:id/:language', permissions: '*'},
|
||||
{resources: '/api/collections', permissions: '*'},
|
||||
{resources: '/api/collections/torrent/:torrentId', permissions: '*'},
|
||||
{resources: '/api/collections/:collectionId', permissions: '*'},
|
||||
{resources: '/api/collections/:collectionId/insert/:torrentId', permissions: '*'},
|
||||
{resources: '/api/collections/:collectionId/remove/:torrentId', permissions: '*'},
|
||||
@@ -32,6 +33,7 @@ exports.invokeRolesPolicies = function () {
|
||||
{resources: '/api/search/collection/:language', permissions: ['get']},
|
||||
{resources: '/api/collectionInfo/:id/:language', permissions: ['get']},
|
||||
{resources: '/api/collections', permissions: ['get']},
|
||||
{resources: '/api/collections/torrent/:torrentId', permissions: ['get']},
|
||||
{resources: '/api/collections/:collectionId', permissions: ['get']}
|
||||
]
|
||||
},
|
||||
@@ -41,6 +43,7 @@ exports.invokeRolesPolicies = function () {
|
||||
{resources: '/api/search/collection/:language', permissions: ['get']},
|
||||
{resources: '/api/collectionInfo/:id/:language', permissions: ['get']},
|
||||
{resources: '/api/collections', permissions: ['get']},
|
||||
{resources: '/api/collections/torrent/:torrentId', permissions: ['get']},
|
||||
{resources: '/api/collections/:collectionId', permissions: ['get']}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ module.exports = function (app) {
|
||||
.get(collections.list)
|
||||
.post(collections.create);
|
||||
|
||||
app.route('/api/collections/torrent/:torrentId').all(collectionsPolicy.isAllowed)
|
||||
.get(collections.getTorrentCollections);
|
||||
|
||||
app.route('/api/collections/:collectionId').all(collectionsPolicy.isAllowed)
|
||||
.get(collections.read)
|
||||
.put(collections.update)
|
||||
|
||||
@@ -606,6 +606,8 @@
|
||||
ENTER_RESOURCE_TITLE: '• Please enter the resource main title and sub title',
|
||||
RESOURCE_TITLE: 'resource main title',
|
||||
RESOURCE_SUB_TITLE: 'resource sub title',
|
||||
JOINED_COLLECTIONS: 'Joined collections',
|
||||
JOINED_ALBUMS: 'Joined albums',
|
||||
SELECT_RESOURCE_IMAGE: '• Please select resource cover image',
|
||||
ENTER_RESOURCE_DETAIL_INFO: '• Please enter the resource detail info',
|
||||
|
||||
|
||||
@@ -606,6 +606,8 @@
|
||||
ENTER_RESOURCE_TITLE: '• 請輸入資源標題與描述',
|
||||
RESOURCE_TITLE: '資源標題',
|
||||
RESOURCE_SUB_TITLE: '資源副標題',
|
||||
JOINED_COLLECTIONS: '所屬系列',
|
||||
JOINED_ALBUMS: '所屬專輯',
|
||||
SELECT_RESOURCE_IMAGE: '• 請選擇資源封面圖片',
|
||||
ENTER_RESOURCE_DETAIL_INFO: '• 請輸入資源詳細資訊',
|
||||
|
||||
|
||||
@@ -606,6 +606,8 @@
|
||||
ENTER_RESOURCE_TITLE: '• 请输入资源主副标题',
|
||||
RESOURCE_TITLE: '资源主标题',
|
||||
RESOURCE_SUB_TITLE: '资源副标题',
|
||||
JOINED_COLLECTIONS: '所属系列',
|
||||
JOINED_ALBUMS: '所属专辑',
|
||||
SELECT_RESOURCE_IMAGE: '• 请选择资源封面图片',
|
||||
ENTER_RESOURCE_DETAIL_INFO: '• 请输入资源详细信息',
|
||||
|
||||
|
||||
@@ -176,12 +176,42 @@
|
||||
$('.backdrop').css('backgroundImage', 'url("' + vm.TGI.getTorrentBackdropImage(vm.torrentLocalInfo) + '")');
|
||||
|
||||
vm.rating_vote = res.resource_detail_info.vote_average;
|
||||
|
||||
vm.getTorrentCollectionsInfo($stateParams.torrentId);
|
||||
vm.getTorrentAlbumsInfo($stateParams.torrentId);
|
||||
|
||||
vm.initTabLists();
|
||||
vm.commentBuildPager();
|
||||
vm.buildPeersPager();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getTorrentCollectionsInfo
|
||||
* @param tid
|
||||
*/
|
||||
vm.getTorrentCollectionsInfo = function (tid) {
|
||||
CollectionsService.getTorrentCollections({
|
||||
torrentId: tid
|
||||
}, function (res) {
|
||||
console.log(res);
|
||||
vm.torrentCollectionsInfo = res;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getTorrentAlbumsInfo
|
||||
* @param tid
|
||||
*/
|
||||
vm.getTorrentAlbumsInfo = function (tid) {
|
||||
AlbumsService.getTorrentAlbums({
|
||||
torrentId: tid
|
||||
}, function (res) {
|
||||
console.log(res);
|
||||
vm.torrentAlbumsInfo = res;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* reviewedTorrentStatus
|
||||
* @param item
|
||||
|
||||
@@ -555,3 +555,9 @@ pre.prettyprint {
|
||||
|
||||
/* csslint ignore:end */
|
||||
//popup overlay end -------------------------------------------
|
||||
|
||||
.joined-coll-list,
|
||||
.joined-album-list {
|
||||
font-weight: 500;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -732,6 +732,30 @@
|
||||
callback="onTorrentSubTitleEdited"></span>
|
||||
</dd>
|
||||
|
||||
<div ng-if="vm.torrentCollectionsInfo.length>0">
|
||||
<dt class="h-line">{{ 'JOINED_COLLECTIONS' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<ul class="list-unstyled joined-coll-list">
|
||||
<li ng-repeat="coll in vm.torrentCollectionsInfo">
|
||||
<i class="fa fa-sitemap text-mt" aria-hidden="true"></i>
|
||||
<a ui-sref="collections.view({collectionId: m._id})">{{coll.name}} ({{coll.torrents.length}})</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.torrentAlbumsInfo.length>0">
|
||||
<dt class="h-line">{{ 'JOINED_ALBUMS' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<ul class="list-unstyled joined-album-list">
|
||||
<li ng-repeat="ab in vm.torrentAlbumsInfo">
|
||||
<i class="fab fa-readme text-mt" aria-hidden="true"></i>
|
||||
<a ui-sref="albums.view({albumId: ab._id})">{{ab.name}} ({{ab.torrents.length}})</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<dt class="h-line">{{ 'TABLE_FIELDS.PUBLISHER' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<span ng-if="!vm.torrentLocalInfo.isAnonymous" user-info="vm.torrentLocalInfo.user" info-name></span>
|
||||
|
||||
Reference in New Issue
Block a user