Browse Source

Single movie UI update

pull/358/merge
Ruud 13 years ago
parent
commit
06db2d9850
  1. 9
      couchpotato/core/notifications/core/main.py
  2. 2
      couchpotato/core/notifications/core/static/notification.js
  3. 2
      couchpotato/core/plugins/library/main.py
  4. 12
      couchpotato/core/plugins/movie/main.py
  5. 63
      couchpotato/core/plugins/movie/static/movie.js
  6. 14
      couchpotato/core/plugins/searcher/main.py
  7. 2
      couchpotato/static/scripts/page/wanted.js

9
couchpotato/core/notifications/core/main.py

@ -1,6 +1,6 @@
from couchpotato import get_session from couchpotato import get_session
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import addEvent, fireEvent from couchpotato.core.event import addEvent
from couchpotato.core.helpers.encoding import toUnicode from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.helpers.request import jsonified, getParam from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.helpers.variable import tryInt from couchpotato.core.helpers.variable import tryInt
@ -48,13 +48,6 @@ class CoreNotifier(Notification):
addApiView('notification.listener', self.listener) addApiView('notification.listener', self.listener)
self.registerEvents()
def registerEvents(self):
# Library update, frontend refresh
addEvent('library.update_finish', lambda data: fireEvent('notify.frontend', type = 'library.update', data = data))
def markAsRead(self): def markAsRead(self):
ids = [x.strip() for x in getParam('ids').split(',')] ids = [x.strip() for x in getParam('ids').split(',')]

2
couchpotato/core/notifications/core/static/notification.js

