// Sample data - in a real app this would come from an API
const sampleLogs = [
{
id: 1,
status: 500,
method: 'POST',
time: '2025-10-18 14:32:45',
url: 'https://api.example.com/v1/users',
errorMessage: 'Internal Server Error: Database connection timeout',
errorCode: 'DB_CONN_TIMEOUT',
errorType: 'Database',
resolution: 'Check database connection pool. Verify database server is running and accessible. Consider increasing connection timeout setting.'
},
{
id: 2,
status: 404,
method: 'GET',
time: '2023-05-15 14:30:12',
url: 'https://api.example.com/v1/products/12345',
errorMessage: 'Product not found with ID 12345',
errorCode: 'RESOURCE_NOT_FOUND',
errorType: 'Validation',
resolution: 'Verify the product ID exists in the database. Check if the product was deleted. Validate the request parameters.'
},
{
id: 3,
status: 400,
method: 'PUT',
time: '2023-05-15 14:25:33',
url: 'https://api.example.com/v1/orders/678',
errorMessage: 'Invalid request body: Missing required field "quantity"',
errorCode: 'VALIDATION_ERROR',
errorType: 'Validation',
resolution: 'Check the API documentation for required fields. Validate the request body before sending. Ensure all required fields are included.'
},
{
id: 4,
status: 401,
method: 'GET',
time: '2023-05-15 14:20:18',
url: 'https://api.example.com/v1/users/me',
errorMessage: 'Unauthorized: Invalid or expired access token',
errorCode: 'INVALID_TOKEN',
errorType: 'Authentication',
resolution: 'Check if the access token is valid and not expired. Verify the token signature. Refresh the token if needed.'
},
{
id: 5,
status: 503,
method: 'POST',
time: '2023-05-15 14:15:42',
url: 'https://api.example.com/v1/payments',
errorMessage: 'Service Unavailable: Payment gateway not responding',
errorCode: 'GATEWAY_TIMEOUT',
errorType: 'Integration',
resolution: 'Check the payment gateway status. Verify network connectivity. Implement retry logic with exponential backoff.'
}
];
// DOM elements
const logsTable = document.getElementById('logsTable');
const searchInput = document.querySelector('input[type="text"]');
let errorModal;
let closeModal;
let closeModalBtn;
let submitTicket;
// Current selected log
let currentLog = null;
// Function to render logs table with optional filter
function renderLogsTableWithFilter(filteredLogs) {
logsTable.innerHTML = '';
filteredLogs.forEach(log => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50';
row.innerHTML = `