2016-02-11 00:20:17 -05:00
|
|
|
(function () {
|
|
|
|
|
'use strict';
|
2014-02-10 13:09:31 +02:00
|
|
|
|
2016-02-11 00:20:17 -05:00
|
|
|
angular
|
|
|
|
|
.module('core')
|
|
|
|
|
.controller('HomeController', HomeController);
|
|
|
|
|
|
2017-05-13 19:10:28 +08:00
|
|
|
HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig', 'getStorageLangService'];
|
2017-03-26 00:52:31 +08:00
|
|
|
|
2017-05-13 19:10:28 +08:00
|
|
|
function HomeController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService) {
|
2016-02-11 00:20:17 -05:00
|
|
|
var vm = this;
|
2017-04-07 15:34:51 +08:00
|
|
|
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
|
2017-04-04 01:02:21 +08:00
|
|
|
vm.movieTopList = undefined;
|
2017-04-02 13:37:40 +08:00
|
|
|
|
2017-04-01 15:00:59 +08:00
|
|
|
vm.info_is_ready = false;
|
2017-03-26 00:52:31 +08:00
|
|
|
|
|
|
|
|
vm.COMING = 'coming soon...';
|
2017-04-01 14:22:11 +08:00
|
|
|
|
2017-05-13 19:10:28 +08:00
|
|
|
/**
|
|
|
|
|
* If user is not signed in then redirect back signin
|
|
|
|
|
*/
|
|
|
|
|
if (!Authentication.user) {
|
|
|
|
|
$state.go('authentication.signin');
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-08 17:58:09 +08:00
|
|
|
/**
|
|
|
|
|
* initInfo
|
|
|
|
|
*/
|
2017-04-01 14:22:11 +08:00
|
|
|
vm.initInfo = function () {
|
|
|
|
|
TorrentsService.getTMDBInfo({
|
|
|
|
|
tmdbid: '329865',
|
2017-05-05 18:27:22 +08:00
|
|
|
language: getStorageLangService.getLang()
|
2017-04-01 14:22:11 +08:00
|
|
|
}, function (res) {
|
|
|
|
|
Notification.success({
|
|
|
|
|
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TMDB_ID_OK')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
vm.movieinfo = res;
|
2017-04-01 15:00:59 +08:00
|
|
|
vm.info_is_ready = true;
|
2017-04-02 13:37:40 +08:00
|
|
|
$('.backdrop').css('backgroundImage', 'url(' + vm.tmdbConfig.backdrop_img_base_url + res.backdrop_path + ')');
|
2017-04-01 14:22:11 +08:00
|
|
|
}, function (err) {
|
|
|
|
|
Notification.error({
|
|
|
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TMDB_ID_ERROR')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2017-04-04 01:02:21 +08:00
|
|
|
|
2017-04-08 17:58:09 +08:00
|
|
|
/**
|
|
|
|
|
* getTopInfo
|
|
|
|
|
*/
|
2017-04-04 01:02:21 +08:00
|
|
|
vm.getTopInfo = function () {
|
|
|
|
|
vm.getMovieTopInfo();
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-08 17:58:09 +08:00
|
|
|
/**
|
|
|
|
|
* getMovieTopInfo
|
|
|
|
|
*/
|
2017-04-04 01:02:21 +08:00
|
|
|
vm.getMovieTopInfo = function () {
|
2017-04-27 09:36:56 +08:00
|
|
|
vm.moviesInfo = TorrentsService.get({
|
2017-04-26 13:06:05 +08:00
|
|
|
limit: 16
|
2017-04-04 01:02:21 +08:00
|
|
|
}, function (items) {
|
2017-04-27 09:36:56 +08:00
|
|
|
vm.movieTopList = items.rows;
|
2017-04-04 01:02:21 +08:00
|
|
|
}, function (err) {
|
|
|
|
|
Notification.error({
|
|
|
|
|
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TOP_MOVIE_INFO_ERROR')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2017-04-08 17:58:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* openTorrentInfo
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
vm.openTorrentInfo = function (id) {
|
|
|
|
|
var url = $state.href('torrents.view', {torrentId: id});
|
2017-04-09 01:35:09 +08:00
|
|
|
window.open(url, '_blank');
|
|
|
|
|
};
|
2015-07-25 16:53:11 -04:00
|
|
|
}
|
2016-02-11 00:20:17 -05:00
|
|
|
}());
|