Files
meanTorrent/modules/users/client/controllers/admin/user-uploaded.client.controller.js
OldHawk c93ff903bf fix(vip): Reorganize vip torrents show/hide
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
2017-12-07 11:45:58 +08:00

84 lines
2.6 KiB
JavaScript

(function () {
'use strict';
angular
.module('users')
.controller('UserUploadedController', UserUploadedController);
UserUploadedController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', '$window', '$filter', 'DownloadService', 'DebugConsoleService', 'TorrentGetInfoServices', 'ResourcesTagsServices'];
function UserUploadedController($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.userUploadedList, {
$: 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);
});
});
};
/**
* getUserUploadedTorrent
*/
vm.getUserUploadedTorrent = function () {
TorrentsService.get({
userid: $state.params.userId,
torrent_type: 'all',
torrent_status: 'all'
}, function (items) {
vm.userUploadedList = items.rows;
vm.buildPager();
}, function (err) {
Notification.error({
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('UPLOADED_LIST_ERROR')
});
});
};
}
}());