2020-12-13 13:40:55 -05:00
|
|
|
{% extends ../base.html %}
|
|
|
|
|
|
|
|
{% block meta %}
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
{% block title %}Crafty Controller - Activity Logs{% end %}
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
|
|
<div class="content-wrapper">
|
|
|
|
|
2022-04-02 21:25:26 -04:00
|
|
|
<!-- Page Title Header Starts-->
|
2020-12-13 13:40:55 -05:00
|
|
|
<div class="row page-title-header">
|
|
|
|
<div class="col-12">
|
|
|
|
<div class="page-header">
|
|
|
|
<h4 class="page-title">Activity Logs</h4>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- Page Title Header Ends-->
|
|
|
|
<div class="row">
|
2022-01-12 22:54:22 -05:00
|
|
|
<div class="col-md-12 col-lg-12 grid-margin stretch-card">
|
2020-12-13 13:40:55 -05:00
|
|
|
<div class="card">
|
2022-01-12 22:54:22 -05:00
|
|
|
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
|
|
|
<h4 class="card-title"><i class="fas fa-history"></i> Audit Logs</h4>
|
2022-04-02 21:25:26 -04:00
|
|
|
{% if data['user_data']['hints'] %}
|
|
|
|
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" ,
|
|
|
|
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
|
|
|
|
data-placement="top"></span>
|
|
|
|
{% end %}
|
2022-01-12 22:54:22 -05:00
|
|
|
</div>
|
2020-12-13 13:40:55 -05:00
|
|
|
<div class="card-body">
|
2022-01-12 22:54:22 -05:00
|
|
|
|
|
|
|
<div class="table-responsive">
|
2022-01-12 22:56:44 -05:00
|
|
|
<table class="table table-hover" id="audit_table" style="overflow: scroll;" width="100%">
|
2022-01-12 22:54:22 -05:00
|
|
|
<thead>
|
2022-04-02 21:25:26 -04:00
|
|
|
<tr class="rounded">
|
2024-04-20 15:47:50 -04:00
|
|
|
<th>Time</th>
|
|
|
|
<th>Username</th>
|
|
|
|
<th>Action</th>
|
|
|
|
<th>Server ID</th>
|
|
|
|
<th>IP</th>
|
2022-04-02 21:25:26 -04:00
|
|
|
</tr>
|
2022-01-12 22:54:22 -05:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
</tbody>
|
2022-04-02 21:25:26 -04:00
|
|
|
</table>
|
2022-01-12 22:54:22 -05:00
|
|
|
|
|
|
|
</div>
|
2020-12-13 13:40:55 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-12 22:54:22 -05:00
|
|
|
<style>
|
2022-04-02 21:25:26 -04:00
|
|
|
.popover-body {
|
|
|
|
color: white !important;
|
|
|
|
;
|
|
|
|
}
|
2022-01-12 22:54:22 -05:00
|
|
|
</style>
|
2020-12-13 13:40:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- content-wrapper ends -->
|
|
|
|
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
{% block js %}
|
2022-01-12 22:54:22 -05:00
|
|
|
<script>
|
2022-04-02 21:25:26 -04:00
|
|
|
$(document).ready(function () {
|
2022-01-12 22:54:22 -05:00
|
|
|
$('[data-toggle="popover"]').popover();
|
2022-04-02 21:25:26 -04:00
|
|
|
if ($(window).width() < 1000) {
|
2022-01-12 22:54:22 -05:00
|
|
|
$('.too_small').popover("show");
|
|
|
|
}
|
2022-01-21 23:50:04 +01:00
|
|
|
|
2022-01-12 22:54:22 -05:00
|
|
|
});
|
2022-04-02 21:25:26 -04:00
|
|
|
$(window).ready(function () {
|
|
|
|
$('body').click(function () {
|
|
|
|
$('.too_small').popover("hide");
|
|
|
|
});
|
2022-01-12 22:54:22 -05:00
|
|
|
});
|
2022-04-02 21:25:26 -04:00
|
|
|
$(window).resize(function () {
|
2022-01-12 22:54:22 -05:00
|
|
|
// This will execute whenever the window is resized
|
2022-04-02 21:25:26 -04:00
|
|
|
if ($(window).width() < 1000) {
|
2022-01-12 22:54:22 -05:00
|
|
|
$('.too_small').popover("show");
|
|
|
|
}
|
2022-04-02 21:25:26 -04:00
|
|
|
else {
|
2022-01-12 22:54:22 -05:00
|
|
|
$('.too_small').popover("hide");
|
|
|
|
} // New width
|
|
|
|
});
|
2024-04-20 15:47:50 -04:00
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
console.log('ready for JS!')
|
|
|
|
// Initialize DataTables
|
|
|
|
// Load initial data
|
|
|
|
getActivity();
|
|
|
|
});
|
|
|
|
|
|
|
|
function updateActivity(data) {
|
|
|
|
let tbody = $('#audit_table tbody');
|
|
|
|
tbody.empty(); // Clear existing rows
|
|
|
|
$.each(data, function (index, value) {
|
|
|
|
let row = $('<tr>');
|
|
|
|
row.append(`<td>${value.time}</td>`);
|
|
|
|
row.append(`<td><a href="/panel/edit_user?id=${value.user_id}">${value.user_name}</a></td>`);
|
|
|
|
row.append(`<td>${value.log_msg}</td>`);
|
|
|
|
row.append(`<td>${value.server_id}</td>`);
|
|
|
|
row.append(`<td>${value.source_ip}</td>`);
|
|
|
|
tbody.append(row);
|
|
|
|
});
|
|
|
|
$('#audit_table').DataTable({
|
|
|
|
'order': [[0, 'desc']], // Sort by the first column in descending order
|
|
|
|
filter: true,
|
|
|
|
"searching": true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getActivity() {
|
|
|
|
var token = getCookie("_xsrf");
|
|
|
|
let res = await fetch(`/api/v2/crafty/logs/audit`, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'X-XSRFToken': token
|
|
|
|
},
|
|
|
|
});
|
|
|
|
let responseData = await res.json();
|
|
|
|
console.log(responseData);
|
|
|
|
if (responseData.status === "ok") {
|
|
|
|
updateActivity(responseData.data);
|
|
|
|
console.log("activity update")
|
|
|
|
} else {
|
|
|
|
bootbox.alert(responseData.error)
|
|
|
|
}
|
|
|
|
}
|
2022-04-02 21:25:26 -04:00
|
|
|
</script>
|
2020-12-13 13:40:55 -05:00
|
|
|
|
|
|
|
{% end %}
|