Skip to content

Commit

Permalink
add Torrents movie list view,controller
Browse files Browse the repository at this point in the history
  • Loading branch information
taobataoma committed Apr 4, 2017
1 parent 6e64b74 commit e3bcc00
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 8 deletions.
3 changes: 3 additions & 0 deletions modules/core/client/app/trans-string-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
TITLE_FINISHED: '完成下载数',
TITLE_IMDB_VOTES: 'IMDB 评分',

//TorrentsController & views
MOVIE_PAGE_INFO_ERROR: '获取电影分页列表失败',

//TorrentsUploadsController
TORRENTS_UPLOAD_SUCCESSFULLY: '文件上传成功',
TORRENTS_UPLOAD_FAILED: '文件上传失败',
Expand Down
3 changes: 3 additions & 0 deletions modules/core/client/app/trans-string-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
TITLE_FINISHED: 'Finished users',
TITLE_IMDB_VOTES: 'IMDB Votes',

//TorrentsController & views
MOVIE_PAGE_INFO_ERROR: 'Get movie page info faild',

//TorrentsUploadsController & views
TORRENTS_UPLOAD_SUCCESSFULLY: 'Successfully uploads file',
TORRENTS_UPLOAD_FAILED: 'Failed to uploads file',
Expand Down
80 changes: 80 additions & 0 deletions modules/core/client/less/margin.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.margin-top-10 {
margin-top: 10px;
}

.margin-top-20 {
margin-top: 20px;
}

.margin-top-30 {
margin-top: 30px;
}

.margin-top-40 {
margin-top: 40px;
}

.margin-top-50 {
margin-top: 50px;
}

.margin-bottom-10 {
margin-bottom: 10px;
}

.margin-bottom-20 {
margin-bottom: 20px;
}

.margin-bottom-30 {
margin-bottom: 30px;
}

.margin-bottom-40 {
margin-bottom: 40px;
}

.margin-bottom-50 {
margin-bottom: 50px;
}

.padding-top-10 {
padding-top: 10px;
}

.padding-top-20 {
padding-top: 20px;
}

.padding-top-30 {
padding-top: 30px;
}

.padding-top-40 {
padding-top: 40px;
}

.padding-top-50 {
padding-top: 50px;
}

.padding-bottom-10 {
padding-bottom: 10px;
}

.padding-bottom-20 {
padding-bottom: 20px;
}

.padding-bottom-30 {
padding-bottom: 30px;
}

.padding-bottom-40 {
padding-bottom: 40px;
}

.padding-bottom-50 {
padding-bottom: 50px;
}

16 changes: 15 additions & 1 deletion modules/core/client/less/mt.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import (reference) "../../../../public/lib/bootstrap/less/variables.less";

.bodysize {
background-color: #fff;
min-height: 600px;
Expand Down Expand Up @@ -59,9 +61,10 @@
}
}

