List notifications
This commit is contained in:
@@ -33,6 +33,19 @@ class CoreNotifier(Notification):
|
|||||||
'id': {'desc': 'Notification id you want to mark as read.', 'type': 'int (comma separated)'},
|
'id': {'desc': 'Notification id you want to mark as read.', 'type': 'int (comma separated)'},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addApiView('notification.list', self.listView, docs = {
|
||||||
|
'desc': 'Get list of notifications',
|
||||||
|
'params': {
|
||||||
|
'limit_offset': {'desc': 'Limit and offset the notification list. Examples: "50" or "50,30"'},
|
||||||
|
},
|
||||||
|
'return': {'type': 'object', 'example': """{
|
||||||
|
'success': True,
|
||||||
|
'empty': bool, any notification returned or not,
|
||||||
|
'notifications': array, notifications found,
|
||||||
|
}"""}
|
||||||
|
})
|
||||||
|
|
||||||
addApiView('notification.listener', self.listener)
|
addApiView('notification.listener', self.listener)
|
||||||
|
|
||||||
self.registerEvents()
|
self.registerEvents()
|
||||||
@@ -57,6 +70,32 @@ class CoreNotifier(Notification):
|
|||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def listView(self):
|
||||||
|
|
||||||
|
db = get_session()
|
||||||
|
limit_offset = getParam('limit_offset', None)
|
||||||
|
|
||||||
|
q = db.query(Notif)
|
||||||
|
|
||||||
|
if limit_offset:
|
||||||
|
splt = limit_offset.split(',')
|
||||||
|
limit = splt[0]
|
||||||
|
offset = 0 if len(splt) is 1 else splt[1]
|
||||||
|
q = q.limit(limit).offset(offset)
|
||||||
|
|
||||||
|
results = q.all()
|
||||||
|
notifications = []
|
||||||
|
for n in results:
|
||||||
|
ndict = n.to_dict()
|
||||||
|
ndict['type'] = 'notification'
|
||||||
|
notifications.append(ndict)
|
||||||
|
|
||||||
|
return jsonified({
|
||||||
|
'success': True,
|
||||||
|
'empty': len(notifications) == 0,
|
||||||
|
'notifications': notifications
|
||||||
|
})
|
||||||
|
|
||||||
def notify(self, message = '', data = {}):
|
def notify(self, message = '', data = {}):
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
@@ -93,7 +132,10 @@ class CoreNotifier(Notification):
|
|||||||
# Get unread
|
# Get unread
|
||||||
if getParam('init'):
|
if getParam('init'):
|
||||||
db = get_session()
|
db = get_session()
|
||||||
notifications = db.query(Notif).filter_by(read = False).all()
|
|
||||||
|
notifications = db.query(Notif) \
|
||||||
|
.filter(or_(Notif.read == False, Notif.added > (time.time() - 259200))) \
|
||||||
|
.all()
|
||||||
for n in notifications:
|
for n in notifications:
|
||||||
ndict = n.to_dict()
|
ndict = n.to_dict()
|
||||||
ndict['type'] = 'notification'
|
ndict['type'] = 'notification'
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ var NotificationBase = new Class({
|
|||||||
$(App.block.notification).inject(App.getBlock('search'), 'after');
|
$(App.block.notification).inject(App.getBlock('search'), 'after');
|
||||||
self.badge = new Element('div.badge').inject(App.block.notification, 'top').hide();
|
self.badge = new Element('div.badge').inject(App.block.notification, 'top').hide();
|
||||||
|
|
||||||
App.getBlock('notification').addLink(new Element('a.more', {
|
/* App.getBlock('notification').addLink(new Element('a.more', {
|
||||||
'href': App.createUrl('notifications'),
|
'href': App.createUrl('notifications'),
|
||||||
'text': 'See more notifications'
|
'text': 'Show older notifications'
|
||||||
}));
|
})); */
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -41,7 +41,7 @@ var NotificationBase = new Class({
|
|||||||
added.setTime(result.added*1000)
|
added.setTime(result.added*1000)
|
||||||
|
|
||||||
result.el = App.getBlock('notification').addLink(
|
result.el = App.getBlock('notification').addLink(
|
||||||
new Element('span').adopt(
|
new Element('span.'+(result.read ? 'read' : '' )).adopt(
|
||||||
new Element('span.message', {'text': result.message}),
|
new Element('span.message', {'text': result.message}),
|
||||||
new Element('span.added', {'text': added.timeDiffInWords(), 'title': added})
|
new Element('span.added', {'text': added.timeDiffInWords(), 'title': added})
|
||||||
)
|
)
|
||||||
@@ -51,11 +51,6 @@ var NotificationBase = new Class({
|
|||||||
if(!result.read)
|
if(!result.read)
|
||||||
self.setBadge(self.notifications.filter(function(n){ return !n.read}).length)
|
self.setBadge(self.notifications.filter(function(n){ return !n.read}).length)
|
||||||
|
|
||||||
if(self.notifications.length >= 5){
|
|
||||||
var n = self.notifications[self.notifications.length-5];
|
|
||||||
n.el.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setBadge: function(value){
|
setBadge: function(value){
|
||||||
@@ -76,14 +71,15 @@ var NotificationBase = new Class({
|
|||||||
ids.include(n.id)
|
ids.include(n.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
Api.request('notification.markread', {
|
if(ids.length > 0)
|
||||||
'data': {
|
Api.request('notification.markread', {
|
||||||
'ids': ids.join(',')
|
'data': {
|
||||||
},
|
'ids': ids.join(',')
|
||||||
'onSuccess': function(){
|
},
|
||||||
self.setBadge('')
|
'onSuccess': function(){
|
||||||
}
|
self.setBadge('')
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class MoviePlugin(Plugin):
|
|||||||
'desc': 'List movies in wanted list',
|
'desc': 'List movies in wanted list',
|
||||||
'params': {
|
'params': {
|
||||||
'status': {'type': 'array or csv', 'desc': 'Filter movie by status. Example:"active,done"'},
|
'status': {'type': 'array or csv', 'desc': 'Filter movie by status. Example:"active,done"'},
|
||||||
'limit_offset': {'desc': 'Limit the movie list. Examples: "50", "50,30"'},
|
'limit_offset': {'desc': 'Limit and offset the movie list. Examples: "50" or "50,30"'},
|
||||||
'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all movies starting with the letter "a"'},
|
'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all movies starting with the letter "a"'},
|
||||||
'search': {'desc': 'Search movie title'},
|
'search': {'desc': 'Search movie title'},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,6 +89,7 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
width: 64%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.movies .info .year {
|
.movies .info .year {
|
||||||
@@ -125,12 +126,22 @@
|
|||||||
.movies .list_view .info .description, .movies .mass_edit_view .info .description {
|
.movies .list_view .info .description, .movies .mass_edit_view .info .description {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.movies .data .quality {
|
||||||
|
display: block;
|
||||||
|
min-height: 20px;
|
||||||
|
vertical-align: mid;
|
||||||
|
}
|
||||||
|
|
||||||
.movies .data .quality span {
|
.movies .data .quality span {
|
||||||
padding: 2px 3px;
|
padding: 2px 3px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 12px;
|
||||||
|
vertical-align: middle;
|
||||||
|
display: inline-block;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@@ -141,7 +152,7 @@
|
|||||||
.movies .list_view .data .quality, .movies .mass_edit_view .data .quality {
|
.movies .list_view .data .quality, .movies .mass_edit_view .data .quality {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
float: right;
|
float: right;
|
||||||
width: 35%;
|
width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.movies .data .quality .available, .movies .data .quality .snatched {
|
.movies .data .quality .available, .movies .data .quality .snatched {
|
||||||
@@ -152,6 +163,10 @@
|
|||||||
|
|
||||||
.movies .data .quality .available { background-color: #578bc3; }
|
.movies .data .quality .available { background-color: #578bc3; }
|
||||||
.movies .data .quality .snatched { background-color: #369545; }
|
.movies .data .quality .snatched { background-color: #369545; }
|
||||||
|
.movies .data .quality .done {
|
||||||
|
background-color: #369545;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
.movies .data .quality .finish {
|
.movies .data .quality .finish {
|
||||||
background-image: url('../images/sprite.png');
|
background-image: url('../images/sprite.png');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
@@ -183,7 +198,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.movies .list_view .data:hover .actions, .movies .mass_edit_view .data:hover .actions {
|
.movies .list_view .data:hover .actions, .movies .mass_edit_view .data:hover .actions {
|
||||||
margin: -35px -7px 0 0;
|
margin: -34px 2px 0 0;
|
||||||
background: #4e5969;
|
background: #4e5969;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +287,7 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
}
|
}
|
||||||
.movies .options .table.files .name { width: 608px; }
|
.movies .options .table.files .name { width: 605px; }
|
||||||
.movies .options .table .type { width: 130px; }
|
.movies .options .table .type { width: 130px; }
|
||||||
.movies .options .table .is_available { width: 90px; }
|
.movies .options .table .is_available { width: 90px; }
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ var Movie = new Class({
|
|||||||
self.quality = new Element('div.quality', {
|
self.quality = new Element('div.quality', {
|
||||||
'events': {
|
'events': {
|
||||||
'click': function(e){
|
'click': function(e){
|
||||||
self.el.getElement('.actions .releases').fireEvent('click', [e])
|
var releases = self.el.getElement('.actions .releases');
|
||||||
|
if(releases)
|
||||||
|
releases.fireEvent('click', [e])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -101,7 +103,7 @@ var Movie = new Class({
|
|||||||
var q = Quality.getQuality(quality_id);
|
var q = Quality.getQuality(quality_id);
|
||||||
return new Element('span', {
|
return new Element('span', {
|
||||||
'text': q.label,
|
'text': q.label,
|
||||||
'class': 'q_'+q.identifier + 'q_id' + q.quality_id
|
'class': 'q_'+q.identifier + ' q_id' + q.id
|
||||||
}).inject(self.quality);
|
}).inject(self.quality);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ Block.Menu = new Class({
|
|||||||
self.el = new Element('div', {
|
self.el = new Element('div', {
|
||||||
'class': 'more_menu '+self.options['class']
|
'class': 'more_menu '+self.options['class']
|
||||||
}).adopt(
|
}).adopt(
|
||||||
self.more_option_ul = new Element('ul'),
|
self.wrapper = new Element('div.wrapper').adopt(
|
||||||
|
self.more_option_ul = new Element('ul')
|
||||||
|
),
|
||||||
new Element('a.button.onlay', {
|
new Element('a.button.onlay', {
|
||||||
'events': {
|
'events': {
|
||||||
'click': function(){
|
'click': function(){
|
||||||
|
|||||||
@@ -235,11 +235,11 @@ body > .spinner, .mask{
|
|||||||
.header .more_menu {
|
.header .more_menu {
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
}
|
}
|
||||||
.header .more_menu ul {
|
.header .more_menu .wrapper {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
margin-left: -110px;
|
margin-left: -110px;
|
||||||
}
|
}
|
||||||
.header .more_menu ul:before {
|
.header .more_menu .wrapper:before {
|
||||||
margin-left: -34px;
|
margin-left: -34px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,15 +262,21 @@ body > .spinner, .mask{
|
|||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header .notification_menu ul {
|
.header .notification_menu .wrapper {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
margin-left: -260px;
|
margin-left: -260px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.header .notification_menu ul:before {
|
|
||||||
|
.header .notification_menu .wrapper:before {
|
||||||
left: 296px;
|
left: 296px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header .notification_menu ul {
|
||||||
|
max-height: 300px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.header .notification_menu > a {
|
.header .notification_menu > a {
|
||||||
background-position: center -209px;
|
background-position: center -209px;
|
||||||
}
|
}
|
||||||
@@ -280,6 +286,8 @@ body > .spinner, .mask{
|
|||||||
display: block;
|
display: block;
|
||||||
border-bottom: 1px solid rgba(0,0,0,0.2);
|
border-bottom: 1px solid rgba(0,0,0,0.2);
|
||||||
}
|
}
|
||||||
|
.header .notification_menu li > span { color: #777; }
|
||||||
|
.header .notification_menu li:last-child > span { border: 0; }
|
||||||
.header .notification_menu li .added {
|
.header .notification_menu li .added {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
@@ -509,7 +517,7 @@ body > .spinner, .mask{
|
|||||||
background-color: #406db8;
|
background-color: #406db8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more_menu ul {
|
.more_menu .wrapper {
|
||||||
display: none;
|
display: none;
|
||||||
border: 1px solid #333;
|
border: 1px solid #333;
|
||||||
background: rgba(255,255,255,0.98);
|
background: rgba(255,255,255,0.98);
|
||||||
@@ -520,7 +528,6 @@ body > .spinner, .mask{
|
|||||||
margin: 32px 0 0 -145px;
|
margin: 32px 0 0 -145px;
|
||||||
width: 185px;
|
width: 185px;
|
||||||
box-shadow: 0 10px 10px -5px rgba(0,0,0,0.4);
|
box-shadow: 0 10px 10px -5px rgba(0,0,0,0.4);
|
||||||
list-style: none;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #000;
|
color: #000;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
@@ -538,7 +545,7 @@ body > .spinner, .mask{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
.more_menu ul:before {
|
.more_menu .wrapper:before {
|
||||||
content: ' ';
|
content: ' ';
|
||||||
height: 0;
|
height: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -549,15 +556,22 @@ body > .spinner, .mask{
|
|||||||
top: -16px;
|
top: -16px;
|
||||||
left: 146px;
|
left: 146px;
|
||||||
}
|
}
|
||||||
.more_menu.show ul {
|
.more_menu.show .wrapper {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.more_menu ul li {
|
|
||||||
|
.more_menu ul {
|
||||||
|
padding: 0;
|
||||||
|
margin: -12px 0 0 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more_menu .wrapper li {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more_menu ul li a {
|
.more_menu .wrapper li a {
|
||||||
display: block;
|
display: block;
|
||||||
border-bottom: 1px solid rgba(255,255,255,0.2);
|
border-bottom: 1px solid rgba(255,255,255,0.2);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
@@ -568,14 +582,10 @@ body > .spinner, .mask{
|
|||||||
padding: 3px 0;
|
padding: 3px 0;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more_menu ul li:first-child {
|
|
||||||
margin-top: -12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.more_menu ul li:last-child a {
|
.more_menu .wrapper li:last-child a {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
.more_menu ul li a:hover {
|
.more_menu .wrapper li a:hover {
|
||||||
background: rgba(0,0,0,0.05);
|
background: rgba(0,0,0,0.05);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user