feat(home): show albums list in home page

This commit is contained in:
OldHawk
2018-05-23 16:55:19 +08:00
parent 1d3d0b5e7e
commit 4428f4434a
19 changed files with 218 additions and 37 deletions

View File

@@ -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: [
{

View File

@@ -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');
});
};
}
}());

View File

@@ -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;
};
}
}());

View File

@@ -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 {

View File

@@ -69,6 +69,14 @@
rlevel: '@rlevel'
},
interceptor: {response: removeCache}
},
toggleHomeItemStatus: {
method: 'PUT',
url: '/api/albums/:albumId/toggleHomeItemStatus',
params: {
albumId: '@_id'
},
interceptor: {response: removeCache}
}
});

View File

@@ -56,6 +56,10 @@
</ul>
</div>
<button class="btn btn-width-160 margin-top-5" mouse-enter-toggle-class="btn-default" base-class="btn-mt-o"
ng-if="vm.user.isOper" ng-click="vm.beginToggleHomeStatus(vm.album)">
{{(vm.album.isHomeStatus ? 'ALBUMS.BTN_PULL_FROM_HOME' : 'ALBUMS.BTN_PUSH_INFO_HOME') | translate}}
</button>
</div>
</div>
</div>

View File

@@ -3,25 +3,29 @@
<div class="col-sm-12">
<div class="albums-list">
<div class="margin-top-30 margin-bottom-30" ng-repeat="tp in vm.albumsTypeList | orderBy: 'idx'">
<legend class="h4" translate="ALBUMS.PREFIX_LIST"
<legend class="h4 text-center" translate="ALBUMS.PREFIX_LIST"
translate-values="{type: '{{'TORRENT_TYPE_LABEL.' + tp.type.toUpperCase() | translate}}' }">
</legend>
<div class="row">
<div class="albums-items">
<div ng-repeat="m in vm.albumsList | filter: tp.type">
<div ng-repeat="m in vm.albumsList | filter: {type: tp.type}">
<div data-ng-if="$index != 0 && $index % 2 == 0" class="clearfix visible-sm-block"></div>
<div data-ng-if="$index != 0 && $index % 4 == 0" class="clearfix visible-md-block visible-lg-block"></div>
<div class="col-sm-6 col-md-4">
<a ui-sref="albums.view({ albumId: m._id })">
<div class="albums-item">
<img ng-src="{{vm.getAlbumBackdropImage(m)}}">
<img ng-src="{{vm.getAlbumBackdropImage(m)}}" align-middle-parent>
<div class="item-info text-center">
<div class="name">{{m.name}}</div>
<div class="row margin-top-40 album-data">
<div class="text-center">
<div class="col-xs-6 text-center col-small-padding">
<i class="fa fa-th-large text-info">
<strong> {{'ALBUMS.CAT_TYPE' | translate}}: {{m.type}}</strong></i>
</div>
<div class="col-xs-6 text-center col-small-padding">
<i class="fa fa-list text-info">
<strong> {{'ALBUMS.FILES_NUMBERS' | translate}}: {{m.torrents.length}}</strong></i>
</div>

View File

@@ -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)

View File

@@ -47,6 +47,10 @@ var AlbumSchema = new Schema({
type: String,
default: 'level0'
},
isHomeStatus: {
type: Boolean,
default: false
},
created_at: {
type: Date,
default: Date.now

View File

@@ -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: '*'}
]
},
{

View File

@@ -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);
};

View File

@@ -33,7 +33,7 @@
<div class="col-sm-6 col-md-4">
<a ui-sref="collections.view({ collectionId: m._id })">
<div class="collection-item">
<img ng-src="{{vm.tmdbConfig.backdropImgBaseUrl_780 + m.backdrop_path}}">
<img ng-src="{{vm.tmdbConfig.backdropImgBaseUrl_780 + m.backdrop_path}}" align-middle-parent>
<div class="item-info text-center">
<div class="name">{{m.name}}</div>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
*/

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -43,9 +43,19 @@
<div class="search-row">
<div class="col-sm-12 text-center search-col">
<div class="home-search">
<p class="search-title" translate="HOME.TITLE_SEARCH"></p>
<!--<p class="search-title" translate="HOME.TITLE_SEARCH"></p>-->
<!--<p class="search-sub-title" translate="HOME.SEARCH_SUB_TITLE"></p>-->
<div class="input-group search-group margin-top-20">
<div class="search-type text-center">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio_torrents" value="torrents"
ng-model="vm.searchType"> {{'HOME.SEARCH_TYPE_TORRENTS' | translate}}
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio_forum" value="forum"
ng-model="vm.searchType"> {{'HOME.SEARCH_TYPE_FORUM' | translate}}
</label>
</div>
<div class="input-group search-group margin-top-10">
<input type="text" class="form-control"
ng-model="vm.searchKeys"
ng-keydown="vm.onSearchKeyDown($event);"
@@ -57,16 +67,6 @@
{{'BTN_GLOBAL_SEARCH' | translate}}
</button>
</div>
<div class="search-type text-center margin-top-20">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio_torrents" value="torrents"
ng-model="vm.searchType"> {{'HOME.SEARCH_TYPE_TORRENTS' | translate}}
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio_forum" value="forum"
ng-model="vm.searchType"> {{'HOME.SEARCH_TYPE_FORUM' | translate}}
</label>
</div>
</div>
</div>
</div>
@@ -105,7 +105,7 @@
</div>
<div ng-if="vm.checkData && vm.checkData.todayIsDone">
<div class="row">
<div class="col-sm-12 text-center">
<div class="col-sm-12 text-center check-in-info">
<span ng-bind-html="vm.getCheckTodayDoneMessage()"></span>
</div>
</div>
@@ -162,6 +162,43 @@
</div>
</div>
<div ng-init="vm.getAlbumsList()">
<div class="filter-albums albums-list" ng-if="vm.homeConfig.showAlbumsList && vm.albumsList.length>0">
<div class="container padding-top-20 padding-bottom-30">
<div class="row">
<div class="albums-items">
<div ng-repeat="m in vm.albumsList | filter: tp.type">
<div data-ng-if="$index != 0 && $index % 2 == 0" class="clearfix visible-sm-block"></div>
<div data-ng-if="$index != 0 && $index % 4 == 0" class="clearfix visible-md-block visible-lg-block"></div>
<div class="col-sm-6 col-md-4">
<a ui-sref="albums.view({ albumId: m._id })">
<div class="albums-item">
<img ng-src="{{vm.getAlbumBackdropImage(m)}}" align-middle-parent>
<div class="item-info text-center">
<div class="name">{{m.name}}</div>
<div class="row margin-top-40 album-data">
<div class="col-xs-6 text-center col-small-padding">
<i class="fa fa-th-large text-info">
<strong> {{'ALBUMS.CAT_TYPE' | translate}}: {{m.type}}</strong></i>
</div>
<div class="col-xs-6 text-center col-small-padding">
<i class="fa fa-list text-info">
<strong> {{'ALBUMS.FILES_NUMBERS' | translate}}: {{m.torrents.length}}</strong></i>
</div>
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="filter-vip home_vip_info" ng-if="vm.homeConfig.showVipBanner">
<div class="vip-half-background">
<div class="container">