.post-info-img {
.torrent-post-info {
cursor: pointer;
&:hover {
background-color: #efefef;
background-color: rgba(224, 224, 224, .3);
}
> img {
Expand Down Expand Up @@ -121,4 +124,15 @@
.torrent-finished {
color: #33FFFF;
}

&.small-info {
@media (min-width: @screen-md-min) {
padding: 5px 0;
font-size: 12px;
.list-inline > li {
padding-left: 1px;
padding-right: 1px;
}
}
}
}
19 changes: 12 additions & 7 deletions modules/core/client/views/home.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ <h3 translate="LOADING_TOP" class="text-capitalize"></h3>
<!--<dd class="h-line">${{vm.movieinfo.revenue}}</dd>-->

<dt class="h-line">{{ 'TMDB_FIELDS.VOTE_AVERAGE' | translate}}:</dt>
<dd class="h-line"><span class="torrent-votes"><kbd>IMDB</kbd></span> {{vm.movieinfo.vote_average}} / {{vm.movieinfo.vote_count}} {{ 'TMDB_FIELDS.VOTE_UNIT' | translate}}</dd>
<dd class="h-line"><span
class="torrent-votes"><kbd>IMDB</kbd></span> {{vm.movieinfo.vote_average}} / {{vm.movieinfo.vote_count}} {{ 'TMDB_FIELDS.VOTE_UNIT' | translate}}
</dd>

<!--<dt class="h-line">{{ 'TMDB_FIELDS.IMDB_LINK' | translate}}:</dt>-->
<!--<dd class="h-line"><a href="https://www.themoviedb.org/movie/{{vm.movieinfo.imdb_id}}"-->
Expand Down Expand Up @@ -133,25 +135,28 @@ <h3 translate="LOADING_TOP" class="text-capitalize"></h3>
<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-3">
<div class="thumbnail post-info-img">
<div class="thumbnail torrent-post-info">
<img ng-src="{{vm.tmdbConfig.poster_img_base_url}}{{item.torrent_img}}" alt="{{item.torrent_title}}"
class="img-responsive">

<div class="torrent-user-info">
<ul class="list-unstyled list-inline">
<li title="{{ 'TITLE_SEEDS' | translate}}"><span class="glyphicon glyphicon-arrow-up torrent-up"></span><span>356</span></li>
<li title="{{ 'TITLE_LEECHERS' | translate}}"><span class="glyphicon glyphicon-arrow-down torrent-down"></span><span>24</span></li>
<li title="{{ 'TITLE_SEEDS' | translate}}"><span
class="glyphicon glyphicon-arrow-up torrent-up"></span><span>{{item.torrent_seeds}}</span></li>
<li title="{{ 'TITLE_LEECHERS' | translate}}"><span
class="glyphicon glyphicon-arrow-down torrent-down"></span><span>{{item.torrent_leechers}}</span></li>
<li title="{{ 'TITLE_FINISHED' | translate}}" class="pull-right"><span
class="glyphicon glyphicon-ok torrent-finished"></span><span>1622</span></li>
class="glyphicon glyphicon-ok torrent-finished"></span><span>{{item.torrent_finished}}</span></li>
</ul>
</div>

<div class="caption">
<ul class="list-unstyled">
<li style="white-space: nowrap; overflow:hidden; text-overflow: ellipsis;">
<strong>{{item.torrent_title}}</strong>
<li><span class="release-date">{{item.torrent_release}}</span><span title="{{ 'TITLE_IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes}}</span></li>
<li><span class="release-date">{{item.torrent_release}}</span>
<span title="{{ 'TITLE_IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes}}</span></li>
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions modules/torrents/client/config/torrents.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
url: '/torrents',
template: '<ui-view/>'
})
.state('torrents.movie', {
url: '/torrents/movie',
templateUrl: '/modules/torrents/client/views/movie-list.client.view.html'
})
.state('torrents.uploads', {
url: '/torrents/uploads',
templateUrl: '/modules/torrents/client/views/uploads-torrents.client.view.html'
Expand Down
48 changes: 48 additions & 0 deletions modules/torrents/client/controllers/torrents.client.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
(function () {
'use strict';

angular
.module('torrents')
.controller('TorrentsController', TorrentsController);

TorrentsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'Notification', 'TorrentsService', 'TMDBConfig'];

function TorrentsController($scope, $state, $translate, Authentication, Notification, TorrentsService, TMDBConfig) {
var vm = this;
vm.user = Authentication.user;
vm.tmdbConfig = TMDBConfig.tmdbConfig;
vm.topNumber = 6;
vm.pageNumber = 50;

// If user is not signed in then redirect back home
if (!Authentication.user) {
$state.go('authentication.signin');
}

vm.getMovieTopInfo = function () {
TorrentsService.query({
limit: vm.topNumber
}, function (items) {
vm.movieTopInfo = items;
}, function (err) {
Notification.error({
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TOP_MOVIE_INFO_ERROR')
});
});
};

vm.getMoviePageInfo = function (p) {
TorrentsService.query({
skip: (p - 1) * vm.pageNumber + vm.topNumber,
limit: p * vm.pageNumber
}, function (items) {
vm.moviesPageInfo = items;
}, function (err) {
Notification.error({
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('MOVIE_PAGE_INFO_ERROR')
});
});

};
}
}());
34 changes: 34 additions & 0 deletions modules/torrents/client/views/movie-list.client.view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<section class="container padding-top-10" ng-controller="TorrentsController as vm" ng-init="vm.getMovieTopInfo();vm.getMoviePageInfo(1);">
<div class="row">
<div ng-repeat="item in vm.movieTopInfo">
<div class="col-sm-4 col-md-2">
<div class="thumbnail torrent-post-info">
<img ng-src="{{vm.tmdbConfig.poster_img_base_url}}{{item.torrent_img}}" alt="{{item.torrent_title}}"
class="img-responsive">

<div class="torrent-user-info small-info">
<ul class="list-unstyled list-inline">
<li title="{{ 'TITLE_SEEDS' | translate}}"><span
class="glyphicon glyphicon-arrow-up torrent-up"></span><span>666</span></li>
<li title="{{ 'TITLE_LEECHERS' | translate}}"><span
class="glyphicon glyphicon-arrow-down torrent-down"></span><span>666</span></li>
<li title="{{ 'TITLE_FINISHED' | translate}}" class="pull-right"><span
class="glyphicon glyphicon-ok torrent-finished"></span><span>6666</span></li>
</ul>
</div>

<div class="caption">
<ul class="list-unstyled">
<li style="white-space: nowrap; overflow:hidden; text-overflow: ellipsis;">
<strong>{{item.torrent_title}}</strong>
<li><span class="release-date">{{item.torrent_release}}</span>
<span title="{{ 'TITLE_IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes}}</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ exports.list = function (req, res) {
if (req.query.limit !== undefined) {
limit = req.query.limit;
}
if (req.query.status !== undefined) {
status = req.query.status;
}

Torrent.find({'torrent_status': status}).sort('-createdat').populate('user', 'displayName').skip(skip).limit(limit).exec(function (err, torrents) {
if (err) {
Expand Down

0 comments on commit e3bcc00

Please sign in to comment.