feat(admin): add warning torrents list of admin method

This commit is contained in:
OldHawk
2017-09-11 16:34:42 +08:00
parent cd07fa5f1e
commit 6cb8934a34
4 changed files with 37 additions and 0 deletions

View File

@@ -155,3 +155,29 @@ exports.getUserDownloading = function (req, res) {
}
});
};
/**
* list user warning torrents
* @param req
* @param res
*/
exports.getUserWarning = function (req, res) {
Complete.find({
user: req.model._id,
hnr_warning: true
}).populate({
path: 'torrent',
populate: {
path: 'user',
select: 'displayName profileImageURL'
}
}).exec(function (err, complets) {
if (err) {
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(complets);
}
});
};

View File

@@ -43,6 +43,7 @@ exports.invokeRolesPolicies = function () {
{resources: '/api/my/warning', permissions: '*'},
{resources: '/api/:userId/seeding', permissions: '*'},
{resources: '/api/:userId/downloading', permissions: '*'},
{resources: '/api/:userId/warning', permissions: '*'},
{resources: '/api/torrents/siteInfo', permissions: ['get']}
]
},

View File

@@ -24,4 +24,7 @@ module.exports = function (app) {
app.route('/api/:userId/downloading').all(torrentsPolicy.isAllowed)
.get(peers.getUserDownloading);
app.route('/api/:userId/warning').all(torrentsPolicy.isAllowed)
.get(peers.getUserWarning);
};

View File

@@ -186,6 +186,13 @@
<dt class="h-line">{{ 'STATUS_FIELD.FINISHED' | translate}}</dt>
<dd class="h-line">{{ vm.user.finished }}</span></dd>
<div ng-if="vm.user.hnr_warning>0">
<dt class="h-line">{{ 'STATUS_FIELD.HNY_WARNING' | translate}}</dt>
<dd class="h-line">
<span class="badge badge_danger">{{vm.user.hnr_warning}}</span>
</dd>
</div>
<li class="status-divider"></li>
</div>