Files
meanTorrent/modules/core/client/controllers/home.client.controller.js

80 lines
2.1 KiB
JavaScript
Raw Normal View History

(function () {
'use strict';
2014-02-10 13:09:31 +02:00
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;
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;
vm.COMING = 'coming soon...';
2017-04-01 14:22:11 +08:00
/**
* If user is not signed in then redirect back signin
*/
if (!Authentication.user) {
$state.go('authentication.signin');
}
/**
* 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
/**
* getTopInfo
*/
2017-04-04 01:02:21 +08:00
vm.getTopInfo = function () {
vm.getMovieTopInfo();
};
/**
* 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')
});
});
};
/**
* 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');
};
}
}());