Skip to content

Commit

Permalink
load home data from local db
Browse files Browse the repository at this point in the history
  • Loading branch information
taobataoma committed May 17, 2017
1 parent b41e575 commit 9625893
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 45 deletions.
13 changes: 6 additions & 7 deletions modules/core/client/controllers/home.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
vm.initTopOneInfo = function () {
$('.backdrop').css('backgroundImage', 'url(' + vm.tmdbConfig.backdrop_img_base_url + vm.movieTopOne.torrent_backdrop_img + ')');

TorrentsService.getTMDBInfo({
tmdbid: vm.movieTopOne.torrent_tmdb_id,
language: getStorageLangService.getLang()
}, function (res) {
vm.movieTopInfo = res;
});
//TorrentsService.getTMDBInfo({
// tmdbid: vm.movieTopOne.torrent_tmdb_id,
// language: getStorageLangService.getLang()
//}, function (res) {
// vm.movieTopInfo = res;
//});
};

/**
Expand Down Expand Up @@ -71,7 +71,6 @@
limit: 14
}, function (items) {
vm.movieNewList = items.rows;
console.log(vm.movieNewList);
}, function (err) {
Notification.error({
message: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TOP_MOVIE_INFO_ERROR')
Expand Down
5 changes: 4 additions & 1 deletion modules/core/client/less/mt.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ body {
background-color: rgba(0, 0, 0, .7);
//opacity: 0.5;
padding-top: 30px;
padding-bottom: 30px;
//padding-bottom: 30px;
}
.loading {
color: #ccc;
Expand All @@ -57,6 +57,9 @@ body {
legend {
color: #ccc;
}
.genres-item {
color: #fff;
}
.img-circle {
&:hover {
/* csslint ignore:start */
Expand Down
67 changes: 37 additions & 30 deletions modules/core/client/views/home.client.view.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section ng-controller="HomeController as vm" ng-init="vm.getTopInfo();">
<div class="backdrop">
<div class="backdrop" ng-show="vm.movieTopOne">
<div class="filter">
<div class="container">
<div class="topone">
Expand All @@ -19,6 +19,9 @@
<dt class="h-line">{{ 'TMDB_FIELDS.TITLE' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.torrent_title}}</dd>

<dt class="h-line">{{ 'TMDB_FIELDS.DIRECTOR' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.torrent_director}}</dd>

<!--<dt class="h-line">{{ 'TMDB_FIELDS.ORIGINAL_LANGUAGE' | translate}}:</dt>-->
<!--<dd class="h-line">{{vm.movieTopOne.original_language}}</dd>-->

Expand All @@ -27,23 +30,27 @@
<span class="genres-item" ng-repeat="item in vm.movieTopOne.torrent_genres">{{item}}</span>
</dd>

<!--<dt class="h-line">{{ 'TMDB_FIELDS.PRODUCTION_COUNTRIES' | translate}}:</dt>-->
<!--<dd class="h-line list-all-countries">-->
<!--<span class="country-item" ng-repeat="item in vm.movieinfo.production_countries">{{item.iso_3166_1}}</span>-->
<!--<span ng-show="vm.movieinfo.production_countries.length ==0">-</span>-->
<!--</dd>-->
<dt class="h-line">{{ 'TMDB_FIELDS.PRODUCTION_COUNTRIES' | translate}}:</dt>
<dd class="h-line list-all-countries">
<span class="country-item" ng-repeat="item in vm.movieTopOne.torrent_countries">{{item}}</span>
<span ng-show="vm.movieTopOne.torrent_countries.length ==0">-</span>
</dd>

<dt class="h-line">{{ 'TMDB_FIELDS.RELEASE_DATE' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.torrent_release}}</dd>

<dt class="h-line">{{ 'TMDB_FIELDS.RUNTIME' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.runtime}}</dd>
<dd class="h-line">{{vm.movieTopOne.torrent_runtime | runtime}}</dd>

<!--<dt class="h-line">{{ 'TMDB_FIELDS.BUDGET' | translate}}:</dt>-->
<!--<dd class="h-line">${{vm.movieinfo.budget}}</dd>-->
<div ng-hide="vm.movieTopOne.torrent_budget == 0">
<dt class="h-line">{{ 'TMDB_FIELDS.BUDGET' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.torrent_budget | dollar:2}}</dd>
</div>

<!--<dt class="h-line">{{ 'TMDB_FIELDS.REVENUE' | translate}}:</dt>-->
<!--<dd class="h-line">${{vm.movieinfo.revenue}}</dd>-->
<div ng-hide="vm.movieTopOne.torrent_revenue == 0">
<dt class="h-line">{{ 'TMDB_FIELDS.REVENUE' | translate}}:</dt>
<dd class="h-line">{{vm.movieTopOne.torrent_revenue | dollar:2}}</dd>
</div>

<dt class="h-line">{{ 'TMDB_FIELDS.VOTE_AVERAGE' | translate}}:</dt>
<dd class="h-line"><span
Expand All @@ -56,55 +63,55 @@
<legend class="xsmall-legend strong-legend" translate="TMDB_FIELDS.CAST"></legend>
<div class="row cast-list">
<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[0].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[0].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[0].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[0].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[0].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[0].character}}</p>
</div>
<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[1].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[1].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[1].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[1].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[1].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[1].character}}</p>
</div>
<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[2].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[2].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[2].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[2].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[2].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[2].character}}</p>
</div>

<div class="clearfix visible-xs-block visible-sm-block"></div>

