diff --git a/modules/torrents/client/controllers/admin/admin-list.client.controller.js b/modules/torrents/client/controllers/admin/admin-list.client.controller.js index 5601c166..f40908f9 100644 --- a/modules/torrents/client/controllers/admin/admin-list.client.controller.js +++ b/modules/torrents/client/controllers/admin/admin-list.client.controller.js @@ -6,20 +6,18 @@ .controller('TorrentsAdminController', TorrentsAdminController); TorrentsAdminController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService', - 'MeanTorrentConfig', 'DownloadService', '$window', 'ModalConfirmService', 'NotifycationService', 'DebugConsoleService']; + 'MeanTorrentConfig', 'DownloadService', '$window', 'ModalConfirmService', 'NotifycationService', 'DebugConsoleService', 'TorrentGetInfoServices']; function TorrentsAdminController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, MeanTorrentConfig, - DownloadService, $window, ModalConfirmService, NotifycationService, mtDebug) { + DownloadService, $window, ModalConfirmService, NotifycationService, mtDebug, TGI) { var vm = this; + vm.TGI = TGI; vm.user = Authentication.user; vm.announce = MeanTorrentConfig.meanTorrentConfig.announce; - vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; - vm.imdbConfig = MeanTorrentConfig.meanTorrentConfig.imdbConfig; vm.resourcesTags = MeanTorrentConfig.meanTorrentConfig.resourcesTags; vm.torrentSalesType = MeanTorrentConfig.meanTorrentConfig.torrentSalesType; vm.torrentRLevels = MeanTorrentConfig.meanTorrentConfig.torrentRecommendLevel; vm.torrentType = MeanTorrentConfig.meanTorrentConfig.torrentType; - vm.voteTitleConfig = MeanTorrentConfig.meanTorrentConfig.voteTitle; vm.selectedType = 'movie'; vm.searchTags = []; @@ -494,79 +492,5 @@ }); }); }; - - /** - * getTorrentListImage - * @param item - * @returns {string} - */ - vm.getTorrentListImage = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - case 'tvserial': - result = vm.tmdbConfig.posterListBaseUrl + item.resource_detail_info.poster_path; - break; - case 'music': - result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover; - break; - } - return result; - }; - - /** - * getTorrentTitle - * @param item - * @returns {string} - */ - vm.getTorrentTitle = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - result = item.resource_detail_info.original_title; - break; - case 'tvserial': - result = item.resource_detail_info.original_name; - break; - case 'music': - result = item.resource_detail_info.title; - break; - } - return result; - }; - - /** - * getTorrentOriginalTitle - * @param item - * @returns {string} - */ - vm.getTorrentOriginalTitle = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - if (item.resource_detail_info.original_title !== item.resource_detail_info.title) { - result = item.resource_detail_info.title; - } - break; - case 'tvserial': - if (item.resource_detail_info.original_name !== item.resource_detail_info.name) { - result = item.resource_detail_info.name; - } - break; - } - return result; - }; - - /** - * getVoteTitle - * @param item - * @returns {string} - */ - vm.getVoteTitle = function (item) { - return item.resource_detail_info.vote_average ? vm.voteTitleConfig.imdb : vm.voteTitleConfig.mt; - }; } }()); diff --git a/modules/torrents/client/controllers/torrents.client.controller.js b/modules/torrents/client/controllers/torrents.client.controller.js index 41ff3da5..cb63368b 100644 --- a/modules/torrents/client/controllers/torrents.client.controller.js +++ b/modules/torrents/client/controllers/torrents.client.controller.js @@ -6,20 +6,18 @@ .controller('TorrentsController', TorrentsController); TorrentsController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService', - 'MeanTorrentConfig', 'DownloadService', '$window', 'ScrapeService', 'DebugConsoleService']; + 'MeanTorrentConfig', 'DownloadService', '$window', 'ScrapeService', 'DebugConsoleService', 'TorrentGetInfoServices']; function TorrentsController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, MeanTorrentConfig, - DownloadService, $window, ScrapeService, mtDebug) { + DownloadService, $window, ScrapeService, mtDebug, TGI) { var vm = this; + vm.TGI = TGI; vm.user = Authentication.user; vm.announce = MeanTorrentConfig.meanTorrentConfig.announce; vm.scrapeConfig = MeanTorrentConfig.meanTorrentConfig.scrapeTorrentStatus; - vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; - vm.imdbConfig = MeanTorrentConfig.meanTorrentConfig.imdbConfig; vm.resourcesTags = MeanTorrentConfig.meanTorrentConfig.resourcesTags; vm.torrentSalesType = MeanTorrentConfig.meanTorrentConfig.torrentSalesType; vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage; - vm.voteTitleConfig = MeanTorrentConfig.meanTorrentConfig.voteTitle; vm.searchTags = []; vm.searchKey = ''; @@ -326,99 +324,5 @@ var url = $state.href('torrents.view', {torrentId: id}); $window.open(url, '_blank'); }; - - /** - * getTorrentListImage - * @param item - * @returns {string} - */ - vm.getTorrentListImage = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - case 'tvserial': - result = vm.tmdbConfig.posterListBaseUrl + item.resource_detail_info.poster_path; - break; - case 'music': - result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover; - break; - } - return result; - }; - - /** - * getTorrentListTopImage - * @param item - * @returns {string} - */ - vm.getTorrentListTopImage = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - case 'tvserial': - result = vm.tmdbConfig.posterImgBaseUrl + item.resource_detail_info.poster_path; - break; - case 'music': - result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover; - break; - } - return result; - }; - - /** - * getTorrentTitle - * @param item - * @returns {string} - */ - vm.getTorrentTitle = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - result = item.resource_detail_info.original_title; - break; - case 'tvserial': - result = item.resource_detail_info.original_name; - break; - case 'music': - result = item.resource_detail_info.title; - break; - } - return result; - }; - - /** - * getTorrentOriginalTitle - * @param item - * @returns {string} - */ - vm.getTorrentOriginalTitle = function (item) { - var result = null; - - switch (item.torrent_type) { - case 'movie': - if (item.resource_detail_info.original_title !== item.resource_detail_info.title) { - result = item.resource_detail_info.title; - } - break; - case 'tvserial': - if (item.resource_detail_info.original_name !== item.resource_detail_info.name) { - result = item.resource_detail_info.name; - } - break; - } - return result; - }; - - /** - * getVoteTitle - * @param item - * @returns {string} - */ - vm.getVoteTitle = function (item) { - return item.resource_detail_info.vote_average ? vm.voteTitleConfig.imdb : vm.voteTitleConfig.mt; - }; } }()); diff --git a/modules/torrents/client/services/torrent-get-info.client.service.js b/modules/torrents/client/services/torrent-get-info.client.service.js new file mode 100644 index 00000000..a86ef03d --- /dev/null +++ b/modules/torrents/client/services/torrent-get-info.client.service.js @@ -0,0 +1,122 @@ +(function () { + 'use strict'; + + // Authentication service for user variables + + angular + .module('torrents.services') + .factory('TorrentGetInfoServices', TorrentGetInfoServices); + + TorrentGetInfoServices.$inject = ['MeanTorrentConfig']; + + function TorrentGetInfoServices(MeanTorrentConfig) { + var voteTitleConfig = MeanTorrentConfig.meanTorrentConfig.voteTitle; + var tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; + + var service = { + getTorrentTitle: getTorrentTitle, + getTorrentOriginalTitle: getTorrentOriginalTitle, + getTorrentListImage: getTorrentListImage, + getTorrentListTopImage: getTorrentListTopImage, + getVoteTitle: getVoteTitle + }; + + return service; + + + /** + * getTorrentTitle + * @param item + * @returns {string} + */ + function getTorrentTitle(item) { + var result = null; + + switch (item.torrent_type) { + case 'movie': + result = item.resource_detail_info.original_title; + break; + case 'tvserial': + result = item.resource_detail_info.original_name; + break; + case 'music': + result = item.resource_detail_info.title; + break; + } + return result; + } + + /** + * getTorrentOriginalTitle + * @param item + * @returns {string} + */ + function getTorrentOriginalTitle(item) { + var result = null; + + switch (item.torrent_type) { + case 'movie': + if (item.resource_detail_info.original_title !== item.resource_detail_info.title) { + result = item.resource_detail_info.title; + } + break; + case 'tvserial': + if (item.resource_detail_info.original_name !== item.resource_detail_info.name) { + result = item.resource_detail_info.name; + } + break; + } + return result; + } + + /** + * getTorrentListImage + * @param item + * @returns {string} + */ + function getTorrentListImage(item) { + var result = null; + + switch (item.torrent_type) { + case 'movie': + case 'tvserial': + result = tmdbConfig.posterListBaseUrl + item.resource_detail_info.poster_path; + break; + case 'music': + result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover; + break; + } + return result; + } + + /** + * getTorrentListTopImage + * @param item + * @returns {string} + */ + function getTorrentListTopImage(item) { + var result = null; + + switch (item.torrent_type) { + case 'movie': + case 'tvserial': + result = tmdbConfig.posterImgBaseUrl + item.resource_detail_info.poster_path; + break; + case 'music': + result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover; + break; + } + return result; + } + + /** + * getVoteTitle + * @param item + * @returns {string} + */ + function getVoteTitle(item) { + return item.resource_detail_info.vote_average ? voteTitleConfig.imdb : voteTitleConfig.mt; + } + + } +}()); diff --git a/modules/torrents/client/views/admin/admin-list.client.view.html b/modules/torrents/client/views/admin/admin-list.client.view.html index e65b110c..facb55da 100644 --- a/modules/torrents/client/views/admin/admin-list.client.view.html +++ b/modules/torrents/client/views/admin/admin-list.client.view.html @@ -160,7 +160,7 @@
...
@@ -172,8 +172,8 @@
-
{{vm.getTorrentTitle(item)}} - / {{vm.getTorrentOriginalTitle(item)}} +
{{vm.TGI.getTorrentTitle(item)}} + / {{vm.TGI.getTorrentOriginalTitle(item)}} (By: )
@@ -223,7 +223,7 @@ {{vm.getVoteTitle(item)}} {{item.resource_detail_info.vote_average | number : 1}} + class="torrent-votes">{{vm.TGI.getVoteTitle(item)}} {{item.resource_detail_info.vote_average | number : 1}} {{item.createdat | life}} {{item.torrent_size | bytes:2}} diff --git a/modules/torrents/client/views/list-torrents.client.view.html b/modules/torrents/client/views/list-torrents.client.view.html index 498b9ac3..a5a02bab 100644 --- a/modules/torrents/client/views/list-torrents.client.view.html +++ b/modules/torrents/client/views/list-torrents.client.view.html @@ -7,8 +7,8 @@