diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index a37a6667..e0af50de 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -136,23 +136,24 @@ class CoreNotifier(Notification): #db.close() return True - def frontend(self, type = 'notification', data = {}): + def frontend(self, type = 'notification', data = {}, message = None): self.m_lock.acquire() - message = { + notification = { 'message_id': str(uuid.uuid4()), 'time': time.time(), 'type': type, 'data': data, + 'message': message, } - self.messages.append(message) + self.messages.append(notification) while len(self.listeners) > 0 and not self.shuttingDown(): try: listener, last_id = self.listeners.pop() listener({ 'success': True, - 'result': [message], + 'result': [notification], }) except: break diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js index 8e6a52b8..d3811d4d 100644 --- a/couchpotato/core/notifications/core/static/notification.js +++ b/couchpotato/core/notifications/core/static/notification.js @@ -126,11 +126,12 @@ var NotificationBase = new Class({ processData: function(json){ var self = this; - // Process data if(json){ Array.each(json.result, function(result){ - App.fireEvent(result.type, result) + App.fireEvent(result.type, result); + if(result.message && result.read === undefined) + self.showMessage(result.message); }) if(json.result.length > 0) @@ -140,7 +141,31 @@ var NotificationBase = new Class({ // Restart poll self.startPoll() }, - + + showMessage: function(message){ + var self = this; + + if(!self.message_container) + self.message_container = new Element('div.messages').inject(document.body); + + var new_message = new Element('div.message', { + 'text': message + }).inject(self.message_container); + + setTimeout(function(){ + new_message.addClass('show') + }, 10); + + setTimeout(function(){ + new_message.addClass('hide') + setTimeout(function(){ + new_message.destroy(); + }, 1000); + }, 4000); + + }, + + // Notification setting tests addTestButtons: function(){ var self = this; diff --git a/couchpotato/core/plugins/movie/main.py b/couchpotato/core/plugins/movie/main.py index 3a7a7361..ab23a18c 100644 --- a/couchpotato/core/plugins/movie/main.py +++ b/couchpotato/core/plugins/movie/main.py @@ -240,7 +240,6 @@ class MoviePlugin(Plugin): db = get_session() for id in getParam('id').split(','): - fireEvent('notify.frontend', type = 'movie.busy.%s' % id, data = True) movie = db.query(Movie).filter_by(id = id).first() if movie: @@ -250,6 +249,7 @@ class MoviePlugin(Plugin): for title in movie.library.titles: if title.default: default_title = title.title + fireEvent('notify.frontend', type = 'movie.busy.%s' % id, data = True, message = 'Updating "%s"' % default_title) fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True, on_complete = self.createOnComplete(id)) @@ -342,7 +342,7 @@ class MoviePlugin(Plugin): onComplete() if added: - fireEvent('notify.frontend', type = 'movie.added', data = movie_dict) + fireEvent('notify.frontend', type = 'movie.added', data = movie_dict, message = 'Successfully added "%s" to your wanted list.' % params.get('title', '')) #db.close() return movie_dict diff --git a/couchpotato/core/plugins/movie/static/movie.js b/couchpotato/core/plugins/movie/static/movie.js index b7849e6a..d71eb648 100644 --- a/couchpotato/core/plugins/movie/static/movie.js +++ b/couchpotato/core/plugins/movie/static/movie.js @@ -17,10 +17,13 @@ var Movie = new Class({ self.parent(self, options); App.addEvent('movie.update.'+data.id, self.update.bind(self)); - App.addEvent('movie.busy.'+data.id, function(notification){ - if(notification.data) - self.busy(true) - }); + + ['movie.busy', 'searcher.started'].each(function(listener){ + App.addEvent(listener+'.'+data.id, function(notification){ + if(notification.data) + self.busy(true) + }); + }) }, busy: function(set_busy){ diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index ce8deeb5..18e89320 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -84,7 +84,7 @@ class Searcher(Plugin): if not default_title: return - fireEvent('notify.frontend', type = 'searcher.started.%s' % movie['id'], data = True) + fireEvent('notify.frontend', type = 'searcher.started.%s' % movie['id'], data = True, message = 'Searching for "%s"' % default_title) ret = False for quality_type in movie['profile']['types']: diff --git a/couchpotato/static/style/main.css b/couchpotato/static/style/main.css index dd792b87..8524534a 100644 --- a/couchpotato/static/style/main.css +++ b/couchpotato/static/style/main.css @@ -601,4 +601,40 @@ body > .spinner, .mask{ } .more_menu .wrapper li a:hover { background: rgba(0,0,0,0.05); - } \ No newline at end of file + } + +.messages { + position: fixed; + right: 0; + bottom: 0; + padding: 2px; + width: 240px; + z-index: 2; +} + + .messages .message { + text-align: center; + border-radius: 2px; + margin: 2px 0 0 0; + height: 0; + overflow: hidden; + position: relative; + transition: all .4s cubic-bezier(0.9,0,0.1,1); + font-size: 12px; + box-shadow: 0 1px 1px rgba(0,0,0,0.35), inset 0 1px 0px rgba(255,255,255,0.20); + background-image: linear-gradient( + 270deg, + #5b9bd1 0%, + #406db8 100% + ); + } + .messages .message.show { + height: auto; + padding: 3px 5px; + min-height: 10px; + max-height: 400px; + } + .messages .message.hide { + right: -240px; + opacity: 0; + } \ No newline at end of file