mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-13 02:42:23 +01:00
107 lines
3.4 KiB
JavaScript
107 lines
3.4 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
angular
|
|
.module('users')
|
|
.controller('UploadedController', UploadedController);
|
|
|
|
UploadedController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService',
|
|
'MeanTorrentConfig', '$window', '$filter', 'DownloadService', 'DebugConsoleService', 'TorrentGetInfoServices', 'ResourcesTagsServices'];
|
|
|
|
function UploadedController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, MeanTorrentConfig,
|
|
$window, $filter, DownloadService, mtDebug, TorrentGetInfoServices, ResourcesTagsServices) {
|
|
var vm = this;
|
|
vm.DLS = DownloadService;
|
|
vm.TGI = TorrentGetInfoServices;
|
|
vm.user = Authentication.user;
|
|
vm.RTS = ResourcesTagsServices;
|
|
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
|
|
|
|
vm.searchTags = [];
|
|
vm.releaseYear = undefined;
|
|
vm.filterType = undefined;
|
|
vm.filterHnR = false;
|
|
vm.filterTop = false;
|
|
vm.filterUnique = false;
|
|
vm.filterSale = false;
|
|
vm.torrentRLevel = 'level0';
|
|
vm.torrentType = 'aggregate';
|
|
|
|
/**
|
|
* buildPager
|
|
*/
|
|
vm.buildPager = function () {
|
|
vm.pagedItems = [];
|
|
vm.itemsPerPage = vm.itemsPerPageConfig.torrentsPerPage;
|
|
vm.currentPage = 1;
|
|
vm.figureOutItemsToDisplay();
|
|
};
|
|
|
|
/**
|
|
* figureOutItemsToDisplay
|
|
*/
|
|
vm.figureOutItemsToDisplay = function (callback) {
|
|
vm.tooltipMsg = 'VIP.VIP_TORRENTS_IS_LOADING';
|
|
vm.getUploadedTorrent(vm.currentPage, function (items) {
|
|
vm.filterLength = items.total;
|
|
vm.pagedItems = items.rows;
|
|
|
|
if (vm.pagedItems.length === 0) {
|
|
vm.tooltipMsg = 'VIP.VIP_TORRENTS_IS_EMPTY';
|
|
} else {
|
|
vm.tooltipMsg = undefined;
|
|
}
|
|
if (callback) callback();
|
|
});
|
|
};
|
|
|
|
/**
|
|
* pageChanged
|
|
*/
|
|
vm.pageChanged = function () {
|
|
var element = angular.element('#top_of_torrent_list');
|
|
|
|
$('.tb-v-middle').fadeTo(100, 0.01, function () {
|
|
vm.figureOutItemsToDisplay(function () {
|
|
$timeout(function () {
|
|
$('.tb-v-middle').fadeTo(400, 1, function () {
|
|
//window.scrollTo(0, element[0].offsetTop - 60);
|
|
$('html,body').animate({scrollTop: element[0].offsetTop - 60}, 200);
|
|
});
|
|
}, 100);
|
|
});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* getUploadedTorrent
|
|
* @param p
|
|
* @param callback
|
|
*/
|
|
vm.getUploadedTorrent = function (p, callback) {
|
|
TorrentsService.get({
|
|
skip: (p - 1) * vm.itemsPerPage,
|
|
limit: vm.itemsPerPage,
|
|
userid: vm.user._id,
|
|
torrent_type: (vm.filterType && vm.filterType !== 'aggregate') ? vm.filterType : (vm.torrentType === 'aggregate' ? 'all' : vm.torrentType),
|
|
torrent_status: 'all',
|
|
torrent_vip: vm.filterVIP ? vm.filterVIP : undefined,
|
|
torrent_rlevel: vm.torrentRLevel,
|
|
torrent_release: vm.releaseYear,
|
|
torrent_tags: vm.searchTags,
|
|
torrent_hnr: vm.filterHnR,
|
|
torrent_sale: vm.filterSale,
|
|
isTop: vm.filterTop,
|
|
isUnique: vm.filterUnique
|
|
}, function (data) {
|
|
mtDebug.info(data);
|
|
callback(data);
|
|
}, function (err) {
|
|
Notification.error({
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('UPLOADED_LIST_ERROR')
|
|
});
|
|
});
|
|
};
|
|
}
|
|
}());
|