mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Only check browser notifications if enabled
This commit is contained in:
parent
a3a62b1d94
commit
600bca7e8b
4 changed files with 56 additions and 41 deletions
|
@ -296,6 +296,9 @@ ${next.headerIncludes()}
|
||||||
<script src="${http_root}js/bootstrap-hover-dropdown.min.js"></script>
|
<script src="${http_root}js/bootstrap-hover-dropdown.min.js"></script>
|
||||||
<script src="${http_root}js/pnotify.custom.min.js"></script>
|
<script src="${http_root}js/pnotify.custom.min.js"></script>
|
||||||
<script src="${http_root}js/script.js"></script>
|
<script src="${http_root}js/script.js"></script>
|
||||||
|
% if plexpy.CONFIG.BROWSER_ENABLED:
|
||||||
|
<script src="${http_root}js/ajaxNotifications.js"></script>
|
||||||
|
% endif
|
||||||
<script>
|
<script>
|
||||||
$('#updateDismiss').click(function() {
|
$('#updateDismiss').click(function() {
|
||||||
$('#updatebar').slideUp('slow');
|
$('#updatebar').slideUp('slow');
|
||||||
|
|
42
data/interfaces/default/js/ajaxNotifications.js
Normal file
42
data/interfaces/default/js/ajaxNotifications.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Taken from https://github.com/SickRage/SickRage
|
||||||
|
|
||||||
|
PNotify.prototype.options.addclass = "stack-bottomright";
|
||||||
|
PNotify.prototype.options.buttons.closer_hover = false;
|
||||||
|
PNotify.prototype.options.desktop = { desktop: true, icon: 'images/favicon.png' }
|
||||||
|
PNotify.prototype.options.history = false;
|
||||||
|
PNotify.prototype.options.shadow = false;
|
||||||
|
PNotify.prototype.options.stack = { dir1: 'up', dir2: 'left', firstpos1: 25, firstpos2: 25 };
|
||||||
|
PNotify.prototype.options.styling = 'fontawesome';
|
||||||
|
PNotify.prototype.options.type = 'notice';
|
||||||
|
PNotify.prototype.options.width = '340px';
|
||||||
|
|
||||||
|
function displayPNotify(title, message) {
|
||||||
|
var notification = new PNotify({
|
||||||
|
title: title,
|
||||||
|
text: message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_notifications() {
|
||||||
|
$.getJSON('get_browser_notifications', function (data) {
|
||||||
|
if (data) {
|
||||||
|
$.each(data, function (i, notification) {
|
||||||
|
if (notification.delay == 0) {
|
||||||
|
PNotify.prototype.options.hide = false;
|
||||||
|
} else {
|
||||||
|
PNotify.prototype.options.hide = true;
|
||||||
|
PNotify.prototype.options.delay = notification.delay * 1000;
|
||||||
|
}
|
||||||
|
displayPNotify(notification.subject_text, notification.body_text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
"use strict";
|
||||||
|
check_notifications();
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
check_notifications();
|
||||||
|
});
|
|
@ -407,43 +407,4 @@ window.onerror = function (message, file, line) {
|
||||||
|
|
||||||
$.post("log_js_errors", e, function (data) {
|
$.post("log_js_errors", e, function (data) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
PNotify.prototype.options.addclass = "stack-bottomright";
|
|
||||||
PNotify.prototype.options.buttons.closer_hover = false;
|
|
||||||
PNotify.prototype.options.desktop = { desktop: true, icon: 'images/favicon.png' }
|
|
||||||
PNotify.prototype.options.history = false;
|
|
||||||
PNotify.prototype.options.shadow = false;
|
|
||||||
PNotify.prototype.options.stack = { dir1: 'up', dir2: 'left', firstpos1: 25, firstpos2: 25 };
|
|
||||||
PNotify.prototype.options.styling = 'fontawesome';
|
|
||||||
PNotify.prototype.options.type = 'notice';
|
|
||||||
PNotify.prototype.options.width = '340px';
|
|
||||||
|
|
||||||
function displayPNotify(title, message) {
|
|
||||||
var notification = new PNotify({
|
|
||||||
title: title,
|
|
||||||
text: message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_notifications() {
|
|
||||||
$.getJSON('get_browser_notifications', function (data) {
|
|
||||||
$.each(data, function (i, notification) {
|
|
||||||
if (notification.delay == 0) {
|
|
||||||
PNotify.prototype.options.hide = false;
|
|
||||||
} else {
|
|
||||||
PNotify.prototype.options.hide = true;
|
|
||||||
PNotify.prototype.options.delay = notification.delay * 1000;
|
|
||||||
}
|
|
||||||
displayPNotify(notification.subject_text, notification.body_text);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
setTimeout(function () {
|
|
||||||
"use strict";
|
|
||||||
check_notifications();
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
check_notifications();
|
|
||||||
});
|
|
|
@ -2438,6 +2438,9 @@ class Browser(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_notifications(self):
|
def get_notifications(self):
|
||||||
|
if not self.enabled:
|
||||||
|
return
|
||||||
|
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
result = monitor_db.select('SELECT subject_text, body_text FROM notify_log '
|
result = monitor_db.select('SELECT subject_text, body_text FROM notify_log '
|
||||||
'WHERE agent_id = 17 AND timestamp >= ? ',
|
'WHERE agent_id = 17 AND timestamp >= ? ',
|
||||||
|
@ -2457,7 +2460,13 @@ class Browser(object):
|
||||||
self.notify('PlexPy', 'Test Notification')
|
self.notify('PlexPy', 'Test Notification')
|
||||||
|
|
||||||
def return_config_options(self):
|
def return_config_options(self):
|
||||||
config_option = [{'label': 'Allow Notifications',
|
config_option = [{'label': 'Enable Browser Notifications',
|
||||||
|
'value': self.enabled,
|
||||||
|
'name': 'browser_enabled',
|
||||||
|
'description': 'Enable to display desktop notifications from your browser.',
|
||||||
|
'input_type': 'checkbox'
|
||||||
|
},
|
||||||
|
{'label': 'Allow Notifications',
|
||||||
'value': 'Allow Notifications',
|
'value': 'Allow Notifications',
|
||||||
'name': 'allow_browser',
|
'name': 'allow_browser',
|
||||||
'description': 'Click to allow browser notifications. You must click this button for each browser.',
|
'description': 'Click to allow browser notifications. You must click this button for each browser.',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue