fix(torrents): remove redundant string code

This commit is contained in:
OldHawk
2017-11-02 17:48:38 +08:00
parent fb48320b9c
commit cb9b77b832
4 changed files with 25 additions and 48 deletions

View File

@@ -69,13 +69,12 @@
* orderByVote
*/
vm.orderByVote = function () {
vm.sortSLF = undefined;
if (vm.sortVote === undefined) {
vm.sortVote = '-';
vm.sort = '-resource_detail_info.vote_average';
vm.sort = {'resource_detail_info.vote_average': -1};
} else if (vm.sortVote === '-') {
vm.sortVote = '+';
vm.sort = 'resource_detail_info.vote_average';
} else if (vm.sortVote === '+') {
vm.sortVote = undefined;
vm.sort = undefined;
}
@@ -87,33 +86,19 @@
* orderBySLF
*/
vm.orderBySLF = function () {
vm.sortVote = undefined;
if (vm.sortSLF === undefined) {
vm.sortSLF = '-S';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_S');
vm.sort = '-torrent_seeds';
vm.sort = {torrent_seeds: -1};
} else if (vm.sortSLF === '-S') {
vm.sortSLF = '+S';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_S');
vm.sort = 'torrent_seeds';
} else if (vm.sortSLF === '+S') {
vm.sortSLF = '-L';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_L');
vm.sort = '-torrent_leechers';
vm.sort = {torrent_leechers: -1};
} else if (vm.sortSLF === '-L') {
vm.sortSLF = '+L';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_L');
vm.sort = 'torrent_leechers';
} else if (vm.sortSLF === '+L') {
vm.sortSLF = '-F';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_F');
vm.sort = '-torrent_finished';
vm.sort = {torrent_finished: -1};
} else if (vm.sortSLF === '-F') {
vm.sortSLF = '+F';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_F');
vm.sort = 'torrent_finished';
} else if (vm.sortSLF === '+F') {
vm.sortSLF = undefined;
vm.sortSLFString = undefined;
vm.sort = undefined;
}

View File

@@ -131,7 +131,6 @@
ng-click="vm.orderByVote();"
uib-tooltip="{{ 'TABLE_FIELDS.TITLE_VOTES' | translate}}">{{ 'TABLE_FIELDS.VOTES' | translate}}</a>
<i class="fa fa-caret-down text-info" ng-if="vm.sortVote == '-'"></i>
<i class="fa fa-caret-up text-info" ng-if="vm.sortVote == '+'"></i>
</th>
<th class="text-center">{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SIZE' | translate}}</th>

View File

@@ -61,13 +61,12 @@
* orderByVote
*/
vm.orderByVote = function () {
vm.sortSLF = undefined;
if (vm.sortVote === undefined) {
vm.sortVote = '-';
vm.sort = '-resource_detail_info.vote_average';
vm.sort = {'resource_detail_info.vote_average': -1};
} else if (vm.sortVote === '-') {
vm.sortVote = '+';
vm.sort = 'resource_detail_info.vote_average';
} else if (vm.sortVote === '+') {
vm.sortVote = undefined;
vm.sort = undefined;
}
@@ -79,33 +78,19 @@
* orderBySLF
*/
vm.orderBySLF = function () {
vm.sortVote = undefined;
if (vm.sortSLF === undefined) {
vm.sortSLF = '-S';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_S');
vm.sort = '-torrent_seeds';
vm.sort = {torrent_seeds: -1};
} else if (vm.sortSLF === '-S') {
vm.sortSLF = '+S';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_S');
vm.sort = 'torrent_seeds';
} else if (vm.sortSLF === '+S') {
vm.sortSLF = '-L';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_L');
vm.sort = '-torrent_leechers';
vm.sort = {torrent_leechers: -1};
} else if (vm.sortSLF === '-L') {
vm.sortSLF = '+L';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_L');
vm.sort = 'torrent_leechers';
} else if (vm.sortSLF === '+L') {
vm.sortSLF = '-F';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_F');
vm.sort = '-torrent_finished';
vm.sort = {torrent_finished: -1};
} else if (vm.sortSLF === '-F') {
vm.sortSLF = '+F';
vm.sortSLFString = $translate.instant('TABLE_FIELDS.SORT_F');
vm.sort = 'torrent_finished';
} else if (vm.sortSLF === '+F') {
vm.sortSLF = undefined;
vm.sortSLFString = undefined;
vm.sort = undefined;
}
@@ -165,6 +150,15 @@
* @param callback
*/
vm.getVIPTorrents = function (p, callback) {
console.log({
skip: (p - 1) * vm.itemsPerPage,
limit: vm.itemsPerPage,
sort: vm.sort,
torrent_type: vm.vipTorrentType,
torrent_status: 'reviewed',
torrent_vip: true,
keys: vm.search
});
TorrentsService.get({
skip: (p - 1) * vm.itemsPerPage,
limit: vm.itemsPerPage,

View File

@@ -71,7 +71,6 @@
ng-click="vm.orderByVote();"
uib-tooltip="{{ 'TABLE_FIELDS.TITLE_VOTES' | translate}}">{{ 'TABLE_FIELDS.VOTES' | translate}}</a>
<i class="fa fa-caret-down text-info" ng-if="vm.sortVote == '-'"></i>
<i class="fa fa-caret-up text-info" ng-if="vm.sortVote == '+'"></i>
</th>
<th class="text-center">{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SIZE' | translate}}</th>