plexpy/data/interfaces/default/logs.html
2017-04-19 19:32:35 -07:00

437 lines
19 KiB
HTML

<%inherit file="base.html"/>
<%!
from plexpy import helpers
%>
<%def name="headIncludes()">
<link rel="stylesheet" href="${http_root}css/dataTables.bootstrap.css">
<link rel="stylesheet" href="${http_root}css/plexpy-dataTables.css">
<style>
td {word-break: break-all;}
</style>
</%def>
<%def name="headerIncludes()">
</%def>
<%def name="body()">
<div class='container-fluid'>
<div class='table-card-header'>
<div class="header-bar">
<span><i class="fa fa-list-alt"></i> Logs</span>
</div>
<div class="button-bar">
<div class="btn-group" id="plexpy-log-levels">
<label>
<select name="plexpy-log-level-filter" id="plexpy-log-level-filter" class="btn" style="color: inherit;">
<option value="">All log levels</option>
<option disabled>&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;</option>
<option value="DEBUG">Debug</option>
<option value="INFO">Info</option>
<option value="WARNING">Warning</option>
<option value="ERROR">Error</option>
</select>
</label>
</div>
<div class="btn-group" id="plex-log-levels" style="display: none;">
<label>
<select name="plex-log-level-filter" id="plex-log-level-filter" class="btn" style="color: inherit;">
<option value="">All log levels</option>
<option disabled>&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;</option>
<option value="DEBUG">Debug</option>
<option value="INFO">Info</option>
<option value="WARN">Warning</option>
<option value="ERROR">Error</option>
</select>
</label>
</div>
<button class="btn btn-dark" id="download-plexpylog"><i class="fa fa-download"></i> Download logs</button>
<button class="btn btn-dark" id="download-plexserverlog" style="display: none;"><i class="fa fa-download"></i> Download logs</button>
<button class="btn btn-dark" id="download-plexscannerlog" style="display: none;"><i class="fa fa-download"></i> Download logs</button>
<button class="btn btn-dark" id="clear-logs"><i class="fa fa-trash-o"></i> Clear logs</button>
<button class="btn btn-dark" id="clear-notify-logs" style="display: none;"><i class="fa fa-trash-o"></i> Clear logs</button>
<button class="btn btn-dark" id="clear-login-logs" style="display: none;"><i class="fa fa-trash-o"></i> Clear logs</button>
</div>
</div>
<div class='table-card-back'>
<div>
<ul class="nav nav-pills" role="tablist">
<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-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>
<li role="presentation"><a id="login-logs-btn" href="#tabs-5" aria-controls="tabs-5" role="tab" data-toggle="tab">Login Logs</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tabs-1">
<table class="display" id="log_table" width="100%">
<thead>
<tr>
<th class="min-tablet" align="left" id="timestamp">Timestamp</th>
<th class="desktop" align="left" id="level">Level</th>
<th class="all" align="left" id="message">Message</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="tabs-2">
<table class="display" id="plex_log_table" width="100%">
<thead>
<tr>
<th align="left" id="plex_timestamp">Timestamp</th>
<th align="left" id="plex_level">Level</th>
<th align="left" id="plex_message">Message</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="tabs-3">
<table class="display" id="plex_scanner_log_table" width="100%">
<thead>
<tr>
<th align="left" id="plex_scanner_timestamp">Timestamp</th>
<th align="left" id="plex_scanner_level">Level</th>
<th align="left" id="plex_scanner_message">Message</th>
</tr>
</thead>
<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_notifier_id">Notifier ID</th>
<th align="left" id="notification_agent_name">Agent</th>
<th align="left" id="notification_notify_action">Action</th>
<th align="left" id="notification_subject_text">Subject Text</th>
<th align="left" id="notification_body_text">Body Text</th>
<th align="left" id="notification_success"></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="tabs-5">
<table class="display login_log_table" id="login_log_table" width="100%">
<thead>
<tr>
<th align="left" id="timestamp">Timestamp</th>
<th align="left" id="friendly_name">User</th>
<th align="left" id="user_group">User Group</th>
<th align="left" id="ip_address">IP Address</th>
<th align="left" id="host">Host</th>
<th align="left" id="os">Operating System</th>
<th align="left" id="browser">Browser</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br>
<div align="center">
Refresh rate:
<select id="refreshrate" onchange="setRefresh()">
<option value="0" selected="selected">No Refresh</option>
<option value="5">5 Seconds</option>
<option value="15">15 Seconds</option>
<option value="30">30 Seconds</option>
<option value="60">60 Seconds</option>
<option value="300">5 Minutes</option>
<option value="600">10 Minutes</option>
</select>
</div>
</%def>
<%def name="modalIncludes()">
<div class="modal fade" id="ip-info-modal" tabindex="-1" role="dialog" aria-labelledby="ip-info-modal">
</div>
</%def>
<%def name="javascriptIncludes()">
<script src="${http_root}js/jquery.dataTables.min.js"></script>
<script src="${http_root}js/dataTables.bootstrap.min.js"></script>
<script src="${http_root}js/dataTables.bootstrap.pagination.js"></script>
<script src="${http_root}js/moment-with-locale.js"></script>
<script src="${http_root}js/tables/logs.js"></script>
<script src="${http_root}js/tables/plex_logs.js"></script>
<script src="${http_root}js/tables/notification_logs.js"></script>
<script src="${http_root}js/tables/login_logs.js"></script>
<script>
$(document).ready(function() {
loadPlexPyLogs(selected_log_level);
clearSearchButton('log_table', log_table);
});
var log_levels = ['DEBUG', 'INFO', 'WARN', 'ERROR'];
function bindLogLevelFilter() {
clearLogLevelFilter();
var log_level_column = this.api().column(1);
var select = $('#plex-log-level-filter');
select.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
var search_string = '';
var levelIndex = log_levels.indexOf(val);
if (levelIndex >= 0) {
search_string = '^' + log_levels
.slice(levelIndex)
.join('|') + '$';
}
log_level_column
.search(search_string, true, false)
.draw();
}).change();
}
function clearLogLevelFilter() {
$('#plex-log-level-filter').off('change');
}
var selected_log_level = null;
function loadPlexPyLogs(selected_log_level) {
log_table_options.ajax = {
url: "get_log",
type: 'post',
data: function (d) {
return {
json_data: JSON.stringify(d),
log_level: selected_log_level
};
}
}
log_table = $('#log_table').DataTable(log_table_options);
$('#plexpy-log-level-filter').on('change', function () {
selected_log_level = $(this).val() || null;
log_table.draw();
});
}
function loadPlexLogs() {
plex_log_table_options.ajax = {
url: "get_plex_log?log_type=server"
}
plex_log_table_options.initComplete = bindLogLevelFilter;
plex_log_table = $('#plex_log_table').DataTable(plex_log_table_options);
}
function loadPlexScannerLogs() {
plex_log_table_options.ajax = {
url: "get_plex_log?log_type=scanner"
}
plex_log_table_options.initComplete = bindLogLevelFilter;
plex_scanner_log_table = $('#plex_scanner_log_table').DataTable(plex_log_table_options);
}
function loadNotificationLogs() {
notification_log_table_options.ajax = {
url: "get_notification_log",
data: function (d) {
return {
json_data: JSON.stringify(d)
};
}
}
notification_log_table = $('#notification_log_table').DataTable(notification_log_table_options);
}
function loadLoginLogs() {
login_log_table_options.pageLength = 50;
login_log_table_options.ajax = {
url: "get_user_logins",
data: function (d) {
return {
json_data: JSON.stringify(d)
};
}
}
login_log_table = $('#login_log_table').DataTable(login_log_table_options);
}
$("#plexpy-logs-btn").click(function () {
$("#plexpy-log-levels").show();
$("#plex-log-levels").hide();
$("#clear-logs").show();
$("#download-plexpylog").show()
$("#download-plexserverlog").hide()
$("#download-plexscannerlog").hide()
$("#clear-notify-logs").hide();
$("#clear-login-logs").hide();
loadPlexPyLogs(selected_log_level);
clearSearchButton('log_table', log_table);
});
$("#plex-logs-btn").click(function () {
$("#plexpy-log-levels").hide();
$("#plex-log-levels").show();
$("#clear-logs").hide();
$("#download-plexpylog").hide()
$("#download-plexserverlog").show()
$("#download-plexscannerlog").hide()
$("#clear-notify-logs").hide();
$("#clear-login-logs").hide();
loadPlexLogs();
clearSearchButton('plex_log_table', plex_log_table);
});
$("#plex-scanner-logs-btn").click(function () {
$("#plexpy-log-levels").hide();
$("#plex-log-levels").show();
$("#clear-logs").hide();
$("#download-plexpylog").hide()
$("#download-plexserverlog").hide()
$("#download-plexscannerlog").show()
$("#clear-notify-logs").hide();
$("#clear-login-logs").hide();
loadPlexScannerLogs();
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
});
$("#notification-logs-btn").click(function () {
$("#plexpy-log-levels").hide();
$("#plex-log-levels").hide();
$("#clear-logs").hide();
$("#download-plexpylog").hide()
$("#download-plexserverlog").hide()
$("#download-plexscannerlog").hide()
$("#clear-notify-logs").show();
$("#clear-login-logs").hide();
loadNotificationLogs();
clearSearchButton('notification_log_table', notification_log_table);
});
$("#login-logs-btn").click(function () {
$("#plexpy-log-levels").hide();
$("#plex-log-levels").hide();
$("#clear-logs").hide();
$("#download-plexpylog").hide()
$("#download-plexserverlog").hide()
$("#download-plexscannerlog").hide()
$("#clear-notify-logs").hide();
$("#clear-login-logs").show();
loadLoginLogs();
clearSearchButton('login_log_table', notification_log_table);
});
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
});
$("#clear-logs").click(function () {
$("#confirm-message").text("Are you sure you want to clear the PlexPy logs?");
$('#confirm-modal').modal();
$('#confirm-modal').one('click', '#confirm-button', function () {
$.ajax({
url: 'delete_logs',
type: 'POST',
complete: function (xhr, status) {
result = $.parseJSON(xhr.responseText);
msg = result.message;
if (result.result == 'success') {
showMsg('<i class="fa fa-check"></i> ' + msg, false, true, 5000)
} else {
showMsg('<i class="fa fa-times"></i> ' + msg, false, true, 5000, true)
}
log_table.draw();
}
});
});
});
$("#download-plexpylog").click(function () {
window.location.href = "download_log";
});
$("#download-plexserverlog").click(function () {
window.location.href = "download_plex_log?log_type=server";
});
$("#download-plexscannerlog").click(function () {
window.location.href = "download_plex_log?log_type=scanner";
});
$("#clear-notify-logs").click(function () {
$("#confirm-message").text("Are you sure you want to clear the PlexPy notification logs?");
$('#confirm-modal').modal();
$('#confirm-modal').one('click', '#confirm-button', function () {
$.ajax({
url: 'delete_notification_log',
type: 'POST',
complete: function (xhr, status) {
result = $.parseJSON(xhr.responseText);
msg = result.message;
if (result.result == 'success') {
showMsg('<i class="fa fa-check"></i> ' + msg, false, true, 5000)
} else {
showMsg('<i class="fa fa-times"></i> ' + msg, false, true, 5000, true)
}
notification_log_table.draw();
}
});
});
});
$("#clear-login-logs").click(function () {
$("#confirm-message").text("Are you sure you want to clear the PlexPy login logs?");
$('#confirm-modal').modal();
$('#confirm-modal').one('click', '#confirm-button', function () {
$.ajax({
url: 'delete_login_log',
type: 'POST',
complete: function (xhr, status) {
result = $.parseJSON(xhr.responseText);
msg = result.message;
if (result.result == 'success') {
showMsg('<i class="fa fa-check"></i> ' + msg, false, true, 5000)
} else {
showMsg('<i class="fa fa-times"></i> ' + msg, false, true, 5000, true)
}
login_log_table.draw();
}
});
});
});
var timer;
function setRefresh()
{
refreshrate = document.getElementById('refreshrate');
if(refreshrate != null)
{
if(timer)
{
clearInterval(timer);
}
if(refreshrate.value != 0)
{
timer = setInterval(function() {
if ($("#tabs-1").hasClass("active")) {
log_table.ajax.reload();
} else if ($("#tabs-2").hasClass("active")) {
plex_log_table.ajax.reload();
} else if ($("#tabs-3").hasClass("active")) {
plex_scanner_log_table.ajax.reload();
} else if ($("#tabs-4").hasClass("active")) {
notification_log_table.ajax.reload();
} else if ($("#tabs-5").hasClass("active")) {
login_log_table.ajax.reload();
}
}, 1000*refreshrate.value);
}
}
}
</script>
</%def>