diff --git a/config/env/torrents.js b/config/env/torrents.js index 5da5b186..7d9e4935 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -281,6 +281,7 @@ module.exports = { * @showVipBanner: setting whether show vip AD banner * @showForumNewTopicsAndNewestTorrents: setting whether show forum new topics and newest torrents in home page * @showTopLevelTorrents: setting whether show top level torrents list + * @showAlbumsList: setting whether show albums list of home * @bodyBackgroundImage: background image url of home page body * @buttonList: a function list area of home page */ @@ -288,6 +289,7 @@ module.exports = { showVipBanner: false, showForumNewTopicsAndNewestTorrents: false, showTopLevelTorrents: false, + showAlbumsList: true, bodyBackgroundImage: 'https://image.tmdb.org/t/p/w1280/cnKAGbX1rDkAquF2V1wVkptHDJO.jpg', buttonList: [ { diff --git a/modules/albums/client/controllers/album-view.client.controller.js b/modules/albums/client/controllers/album-view.client.controller.js index 2acc815c..a335a3b8 100644 --- a/modules/albums/client/controllers/album-view.client.controller.js +++ b/modules/albums/client/controllers/album-view.client.controller.js @@ -10,8 +10,8 @@ '$compile', 'marked']; function AlbumItemController($scope, $state, $translate, MeanTorrentConfig, AlbumsService, NotifycationService, DownloadService, - mtDebug, TorrentGetInfoServices, Authentication, ResourcesTagsServices, ModalConfirmService, localStorageService, - $compile, marked) { + mtDebug, TorrentGetInfoServices, Authentication, ResourcesTagsServices, ModalConfirmService, localStorageService, + $compile, marked) { var vm = this; vm.DLS = DownloadService; vm.TGI = TorrentGetInfoServices; @@ -219,5 +219,20 @@ }); }); }; + + /** + * beginToggleHomeStatus + * @param item + */ + vm.beginToggleHomeStatus = function (item) { + AlbumsService.toggleHomeItemStatus({ + _id: item._id + }, function (res) { + vm.album = res; + NotifycationService.showSuccessNotify('ALBUMS.HOME_STATUS_SUCCESSFULLY'); + }, function (res) { + NotifycationService.showSuccessNotify('ALBUMS.HOME_STATUS_ERROR'); + }); + }; } }()); diff --git a/modules/albums/client/controllers/albums.client.controller.js b/modules/albums/client/controllers/albums.client.controller.js index 35e4b9bf..5c58e8b7 100644 --- a/modules/albums/client/controllers/albums.client.controller.js +++ b/modules/albums/client/controllers/albums.client.controller.js @@ -29,7 +29,7 @@ }; /** - * getCollectionsList + * getAlbumsList */ vm.getAlbumsList = function () { AlbumsService.query({}, function (data) { @@ -66,7 +66,7 @@ } }); - console.log(vm.albumsTypeList); + mtDebug.info(vm.albumsTypeList); function getTorrentsCount(ct) { var i = 0; @@ -92,6 +92,5 @@ } return result; }; - } }()); diff --git a/modules/albums/client/less/albums.less b/modules/albums/client/less/albums.less index f40c56c7..10157b41 100644 --- a/modules/albums/client/less/albums.less +++ b/modules/albums/client/less/albums.less @@ -15,6 +15,7 @@ max-width: 400px; border: solid 1px #666; min-height: 160px; + max-height: 226px; z-index: 1; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); &:hover { diff --git a/modules/albums/client/services/albums.client.service.js b/modules/albums/client/services/albums.client.service.js index c8060c33..9b151461 100644 --- a/modules/albums/client/services/albums.client.service.js +++ b/modules/albums/client/services/albums.client.service.js @@ -69,6 +69,14 @@ rlevel: '@rlevel' }, interceptor: {response: removeCache} + }, + toggleHomeItemStatus: { + method: 'PUT', + url: '/api/albums/:albumId/toggleHomeItemStatus', + params: { + albumId: '@_id' + }, + interceptor: {response: removeCache} } }); diff --git a/modules/albums/client/views/album-view.client.view.html b/modules/albums/client/views/album-view.client.view.html index 23fd3067..48d9e965 100644 --- a/modules/albums/client/views/album-view.client.view.html +++ b/modules/albums/client/views/album-view.client.view.html @@ -56,6 +56,10 @@ + diff --git a/modules/albums/client/views/albums.client.view.html b/modules/albums/client/views/albums.client.view.html index 101df3b8..f629e3d9 100644 --- a/modules/albums/client/views/albums.client.view.html +++ b/modules/albums/client/views/albums.client.view.html @@ -3,25 +3,29 @@
-
-
+
- +
{{m.name}}
-
+
+ + {{'ALBUMS.CAT_TYPE' | translate}}: {{m.type}} +
+
{{'ALBUMS.FILES_NUMBERS' | translate}}: {{m.torrents.length}}
diff --git a/modules/albums/server/controllers/albums.server.controller.js b/modules/albums/server/controllers/albums.server.controller.js index 0589e3a7..5909d6f1 100644 --- a/modules/albums/server/controllers/albums.server.controller.js +++ b/modules/albums/server/controllers/albums.server.controller.js @@ -160,6 +160,27 @@ exports.setRecommendLevel = function (req, res) { }; +/** + * toggleHomeItemStatus + * @param req + * @param res + */ +exports.toggleHomeItemStatus = function (req, res) { + var album = req.album; + + album.isHomeStatus = !album.isHomeStatus; + + album.save(function (err) { + if (err) { + return res.status(422).send({ + message: errorHandler.getErrorMessage(err) + }); + } else { + res.json(album); + } + }); +}; + /** * Delete an album */ @@ -182,15 +203,24 @@ exports.delete = function (req, res) { */ exports.list = function (req, res) { var type = undefined; + var isHomeStatus = undefined; var condition = {}; if (req.query.type !== undefined) { type = req.query.type; } + if (req.query.isHomeStatus !== undefined) { + isHomeStatus = (req.query.isHomeStatus === 'true'); + } if (type !== undefined) { condition.type = type; } + if (isHomeStatus !== undefined) { + condition.isHomeStatus = isHomeStatus; + } + + mtDebug.info(condition); var findQuery = function (callback) { Album.find(condition) diff --git a/modules/albums/server/models/albums.server.model.js b/modules/albums/server/models/albums.server.model.js index 47cce983..34aa4d4f 100644 --- a/modules/albums/server/models/albums.server.model.js +++ b/modules/albums/server/models/albums.server.model.js @@ -47,6 +47,10 @@ var AlbumSchema = new Schema({ type: String, default: 'level0' }, + isHomeStatus: { + type: Boolean, + default: false + }, created_at: { type: Date, default: Date.now diff --git a/modules/albums/server/policies/albums.server.policy.js b/modules/albums/server/policies/albums.server.policy.js index 1aba00a9..9ec016e4 100644 --- a/modules/albums/server/policies/albums.server.policy.js +++ b/modules/albums/server/policies/albums.server.policy.js @@ -21,7 +21,8 @@ exports.invokeRolesPolicies = function () { {resources: '/api/albums/:albumId', permissions: '*'}, {resources: '/api/albums/:albumId/insert/:torrentId', permissions: '*'}, {resources: '/api/albums/:albumId/remove/:torrentId', permissions: '*'}, - {resources: '/api/albums/:albumId/set/recommendlevel/:rlevel', permissions: '*'} + {resources: '/api/albums/:albumId/set/recommendlevel/:rlevel', permissions: '*'}, + {resources: '/api/albums/:albumId/toggleHomeItemStatus', permissions: '*'} ] }, { diff --git a/modules/albums/server/routes/albums.server.routes.js b/modules/albums/server/routes/albums.server.routes.js index 05466af5..6650a265 100644 --- a/modules/albums/server/routes/albums.server.routes.js +++ b/modules/albums/server/routes/albums.server.routes.js @@ -23,6 +23,8 @@ module.exports = function (app) { .put(albums.removeFromAlbum); app.route('/api/albums/:albumId/set/recommendlevel/:rlevel').all(albumsPolicy.isAllowed) .put(albums.setRecommendLevel); + app.route('/api/albums/:albumId/toggleHomeItemStatus').all(albumsPolicy.isAllowed) + .put(albums.toggleHomeItemStatus); app.param('albumId', albums.albumByID); }; diff --git a/modules/collections/client/views/collections.client.view.html b/modules/collections/client/views/collections.client.view.html index a262e24c..17e86f0e 100644 --- a/modules/collections/client/views/collections.client.view.html +++ b/modules/collections/client/views/collections.client.view.html @@ -33,7 +33,7 @@
- +
{{m.name}}
diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 402ea2e2..8e12fa14 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -782,8 +782,11 @@ INSERT_FAILED: 'Insert resource into album failed', PREFIX_LIST: '{{type}} Albums List', FILES_NUMBERS: 'Torrents', + CAT_TYPE: 'Cat', BTN_EDIT_OVERVIEW: 'Edit Overview', BTN_REMOVE_ALBUM: 'Delete Album', + BTN_PUSH_INFO_HOME: 'Push Into Home', + BTN_PULL_FROM_HOME: 'Pull From Home', BTN_REMOVE_FROM_ALBUM: 'Remove', BTN_REMOVE_TITLE: 'Remove From Album', DELETE_CONFIRM_BODY_TEXT: 'Are you sure want to delete this album?', @@ -798,7 +801,9 @@ REMOVE_SUCCESSFULLY: 'Remove the torrent from this album successfully', REMOVE_FAILED: 'Remove the torrent from this album failed', EDIT_OVERVIEW_SUCCESSFULLY: 'Edit album overview successfully', - EDIT_OVERVIEW_FAILED: 'Edit album overview failed' + EDIT_OVERVIEW_FAILED: 'Edit album overview failed', + HOME_STATUS_SUCCESSFULLY: 'Toggle home status successfully', + HOME_STATUS_ERROR: 'Toggle home status faild' }, //backup views settings diff --git a/modules/core/client/app/trans-string-zh-tw.js b/modules/core/client/app/trans-string-zh-tw.js index bfa72aff..3e44fcb2 100644 --- a/modules/core/client/app/trans-string-zh-tw.js +++ b/modules/core/client/app/trans-string-zh-tw.js @@ -782,8 +782,11 @@ INSERT_FAILED: '添加資源到專輯失敗', PREFIX_LIST: '{{type}}專輯清單', FILES_NUMBERS: '種子數', + CAT_TYPE: '分類', BTN_EDIT_OVERVIEW: '編輯專輯簡介', BTN_REMOVE_ALBUM: '刪除專輯', + BTN_PUSH_INFO_HOME: '推送到首頁', + BTN_PULL_FROM_HOME: '從首頁移出', BTN_REMOVE_FROM_ALBUM: '移出專輯', BTN_REMOVE_TITLE: '將其從專輯中移出', DELETE_CONFIRM_BODY_TEXT: '您確定要刪除這個資源專輯?', @@ -798,7 +801,9 @@ REMOVE_SUCCESSFULLY: '從專輯中移除種子成功', REMOVE_FAILED: '從專輯中移除種子失敗', EDIT_OVERVIEW_SUCCESSFULLY: '編輯專輯簡介成功', - EDIT_OVERVIEW_FAILED: '編輯專輯簡介失敗' + EDIT_OVERVIEW_FAILED: '編輯專輯簡介失敗', + HOME_STATUS_SUCCESSFULLY: '首頁推送狀態修改成功', + HOME_STATUS_ERROR: '首頁推送狀態修改失敗' }, //backup views settings diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 140c433d..12f89edd 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -782,8 +782,11 @@ INSERT_FAILED: '添加资源到专辑失败', PREFIX_LIST: '{{type}}专辑清单', FILES_NUMBERS: '种子数', + CAT_TYPE: '分类', BTN_EDIT_OVERVIEW: '编辑专辑简介', BTN_REMOVE_ALBUM: '删除专辑', + BTN_PUSH_INFO_HOME: '推送到首页', + BTN_PULL_FROM_HOME: '从首页移出', BTN_REMOVE_FROM_ALBUM: '移出专辑', BTN_REMOVE_TITLE: '将其从专辑中移出', DELETE_CONFIRM_BODY_TEXT: '您确定要删除这个资源专辑?', @@ -798,7 +801,9 @@ REMOVE_SUCCESSFULLY: '从专辑中移除种子成功', REMOVE_FAILED: '从专辑中移除种子失败', EDIT_OVERVIEW_SUCCESSFULLY: '编辑专辑简介成功', - EDIT_OVERVIEW_FAILED: '编辑专辑简介失败' + EDIT_OVERVIEW_FAILED: '编辑专辑简介失败', + HOME_STATUS_SUCCESSFULLY: '首页推送状态修改成功', + HOME_STATUS_ERROR: '首页推送状态修改失败' }, //backup views settings diff --git a/modules/core/client/controllers/home.client.controller.js b/modules/core/client/controllers/home.client.controller.js index 4ec46805..23feb71d 100644 --- a/modules/core/client/controllers/home.client.controller.js +++ b/modules/core/client/controllers/home.client.controller.js @@ -7,11 +7,11 @@ HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'NotifycationService', 'MeanTorrentConfig', 'getStorageLangService', 'ForumsService', '$timeout', 'localStorageService', 'TopicsService', 'TorrentGetInfoServices', 'DebugConsoleService', - 'marked', 'CheckService']; + 'marked', 'CheckService', 'AlbumsService']; function HomeController($scope, $state, $translate, Authentication, TorrentsService, NotifycationService, MeanTorrentConfig, getStorageLangService, ForumsService, $timeout, localStorageService, TopicsService, TorrentGetInfoServices, mtDebug, - marked, CheckService) { + marked, CheckService, AlbumsService) { var vm = this; vm.user = Authentication.user; vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app; @@ -24,10 +24,18 @@ vm.homeConfig = MeanTorrentConfig.meanTorrentConfig.home; vm.supportConfig = MeanTorrentConfig.meanTorrentConfig.support; vm.scoreConfig = MeanTorrentConfig.meanTorrentConfig.score; + vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; vm.searchType = 'torrents'; vm.checkData = undefined; + /** + * window.resize() + */ + $(window).resize(function () { + vm.setAlbumItemHeight(); + }); + /** * initBodyBackground */ @@ -68,6 +76,45 @@ }); }; + /** + * setAlbumItemHeight + */ + vm.setAlbumItemHeight = function () { + $('.albums-item').height($('.albums-item').width() / 1.772); + }; + + /** + * getCollectionsList + */ + vm.getAlbumsList = function () { + AlbumsService.query({ + isHomeStatus: true + }, function (data) { + vm.albumsList = data; + mtDebug.info(data); + + $timeout(function () { + vm.setAlbumItemHeight(); + }, 10); + }); + }; + + /** + * getAlbumBackdropImage + * @param item + * @returns {string} + */ + vm.getAlbumBackdropImage = function (item) { + var result = null; + + if (item.backdrop_path) { + result = vm.tmdbConfig.backdropImgBaseUrl + item.backdrop_path; + } else if (item.cover) { + result = '/modules/torrents/client/uploads/cover/' + item.cover; + } + return result; + }; + /** * getForumList */ diff --git a/modules/core/client/directives/align-middle-parent.client.directive.js b/modules/core/client/directives/align-middle-parent.client.directive.js index 68c0e2ae..a139bce7 100644 --- a/modules/core/client/directives/align-middle-parent.client.directive.js +++ b/modules/core/client/directives/align-middle-parent.client.directive.js @@ -4,7 +4,7 @@ angular.module('core') .directive('alignMiddleParent', alignMiddleParent); - alignMiddleParent.$inject=['$timeout']; + alignMiddleParent.$inject = ['$timeout']; function alignMiddleParent($timeout) { var directive = { @@ -16,7 +16,7 @@ function link(scope, element, attrs) { element.on('load', function (event) { - $timeout(function(){ + $timeout(function () { if (element.height() > element.parent().height()) { element.css('margin-top', -(element.height() - element.parent().height()) / 2); } else { diff --git a/modules/core/client/less/home.less b/modules/core/client/less/home.less index 5aac86d9..17703317 100644 --- a/modules/core/client/less/home.less +++ b/modules/core/client/less/home.less @@ -66,7 +66,7 @@ } .home-help, .home-notice, .home-new-topic, .home-new-torrents { - margin: 50px 20px; + margin: 30px 20px; //color: #fff; //text-shadow: 0 0 0.1em #000,-0 -0 0.1em #000; .list-items { @@ -92,7 +92,7 @@ } } .list-title { - margin-bottom: 20px; + margin-bottom: 10px; position: relative; .fa-stack { font-size: 30px; @@ -122,8 +122,9 @@ } .home-check-in { - padding: 10px 0; h4, .h4 { + font-size: 16px; + font-weight: 400 !important; line-height: 1.8; } .check-in-btn { @@ -138,7 +139,7 @@ } .home-button-list { - padding: 50px 0; + padding: 20px 0 30px; @media (max-width: @screen-xs-max) { padding-top: 20px; .fun-item { @@ -328,6 +329,18 @@ } } +.filter-albums { + position: relative; + margin-top: 2px; + background-color: @mt-body-background-color; + background-color: rgba(255, 255, 255, .85); + transition: background-color .2s ease-in; + &:hover { + background-color: @mt-body-background-color; + background-color: rgba(255, 255, 255, .95); + } +} + .filter-button-list { position: relative; margin-top: 2px; @@ -386,7 +399,7 @@ .filter-disclaimer { position: relative; margin-top: 2px; - padding: 30px 0 60px 0; + padding: 0 0 30px 0; background-color: @progress-bar-danger-bg; background-color: rgba(217, 83, 79, .85); transition: background-color .2s ease-in; @@ -415,7 +428,6 @@ } } .top-panel { - min-height: 120px; padding: 20px 0; text-shadow: 0 0 0.1em #000,-0 -0 0.1em #000; .home-search { diff --git a/modules/core/client/views/home.client.view.html b/modules/core/client/views/home.client.view.html index 4f03eda5..3144e689 100644 --- a/modules/core/client/views/home.client.view.html +++ b/modules/core/client/views/home.client.view.html @@ -43,9 +43,19 @@
@@ -105,7 +105,7 @@
-
+
@@ -162,6 +162,43 @@
+
+