mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-14 03:12:21 +01:00
show in user status uploaded torrents list show in uploaded list at admin user page show in all newest torrents list at admin manage page
85 lines
2.6 KiB
JavaScript
85 lines
2.6 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 = [];
|
|
|
|
/**
|
|
* buildPager
|
|
*/
|
|
vm.buildPager = function () {
|
|
vm.pagedItems = [];
|
|
vm.itemsPerPage = vm.itemsPerPageConfig.torrentsPerPage;
|
|
vm.currentPage = 1;
|
|
vm.figureOutItemsToDisplay();
|
|
};
|
|
|
|
/**
|
|
* figureOutItemsToDisplay
|
|
*/
|
|
vm.figureOutItemsToDisplay = function (callback) {
|
|
vm.filteredItems = $filter('filter')(vm.uploadedList, {
|
|
$: vm.search
|
|
});
|
|
vm.filterLength = vm.filteredItems.length;
|
|
var begin = ((vm.currentPage - 1) * vm.itemsPerPage);
|
|
var end = begin + vm.itemsPerPage;
|
|
vm.pagedItems = vm.filteredItems.slice(begin, end);
|
|
|
|
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
|
|
*/
|
|
vm.getUploadedTorrent = function () {
|
|
TorrentsService.get({
|
|
userid: vm.user._id,
|
|
torrent_type: 'all',
|
|
torrent_status: 'all'
|
|
}, function (items) {
|
|
vm.uploadedList = items.rows;
|
|
mtDebug.info(items);
|
|
vm.buildPager();
|
|
}, function (err) {
|
|
Notification.error({
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('UPLOADED_LIST_ERROR')
|
|
});
|
|
});
|
|
};
|
|
}
|
|
}());
|