<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[3].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[3].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[3].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[3].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[3].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[3].character}}</p>
</div>
<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[4].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[4].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[4].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[4].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[4].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[4].character}}</p>
</div>
<div class="col-xs-4 col-md-2 text-center">
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopInfo.credits.cast[5].profile_path}}"
<img ng-src="{{vm.tmdbConfig.cast_img_base_url}}{{vm.movieTopOne.torrent_cast[5].profile_path}}"
on-error-src="/./modules/core/client/img/default_face.jpg"
class="img-circle img-thumbnail img-responsive center-block" onload="this.style.opacity='1';">
<span class="cast-xs-info"><strong>{{vm.movieTopInfo.credits.cast[5].name}}</strong></span>
<span class="cast-xs-info"><strong>{{vm.movieTopOne.torrent_cast[5].name}}</strong></span>

<p class="cast-xs-info character">{{vm.movieTopInfo.credits.cast[5].character}}</p>
<p class="cast-xs-info character">{{vm.movieTopOne.torrent_cast[5].character}}</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -170,7 +177,7 @@
<div class="col-md-3 col-md-height col-small-padding" style="padding-left: 15px;">
<div class="fill-height-table">
<div class="fill-height-row" style="overflow-y: auto;">
<div class="panel panel-default panel-newest-list">
<div class="panel panel-default panel-newest-list" ng-show="vm.movieNewList">
<div class="panel-heading"><h5>Newest Movie Torrents</h5></div>
<table class="table">
<tr ng-repeat="nt in vm.movieNewList" mouse-enter-toggle-class="show-big" base-class="hide-big"
Expand Down
42 changes: 39 additions & 3 deletions modules/torrents/client/controllers/uploads.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'TorrentsService', 'getStorageLangService'];

function TorrentsUploadController($scope, $state, $translate, $timeout, Authentication, MeanTorrentConfig, Upload, Notification,
TorrentsService, getStorageLangService) {
TorrentsService, getStorageLangService) {
var vm = this;
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
Expand Down Expand Up @@ -186,31 +186,67 @@
g.push(item.name);
});

var com = [];
angular.forEach(vm.movieinfo.production_companies, function (item) {
com.push(item.name);
});

var country = [];
angular.forEach(vm.movieinfo.production_countries, function (item) {
country.push(item.iso_3166_1);
});

var casts = [], i = 0;
angular.forEach(vm.movieinfo.credits.cast, function (item) {
if (i < 6) {
var c = {
name: item.name,
character: item.character,
profile_path: item.profile_path
};
casts.push(c);
i++
}
});

var dir = undefined;
angular.forEach(vm.movieinfo.credits.crew, function (item) {
if (item.job === 'Director') {
dir = item.name;
}
});


var torrent = new TorrentsService({
info_hash: vm.torrentInfo.info_hash,
torrent_filename: vm.torrentInfo.filename,
torrent_tmdb_id: vm.tmdb_id,
torrent_imdb_id: vm.movieinfo.imdb_id,
torrent_title: vm.movieinfo.title,
torrent_original_title: vm.movieinfo.original_title,
torrent_original_language: vm.movieinfo.original_language,
torrent_tagline: vm.movieinfo.tagline,
torrent_overview: vm.movieinfo.overview,
torrent_type: 'movie',
torrent_genres: g,
torrent_companies: com,
torrent_countries: country,
torrent_cast: casts,
torrent_director: dir,
torrent_tags: t,
torrent_nfo: vm.videoNfo,
torrent_announce: vm.torrentInfo.announce,
torrent_imdb_votes: vm.movieinfo.vote_average,
torrent_imdb_votes_users: vm.movieinfo.vote_count,
torrent_runtime: vm.movieinfo.runtime,
torrent_budget: vm.movieinfo.budget,
torrent_revenue: vm.movieinfo.revenue,
torrent_size: l,
torrent_img: vm.movieinfo.poster_path,
torrent_backdrop_img: vm.movieinfo.backdrop_path,
torrent_release: d.getFullYear()
});

console.log(torrent);

torrent.$save(function (response) {
successCallback(response);
}, function (errorResponse) {
Expand Down
12 changes: 8 additions & 4 deletions modules/torrents/client/views/view-torrent.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
<dt class="h-line">{{ 'TMDB_FIELDS.RUNTIME' | translate}}:</dt>
<dd class="h-line">{{vm.movieinfo.runtime | runtime}}</dd>

<dt class="h-line">{{ 'TMDB_FIELDS.BUDGET' | translate}}:</dt>
<dd class="h-line">{{vm.movieinfo.budget | dollar:2}}</dd>
<div ng-hide="vm.movieTopOne.torrent_budget == 0">
<dt class="h-line">{{ 'TMDB_FIELDS.BUDGET' | translate}}:</dt>
<dd class="h-line">{{vm.movieinfo.budget | dollar:2}}</dd>
</div>

<dt class="h-line">{{ 'TMDB_FIELDS.REVENUE' | translate}}:</dt>
<dd class="h-line">{{vm.movieinfo.revenue | dollar:2}}</dd>
<div ng-hide="vm.movieTopOne.torrent_revenue == 0">
<dt class="h-line">{{ 'TMDB_FIELDS.REVENUE' | translate}}:</dt>
<dd class="h-line">{{vm.movieinfo.revenue | dollar:2}}</dd>
</div>

<dt class="h-line">{{ 'TMDB_FIELDS.VOTE_AVERAGE' | translate}}:</dt>
<dd class="h-line">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ exports.create = function (req, res) {
var torrent = new Torrent(req.body);
torrent.user = req.user;

//console.log(torrent);

torrent.save(function (err) {
if (err) {
return res.status(422).send({
Expand Down

0 comments on commit 9625893

Please sign in to comment.