commit 04/02/2026
This commit is contained in:
67
html/semiauto/assets/js/log.js
Normal file
67
html/semiauto/assets/js/log.js
Normal file
@@ -0,0 +1,67 @@
|
||||
tblog = null;
|
||||
|
||||
function load_log_data(datevalue){
|
||||
// check if format yyyy-mm-dd, convert to dd-mm-yyyy
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(datevalue)) {
|
||||
const parts = datevalue.split("-");
|
||||
if (parts.length === 3) {
|
||||
datevalue = parts[2] + "-" + parts[1] + "-" + parts[0];
|
||||
}
|
||||
}
|
||||
console.log("Loading log data for date:", datevalue);
|
||||
tblog.clear().draw();
|
||||
fetchAPI('Log/'+datevalue,'GET',{}, null,function(data){
|
||||
//console.log("Log data fetched:", data);
|
||||
if (data && Array.isArray(data) && data.length > 0){
|
||||
data.forEach(function(item, index){
|
||||
tblog.row.add({
|
||||
index: index + 1,
|
||||
date: item.datenya,
|
||||
time: item.timenya,
|
||||
source: item.machine,
|
||||
message: item.description
|
||||
})
|
||||
});
|
||||
tblog.draw();
|
||||
}
|
||||
},function(error){
|
||||
console.error("Error fetching log data:", error);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
console.log("Log.js is loaded");
|
||||
tblog = new DataTable('#logtable',{
|
||||
columns: [
|
||||
{title: 'Index', data: 'index'},
|
||||
{title: 'Date', data: 'date'},
|
||||
{title: 'Time', data: 'time'},
|
||||
{title: 'Source', data: 'source'},
|
||||
{title: 'Message', data: 'message'}
|
||||
],
|
||||
pageLength: 25,
|
||||
data: [],
|
||||
buttons: ['excel', 'pdf', 'print'],
|
||||
layout: {
|
||||
topStart: 'buttons',
|
||||
topEnd: 'search'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$('#reload_log').on('click', function(){
|
||||
// get value from date_log
|
||||
let datevalue = $('#date_log').val();
|
||||
load_log_data(datevalue);
|
||||
});
|
||||
|
||||
let today = new Date().toISOString().split('T')[0];
|
||||
|
||||
$('#date_log').val(today);
|
||||
load_log_data(today);
|
||||
|
||||
$('#date_log').on('change', function(){
|
||||
let datevalue = $(this).val();
|
||||
load_log_data(datevalue);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user