mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Add notification log table
This commit is contained in:
parent
c93b65b299
commit
de9f60aa7f
4 changed files with 228 additions and 15 deletions
99
data/interfaces/default/js/tables/notification_logs.js
Normal file
99
data/interfaces/default/js/tables/notification_logs.js
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
notification_log_table_options = {
|
||||||
|
"destroy": true,
|
||||||
|
"serverSide": true,
|
||||||
|
"processing": false,
|
||||||
|
"pagingType": "bootstrap",
|
||||||
|
"order": [ 0, 'desc'],
|
||||||
|
"pageLength": 50,
|
||||||
|
"stateSave": false,
|
||||||
|
"language": {
|
||||||
|
"search":"Search: ",
|
||||||
|
"lengthMenu":"Show _MENU_ lines per page",
|
||||||
|
"emptyTable": "No log information available",
|
||||||
|
"info":"Showing _START_ to _END_ of _TOTAL_ lines",
|
||||||
|
"infoEmpty":"Showing 0 to 0 of 0 lines",
|
||||||
|
"infoFiltered":"(filtered from _MAX_ total lines)"},
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": [0],
|
||||||
|
"data": "timestamp",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(moment(cellData, "X").format('YYYY-MM-DD HH:mm:ss'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "10%",
|
||||||
|
"className": "no-wrap hidden-xs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [1],
|
||||||
|
"data": "agent_name",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "7%",
|
||||||
|
"className": "no-wrap hidden-sm hidden-xs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [2],
|
||||||
|
"data": "notify_action",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "5%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [3],
|
||||||
|
"data": "subject_text",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "16%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [4],
|
||||||
|
"data": "body_text",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "35%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [5],
|
||||||
|
"data": "script_args",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "15%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [6],
|
||||||
|
"data": "poster_url",
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
if (cellData !== '') {
|
||||||
|
$(td).html(cellData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": "12%"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"drawCallback": function (settings) {
|
||||||
|
// Jump to top of page
|
||||||
|
//$('html,body').scrollTop(0);
|
||||||
|
$('#ajaxMsg').fadeOut();
|
||||||
|
},
|
||||||
|
"preDrawCallback": function(settings) {
|
||||||
|
var msg = "<i class='fa fa-refresh fa-spin'></i> Fetching rows...";
|
||||||
|
showMsg(msg, false, false, 0)
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ from plexpy import helpers
|
||||||
<li role="presentation" class="active"><a id="plexpy-logs-btn" href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">PlexPy Logs</a></li>
|
<li role="presentation" class="active"><a id="plexpy-logs-btn" href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">PlexPy Logs</a></li>
|
||||||
<li role="presentation"><a id="plex-logs-btn" href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">Plex Media Server Logs</a></li>
|
<li role="presentation"><a id="plex-logs-btn" href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">Plex Media Server Logs</a></li>
|
||||||
<li role="presentation"><a id="plex-scanner-logs-btn" href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">Plex Media Scanner Logs</a></li>
|
<li role="presentation"><a id="plex-scanner-logs-btn" href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">Plex Media Scanner Logs</a></li>
|
||||||
|
<li role="presentation"><a id="notification-logs-btn" href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">Notification Logs</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane active" id="tabs-1">
|
<div role="tabpanel" class="tab-pane active" id="tabs-1">
|
||||||
|
@ -61,14 +62,29 @@ from plexpy import helpers
|
||||||
<div role="tabpanel" class="tab-pane" id="tabs-3">
|
<div role="tabpanel" class="tab-pane" id="tabs-3">
|
||||||
<table class="display" id="plex_scanner_log_table" width="100%">
|
<table class="display" id="plex_scanner_log_table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align='left' id="plex_scanner_timestamp">Timestamp</th>
|
<th align='left' id="plex_scanner_timestamp">Timestamp</th>
|
||||||
<th align='left' id="plex_scanner_level">Level</th>
|
<th align='left' id="plex_scanner_level">Level</th>
|
||||||
<th align='left' id="plex_scanner_message">Message</th>
|
<th align='left' id="plex_scanner_message">Message</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
</tbody>
|
</table>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="tabs-4">
|
||||||
|
<table class="display" id="notification_log_table" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th align='left' id="notification_timestamp">Timestamp</th>
|
||||||
|
<th align='left' id="notification_agent_name">Agent</th>
|
||||||
|
<th align='left' id="notification_action">Action</th>
|
||||||
|
<th align='left' id="notification_poster_url">Subject Text</th>
|
||||||
|
<th align='left' id="notification_poster_url">Body Text</th>
|
||||||
|
<th align='left' id="notification_poster_url">Script Args</th>
|
||||||
|
<th align='left' id="notification_poster_url">Poster URL</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,8 +110,10 @@ from plexpy import helpers
|
||||||
<script src="interfaces/default/js/jquery.dataTables.min.js"></script>
|
<script src="interfaces/default/js/jquery.dataTables.min.js"></script>
|
||||||
<script src="interfaces/default/js/dataTables.bootstrap.min.js"></script>
|
<script src="interfaces/default/js/dataTables.bootstrap.min.js"></script>
|
||||||
<script src="interfaces/default/js/dataTables.bootstrap.pagination.js"></script>
|
<script src="interfaces/default/js/dataTables.bootstrap.pagination.js"></script>
|
||||||
|
<script src="interfaces/default/js/moment-with-locale.js"></script>
|
||||||
<script src="interfaces/default/js/tables/logs.js"></script>
|
<script src="interfaces/default/js/tables/logs.js"></script>
|
||||||
<script src="interfaces/default/js/tables/plex_logs.js"></script>
|
<script src="interfaces/default/js/tables/plex_logs.js"></script>
|
||||||
|
<script src="interfaces/default/js/tables/notification_logs.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
@ -105,44 +123,63 @@ from plexpy import helpers
|
||||||
|
|
||||||
function LoadPlexPyLogs() {
|
function LoadPlexPyLogs() {
|
||||||
log_table_options.ajax = {
|
log_table_options.ajax = {
|
||||||
"url": "getLog"
|
url: "getLog"
|
||||||
}
|
}
|
||||||
log_table = $('#log_table').DataTable(log_table_options);
|
log_table = $('#log_table').DataTable(log_table_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadPlexLogs() {
|
function LoadPlexLogs() {
|
||||||
plex_log_table_options.ajax = {
|
plex_log_table_options.ajax = {
|
||||||
"url": "get_plex_log?log_type=server"
|
url: "get_plex_log?log_type=server"
|
||||||
}
|
}
|
||||||
plex_log_table = $('#plex_log_table').DataTable(plex_log_table_options);
|
plex_log_table = $('#plex_log_table').DataTable(plex_log_table_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadPlexScannerLogs() {
|
function LoadPlexScannerLogs() {
|
||||||
plex_log_table_options.ajax = {
|
plex_log_table_options.ajax = {
|
||||||
"url": "get_plex_log?log_type=scanner"
|
url: "get_plex_log?log_type=scanner"
|
||||||
}
|
}
|
||||||
plex_scanner_log_table = $('#plex_scanner_log_table').DataTable(plex_log_table_options);
|
plex_scanner_log_table = $('#plex_scanner_log_table').DataTable(plex_log_table_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#plexpy-logs-btn").click(function() {
|
function LoadNotificationLogs() {
|
||||||
|
notification_log_table_options.ajax = {
|
||||||
|
url: "get_notification_log",
|
||||||
|
type: 'post',
|
||||||
|
data: function (d) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify(d)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notification_log_table = $('#notification_log_table').DataTable(notification_log_table_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#plexpy-logs-btn").click(function () {
|
||||||
$("#clear-logs").show();
|
$("#clear-logs").show();
|
||||||
LoadPlexPyLogs();
|
LoadPlexPyLogs();
|
||||||
clearSearchButton('log_table', log_table);
|
clearSearchButton('log_table', log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#plex-logs-btn").click(function() {
|
$("#plex-logs-btn").click(function () {
|
||||||
$("#clear-logs").hide();
|
$("#clear-logs").hide();
|
||||||
LoadPlexLogs();
|
LoadPlexLogs();
|
||||||
clearSearchButton('plex_log_table', plex_log_table);
|
clearSearchButton('plex_log_table', plex_log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#plex-scanner-logs-btn").click(function() {
|
$("#plex-scanner-logs-btn").click(function () {
|
||||||
$("#clear-logs").hide();
|
$("#clear-logs").hide();
|
||||||
LoadPlexScannerLogs();
|
LoadPlexScannerLogs();
|
||||||
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
|
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#clear-logs").click(function() {
|
$("#notification-logs-btn").click(function () {
|
||||||
|
$("#clear-logs").hide();
|
||||||
|
LoadNotificationLogs();
|
||||||
|
clearSearchButton('notification_log_table', notification_log_table);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#clear-logs").click(function () {
|
||||||
var r = confirm("Are you sure you want to clear the PlexPy log?");
|
var r = confirm("Are you sure you want to clear the PlexPy log?");
|
||||||
if (r == true) {
|
if (r == true) {
|
||||||
window.location.href = "clearLogs";
|
window.location.href = "clearLogs";
|
||||||
|
|
|
@ -1113,3 +1113,71 @@ class DataFactory(object):
|
||||||
old_rating_key]
|
old_rating_key]
|
||||||
|
|
||||||
monitor_db.action(query=query, args=args)
|
monitor_db.action(query=query, args=args)
|
||||||
|
|
||||||
|
def get_notification_log(self, kwargs=None):
|
||||||
|
data_tables = datatables.DataTables()
|
||||||
|
|
||||||
|
columns = ['notify_log.id',
|
||||||
|
'notify_log.timestamp',
|
||||||
|
'notify_log.session_key',
|
||||||
|
'notify_log.rating_key',
|
||||||
|
'notify_log.user_id',
|
||||||
|
'notify_log.user',
|
||||||
|
'notify_log.agent_id',
|
||||||
|
'notify_log.agent_name',
|
||||||
|
'notify_log.notify_action',
|
||||||
|
'notify_log.subject_text',
|
||||||
|
'notify_log.body_text',
|
||||||
|
'notify_log.script_args',
|
||||||
|
'notify_log.poster_url',
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
query = data_tables.ssp_query(table_name='notify_log',
|
||||||
|
columns=columns,
|
||||||
|
custom_where=[],
|
||||||
|
group_by=[],
|
||||||
|
join_types=[],
|
||||||
|
join_tables=[],
|
||||||
|
join_evals=[],
|
||||||
|
kwargs=kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for get_notification_log: %s." % e)
|
||||||
|
return {'recordsFiltered': 0,
|
||||||
|
'recordsTotal': 0,
|
||||||
|
'draw': 0,
|
||||||
|
'data': 'null',
|
||||||
|
'error': 'Unable to execute database query.'}
|
||||||
|
|
||||||
|
notifications = query['result']
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
for item in notifications:
|
||||||
|
if item['body_text']:
|
||||||
|
body_text = item['body_text'].replace('\r\n', '<br />').replace('\n', '<br />')
|
||||||
|
else:
|
||||||
|
body_text = ''
|
||||||
|
|
||||||
|
row = {'id': item['id'],
|
||||||
|
'timestamp': item['timestamp'],
|
||||||
|
'session_key': item['session_key'],
|
||||||
|
'rating_key': item['rating_key'],
|
||||||
|
'user_id': item['user_id'],
|
||||||
|
'user': item['user'],
|
||||||
|
'agent_id': item['agent_id'],
|
||||||
|
'agent_name': item['agent_name'],
|
||||||
|
'notify_action': item['notify_action'],
|
||||||
|
'subject_text': item['subject_text'],
|
||||||
|
'body_text': body_text,
|
||||||
|
'script_args': item['script_args'],
|
||||||
|
'poster_url': item['poster_url']
|
||||||
|
}
|
||||||
|
|
||||||
|
rows.append(row)
|
||||||
|
|
||||||
|
dict = {'recordsFiltered': query['filteredCount'],
|
||||||
|
'recordsTotal': query['totalCount'],
|
||||||
|
'data': rows,
|
||||||
|
'draw': query['draw']
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict
|
|
@ -1082,6 +1082,15 @@ class WebInterface(object):
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
return json.dumps(log_lines)
|
return json.dumps(log_lines)
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@addtoapi()
|
||||||
|
def get_notification_log(self, **kwargs):
|
||||||
|
data_factory = datafactory.DataFactory()
|
||||||
|
notifications = data_factory.get_notification_log(kwargs=kwargs)
|
||||||
|
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps(notifications)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def clearLogs(self):
|
def clearLogs(self):
|
||||||
plexpy.LOG_LIST = []
|
plexpy.LOG_LIST = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue