Add notifier id to config modal

This commit is contained in:
JonnyWong16 2016-10-01 13:38:41 -07:00 committed by JonnyWong16
commit 1206d13978
5 changed files with 15 additions and 13 deletions

View file

@ -3077,7 +3077,8 @@ a:hover .overlay-refresh-image:hover {
#api_key.form-control[readonly]:focus { #api_key.form-control[readonly]:focus {
background-color: #fff; background-color: #fff;
} }
#plexpy-notifiers-table .friendly_name { #plexpy-notifiers-table .friendly_name,
#notifier-config-modal span.notifier_id {
color: #777; color: #777;
} }
#notifier-config-modal .nav-tabs { #notifier-config-modal .nav-tabs {

View file

@ -7,7 +7,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title" id="notifier-config-modal-header">${notifier['agent_label']} Settings</h4> <h4 class="modal-title" id="notifier-config-modal-header">${notifier['agent_label']} Settings <small><span class="notifier_id">(Notifier ID: ${notifier['id']})</span></small></h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="container-fluid"> <div class="container-fluid">

View file

@ -13,7 +13,7 @@ DOCUMENTATION :: END
% for notifier in notifiers_list: % for notifier in notifiers_list:
<li> <li>
<span> <span>
<span class="toggle-left trigger-tooltip ${'active' if any(notifier['actions'].values()) else ''}" data-toggle="tooltip" data-placement="top" title="Triggers active"><i class="fa fa-lg fa-bell"></i></span> <span class="toggle-left trigger-tooltip ${'active' if notifier['active'] else ''}" data-toggle="tooltip" data-placement="top" title="Triggers active"><i class="fa fa-lg fa-bell"></i></span>
${notifier['agent_label']} <span class="friendly_name">(${notifier['friendly_name'] or notifier['id']})</span> ${notifier['agent_label']} <span class="friendly_name">(${notifier['friendly_name'] or notifier['id']})</span>
<a href="#" data-target="#notifier-config-modal" data-id="${notifier['id']}" class="toggle-notifier-config-modal toggle-right" data-toggle="modal"><i class="fa fa-lg fa-cog"></i></a> <a href="#" data-target="#notifier-config-modal" data-id="${notifier['id']}" class="toggle-notifier-config-modal toggle-right" data-toggle="modal"><i class="fa fa-lg fa-cog"></i></a>
</span> </span>

View file

@ -323,17 +323,21 @@ def get_notify_actions():
def get_notifiers(notifier_id=None, notify_action=None): def get_notifiers(notifier_id=None, notify_action=None):
notify_actions = get_notify_actions() notify_actions = get_notify_actions()
where_action = '' where = where_id = where_action = ''
if notifier_id or notify_action:
where = 'WHERE '
if notifier_id:
where_id += 'notifier_id = %s' % notifier_id
if notify_action and notify_action in notify_actions: if notify_action and notify_action in notify_actions:
where_action = 'WHERE %s = 1 ' % notify_action where_action = '%s = 1' % notify_action
where += ' AND '.join([w for w in [where_id, where_action] if w])
monitor_db = database.MonitorDatabase() monitor_db = database.MonitorDatabase()
result = monitor_db.select('SELECT id, agent_id, agent_name, agent_label, friendly_name, %s FROM notifiers %s' result = monitor_db.select('SELECT id, agent_id, agent_name, agent_label, friendly_name, %s FROM notifiers %s'
% (', '.join(notify_actions), where_action)) % (', '.join(notify_actions), where))
for item in result: for item in result:
item['actions'] = {k: helpers.cast_to_int(item.pop(k)) item['active'] = int(any([item.pop(k) for k in item.keys() if k in notify_actions]))
for k in item.keys() if k in notify_actions}
return sorted(result, key=lambda k: (k['agent_label'], k['id'])) return sorted(result, key=lambda k: (k['agent_label'], k['id']))

View file

@ -2863,10 +2863,7 @@ class WebInterface(object):
"agent_name": "telegram", "agent_name": "telegram",
"agent_label": "Telegram", "agent_label": "Telegram",
"friendly_name": "", "friendly_name": "",
"actions": {"on_play": 0, "active": 1
"on_stop": 0,
...
},
} }
] ]
``` ```