From 483bf3307170574dbec56a306efb84efab7dfd63 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 10 Jun 2012 14:12:48 +0200 Subject: [PATCH] Show totals. close #393 --- couchpotato/core/plugins/movie/main.py | 11 ++++++----- couchpotato/core/plugins/movie/static/list.js | 16 ++++++++++++++-- couchpotato/core/plugins/movie/static/movie.css | 16 +++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/couchpotato/core/plugins/movie/main.py b/couchpotato/core/plugins/movie/main.py index bcd5d63e..f59ba0ba 100644 --- a/couchpotato/core/plugins/movie/main.py +++ b/couchpotato/core/plugins/movie/main.py @@ -130,6 +130,8 @@ class MoviePlugin(Plugin): .filter(or_(*[Movie.status.has(identifier = s) for s in status])) \ .group_by(Movie.id) + total_count = q.count() + filter_or = [] if starts_with: starts_with = toUnicode(starts_with.lower()) @@ -156,8 +158,7 @@ class MoviePlugin(Plugin): .options(joinedload_all('library.titles')) \ .options(joinedload_all('library.files')) \ .options(joinedload_all('status')) \ - .options(joinedload_all('files')) \ - + .options(joinedload_all('files')) if limit_offset: splt = [x.strip() for x in limit_offset.split(',')] @@ -165,7 +166,6 @@ class MoviePlugin(Plugin): offset = 0 if len(splt) is 1 else splt[1] q2 = q2.limit(limit).offset(offset) - results = q2.all() movies = [] for movie in results: @@ -178,7 +178,7 @@ class MoviePlugin(Plugin): movies.append(temp) #db.close() - return movies + return (total_count, movies) def availableChars(self, status = ['active']): @@ -214,11 +214,12 @@ class MoviePlugin(Plugin): starts_with = params.get('starts_with', None) search = params.get('search', None) - movies = self.list(status = status, limit_offset = limit_offset, starts_with = starts_with, search = search) + total_movies, movies = self.list(status = status, limit_offset = limit_offset, starts_with = starts_with, search = search) return jsonified({ 'success': True, 'empty': len(movies) == 0, + 'total': total_movies, 'movies': movies, }) diff --git a/couchpotato/core/plugins/movie/static/list.js b/couchpotato/core/plugins/movie/static/list.js index 52afbc20..38fc7109 100644 --- a/couchpotato/core/plugins/movie/static/list.js +++ b/couchpotato/core/plugins/movie/static/list.js @@ -72,7 +72,7 @@ var MovieList = new Class({ self.created = true; }, - addMovies: function(movies){ + addMovies: function(movies, total){ var self = this; if(!self.created) self.create(); @@ -86,8 +86,19 @@ var MovieList = new Class({ Object.each(movies, function(movie){ self.createMovie(movie); }); + + self.setCounter(total); }, + + setCounter: function(count){ + var self = this; + + if(!self.navigation_counter) return; + + self.navigation_counter.set('text', (count || 0)); + + }, createMovie: function(movie, inject_at){ var self = this; @@ -118,6 +129,7 @@ var MovieList = new Class({ self.navigation = new Element('div.alph_nav').adopt( self.navigation_actions = new Element('ul.inlay.actions.reversed'), + self.navigation_counter = new Element('span.counter[title=Total]'), self.navigation_alpha = new Element('ul.numbers', { 'events': { 'click:relay(li)': function(e, el){ @@ -443,7 +455,7 @@ var MovieList = new Class({ }, self.filter), 'onComplete': function(json){ self.store(json.movies); - self.addMovies(json.movies); + self.addMovies(json.movies, json.total); self.load_more.set('text', 'load more movies'); if(self.scrollspy) self.scrollspy.start(); } diff --git a/couchpotato/core/plugins/movie/static/movie.css b/couchpotato/core/plugins/movie/static/movie.css index f626f2ab..c2cae584 100644 --- a/couchpotato/core/plugins/movie/static/movie.css +++ b/couchpotato/core/plugins/movie/static/movie.css @@ -338,7 +338,9 @@ background: #4e5969; } -.movies .alph_nav ul.numbers, .movies .alph_nav ul.actions { +.movies .alph_nav ul.numbers, +.movies .alph_nav .counter, +.movies .alph_nav ul.actions { list-style: none; padding: 0 0 1px; margin: 0; @@ -346,10 +348,15 @@ user-select: none; } + .movies .alph_nav .counter { + width: 60px; + text-align: center; + } + .movies .alph_nav .numbers li, .movies .alph_nav .actions li { display: inline-block; vertical-align: top; - width: 22px; + width: 20px; height: 24px; line-height: 26px; text-align: center; @@ -361,7 +368,6 @@ } .movies .alph_nav .numbers li:first-child { width: 43px; - margin-left: 7px; } .movies .alph_nav li.available { color: rgba(255,255,255,0.8); @@ -370,8 +376,8 @@ } .movies .alph_nav li.active.available, .movies .alph_nav li.available:hover { color: #fff; - font-size: 24px; - line-height: 24px; + font-size: 20px; + line-height: 20px; } .movies .alph_nav input {