add torrent reviewed status change function

This commit is contained in:
OldHawk
2017-05-08 13:47:24 +08:00
parent 71ae0ed8c9
commit b9e09cd368
11 changed files with 137 additions and 7 deletions

View File

@@ -122,6 +122,7 @@
MOVIE_PAGE_INFO_EMPTY: 'No movie founded, please change some new tags to research',
TAGS_SEARCH: 'Tags Search',
CA_KEYWORD: 'Keyword',
CA_TORRENT_STATUS: 'Torrent status',
PH_KEYWORD: 'Search keyword',
CLEAR_ALL_CONDITION: 'Clear All Condition',
MORE_TAGS: 'More Tags',
@@ -175,6 +176,7 @@
OTHER_TORRENT_LIST_TITLE: 'This resources has {{x}} other version torrent, you can view or download from here:',
ADMIN_BASIC_COMMAND: 'Basic Command',
ADMIN_BASIC_REVIEWED: 'Reviewed',
ADMIN_BASIC_DELETE: 'Delete torrent',
ADMIN_BASIC_TYPE_SET: 'Sale Type',
ADMIN_SALE_TYPE_SET: 'Sale Type Set',
@@ -187,6 +189,8 @@
TORRENT_DELETE_ERROR: 'Torrent delete failed',
TORRENT_SETSALETYPE_SUCCESSFULLY: 'Torrent sale type set successfully',
TORRENT_SETSALETYPE_ERROR: 'Torrent sale type set failed',
TORRENT_SETREVIEWED_SUCCESSFULLY: 'Torrent status reviewed set successfully',
TORRENT_SETREVIEWED_ERROR: 'Torrent status reviewed set failed',
//page text
PAGE_TEXT_FIRST: 'First',

View File

@@ -122,6 +122,7 @@
MOVIE_PAGE_INFO_EMPTY: '没有找到信息,请更换标签重新检索',
TAGS_SEARCH: '标签检索',
CA_KEYWORD: '关键字',
CA_TORRENT_STATUS: '种子状态',
PH_KEYWORD: '搜索关键字',
CLEAR_ALL_CONDITION: '清空所有条件',
MORE_TAGS: '显示更多标签',
@@ -175,6 +176,7 @@
OTHER_TORRENT_LIST_TITLE: '该资源有 {{x}} 个其它版本的种子, 你可以从下面查看或直接下载:',
ADMIN_BASIC_COMMAND: '操作命令',
ADMIN_BASIC_REVIEWED: '通过审核',
ADMIN_BASIC_DELETE: '删除种子',
ADMIN_BASIC_TYPE_SET: '设置促销',
ADMIN_SALE_TYPE_SET: '种子促销类型',
@@ -187,6 +189,8 @@
TORRENT_DELETE_ERROR: '种子信息删除失败',
TORRENT_SETSALETYPE_SUCCESSFULLY: '种子促销类型设置成功',
TORRENT_SETSALETYPE_ERROR: '种子促销类型设置失败',
TORRENT_SETREVIEWED_SUCCESSFULLY: '种子审核状态设置成功',
TORRENT_SETREVIEWED_ERROR: '种子审核状态设置失败',
//page text
PAGE_TEXT_FIRST: '首页',

View File

@@ -1,3 +1,7 @@
.margin-top-2 {
margin-top: 2px;
}
.margin-top-10 {
margin-top: 10px;
}

View File

@@ -569,4 +569,9 @@
border-top: solid 1px lighten(@gray-light, 35%);
margin-top: 5px;
padding-top: 5px;
}
.upload-by {
color: #888;
font-size: 12px;
}

View File

