mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Merge pull request #239 from JonnyWong16/miscellaneous-fixes
Notification agent sounds
This commit is contained in:
commit
26d825dc09
9 changed files with 134 additions and 45 deletions
|
@ -65,7 +65,7 @@ DOCUMENTATION :: END
|
|||
%>
|
||||
|
||||
% if data:
|
||||
% if data[0]['rows'] or data[1]['rows'] or data[2]['rows'] or data[3]['rows'] or data[4]['rows'] or data[5]['rows']:
|
||||
% if data[0]['rows']:
|
||||
<ul class="list-unstyled">
|
||||
% for top_stat in data:
|
||||
% if top_stat['stat_id'] == 'top_tv' and top_stat['rows']:
|
||||
|
|
|
@ -214,13 +214,13 @@ history_table_options = {
|
|||
{
|
||||
"targets": [11],
|
||||
"data": "watched_status",
|
||||
"render": function (data, type, full) {
|
||||
if (data == 1) {
|
||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Watched"><i class="fa fa-lg fa-circle"></i></span>'
|
||||
} else if (data == 0.5) {
|
||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Partial"><i class="fa fa-lg fa-adjust fa-rotate-180"></i></span>'
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData == 1) {
|
||||
$(td).html('<span class="watched-tooltip" data-toggle="tooltip" title="' + rowData['percent_complete'] + '%"><i class="fa fa-lg fa-circle"></i></span>');
|
||||
} else if (cellData == 0.5) {
|
||||
$(td).html('<span class="watched-tooltip" data-toggle="tooltip" title="' + rowData['percent_complete'] + '%"><i class="fa fa-lg fa-adjust fa-rotate-180"></i></span>');
|
||||
} else {
|
||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Unwatched"><i class="fa fa-lg fa-circle-o"></i></span>'
|
||||
$(td).html('<span class="watched-tooltip" data-toggle="tooltip" title="' + rowData['percent_complete'] + '%"><i class="fa fa-lg fa-circle-o"></i></span>');
|
||||
}
|
||||
},
|
||||
"searchable": false,
|
||||
|
@ -236,12 +236,13 @@ history_table_options = {
|
|||
|
||||
// Create the tooltips.
|
||||
$('.expand-history-tooltip').tooltip({ container: 'body' });
|
||||
$('.external-ip-tooltip').tooltip();
|
||||
$('.transcode-tooltip').tooltip();
|
||||
$('.media-type-tooltip').tooltip();
|
||||
$('.watched-tooltip').tooltip();
|
||||
$('.external-ip-tooltip').tooltip({ container: 'body' });
|
||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
||||
$('.watched-tooltip').tooltip({ container: 'body' });
|
||||
$('.thumb-tooltip').popover({
|
||||
html: true,
|
||||
container: 'body',
|
||||
trigger: 'hover',
|
||||
placement: 'right',
|
||||
content: function () {
|
||||
|
|
|
@ -2,7 +2,7 @@ sync_table_options = {
|
|||
"processing": false,
|
||||
"serverSide": false,
|
||||
"pagingType": "bootstrap",
|
||||
"order": [ 0, 'desc'],
|
||||
"order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ],
|
||||
"pageLength": 25,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
|
|
|
@ -44,6 +44,24 @@ from plexpy import helpers
|
|||
<p class="help-block">${item['description']}</p>
|
||||
<input type="hidden" id="${item['name']}" name="${item['name']}" value="${item['value']}">
|
||||
</div>
|
||||
% elif item['input_type'] == 'select':
|
||||
<div class="form-group">
|
||||
<label for="${item['name']}">${item['label']}</label>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<select class="form-control" id="${item['name']}" name="${item['name']}" >
|
||||
% for key, value in sorted(item['select_options'].iteritems()):
|
||||
% if key == item['value']:
|
||||
<option value="${key}" selected>${value}</option>
|
||||
% else:
|
||||
<option value="${key}">${value}</option>
|
||||
% endif
|
||||
% endfor
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block">${item['description']}</p>
|
||||
</div>
|
||||
% endif
|
||||
% endfor
|
||||
</div>
|
||||
|
@ -68,29 +86,38 @@ from plexpy import helpers
|
|||
<script>
|
||||
$('#osxnotifyregister').click(function () {
|
||||
var osx_notify_app = $("#osx_notify_app").val();
|
||||
$.get("/osxnotifyregister", {'app': osx_notify_app}, function (data) { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+data+"</div>"); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut()
|
||||
$.get("/osxnotifyregister", { 'app': osx_notify_app }, function (data) { $('#ajaxMsg').html("<i class='fa fa-check'></i> " + data); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
})
|
||||
|
||||
var notificationConfig = $("#set_notification_config");
|
||||
$('#save-notification-item').click(function() {
|
||||
doAjaxCall('set_notification_config',$(this),'tabs',true);
|
||||
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
||||
// Reload modal to update certain fields
|
||||
$.ajax({
|
||||
url: 'get_notification_agent_config',
|
||||
data: { config_id: '${config_id}' },
|
||||
cache: false,
|
||||
async: true,
|
||||
complete: function (xhr, status) {
|
||||
$("#notification-config-modal").html(xhr.responseText);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#twitterStep1').click(function () {
|
||||
$.get("/twitterStep1", function (data) {window.open(data); })
|
||||
.done(function () { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>Confirm Authorization. Check pop-up blocker if no response.</div>"); });
|
||||
.done(function () { $('#ajaxMsg').html("<i class='fa fa-check'></i> Confirm Authorization. Check pop-up blocker if no response."); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
$('#twitterStep2').click(function () {
|
||||
var twitter_key = $("#twitter_key").val();
|
||||
$.get("/twitterStep2", {'key': twitter_key}, function (data) { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+data+"</div>"); });
|
||||
$.get("/twitterStep2", { 'key': twitter_key }, function (data) { $('#ajaxMsg').html("<i class='fa fa-check'></i> " + data); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
$('#testTwitter').click(function () {
|
||||
$.get("/testTwitter",
|
||||
function (data) { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+data+"</div>"); });
|
||||
function (data) { $('#ajaxMsg').html("<i class='fa fa-check'></i> " + data); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th align='left' id="state">State</th>
|
||||
<th align='left' id="username">Username</th>
|
||||
<th align='left' id="user">User</th>
|
||||
<th align='left' id="title">Title</th>
|
||||
<th align='left' id="type">Type</th>
|
||||
<th align='left' id="platform">Platform</th>
|
||||
|
|
|
@ -37,6 +37,7 @@ _CONFIG_DEFINITIONS = {
|
|||
'API_KEY': (str, 'General', ''),
|
||||
'BOXCAR_ENABLED': (int, 'Boxcar', 0),
|
||||
'BOXCAR_TOKEN': (str, 'Boxcar', ''),
|
||||
'BOXCAR_SOUND': (str, 'Boxcar', ''),
|
||||
'BOXCAR_ON_PLAY': (int, 'Boxcar', 0),
|
||||
'BOXCAR_ON_STOP': (int, 'Boxcar', 0),
|
||||
'BOXCAR_ON_PAUSE': (int, 'Boxcar', 0),
|
||||
|
|
|
@ -136,6 +136,7 @@ class DataFactory(object):
|
|||
"thumb": thumb,
|
||||
"video_decision": item["video_decision"],
|
||||
"audio_decision": item["audio_decision"],
|
||||
"percent_complete": int(round(item['percent_complete'])),
|
||||
"watched_status": watched_status,
|
||||
"group_count": item["group_count"],
|
||||
"group_ids": item["group_ids"]
|
||||
|
@ -159,7 +160,7 @@ class DataFactory(object):
|
|||
home_stats = []
|
||||
|
||||
for stat in stats_cards:
|
||||
if 'top_tv' in stat:
|
||||
if stat == 'top_tv':
|
||||
top_tv = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -205,7 +206,7 @@ class DataFactory(object):
|
|||
'stat_type': sort_type,
|
||||
'rows': top_tv})
|
||||
|
||||
elif 'popular_tv' in stat:
|
||||
elif stat == 'popular_tv':
|
||||
popular_tv = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -251,7 +252,7 @@ class DataFactory(object):
|
|||
home_stats.append({'stat_id': stat,
|
||||
'rows': popular_tv})
|
||||
|
||||
elif 'top_movies' in stat:
|
||||
elif stat == 'top_movies':
|
||||
top_movies = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -297,7 +298,7 @@ class DataFactory(object):
|
|||
'stat_type': sort_type,
|
||||
'rows': top_movies})
|
||||
|
||||
elif 'popular_movies' in stat:
|
||||
elif stat == 'popular_movies':
|
||||
popular_movies = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -343,7 +344,7 @@ class DataFactory(object):
|
|||
home_stats.append({'stat_id': stat,
|
||||
'rows': popular_movies})
|
||||
|
||||
elif 'top_music' in stat:
|
||||
elif stat == 'top_music':
|
||||
top_music = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -389,7 +390,7 @@ class DataFactory(object):
|
|||
'stat_type': sort_type,
|
||||
'rows': top_music})
|
||||
|
||||
elif 'popular_music' in stat:
|
||||
elif stat == 'popular_music':
|
||||
popular_music = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
@ -435,7 +436,7 @@ class DataFactory(object):
|
|||
home_stats.append({'stat_id': stat,
|
||||
'rows': popular_music})
|
||||
|
||||
elif 'top_users' in stat:
|
||||
elif stat == 'top_users':
|
||||
top_users = []
|
||||
try:
|
||||
query = 'SELECT session_history.user, ' \
|
||||
|
@ -488,7 +489,7 @@ class DataFactory(object):
|
|||
'stat_type': sort_type,
|
||||
'rows': top_users})
|
||||
|
||||
elif 'top_platforms' in stat:
|
||||
elif stat == 'top_platforms':
|
||||
top_platform = []
|
||||
|
||||
try:
|
||||
|
@ -536,7 +537,7 @@ class DataFactory(object):
|
|||
'stat_type': sort_type,
|
||||
'rows': top_platform})
|
||||
|
||||
elif 'last_watched' in stat:
|
||||
elif stat == 'last_watched':
|
||||
last_watched = []
|
||||
try:
|
||||
query = 'SELECT session_history_metadata.id, ' \
|
||||
|
|
|
@ -467,8 +467,9 @@ class PROWL(object):
|
|||
{'label': 'Priority',
|
||||
'value': self.priority,
|
||||
'name': 'prowl_priority',
|
||||
'description': 'Set the priority (-2,-1,0,1 or 2).',
|
||||
'input_type': 'number'
|
||||
'description': 'Set the priority.',
|
||||
'input_type': 'select',
|
||||
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -695,8 +696,9 @@ class NMA(object):
|
|||
{'label': 'Priority',
|
||||
'value': plexpy.CONFIG.NMA_PRIORITY,
|
||||
'name': 'nma_priority',
|
||||
'description': 'Set the priority (-2,-1,0,1 or 2).',
|
||||
'input_type': 'number'
|
||||
'description': 'Set the priority.',
|
||||
'input_type': 'select',
|
||||
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -872,9 +874,9 @@ class PUSHOVER(object):
|
|||
'priority': plexpy.CONFIG.PUSHOVER_PRIORITY}
|
||||
|
||||
http_handler.request("POST",
|
||||
"/1/messages.json",
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
body=urlencode(data))
|
||||
"/1/messages.json",
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
body=urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
# logger.debug(u"Pushover response status: %r" % request_status)
|
||||
|
@ -903,29 +905,49 @@ class PUSHOVER(object):
|
|||
|
||||
self.notify('Main Screen Activate', 'Test Message')
|
||||
|
||||
def get_sounds(self):
|
||||
http_handler = HTTPSConnection("api.pushover.net")
|
||||
http_handler.request("GET", "/1/sounds.json?token=" + self.application_token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
if request_status == 200:
|
||||
data = json.loads(response.read())
|
||||
sounds = data.get('sounds', {})
|
||||
sounds.update({'': ''})
|
||||
return sounds
|
||||
elif request_status >= 400 and request_status < 500:
|
||||
logger.info(u"Unable to retrieve Pushover notification sounds list: %s" % response.reason)
|
||||
return {'': ''}
|
||||
else:
|
||||
logger.info(u"Unable to retrieve Pushover notification sounds list.")
|
||||
return {'': ''}
|
||||
|
||||
def return_config_options(self):
|
||||
config_option = [{'label': 'Pushover API Key',
|
||||
config_option = [{'label': 'Pushover User Key',
|
||||
'value': self.keys,
|
||||
'name': 'pushover_keys',
|
||||
'description': 'Your Pushover API key.',
|
||||
'description': 'Your Pushover user key.',
|
||||
'input_type': 'text'
|
||||
},
|
||||
{'label': 'Priority',
|
||||
'value': self.priority,
|
||||
'name': 'pushover_priority',
|
||||
'description': 'Set the priority (-2,-1,0,1 or 2).',
|
||||
'input_type': 'number'
|
||||
'description': 'Set the priority.',
|
||||
'input_type': 'select',
|
||||
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
|
||||
},
|
||||
{'label': 'Sound',
|
||||
'value': self.sound,
|
||||
'name': 'pushover_sound',
|
||||
'description': 'Set the notification sound (choose from <a href="https://pushover.net/api#sounds" target="_blank">this list</a> or leave blank for default)',
|
||||
'input_type': 'text'
|
||||
'description': 'Set the notification sound. Leave blank for the default sound.',
|
||||
'input_type': 'select',
|
||||
'select_options': self.get_sounds()
|
||||
},
|
||||
{'label': 'Pushover API Token',
|
||||
'value': plexpy.CONFIG.PUSHOVER_APITOKEN,
|
||||
'name': 'pushover_apitoken',
|
||||
'description': 'Your Pushover API toekn. Leave blank to use PlexPy default.',
|
||||
'description': 'Your Pushover API token. Leave blank to use PlexPy default.',
|
||||
'input_type': 'text'
|
||||
}
|
||||
]
|
||||
|
@ -1144,6 +1166,7 @@ class BOXCAR(object):
|
|||
def __init__(self):
|
||||
self.url = 'https://new.boxcar.io/api/notifications'
|
||||
self.token = plexpy.CONFIG.BOXCAR_TOKEN
|
||||
self.sound = plexpy.CONFIG.BOXCAR_SOUND
|
||||
self.on_play = plexpy.CONFIG.BOXCAR_ON_PLAY
|
||||
self.on_stop = plexpy.CONFIG.BOXCAR_ON_STOP
|
||||
self.on_watched = plexpy.CONFIG.BOXCAR_ON_WATCHED
|
||||
|
@ -1157,7 +1180,7 @@ class BOXCAR(object):
|
|||
'user_credentials': plexpy.CONFIG.BOXCAR_TOKEN,
|
||||
'notification[title]': title.encode('utf-8'),
|
||||
'notification[long_message]': message.encode('utf-8'),
|
||||
'notification[sound]': "done"
|
||||
'notification[sound]': plexpy.CONFIG.BOXCAR_SOUND
|
||||
})
|
||||
|
||||
req = urllib2.Request(self.url)
|
||||
|
@ -1175,6 +1198,42 @@ class BOXCAR(object):
|
|||
'name': 'boxcar_token',
|
||||
'description': 'Your Boxcar access token.',
|
||||
'input_type': 'text'
|
||||
},
|
||||
{'label': 'Sound',
|
||||
'value': self.sound,
|
||||
'name': 'boxcar_sound',
|
||||
'description': 'Set the notification sound. Leave blank for the default sound.',
|
||||
'input_type': 'select',
|
||||
'select_options': {'': '',
|
||||
'beep-crisp': 'Beep (Crisp)',
|
||||
'beep-soft': 'Beep (Soft)',
|
||||
'bell-modern': 'Bell (Modern)',
|
||||
'bell-one-tone': 'Bell (One Tone)',
|
||||
'bell-simple': 'Bell (Simple)',
|
||||
'bell-triple': 'Bell (Triple)',
|
||||
'bird-1': 'Bird (1)',
|
||||
'bird-2': 'Bird (2)',
|
||||
'boing': 'Boing',
|
||||
'cash': 'Cash',
|
||||
'clanging': 'Clanging',
|
||||
'detonator-charge': 'Detonator Charge',
|
||||
'digital-alarm': 'Digital Alarm',
|
||||
'done': 'Done',
|
||||
'echo': 'Echo',
|
||||
'flourish': 'Flourish',
|
||||
'harp': 'Harp',
|
||||
'light': 'Light',
|
||||
'magic-chime':'Magic Chime',
|
||||
'magic-coin': 'Magic Coin',
|
||||
'no-sound': 'No Sound',
|
||||
'notifier-1': 'Notifier (1)',
|
||||
'notifier-2': 'Notifier (2)',
|
||||
'notifier-3': 'Notifier (3)',
|
||||
'orchestral-long': 'Orchestral (Long)',
|
||||
'orchestral-short': 'Orchestral (Short)',
|
||||
'score': 'Score',
|
||||
'success': 'Success',
|
||||
'up': 'Up'}
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -1305,7 +1305,7 @@ class WebInterface(object):
|
|||
checkboxes = {'email_tls': checked(plexpy.CONFIG.EMAIL_TLS)}
|
||||
|
||||
return serve_template(templatename="notification_config.html", title="Notification Configuration",
|
||||
data=config, checkboxes=checkboxes)
|
||||
config_id=config_id, data=config, checkboxes=checkboxes)
|
||||
|
||||
@cherrypy.expose
|
||||
def get_notification_agent_triggers(self, config_id, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue