(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: ' ' + $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: ' ' + $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: ' ' + $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'); }; } }());