@ -88,7 +88,7 @@ var NotificationBase = new Class({
self.request = Api.request('notification.listener', { self.request = Api.request('notification.listener', {
'initialDelay': 100, 'initialDelay': 100,
'delay': 3000, 'delay': 1500,
'data': {'init':true}, 'data': {'init':true},
'onSuccess': self.processData.bind(self) 'onSuccess': self.processData.bind(self)
}) })

2
couchpotato/core/plugins/library/main.py

@ -127,7 +127,7 @@ class LibraryPlugin(Plugin):
library_dict = library.to_dict(self.default_dict) library_dict = library.to_dict(self.default_dict)
fireEvent('library.update_finish', data = library_dict) fireEvent('notify.frontend', type = 'library.update.%s' % identifier, data = library_dict)
#db.close() #db.close()
return library_dict return library_dict

12
couchpotato/core/plugins/movie/main.py

@ -247,8 +247,16 @@ class MoviePlugin(Plugin):
if title.default: default_title = title.title if title.default: default_title = title.title
if movie: if movie:
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True) def notifyFront():
fireEventAsync('searcher.single', movie.to_dict(self.default_dict)) movie = db.query(Movie).filter_by(id = id).first()
fireEvent('notify.frontend', type = 'movie.update.%s' % movie.id, data = movie.to_dict(self.default_dict))
def afterUpdate():
movie = db.query(Movie).filter_by(id = id).first()
fireEventAsync('searcher.single', movie.to_dict(self.default_dict), on_complete = notifyFront)
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True, on_complete = afterUpdate)
#db.close() #db.close()
return jsonified({ return jsonified({

63
couchpotato/core/plugins/movie/static/movie.js

@ -11,14 +11,74 @@ var Movie = new Class({
self.view = options.view || 'thumbs'; self.view = options.view || 'thumbs';
self.list = list; self.list = list;
self.el = new Element('div.movie.inlay');
self.profile = Quality.getProfile(data.profile_id) || {}; self.profile = Quality.getProfile(data.profile_id) || {};
self.parent(self, options); self.parent(self, options);
App.addEvent('movie.update.'+data.id, self.update.bind(self));
App.addEvent('searcher.started.'+data.id, self.searching.bind(self));
App.addEvent('searcher.ended.'+data.id, self.searching.bind(self));
},
searching: function(notification){
var self = this;
if(notification && notification.type.indexOf('ended') > -1){
if(self.spinner){
self.mask.fade('out');
setTimeout(function(){
self.mask.destroy();
self.spinner.el.destroy();
self.spinner = null;
self.mask = null;
}, 400);
}
}
else if(!self.spinner) {
self.createMask();
self.spinner = createSpinner(self.mask);
self.positionMask();
self.mask.fade('in');
}
},
createMask: function(){
var self = this;
self.mask = new Element('div.mask', {
'styles': {
'z-index': '1'
}
}).inject(self.el, 'top').fade('hide');
self.positionMask();
},
positionMask: function(){
var self = this,
s = self.el.getSize()
return self.mask.setStyles({
'width': s.x,
'height': s.y
}).position({
'relativeTo': self.el
})
},
update: function(notification){
var self = this;
self.data = notification.data;
self.container.destroy();
self.profile = Quality.getProfile(self.data.profile_id) || {};
self.create();
}, },
create: function(){ create: function(){
var self = this; var self = this;
self.el = new Element('div.movie.inlay').adopt( self.el.adopt(
self.container = new Element('div').adopt(
self.select_checkbox = new Element('input[type=checkbox].inlay', { self.select_checkbox = new Element('input[type=checkbox].inlay', {
'events': { 'events': {
'change': function(){ 'change': function(){
@ -59,6 +119,7 @@ var Movie = new Class({
), ),
self.actions = new Element('div.actions') self.actions = new Element('div.actions')
) )
)
); );
self.changeView(self.view); self.changeView(self.view);

14
couchpotato/core/plugins/searcher/main.py

@ -83,6 +83,9 @@ class Searcher(Plugin):
if not default_title: if not default_title:
return return
fireEvent('notify.frontend', type = 'searcher.started.%s' % movie['id'], data = True)
ret = False
for quality_type in movie['profile']['types']: for quality_type in movie['profile']['types']:
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases): if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title)) log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title))
@ -107,7 +110,7 @@ class Searcher(Plugin):
# Check if movie isn't deleted while searching # Check if movie isn't deleted while searching
if not db.query(Movie).filter_by(id = movie.get('id')).first(): if not db.query(Movie).filter_by(id = movie.get('id')).first():
return break
# Add them to this movie releases list # Add them to this movie releases list
for nzb in sorted_results: for nzb in sorted_results:
@ -144,7 +147,8 @@ class Searcher(Plugin):
for nzb in sorted_results: for nzb in sorted_results:
downloaded = self.download(data = nzb, movie = movie) downloaded = self.download(data = nzb, movie = movie)
if downloaded is True: if downloaded is True:
return True ret = True
break
elif downloaded != 'try_next': elif downloaded != 'try_next':
break break
else: else:
@ -153,11 +157,13 @@ class Searcher(Plugin):
break break
# Break if CP wants to shut down # Break if CP wants to shut down
if self.shuttingDown(): if self.shuttingDown() or ret:
break break
fireEvent('notify.frontend', type = 'searcher.ended.%s' % movie['id'], data = True)
#db.close() #db.close()
return False return ret
def download(self, data, movie, manual = False): def download(self, data, movie, manual = False):

2
couchpotato/static/scripts/page/wanted.js

@ -17,7 +17,6 @@ Page.Wanted = new Class({
'actions': MovieActions 'actions': MovieActions
}); });
$(self.wanted).inject(self.el); $(self.wanted).inject(self.el);
App.addEvent('library.update', self.wanted.update.bind(self.wanted));
} }
} }
@ -131,6 +130,7 @@ window.addEvent('domready', function(){
var self = this; var self = this;
(e).preventDefault(); (e).preventDefault();
self.movie.searching();
Api.request('movie.refresh', { Api.request('movie.refresh', {
'data': { 'data': {
'id': self.movie.get('id') 'id': self.movie.get('id')

Loading…
Cancel
Save