@@ -22,6 +22,7 @@
vm.searchKey = '';
vm.releaseYear = undefined;
vm.topItems = 6;
vm.torrentStatus = 'reviewed';
/**
* If user is not signed in then redirect back home
@@ -72,6 +73,25 @@
});
};
/**
* onTorrentStatusClicked
* @param event
* @param s: status value
*/
vm.onTorrentStatusClicked = function (event, s) {
var e = angular.element(event.currentTarget);
//if (e.hasClass('btn-success')) {
// return;
//} else {
// e.addClass('btn-success').removeClass('btn-default').siblings().removeClass('btn-success').addClass('btn-default');
// vm.torrentStatus = s;
//}
vm.torrentStatus = s;
e.blur();
vm.torrentBuildPager();
};
/**
* onRadioTagClicked
* @param event
@@ -132,7 +152,7 @@
skip: (p - 1) * vm.torrentItemsPerPage,
limit: vm.torrentItemsPerPage,
keys: vm.searchKey.trim(),
torrent_status: 'reviewed',
torrent_status: vm.torrentStatus,
torrent_type: 'movie',
torrent_release: vm.releaseYear,
torrent_tags: vm.searchTags
@@ -334,5 +354,26 @@
});
});
};
/**
* reviewedTorrentStatus
* @param item
*/
vm.reviewedTorrentStatus = function (item) {
TorrentsService.setReviewedStatus({
_torrentId: item._id
}, function (res) {
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_SETREVIEWED_SUCCESSFULLY')
});
vm.torrentPagedItems[vm.torrentPagedItems.indexOf(item)] = res;
}, function (res) {
Notification.error({
message: res.data.message,
title: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TORRENT_SETREVIEWED_ERROR')
});
});
};
}
}());

View File

@@ -30,6 +30,13 @@
torrentId: '@_torrentId',
saleType: '@_saleType'
}
},
setReviewedStatus: {
method: 'PUT',
url: '/api/torrents/:torrentId/set/reviewed',
params: {
torrentId: '@_torrentId'
}
}
});

View File

