mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Add settings for notification conditions filterer
This commit is contained in:
parent
565dea5ecf
commit
f3349c64a9
5 changed files with 90 additions and 9 deletions
7
data/interfaces/default/js/filterer.jquery.js
Normal file
7
data/interfaces/default/js/filterer.jquery.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -14,15 +14,10 @@
|
|||
<div class="row">
|
||||
<ul class="nav nav-tabs list-unstyled" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#tabs-config" aria-controls="tabs-config" role="tab" data-toggle="tab">Configuration</a></li>
|
||||
% if notifier['agent_name'] == 'scripts':
|
||||
<li role="presentation"><a href="#tabs-notify_triggers" aria-controls="tabs-notify_triggers" role="tab" data-toggle="tab">Script Triggers</a></li>
|
||||
<li role="presentation"><a href="#tabs-notify_text" aria-controls="tabs-notify_text" role="tab" data-toggle="tab">Script Arguments</a></li>
|
||||
<li role="presentation"><a href="#tabs-test_notifications" aria-controls="tabs-test_notifications" role="tab" data-toggle="tab">Test Script</a></li>
|
||||
% else:
|
||||
<li role="presentation"><a href="#tabs-notify_triggers" aria-controls="tabs-notify_triggers" role="tab" data-toggle="tab">Notification Triggers</a></li>
|
||||
<li role="presentation"><a href="#tabs-notify_text" aria-controls="tabs-notify_text" role="tab" data-toggle="tab">Notification Text</a></li>
|
||||
<li role="presentation"><a href="#tabs-notify_triggers" aria-controls="tabs-notify_triggers" role="tab" data-toggle="tab">Triggers</a></li>
|
||||
<li role="presentation"><a href="#tabs-notify_conditions" aria-controls="tabs-notify_conditions" role="tab" data-toggle="tab">Conditions</a></li>
|
||||
<li role="presentation"><a href="#tabs-notify_text" aria-controls="tabs-notify_text" role="tab" data-toggle="tab">${'Arguments' if notifier['agent_name'] == 'scripts' else 'Text'}</a></li>
|
||||
<li role="presentation"><a href="#tabs-test_notifications" aria-controls="tabs-test_notifications" role="tab" data-toggle="tab">Test Notifications</a></li>
|
||||
% endif
|
||||
</ul>
|
||||
</div>
|
||||
<form action="set_notifier_config" method="post" class="form" id="set_notifier_config" data-parsley-validate>
|
||||
|
@ -131,6 +126,26 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="tabs-notify_conditions">
|
||||
<p class="help-block">
|
||||
Add custom notification conditions.
|
||||
<a href="#notify-text-sub-modal" data-toggle="modal">Click here</a> for a description of all the parameters.
|
||||
</p>
|
||||
<p class="help-block">
|
||||
Note: Conditions are checked after the notification trigger and the notification will only be sent if the condition logic is satisfied.
|
||||
</p>
|
||||
<div id="condition-widget"></div>
|
||||
<input type="text" name="custom_conditions" id="custom_conditions" value="${notifier['custom_conditions']}" />
|
||||
|
||||
<div class="form-group">
|
||||
<label for="custom_condition_logic">Condition Logic</label>
|
||||
<input type="text" class="form-control" name="custom_conditions_logic" id="custom_conditions_logic" value="${notifier['custom_conditions_logic']}" required />
|
||||
<p class="help-block">
|
||||
Enter the logic to use when evaluating the conditions.
|
||||
Only the keywords <span class="inline-pre">and</span>/<span class="inline-pre">or</span> and brackets <span class="inline-pre">()</span> are supported.
|
||||
(e.g. <span class="inline-pre">{1} and ({2} or {3}</span>).</p>
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="tabs-notify_text">
|
||||
<p class="help-block">
|
||||
% if notifier['agent_name'] == 'scripts':
|
||||
|
@ -253,10 +268,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="${http_root}js/filterer.jquery.js"></script>
|
||||
<script>
|
||||
|
||||
$('#notifier-config-modal').unbind('hidden.bs.modal');
|
||||
|
||||
$('#condition-widget').filterer({
|
||||
coefficients: [
|
||||
{"name": "Title", "type": "string", "value": "title"},
|
||||
{"name": "Year", "type": "number", "value": "year"}
|
||||
],
|
||||
conditions: [
|
||||
{coefficient: "year", operator: "is", value: ""},
|
||||
{coefficient: "title", operator: "begins with", value: ""}
|
||||
],
|
||||
updateConditions: function(newConditions){
|
||||
$('#custom_conditions').val(JSON.stringify(newConditions));
|
||||
}
|
||||
})
|
||||
|
||||
function reloadModal() {
|
||||
$.ajax({
|
||||
url: 'get_notifier_config_modal',
|
||||
|
|
|
@ -517,7 +517,8 @@ def dbcheck():
|
|||
'on_resume_body TEXT, on_buffer_body TEXT, on_watched_body TEXT, '
|
||||
'on_created_body TEXT, on_extdown_body TEXT, on_intdown_body TEXT, '
|
||||
'on_extup_body TEXT, on_intup_body TEXT, on_pmsupdate_body TEXT, '
|
||||
'on_concurrent_body TEXT, on_newdevice_body TEXT, on_plexpyupdate_body TEXT)'
|
||||
'on_concurrent_body TEXT, on_newdevice_body TEXT, on_plexpyupdate_body TEXT, '
|
||||
'custom_conditions TEXT, custom_conditions_logic TEXT)'
|
||||
)
|
||||
|
||||
# poster_urls table :: This table keeps record of the notification poster urls
|
||||
|
@ -1067,6 +1068,18 @@ def dbcheck():
|
|||
logger.warn(u"Failed to recreate mobile_devices table.")
|
||||
pass
|
||||
|
||||
# Upgrade notifiers table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT custom_condition FROM notifiers')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table custom_condition.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE notifiers ADD COLUMN custom_conditions TEXT'
|
||||
)
|
||||
c_db.execute(
|
||||
'ALTER TABLE notifiers ADD COLUMN custom_conditions_logic TEXT'
|
||||
)
|
||||
|
||||
# Add "Local" user to database as default unauthenticated user.
|
||||
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
|
||||
if not result.fetchone():
|
||||
|
|
|
@ -526,6 +526,8 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
|
|||
'agent_label': agent['label'],
|
||||
'friendly_name': kwargs.get('friendly_name', ''),
|
||||
'notifier_config': json.dumps(notifier_config),
|
||||
'custom_conditions': kwargs.get('custom_conditions', ''),
|
||||
'custom_conditions_logic': kwargs.get('custom_conditions_logic', ''),
|
||||
}
|
||||
values.update(actions)
|
||||
values.update(subject_text)
|
||||
|
|
|
@ -3032,6 +3032,35 @@ class WebInterface(object):
|
|||
|
||||
return serve_template(templatename="notifier_text_preview.html", text=text, agent=agent_name)
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi()
|
||||
def get_notifier_parameters(self, **kwargs):
|
||||
""" Get the list of available notification parameters.
|
||||
|
||||
```
|
||||
Required parameters:
|
||||
None
|
||||
|
||||
Optional parameters:
|
||||
None
|
||||
|
||||
Returns:
|
||||
json:
|
||||
{
|
||||
}
|
||||
```
|
||||
"""
|
||||
parameters = [{'name': param['name'],
|
||||
'type': param['type'],
|
||||
'value': param['value']
|
||||
}
|
||||
for category in common.NOTIFICATION_PARAMETERS
|
||||
for param in category['parameters']]
|
||||
|
||||
return parameters
|
||||
|
||||
@cherrypy.expose
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi("notify")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue