Single movie UI update
This commit is contained in:
1 parent
b350f1e798
commit
06db2d9850
7 files changed
+124
-56
No files matched your search
@@ -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(',')]
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -11,53 +11,114 @@ 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.select_checkbox = new Element('input[type=checkbox].inlay', {
|
self.container = new Element('div').adopt(
|
||||||
'events': {
|
self.select_checkbox = new Element('input[type=checkbox].inlay', {
|
||||||
'change': function(){
|
'events': {
|
||||||
self.fireEvent('select')
|
'change': function(){
|
||||||
}
|
self.fireEvent('select')
|
||||||
}
|
|
||||||
}),
|
|
||||||
self.thumbnail = File.Select.single('poster', self.data.library.files),
|
|
||||||
self.data_container = new Element('div.data.inlay.light', {
|
|
||||||
'tween': {
|
|
||||||
duration: 400,
|
|
||||||
transition: 'quint:in:out',
|
|
||||||
onComplete: self.fireEvent.bind(self, 'slideEnd')
|
|
||||||
}
|
|
||||||
}).adopt(
|
|
||||||
self.info_container = new Element('div.info').adopt(
|
|
||||||
self.title = new Element('div.title', {
|
|
||||||
'text': self.getTitle() || 'n/a'
|
|
||||||
}),
|
|
||||||
self.year = new Element('div.year', {
|
|
||||||
'text': self.data.library.year || 'n/a'
|
|
||||||
}),
|
|
||||||
self.rating = new Element('div.rating.icon', {
|
|
||||||
'text': self.data.library.rating
|
|
||||||
}),
|
|
||||||
self.description = new Element('div.description', {
|
|
||||||
'text': self.data.library.plot
|
|
||||||
}),
|
|
||||||
self.quality = new Element('div.quality', {
|
|
||||||
'events': {
|
|
||||||
'click': function(e){
|
|
||||||
var releases = self.el.getElement('.actions .releases');
|
|
||||||
if(releases)
|
|
||||||
releases.fireEvent('click', [e])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
),
|
}),
|
||||||
self.actions = new Element('div.actions')
|
self.thumbnail = File.Select.single('poster', self.data.library.files),
|
||||||
|
self.data_container = new Element('div.data.inlay.light', {
|
||||||
|
'tween': {
|
||||||
|
duration: 400,
|
||||||
|
transition: 'quint:in:out',
|
||||||
|
onComplete: self.fireEvent.bind(self, 'slideEnd')
|
||||||
|
}
|
||||||
|
}).adopt(
|
||||||
|
self.info_container = new Element('div.info').adopt(
|
||||||
|
self.title = new Element('div.title', {
|
||||||
|
'text': self.getTitle() || 'n/a'
|
||||||
|
}),
|
||||||
|
self.year = new Element('div.year', {
|
||||||
|
'text': self.data.library.year || 'n/a'
|
||||||
|
}),
|
||||||
|
self.rating = new Element('div.rating.icon', {
|
||||||
|
'text': self.data.library.rating
|
||||||
|
}),
|
||||||
|
self.description = new Element('div.description', {
|
||||||
|
'text': self.data.library.plot
|
||||||
|
}),
|
||||||
|
self.quality = new Element('div.quality', {
|
||||||
|
'events': {
|
||||||
|
'click': function(e){
|
||||||
|
var releases = self.el.getElement('.actions .releases');
|
||||||
|
if(releases)
|
||||||
|
releases.fireEvent('click', [e])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
),
|
||||||
|
self.actions = new Element('div.actions')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in new issue
Block a user