renderLogsTable () not working , records not filtered
Browse files
script.js
CHANGED
|
@@ -69,16 +69,19 @@ let currentLog = null;
|
|
| 69 |
function renderLogsTable(filter = '') {
|
| 70 |
logsTable.innerHTML = '';
|
| 71 |
|
| 72 |
-
const filteredLogs = filter
|
| 73 |
-
? sampleLogs
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
const row = document.createElement('tr');
|
| 83 |
row.className = 'hover:bg-gray-50';
|
| 84 |
row.innerHTML = `
|
|
@@ -347,17 +350,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 347 |
const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
|
| 348 |
const now = new Date();
|
| 349 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
| 350 |
-
|
| 351 |
const filteredLogs = sampleLogs.filter(log => {
|
| 352 |
const logDate = new Date(log.time);
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
});
|
| 359 |
-
|
| 360 |
-
// Clear current logs
|
| 361 |
logsTable.innerHTML = '';
|
| 362 |
|
| 363 |
// Render filtered logs
|
|
@@ -427,13 +432,17 @@ const urlFilter = document.querySelector('input[placeholder="URL Contains"]').va
|
|
| 427 |
|
| 428 |
const filteredLogs = sampleLogs.filter(log => {
|
| 429 |
const logDate = new Date(log.time);
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
|
| 438 |
// Clear current logs
|
| 439 |
logsTable.innerHTML = '';
|
|
|
|
| 69 |
function renderLogsTable(filter = '') {
|
| 70 |
logsTable.innerHTML = '';
|
| 71 |
|
| 72 |
+
const filteredLogs = filter === ''
|
| 73 |
+
? sampleLogs
|
| 74 |
+
: sampleLogs.filter(log => {
|
| 75 |
+
const searchTerm = filter.toLowerCase();
|
| 76 |
+
return (
|
| 77 |
+
log.url.toLowerCase().includes(searchTerm) ||
|
| 78 |
+
log.errorMessage.toLowerCase().includes(searchTerm) ||
|
| 79 |
+
log.status.toString().includes(filter) ||
|
| 80 |
+
log.method.toLowerCase().includes(searchTerm) ||
|
| 81 |
+
log.errorCode?.toLowerCase().includes(searchTerm)
|
| 82 |
+
);
|
| 83 |
+
});
|
| 84 |
+
filteredLogs.forEach(log => {
|
| 85 |
const row = document.createElement('tr');
|
| 86 |
row.className = 'hover:bg-gray-50';
|
| 87 |
row.innerHTML = `
|
|
|
|
| 350 |
const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
|
| 351 |
const now = new Date();
|
| 352 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
|
|
|
| 353 |
const filteredLogs = sampleLogs.filter(log => {
|
| 354 |
const logDate = new Date(log.time);
|
| 355 |
+
const timeMatch = logDate >= timeAgo;
|
| 356 |
+
const statusMatch = statusFilter === 'All' || log.status.toString() === statusFilter;
|
| 357 |
+
const methodMatch = methodFilter === 'All' || log.method === methodFilter;
|
| 358 |
+
const urlMatch = urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase());
|
| 359 |
+
const errorMatch = errorFilter === '' ||
|
| 360 |
+
log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()) ||
|
| 361 |
+
log.errorCode?.toLowerCase().includes(errorFilter.toLowerCase());
|
| 362 |
+
|
| 363 |
+
return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
|
| 364 |
});
|
| 365 |
+
// Clear current logs
|
|
|
|
| 366 |
logsTable.innerHTML = '';
|
| 367 |
|
| 368 |
// Render filtered logs
|
|
|
|
| 432 |
|
| 433 |
const filteredLogs = sampleLogs.filter(log => {
|
| 434 |
const logDate = new Date(log.time);
|
| 435 |
+
const logDate = new Date(log.time);
|
| 436 |
+
const timeMatch = logDate >= timeAgo;
|
| 437 |
+
const statusMatch = statusFilter === 'All' || log.status.toString() === statusFilter;
|
| 438 |
+
const methodMatch = methodFilter === 'All' || log.method === methodFilter;
|
| 439 |
+
const urlMatch = urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase());
|
| 440 |
+
const errorMatch = errorFilter === '' ||
|
| 441 |
+
log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()) ||
|
| 442 |
+
log.errorCode?.toLowerCase().includes(errorFilter.toLowerCase());
|
| 443 |
+
|
| 444 |
+
return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
|
| 445 |
+
});
|
| 446 |
|
| 447 |
// Clear current logs
|
| 448 |
logsTable.innerHTML = '';
|