mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-15 03:42:23 +01:00
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
angular
|
|
.module('core')
|
|
.controller('HomeController', HomeController);
|
|
|
|
HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig', 'getStorageLangService'];
|
|
|
|
function HomeController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService) {
|
|
var vm = this;
|
|
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
|
|
vm.movieTopList = undefined;
|
|
|
|
vm.info_is_ready = false;
|
|
|
|
vm.COMING = 'coming soon...';
|
|
|
|
/**
|
|
* If user is not signed in then redirect back signin
|
|
*/
|
|
if (!Authentication.user) {
|
|
$state.go('authentication.signin');
|
|
}
|
|
|
|
/**
|
|
* initInfo
|
|
*/
|
|
vm.initInfo = function () {
|
|
TorrentsService.getTMDBInfo({
|
|
tmdbid: '329865',
|
|
language: getStorageLangService.getLang()
|
|
}, function (res) {
|
|
Notification.success({
|
|
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TMDB_ID_OK')
|
|
});
|
|
|
|
vm.movieinfo = res;
|
|
vm.info_is_ready = true;
|
|
$('.backdrop').css('backgroundImage', 'url(' + vm.tmdbConfig.backdrop_img_base_url + res.backdrop_path + ')');
|
|
}, function (err) {
|
|
Notification.error({
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TMDB_ID_ERROR')
|
|
});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* getTopInfo
|
|
*/
|
|
vm.getTopInfo = function () {
|
|
vm.getMovieTopInfo();
|
|
};
|
|
|
|
/**
|
|
* getMovieTopInfo
|
|
*/
|
|
vm.getMovieTopInfo = function () {
|
|
vm.moviesInfo = TorrentsService.get({
|
|
limit: 16
|
|
}, function (items) {
|
|
vm.movieTopList = items.rows;
|
|
}, function (err) {
|
|
Notification.error({
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TOP_MOVIE_INFO_ERROR')
|
|
});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* openTorrentInfo
|
|
* @param id
|
|
*/
|
|
vm.openTorrentInfo = function (id) {
|
|
var url = $state.href('torrents.view', {torrentId: id});
|
|
window.open(url, '_blank');
|
|
};
|
|
}
|
|
}());
|