@@ -30,6 +30,31 @@
</div>
</dd>
<dt class="h-line">{{ 'CA_TORRENT_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="btn-group btn-group-xs" role="group">
<button id="torrent_status_reviewed"
class="btn btn-xs btn-tag" value="reviewed"
ng-class="{'btn-success': vm.torrentStatus == 'reviewed', 'btn-default': vm.torrentStatus != 'reviewed'}"
ng-click="vm.onTorrentStatusClicked($event, 'reviewed')">
REVIEWED
</button>
<button id="torrent_status_new"
class="btn btn-xs btn-tag" value="new"
ng-class="{'btn-success': vm.torrentStatus == 'new', 'btn-default': vm.torrentStatus != 'new'}"
ng-click="vm.onTorrentStatusClicked($event, 'new')">
NEW
</button>
<button id="torrent_status_all"
class="btn btn-xs btn-tag" value="all"
ng-class="{'btn-success': vm.torrentStatus == 'all', 'btn-default': vm.torrentStatus != 'all'}"
ng-click="vm.onTorrentStatusClicked($event, 'all')">
ALL
</button>
</span>
</div>
</dd>
<div class="more-tags panel-collapsed" style="display: none;">
<div ng-repeat="item in vm.resourcesTags.movie.radio">
<dt class="h-line">{{ 'RESOURCESTAGS.'+item.name+'.SELF' | translate}}</dt>
@@ -94,6 +119,7 @@
<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="upload-by" ng-show="item.user.displayName"> (By: {{item.user.displayName}})</span>
<span class="label label-download text-uppercase"
title="{{ 'TITLE_ALT.DOWNLOAD_TORRENT' | translate}}"
ng-click="vm.downloadTorrent(item._id); $event.stopPropagation();">
@@ -115,6 +141,7 @@
</span>
<span class="label label-sale" ng-if="item.isSaling"
title="{{vm.getSaleTypeDesc(item);}} | {{ 'SALE_EXPIRES_TIME' | translate}}: {{item.torrent_sale_expires | date: 'MM-dd HH:mm'}}"
ng-click="$event.stopPropagation();"
ng-class="{'label-default': !item.isSaling, 'label-success': item.isSaling}">
{{item.torrent_sale_status}} {{item.torrent_sale_expires | unlife}}
</span>
@@ -152,14 +179,21 @@
</td>
<td class="col-md-1 td-v-middle text-center">
<div>
<button class="btn btn-md btn-default btn-block" ng-click="vm.deleteTorrent(item); $event.stopPropagation();">
<button class="btn btn-xs btn-default btn-block"
ng-show="item.torrent_status == 'new'"
ng-click="vm.reviewedTorrentStatus(item); $event.stopPropagation();">
{{ 'ADMIN_BASIC_REVIEWED' | translate}}
</button>
</div>
<div class="margin-top-2">
<button class="btn btn-xs btn-default btn-block" ng-click="vm.deleteTorrent(item); $event.stopPropagation();">
{{ 'ADMIN_BASIC_DELETE' | translate}}
</button>
</div>
<div class="margin-top-10">
<div class="margin-top-2">
<div class="admin-tools-btn-list btn-group" uib-dropdown dropdown-append-to-body>
<button id="btn-append-to-body" type="button"
class="btn btn-md btn-default btn-block"
class="btn btn-xs btn-default btn-block"
ng-click="$event.stopPropagation();"
uib-dropdown-toggle>
{{'ADMIN_BASIC_TYPE_SET' | translate }} <span class="caret"></span>
@@ -168,7 +202,7 @@
aria-labelledby="btn-append-to-body">
<li role="menuitem" ng-repeat="st in vm.torrentSalesType.value"
ng-class="{'active': item.torrent_sale_status == st.name, 'divider-item': $index != 0 && $index % 5 == 0}">
<a href="#" ng-click="vm.setSaleType(item, st);">{{st.name}}</a>
<a href="#" class="small" ng-click="vm.setSaleType(item, st);">{{st.name}}</a>
</li>
</ul>
</div>

View File

@@ -150,6 +150,7 @@
</span>
<span class="label label-sale" ng-if="item.isSaling"
title="{{vm.getSaleTypeDesc(item);}} | {{ 'SALE_EXPIRES_TIME' | translate}}: {{item.torrent_sale_expires | date: 'MM-dd HH:mm'}}"
ng-click="$event.stopPropagation();"
ng-class="{'label-default': !item.isSaling, 'label-success': item.isSaling}">
{{item.torrent_sale_status}} {{item.torrent_sale_expires | unlife}}
</span>

View File

@@ -507,6 +507,7 @@
</span>
<span class="label label-sale" ng-if="item.isSaling"
title="{{vm.getSaleTypeDesc(item);}} | {{ 'SALE_EXPIRES_TIME' | translate}}: {{item.torrent_sale_expires | date: 'MM-dd HH:mm'}}"
ng-click="$event.stopPropagation();"
ng-class="{'label-default': !item.isSaling, 'label-success': item.isSaling}">
{{item.torrent_sale_status}} {{item.torrent_sale_expires | unlife}}
</span>

View File

@@ -327,6 +327,28 @@ exports.setSaleType = function (req, res) {
}
};
/**
* setReviewedStatus
* @param req
* @param res
* @returns {*}
*/
exports.setReviewedStatus = function (req, res) {
var torrent = req.torrent;
torrent.torrent_status = 'reviewed';
torrent.save(function (err) {
if (err) {
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(torrent);
}
});
};
/**
* delete a torrent
* @param req
@@ -400,8 +422,12 @@ exports.list = function (req, res) {
}
var condition = {};
condition.torrent_status = status;
condition.torrent_type = stype;
if (status !== 'all') {
condition.torrent_status = status;
}
if (stype !== 'all') {
condition.torrent_type = stype;
}
if (tagsA.length > 0) {
condition.torrent_tags = {$all: tagsA};

View File

@@ -28,5 +28,8 @@ module.exports = function (app) {
app.route('/api/torrents/:torrentId/set/saletype/:saleType')
.put(torrents.setSaleType);
app.route('/api/torrents/:torrentId/set/reviewed')
.put(torrents.setReviewedStatus);
app.param('torrentId', torrents.torrentByID);
};