mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Add complete login table to logs
This commit is contained in:
parent
ae381f7762
commit
f598d5046e
9 changed files with 180 additions and 66 deletions
20
API.md
20
API.md
|
@ -112,8 +112,23 @@ Returns:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### delete_login_log
|
||||||
|
Delete the PlexPy login logs.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required paramters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### delete_notification_log
|
### delete_notification_log
|
||||||
Delete the notification logs.
|
Delete the PlexPy notification logs.
|
||||||
|
|
||||||
```
|
```
|
||||||
Required paramters:
|
Required paramters:
|
||||||
|
@ -1348,12 +1363,11 @@ Returns:
|
||||||
"recordsFiltered": 10,
|
"recordsFiltered": 10,
|
||||||
"data":
|
"data":
|
||||||
[{"browser": "Safari 7.0.3",
|
[{"browser": "Safari 7.0.3",
|
||||||
"date": 1462591869,
|
|
||||||
"friendly_name": "Jon Snow",
|
"friendly_name": "Jon Snow",
|
||||||
"host": "http://plexpy.castleblack.com",
|
"host": "http://plexpy.castleblack.com",
|
||||||
"ip_address": "xxx.xxx.xxx.xxx",
|
"ip_address": "xxx.xxx.xxx.xxx",
|
||||||
"os": "Mac OS X",
|
"os": "Mac OS X",
|
||||||
"time": 1462591869,
|
"timestamp": 1462591869,
|
||||||
"user": "LordCommanderSnow",
|
"user": "LordCommanderSnow",
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
|
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
|
||||||
"user_group": "guest",
|
"user_group": "guest",
|
||||||
|
|
|
@ -14,7 +14,7 @@ libraries_list_table_options = {
|
||||||
"destroy": true,
|
"destroy": true,
|
||||||
"processing": false,
|
"processing": false,
|
||||||
"serverSide": true,
|
"serverSide": true,
|
||||||
"pageLength": 10,
|
"pageLength": 25,
|
||||||
"order": [ 2, 'asc'],
|
"order": [ 2, 'asc'],
|
||||||
"stateSave": true,
|
"stateSave": true,
|
||||||
"pagingType": "full_numbers",
|
"pagingType": "full_numbers",
|
||||||
|
|
|
@ -13,18 +13,17 @@ login_table_options = {
|
||||||
"pagingType": "full_numbers",
|
"pagingType": "full_numbers",
|
||||||
"processing": false,
|
"processing": false,
|
||||||
"serverSide": true,
|
"serverSide": true,
|
||||||
"pageLength": 10,
|
"pageLength": 25,
|
||||||
"order": [0, 'desc'],
|
"order": [0, 'desc'],
|
||||||
"autoWidth": false,
|
"autoWidth": false,
|
||||||
"scrollX": true,
|
"scrollX": true,
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{
|
{
|
||||||
"targets": [0],
|
"targets": [0],
|
||||||
"data": "date",
|
"data": "timestamp",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData !== '') {
|
if (cellData !== '') {
|
||||||
date = moment(cellData, "X").format(date_format);
|
$(td).html(moment(cellData, "X").format('YYYY-MM-DD HH:mm:ss'));
|
||||||
$(td).html(date);
|
|
||||||
} else {
|
} else {
|
||||||
$(td).html(cellData);
|
$(td).html(cellData);
|
||||||
}
|
}
|
||||||
|
@ -35,21 +34,18 @@ login_table_options = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [1],
|
"targets": [1],
|
||||||
"data": "time",
|
"data": "friendly_name",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
|
||||||
if (cellData !== '') {
|
|
||||||
time = moment(cellData, "X").format(time_format);
|
|
||||||
$(td).html(time);
|
|
||||||
} else {
|
|
||||||
$(td).html(cellData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"searchable": false,
|
|
||||||
"width": "10%",
|
"width": "10%",
|
||||||
"className": "no-wrap"
|
"className": "no-wrap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [2],
|
"targets": [2],
|
||||||
|
"data": "user_group",
|
||||||
|
"width": "10%",
|
||||||
|
"className": "no-wrap"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [3],
|
||||||
"data": "ip_address",
|
"data": "ip_address",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
|
@ -67,23 +63,23 @@ login_table_options = {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"width": "20%",
|
"width": "10%",
|
||||||
"className": "no-wrap modal-control-ip"
|
"className": "no-wrap modal-control-ip"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [3],
|
"targets": [4],
|
||||||
"data": "host",
|
"data": "host",
|
||||||
"width": "20%",
|
"width": "20%",
|
||||||
"className": "no-wrap"
|
"className": "no-wrap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [4],
|
"targets": [5],
|
||||||
"data": "os",
|
"data": "os",
|
||||||
"width": "20%",
|
"width": "20%",
|
||||||
"className": "no-wrap"
|
"className": "no-wrap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [5],
|
"targets": [6],
|
||||||
"data": "browser",
|
"data": "browser",
|
||||||
"width": "20%",
|
"width": "20%",
|
||||||
"className": "no-wrap"
|
"className": "no-wrap"
|
||||||
|
|
|
@ -13,7 +13,7 @@ user_ip_table_options = {
|
||||||
"pagingType": "full_numbers",
|
"pagingType": "full_numbers",
|
||||||
"processing": false,
|
"processing": false,
|
||||||
"serverSide": true,
|
"serverSide": true,
|
||||||
"pageLength": 10,
|
"pageLength": 25,
|
||||||
"order": [ 0, 'desc'],
|
"order": [ 0, 'desc'],
|
||||||
"autoWidth": false,
|
"autoWidth": false,
|
||||||
"scrollX": true,
|
"scrollX": true,
|
||||||
|
|
|
@ -31,7 +31,7 @@ users_list_table_options = {
|
||||||
"destroy": true,
|
"destroy": true,
|
||||||
"processing": false,
|
"processing": false,
|
||||||
"serverSide": true,
|
"serverSide": true,
|
||||||
"pageLength": 10,
|
"pageLength": 25,
|
||||||
"order": [ 2, 'asc'],
|
"order": [ 2, 'asc'],
|
||||||
"stateSave": true,
|
"stateSave": true,
|
||||||
"pagingType": "full_numbers",
|
"pagingType": "full_numbers",
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<button class="btn btn-dark" id="download-plexpylog"><i class="fa fa-download"></i> Download log</button>
|
<button class="btn btn-dark" id="download-plexpylog"><i class="fa fa-download"></i> Download log</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-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-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>
|
</div>
|
||||||
<div class='table-card-back'>
|
<div class='table-card-back'>
|
||||||
|
@ -33,15 +34,16 @@
|
||||||
<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>
|
<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>
|
</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">
|
||||||
<table class="display" id="log_table" width="100%">
|
<table class="display" id="log_table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="min-tablet" align='left' id="timestamp">Timestamp</th>
|
<th class="min-tablet" align="left" id="timestamp">Timestamp</th>
|
||||||
<th class="desktop" align='left' id="level">Level</th>
|
<th class="desktop" align="left" id="level">Level</th>
|
||||||
<th class="all" align='left' id="message">Message</th>
|
<th class="all" align="left" id="message">Message</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -52,9 +54,9 @@
|
||||||
<table class="display" id="plex_log_table" width="100%">
|
<table class="display" id="plex_log_table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align='left' id="plex_timestamp">Timestamp</th>
|
<th align="left" id="plex_timestamp">Timestamp</th>
|
||||||
<th align='left' id="plex_level">Level</th>
|
<th align="left" id="plex_level">Level</th>
|
||||||
<th align='left' id="plex_message">Message</th>
|
<th align="left" id="plex_message">Message</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -65,9 +67,9 @@
|
||||||
<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>
|
||||||
|
@ -77,12 +79,28 @@
|
||||||
<table class="display" id="notification_log_table" width="100%">
|
<table class="display" id="notification_log_table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align='left' id="notification_timestamp">Timestamp</th>
|
<th align="left" id="notification_timestamp">Timestamp</th>
|
||||||
<th align='left' id="notification_agent_name">Agent</th>
|
<th align="left" id="notification_agent_name">Agent</th>
|
||||||
<th align='left' id="notification_action">Action</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">Subject Text</th>
|
||||||
<th align='left' id="notification_poster_url">Body 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">Script Args</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="tabs-5">
|
||||||
|
<table class="display" 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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
|
@ -115,38 +133,38 @@
|
||||||
<script src="${http_root}js/tables/logs.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/plex_logs.js"></script>
|
||||||
<script src="${http_root}js/tables/notification_logs.js"></script>
|
<script src="${http_root}js/tables/notification_logs.js"></script>
|
||||||
|
<script src="${http_root}js/tables/login_table.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
LoadPlexPyLogs();
|
loadPlexPyLogs();
|
||||||
clearSearchButton('log_table', log_table);
|
clearSearchButton('log_table', log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadNotificationLogs() {
|
function loadNotificationLogs() {
|
||||||
notification_log_table_options.ajax = {
|
notification_log_table_options.ajax = {
|
||||||
url: "get_notification_log",
|
url: "get_notification_log",
|
||||||
type: 'post',
|
|
||||||
data: function (d) {
|
data: function (d) {
|
||||||
return {
|
return {
|
||||||
json_data: JSON.stringify(d)
|
json_data: JSON.stringify(d)
|
||||||
|
@ -156,11 +174,25 @@
|
||||||
notification_log_table = $('#notification_log_table').DataTable(notification_log_table_options);
|
notification_log_table = $('#notification_log_table').DataTable(notification_log_table_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadLoginLogs() {
|
||||||
|
login_table_options.pageLength = 50;
|
||||||
|
login_table_options.ajax = {
|
||||||
|
url: "get_user_logins",
|
||||||
|
data: function (d) {
|
||||||
|
return {
|
||||||
|
json_data: JSON.stringify(d)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
login_log_table = $('#login_log_table').DataTable(login_table_options);
|
||||||
|
}
|
||||||
|
|
||||||
$("#plexpy-logs-btn").click(function () {
|
$("#plexpy-logs-btn").click(function () {
|
||||||
$("#clear-logs").show();
|
$("#clear-logs").show();
|
||||||
$("#download-plexpylog").show()
|
$("#download-plexpylog").show()
|
||||||
$("#clear-notify-logs").hide();
|
$("#clear-notify-logs").hide();
|
||||||
LoadPlexPyLogs();
|
$("#clear-login-logs").hide();
|
||||||
|
loadPlexPyLogs();
|
||||||
clearSearchButton('log_table', log_table);
|
clearSearchButton('log_table', log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -168,7 +200,8 @@
|
||||||
$("#clear-logs").hide();
|
$("#clear-logs").hide();
|
||||||
$("#download-plexpylog").hide()
|
$("#download-plexpylog").hide()
|
||||||
$("#clear-notify-logs").hide();
|
$("#clear-notify-logs").hide();
|
||||||
LoadPlexLogs();
|
$("#clear-login-logs").hide();
|
||||||
|
loadPlexLogs();
|
||||||
clearSearchButton('plex_log_table', plex_log_table);
|
clearSearchButton('plex_log_table', plex_log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,7 +209,8 @@
|
||||||
$("#clear-logs").hide();
|
$("#clear-logs").hide();
|
||||||
$("#download-plexpylog").hide()
|
$("#download-plexpylog").hide()
|
||||||
$("#clear-notify-logs").hide();
|
$("#clear-notify-logs").hide();
|
||||||
LoadPlexScannerLogs();
|
$("#clear-login-logs").hide();
|
||||||
|
loadPlexScannerLogs();
|
||||||
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
|
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -184,10 +218,20 @@
|
||||||
$("#clear-logs").hide();
|
$("#clear-logs").hide();
|
||||||
$("#download-plexpylog").hide()
|
$("#download-plexpylog").hide()
|
||||||
$("#clear-notify-logs").show();
|
$("#clear-notify-logs").show();
|
||||||
LoadNotificationLogs();
|
$("#clear-login-logs").hide();
|
||||||
|
loadNotificationLogs();
|
||||||
clearSearchButton('notification_log_table', notification_log_table);
|
clearSearchButton('notification_log_table', notification_log_table);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#login-logs-btn").click(function () {
|
||||||
|
$("#clear-logs").hide();
|
||||||
|
$("#download-plexpylog").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) {
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
|
||||||
});
|
});
|
||||||
|
@ -239,6 +283,27 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#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;
|
var timer;
|
||||||
function setRefresh()
|
function setRefresh()
|
||||||
{
|
{
|
||||||
|
@ -260,6 +325,8 @@
|
||||||
plex_scanner_log_table.ajax.reload();
|
plex_scanner_log_table.ajax.reload();
|
||||||
} else if ($("#tabs-4").hasClass("active")) {
|
} else if ($("#tabs-4").hasClass("active")) {
|
||||||
notification_log_table.ajax.reload();
|
notification_log_table.ajax.reload();
|
||||||
|
} else if ($("#tabs-5").hasClass("active")) {
|
||||||
|
login_log_table.ajax.reload();
|
||||||
}
|
}
|
||||||
}, 1000*refreshrate.value);
|
}, 1000*refreshrate.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,8 +290,9 @@ DOCUMENTATION :: END
|
||||||
<table class="display login_table" id="login_table-UID-${data['user_id']}" width="100%">
|
<table class="display login_table" id="login_table-UID-${data['user_id']}" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left" id="date">Date</th>
|
<th align="left" id="timestamp">Timestamp</th>
|
||||||
<th align="left" id="time">Time</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="ip_address">IP Address</th>
|
||||||
<th align="left" id="host">Host</th>
|
<th align="left" id="host">Host</th>
|
||||||
<th align="left" id="os">Operating System</th>
|
<th align="left" id="os">Operating System</th>
|
||||||
|
@ -478,6 +479,7 @@ DOCUMENTATION :: END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
login_table = $('#login_table-UID-${data["user_id"]}').DataTable(login_table_options);
|
login_table = $('#login_table-UID-${data["user_id"]}').DataTable(login_table_options);
|
||||||
|
login_table.columns([1, 2]).visible(false);
|
||||||
|
|
||||||
var colvis_login = new $.fn.dataTable.ColVis( login_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
var colvis_login = new $.fn.dataTable.ColVis( login_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );
|
||||||
$( colvis_login.button() ).appendTo('#button-bar-login');
|
$( colvis_login.button() ).appendTo('#button-bar-login');
|
||||||
|
|
|
@ -706,17 +706,19 @@ class Users(object):
|
||||||
|
|
||||||
data_tables = datatables.DataTables()
|
data_tables = datatables.DataTables()
|
||||||
|
|
||||||
custom_where = [['user_id', user_id]]
|
if session.get_session_user_id():
|
||||||
|
custom_where = [['user_id', session.get_session_user_id()]]
|
||||||
|
else:
|
||||||
|
custom_where = [['user_id', user_id]] if user_id else []
|
||||||
|
|
||||||
columns = ['user_login.user_id',
|
columns = ['user_login.user_id',
|
||||||
'user_login.user',
|
|
||||||
'user_login.user_group',
|
'user_login.user_group',
|
||||||
'user_login.ip_address',
|
'user_login.ip_address',
|
||||||
'user_login.host',
|
'user_login.host',
|
||||||
'user_login.user_agent',
|
'user_login.user_agent',
|
||||||
'user_login.timestamp AS date',
|
'user_login.timestamp',
|
||||||
'user_login.timestamp AS time',
|
'(CASE WHEN users.friendly_name IS NULL THEN user_login.user ELSE users.friendly_name END) \
|
||||||
'users.friendly_name'
|
AS friendly_name'
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -739,15 +741,13 @@ class Users(object):
|
||||||
(os, browser) = httpagentparser.simple_detect(item['user_agent'])
|
(os, browser) = httpagentparser.simple_detect(item['user_agent'])
|
||||||
|
|
||||||
row = {'user_id': item['user_id'],
|
row = {'user_id': item['user_id'],
|
||||||
'user': item['user'],
|
|
||||||
'user_group': item['user_group'],
|
'user_group': item['user_group'],
|
||||||
'ip_address': item['ip_address'],
|
'ip_address': item['ip_address'],
|
||||||
'host': item['host'],
|
'host': item['host'],
|
||||||
'user_agent': item['user_agent'],
|
'user_agent': item['user_agent'],
|
||||||
'os': os,
|
'os': os,
|
||||||
'browser': browser,
|
'browser': browser,
|
||||||
'date': item['date'],
|
'timestamp': item['timestamp'],
|
||||||
'time': item['time'],
|
|
||||||
'friendly_name': item['friendly_name']
|
'friendly_name': item['friendly_name']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,3 +760,15 @@ class Users(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
|
def delete_login_log(self):
|
||||||
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
try:
|
||||||
|
logger.info(u"PlexPy Users :: Clearing login logs from database.")
|
||||||
|
monitor_db.action('DELETE FROM user_login')
|
||||||
|
monitor_db.action('VACUUM')
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy Users :: Unable to execute database query for delete_login_log: %s." % e)
|
||||||
|
return False
|
|
@ -1190,12 +1190,11 @@ class WebInterface(object):
|
||||||
"recordsFiltered": 10,
|
"recordsFiltered": 10,
|
||||||
"data":
|
"data":
|
||||||
[{"browser": "Safari 7.0.3",
|
[{"browser": "Safari 7.0.3",
|
||||||
"date": 1462591869,
|
|
||||||
"friendly_name": "Jon Snow",
|
"friendly_name": "Jon Snow",
|
||||||
"host": "http://plexpy.castleblack.com",
|
"host": "http://plexpy.castleblack.com",
|
||||||
"ip_address": "xxx.xxx.xxx.xxx",
|
"ip_address": "xxx.xxx.xxx.xxx",
|
||||||
"os": "Mac OS X",
|
"os": "Mac OS X",
|
||||||
"time": 1462591869,
|
"timestamp": 1462591869,
|
||||||
"user": "LordCommanderSnow",
|
"user": "LordCommanderSnow",
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
|
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
|
||||||
"user_group": "guest",
|
"user_group": "guest",
|
||||||
|
@ -1211,13 +1210,12 @@ class WebInterface(object):
|
||||||
# If not, then build the minimal amount of json data for a query
|
# If not, then build the minimal amount of json data for a query
|
||||||
if not kwargs.get('json_data'):
|
if not kwargs.get('json_data'):
|
||||||
# TODO: Find some one way to automatically get the columns
|
# TODO: Find some one way to automatically get the columns
|
||||||
dt_columns = [("date", True, False),
|
dt_columns = [("timestamp", True, False),
|
||||||
("time", True, False),
|
|
||||||
("ip_address", True, True),
|
("ip_address", True, True),
|
||||||
("host", True, True),
|
("host", True, True),
|
||||||
("os", True, True),
|
("os", True, True),
|
||||||
("browser", True, True)]
|
("browser", True, True)]
|
||||||
kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "time")
|
kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "timestamp")
|
||||||
|
|
||||||
user_data = users.Users()
|
user_data = users.Users()
|
||||||
history = user_data.get_datatables_user_login(user_id=user_id, kwargs=kwargs)
|
history = user_data.get_datatables_user_login(user_id=user_id, kwargs=kwargs)
|
||||||
|
@ -2147,7 +2145,7 @@ class WebInterface(object):
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def delete_notification_log(self, **kwargs):
|
def delete_notification_log(self, **kwargs):
|
||||||
""" Delete the notification logs.
|
""" Delete the PlexPy notification logs.
|
||||||
|
|
||||||
```
|
```
|
||||||
Required paramters:
|
Required paramters:
|
||||||
|
@ -2167,6 +2165,31 @@ class WebInterface(object):
|
||||||
|
|
||||||
return {'result': res, 'message': msg}
|
return {'result': res, 'message': msg}
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@cherrypy.tools.json_out()
|
||||||
|
@requireAuth(member_of("admin"))
|
||||||
|
@addtoapi()
|
||||||
|
def delete_login_log(self, **kwargs):
|
||||||
|
""" Delete the PlexPy login logs.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required paramters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
user_data = users.Users()
|
||||||
|
result = user_data.delete_login_log()
|
||||||
|
res = 'success' if result else 'error'
|
||||||
|
msg = 'Cleared login logs.' if result else 'Failed to clear login logs.'
|
||||||
|
|
||||||
|
return {'result': res, 'message': msg}
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue