Add expiry and sign out button to login logs

This commit is contained in:
JonnyWong16 2021-05-14 14:02:48 -07:00
parent 8db75cf718
commit add1b4ec54
4 changed files with 48 additions and 5 deletions

View file

@ -3136,6 +3136,10 @@ div.dataTables_info {
bottom: 0;
text-shadow: 0 0 2px rgba(0,0,0,.5);
}
.sign-out-tooltip:hover {
color: #E5A00D;
cursor: pointer;
}
.history-thumbnail-popover {
z-index: 2000;
padding: 0;

View file

@ -42,7 +42,7 @@ login_log_table_options = {
{
"targets": [2],
"data": "user_group",
"width": "10%",
"width": "7%",
"className": "no-wrap"
},
{
@ -66,23 +66,42 @@ login_log_table_options = {
{
"targets": [4],
"data": "host",
"width": "20%",
"width": "18%",
"className": "no-wrap"
},
{
"targets": [5],
"data": "os",
"width": "20%",
"width": "15%",
"className": "no-wrap"
},
{
"targets": [6],
"data": "browser",
"width": "18%",
"width": "15%",
"className": "no-wrap"
},
{
"targets": [7],
"data": "expiry",
"createdCell": function (td, cellData, rowData, row, col) {
var active = '';
if (rowData['current']) {
active = '<span class="current-tooltip" data-toggle="tooltip" title="Current Session"><i class="fa fa-lg fa-fw fa-check-circle"></i></span>&nbsp;';
}
if (cellData) {
var signout = '&nbsp;<span class="sign-out-tooltip" data-toggle="tooltip" title="Sign Out"><i class="fa fa-lg fa-fw fa-sign-out-alt"></i></span>';
$(td).html(active + cellData + signout);
} else if (rowData['success']) {
$(td).html('expired');
}
},
"searchable": false,
"className": "no-wrap",
"width": "13%"
},
{
"targets": [8],
"data": "success",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData == 1) {
@ -113,6 +132,7 @@ login_log_table_options = {
"preDrawCallback": function (settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0)
$('[data-toggle="tooltip"]').tooltip('destroy');
}
};
@ -126,4 +146,21 @@ $('.login_log_table').on('click', '> tbody > tr > td.modal-control-ip', function
}).then(function (jqXHR) {
$("#ip-info-modal").html(jqXHR);
});
});
});
$('.login_log_table').on('click', '> tbody > tr > td> .sign-out-tooltip', function () {
var tr = $(this).closest('tr');
var row = login_log_table.row(tr);
var rowData = row.data();
$.get('logout_user_session', {
row_ids: rowData['row_id'],
current: rowData['current']
}).then(function () {
if (rowData['current']) {
window.location = 'auth/logout'
} else {
login_log_table.draw();
}
});
});

View file

@ -172,6 +172,7 @@
<th align="left" id="login_host">Host</th>
<th align="left" id="login_os">Operating System</th>
<th align="left" id="login_browser">Browser</th>
<th align="left" id="login_expiry">Expiry</th>
<th align="left" id="login_success"></th>
</tr>
</thead>

View file

@ -435,6 +435,7 @@ DOCUMENTATION :: END
<th align="left" id="host">Host</th>
<th align="left" id="os">Operating System</th>
<th align="left" id="browser">Browser</th>
<th align="left" id="expiry">Expiry</th>
<th align="left" id="login_success"></th>
</tr>
</thead>