mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-26 12:28:28 +02:00
75 lines
No EOL
3 KiB
Twig
75 lines
No EOL
3 KiB
Twig
<script src="/assets/js/tabulator.min.js" defer></script>
|
|
<script src="/assets/js/tabler.min.js" defer></script>
|
|
<script src="/assets/js/xlsx.full.min.js" defer></script>
|
|
<script src="/assets/js/jspdf.umd.min.js" defer></script>
|
|
<script src="/assets/js/jspdf.plugin.autotable.min.js" defer></script>
|
|
<script>
|
|
var table;
|
|
|
|
document.addEventListener("DOMContentLoaded", function(){
|
|
table = new Tabulator("#logsTable", {
|
|
ajaxURL:"/api/records/error_log", // Set the URL for your JSON data
|
|
ajaxConfig:"GET",
|
|
pagination:"local",
|
|
paginationSize: 10,
|
|
paginationSizeSelector:[10, 25, 50, 100],
|
|
clipboard:true,
|
|
clipboardPasteAction:"replace",
|
|
ajaxResponse:function(url, params, response){
|
|
return response.records;
|
|
},
|
|
layout:"fitColumns",
|
|
responsiveLayout: "collapse",
|
|
responsiveLayoutCollapseStartOpen:false,
|
|
resizableColumns:false,
|
|
initialSort:[
|
|
{column:"created_at", dir:"desc"}, // sorting by the "created_at" field in descending order
|
|
],
|
|
placeholder: "{{ __('No Data') }}",
|
|
columns:[
|
|
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
|
|
{title:"{{ __('Channel') }}", field:"channel", minWidth:180, resizable:false, headerSort:true, responsive:0},
|
|
{title:"{{ __('Level') }}", field:"level_name", resizable:false, minWidth:150, headerSort:true, responsive:0},
|
|
{title:"{{ __('Log') }}", field:"message", resizable:false, minWidth:550, headerSort:true, responsive:2},
|
|
{title:"{{ __('Date') }}", field:"created_at", resizable:false, minWidth:250, headerSort:true, responsive:2},
|
|
]
|
|
});
|
|
var searchInput = document.getElementById("search-input");
|
|
searchInput.addEventListener("input", function () {
|
|
var term = searchInput.value.toLowerCase();
|
|
|
|
if (term) { // Only apply the filter when there's a term to search for
|
|
table.setFilter(function (data) {
|
|
// Check if any of the fields contain the search term
|
|
return (
|
|
String(data.channel).toLowerCase().includes(term) ||
|
|
String(data.level_name).toLowerCase().includes(term) ||
|
|
String(data.message).toLowerCase().includes(term) ||
|
|
String(data.created_at).toLowerCase().includes(term)
|
|
);
|
|
});
|
|
} else {
|
|
table.clearFilter(); // Clear the filter when the search box is emptied
|
|
}
|
|
});
|
|
});
|
|
|
|
function downloadCSV() {
|
|
table.download("csv", "log.csv");
|
|
}
|
|
|
|
function downloadJSON() {
|
|
table.download("json", "log.json");
|
|
}
|
|
|
|
function downloadXLSX() {
|
|
table.download("xlsx", "log.xlsx", {sheetName:"My Logs"});
|
|
}
|
|
|
|
function downloadPDF() {
|
|
table.download("pdf", "log.pdf", {
|
|
orientation:"portrait",
|
|
title:"My Logs"
|
|
});
|
|
}
|
|
</script> |