fext(collections): set collection recommend lever(list order)

This commit is contained in:
OldHawk
2017-10-25 10:25:20 +08:00
parent 48d25eea72
commit 3975f6ac08
10 changed files with 91 additions and 3 deletions

View File

@@ -254,6 +254,7 @@ module.exports = {
AdminTorrentDelete: {name: 'AdminTorrentDelete', enable: true},
AdminTorrentSetSaleType: {name: 'AdminTorrentSetSaleType', enable: true},
AdminTorrentSetRecommendLevel: {name: 'AdminTorrentSetRecommendLevel', enable: true},
AdminCollectionSetRecommendLevel: {name: 'AdminCollectionSetRecommendLevel', enable: true},
AdminTorrentSetReviewedStatus: {name: 'AdminTorrentSetReviewedStatus', enable: true},
OperCreateMakerGroup: {name: 'OperCreateMakerGroup', enable: true},
OperCreateCollection: {name: 'OperCreateCollection', enable: true},

View File

@@ -18,6 +18,7 @@
vm.user = Authentication.user;
vm.RTS = ResourcesTagsServices;
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
vm.torrentRLevels = MeanTorrentConfig.meanTorrentConfig.torrentRecommendLevel;
vm.searchTags = [];
@@ -151,5 +152,20 @@
});
};
/**
* vm.setRecommendLevel
*/
vm.setRecommendLevel = function (item, rl) {
CollectionsService.setRecommendLevel({
_id: item._id,
rlevel: rl.value
}, function (res) {
vm.collection = res;
NotifycationService.showSuccessNotify('COLLECTIONS.SETRLEVEL_SUCCESSFULLY');
}, function (res) {
NotifycationService.showSuccessNotify('COLLECTIONS.SETRLEVEL_ERROR');
});
};
}
}());

View File

@@ -139,6 +139,7 @@
text-shadow: 0 0 0.1em #000,-0 -0 0.1em #000;
}
.item-data {
text-shadow: 0 0 0.1em #000,-0 -0 0.1em #000;
.fa {
color: @mt-base-color !important;
}

View File

@@ -45,7 +45,16 @@
collectionId: '@collectionId',
torrentId: '@torrentId'
}
},
setRecommendLevel: {
method: 'PUT',
url: '/api/collections/:collectionId/set/recommendlevel/:rlevel',
params: {
collectionId: '@_id',
rlevel: '@rlevel'
}
}
});
return collection;

View File

@@ -42,6 +42,25 @@
ng-if="vm.user.isOper" ng-click="vm.beginRemoveCollection(vm.collection)">
{{'COLLECTIONS.BTN_REMOVE_COLLECTION' | translate}}
</button>
<div class="btn-group width-100" uib-dropdown dropdown-append-to-body>
<button id="btn-append-to-body" type="button"
class="btn btn-block"
mouse-enter-toggle-class="btn-default" base-class="btn-mt-o"
ng-click="$event.stopPropagation();"
uib-dropdown-toggle>
{{'ADMIN_BASIC_RLEVEL_SET' | translate }} <span class="caret"></span>
</button>
<ul class="dropdown-menu-left" uib-dropdown-menu role="menu"
aria-labelledby="btn-append-to-body">
<li role="menuitem" ng-repeat="l in vm.torrentRLevels.value"
ng-class="{'active': vm.collection.recommend_level == l.value}">
<a href="#"
ng-click="vm.setRecommendLevel(vm.collection, l);">{{ 'TORRENT_RECOMMEND_LEVEL_ITEM.' + l.name | translate}}</a>
</li>
</ul>
</div>
</div>
</div>
</div>

View File

@@ -172,6 +172,41 @@ exports.removeFromCollection = function (req, res) {
});
};
/**
* setRecommendLevel
* @param req
* @param res
*/
exports.setRecommendLevel = function (req, res) {
var coll = req.collection;
if (req.params.rlevel) {
coll.recommend_level = req.params.rlevel;
coll.ordered_at = Date.now();
coll.save(function (err) {
if (err) {
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(coll);
//create trace log
traceLogCreate(req, traceConfig.action.AdminCollectionSetRecommendLevel, {
coll: coll._id,
recommended: req.params.rlevel
});
}
});
} else {
return res.status(422).send({
message: 'PARAMS_RLEVEL_ERROR'
});
}
};
/**
* Delete an collection
*/

View File

@@ -22,7 +22,8 @@ exports.invokeRolesPolicies = function () {
{resources: '/api/collections', permissions: '*'},
{resources: '/api/collections/:collectionId', permissions: '*'},
{resources: '/api/collections/:collectionId/insert/:torrentId', permissions: '*'},
{resources: '/api/collections/:collectionId/remove/:torrentId', permissions: '*'}
{resources: '/api/collections/:collectionId/remove/:torrentId', permissions: '*'},
{resources: '/api/collections/:collectionId/set/recommendlevel/:rlevel', permissions: '*'}
]
},
{

View File

@@ -26,6 +26,8 @@ module.exports = function (app) {
.put(collections.insertIntoCollection);
app.route('/api/collections/:collectionId/remove/:torrentId').all(collectionsPolicy.isAllowed)
.put(collections.removeFromCollection);
app.route('/api/collections/:collectionId/set/recommendlevel/:rlevel').all(collectionsPolicy.isAllowed)
.put(collections.setRecommendLevel);
app.param('collectionId', collections.collectionByID);
};

View File

@@ -525,7 +525,9 @@
BTN_REMOVE_COLLECTION: 'Remove Collection',
DELETE_CONFIRM_BODY_TEXT: 'Are you sure want to delete this collection?',
DELETE_SUCCESSFULLY: 'Movie collection deleted successfully',
DELETE_FAILED: 'Movie collection deleted failed'
DELETE_FAILED: 'Movie collection deleted failed',
SETRLEVEL_SUCCESSFULLY: 'Set collection recommend level successfully',
SETRLEVEL_ERROR: 'Set collection recommend level faild'
},
//user settings

View File

@@ -525,7 +525,9 @@
BTN_REMOVE_COLLECTION: '删除系列',
DELETE_CONFIRM_BODY_TEXT: '您确定要删除这个电影系列?',
DELETE_SUCCESSFULLY: '电影系列删除成功',
DELETE_FAILED: '电影系列删除失败'
DELETE_FAILED: '电影系列删除失败',
SETRLEVEL_SUCCESSFULLY: '修改系列的推荐级别成功',
SETRLEVEL_ERROR: '修改系列的推荐级别失败'
},
//user settings