mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 17:52:59 -07:00
Add test notification for all agents
This commit is contained in:
parent
1e616fa585
commit
f31c4dcccd
3 changed files with 59 additions and 52 deletions
|
@ -66,6 +66,27 @@ from plexpy import helpers
|
|||
% endfor
|
||||
</div>
|
||||
</form>
|
||||
<div class="col-md-12">
|
||||
<h4>Test ${agent['name']}</h4>
|
||||
<p class="help-block">Test if ${agent['name']} notifications are working. See logs for troubleshooting.</p>
|
||||
<div class="form-group">
|
||||
<label for="test_subject">Subject Line</label>
|
||||
<input class="form-control" type="text" id="test_subject" name="test_subject" value="PlexPy">
|
||||
<p class="help-block">Set a custom subject line.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="test_body">Message Body</label>
|
||||
<input class="form-control" type="text" id="test_body" name="test_body" value="Test notification">
|
||||
<p class="help-block">Set a custom body.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<input type="button" class="btn btn-bright" id="test_notifier" name="test_notifier" value="Test ${agent['name']}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -120,16 +141,21 @@ from plexpy import helpers
|
|||
$.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("<i class='fa fa-check'></i> " + data); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
|
||||
$('#testIFTTT').click(function () {
|
||||
$.get("/test_ifttt",
|
||||
function (data) { $('#ajaxMsg').html("<i class='fa fa-check'></i> " + data); });
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
$('#test_notifier').click(function () {
|
||||
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
||||
$.ajax({
|
||||
url: 'test_notifier',
|
||||
data: { config_id: '${agent["id"]}',
|
||||
subject: $('#test_subject').val(),
|
||||
body: $('#test_body').val() },
|
||||
cache: false,
|
||||
async: true,
|
||||
complete: function (xhr, status) {
|
||||
msg = '<i class="fa fa-check"></i> ' + xhr.responseText;
|
||||
showMsg(msg, false, true, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#testSlack').click(function() {
|
||||
|
|
|
@ -1198,12 +1198,6 @@ class TwitterNotifier(object):
|
|||
'description': 'Step 3: Verify the key.',
|
||||
'input_type': 'button'
|
||||
},
|
||||
{'label': 'Test Twitter',
|
||||
'value': 'Test Twitter',
|
||||
'name': 'testTwitter',
|
||||
'description': 'Test if Twitter notifications are working. See logs for troubleshooting.',
|
||||
'input_type': 'button'
|
||||
},
|
||||
{'input_type': 'nosave'
|
||||
}
|
||||
]
|
||||
|
@ -1522,12 +1516,6 @@ class IFTTT(object):
|
|||
'description': 'The Ifttt maker event to fire. The notification subject and body will be sent'
|
||||
' as value1 and value2 respectively.',
|
||||
'input_type': 'text'
|
||||
},
|
||||
{'label': 'Test Event',
|
||||
'value': 'Test Event',
|
||||
'name': 'testIFTTT',
|
||||
'description': 'Test if IFTTT notifications are working. See logs for troubleshooting.',
|
||||
'input_type': 'button'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -659,6 +659,30 @@ class WebInterface(object):
|
|||
|
||||
return a.fetchData()
|
||||
|
||||
@cherrypy.expose
|
||||
def test_notifier(self, config_id=None, subject='PlexPy', body='Test notification', **kwargs):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
|
||||
if config_id.isdigit():
|
||||
agents = notifiers.available_notification_agents()
|
||||
for agent in agents:
|
||||
if int(config_id) == agent['id']:
|
||||
this_agent = agent
|
||||
break
|
||||
else:
|
||||
this_agent = None
|
||||
|
||||
if this_agent:
|
||||
logger.debug("Sending test %s notification." % this_agent['name'])
|
||||
notifiers.send_notification(this_agent['id'], subject, body)
|
||||
return "Notification sent."
|
||||
else:
|
||||
logger.debug("Unable to send test notification, invalid notification agent ID %s." % config_id)
|
||||
return "Invalid notification agent ID %s." % config_id
|
||||
else:
|
||||
logger.debug("Unable to send test notification, no notification agent ID received.")
|
||||
return "No notification agent ID received."
|
||||
|
||||
@cherrypy.expose
|
||||
def twitterStep1(self):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
|
@ -676,37 +700,6 @@ class WebInterface(object):
|
|||
else:
|
||||
return "Unable to verify key"
|
||||
|
||||
@cherrypy.expose
|
||||
def testTwitter(self):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
tweet = notifiers.TwitterNotifier()
|
||||
result = tweet.test_notify()
|
||||
if result:
|
||||
return "Tweet successful, check your twitter to make sure it worked"
|
||||
else:
|
||||
return "Error sending tweet"
|
||||
|
||||
@cherrypy.expose
|
||||
def test_ifttt(self):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
event = notifiers.IFTTT()
|
||||
result = event.test()
|
||||
if result:
|
||||
return "Notification successful."
|
||||
else:
|
||||
return "Error sending event."
|
||||
|
||||
@cherrypy.expose
|
||||
def test_slack(self):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
event = notifiers.SLACK()
|
||||
result = event.test()
|
||||
|
||||
if result:
|
||||
return "Notification successful."
|
||||
else:
|
||||
return "Error sending event."
|
||||
|
||||
@cherrypy.expose
|
||||
def osxnotifyregister(self, app):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue