Promote version db778e6 to main
Browse filesPromoted commit db778e69d1236fde1aa3b5c46eb365f8f12e37c3 to main branch
- index.html +15 -15
- script.js +62 -60
index.html
CHANGED
|
@@ -41,18 +41,18 @@
|
|
| 41 |
<div class="bg-white rounded-lg shadow p-4 mb-6">
|
| 42 |
<div class="grid grid-cols-1 md:grid-cols-5 gap-4">
|
| 43 |
<div>
|
| 44 |
-
<label
|
| 45 |
-
<select
|
| 46 |
-
<option>All</option>
|
| 47 |
<option>200</option>
|
| 48 |
<option>400</option>
|
| 49 |
<option>500</option>
|
| 50 |
</select>
|
| 51 |
</div>
|
| 52 |
<div>
|
| 53 |
-
<label
|
| 54 |
-
<select
|
| 55 |
-
<option>All</option>
|
| 56 |
<option>GET</option>
|
| 57 |
<option>POST</option>
|
| 58 |
<option>PUT</option>
|
|
@@ -72,18 +72,18 @@
|
|
| 72 |
<input id="customHoursInput" type="number" min="1" placeholder="Enter hours"
|
| 73 |
class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm hidden">
|
| 74 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
<div>
|
| 76 |
-
<label
|
| 77 |
-
<input
|
| 78 |
-
</div>
|
| 79 |
-
<div>
|
| 80 |
-
<label for="errorFilter" class="block text-sm font-medium text-gray-700 mb-1">Error Contains</label>
|
| 81 |
-
<input id="errorFilter" type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 82 |
-
</div>
|
| 83 |
</div>
|
| 84 |
<div class="flex justify-end mt-4">
|
| 85 |
-
<button
|
| 86 |
-
</div>
|
| 87 |
</div>
|
| 88 |
|
| 89 |
<!-- Logs Table -->
|
|
|
|
| 41 |
<div class="bg-white rounded-lg shadow p-4 mb-6">
|
| 42 |
<div class="grid grid-cols-1 md:grid-cols-5 gap-4">
|
| 43 |
<div>
|
| 44 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
| 45 |
+
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 46 |
+
<option>All</option>
|
| 47 |
<option>200</option>
|
| 48 |
<option>400</option>
|
| 49 |
<option>500</option>
|
| 50 |
</select>
|
| 51 |
</div>
|
| 52 |
<div>
|
| 53 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Method</label>
|
| 54 |
+
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 55 |
+
<option>All</option>
|
| 56 |
<option>GET</option>
|
| 57 |
<option>POST</option>
|
| 58 |
<option>PUT</option>
|
|
|
|
| 72 |
<input id="customHoursInput" type="number" min="1" placeholder="Enter hours"
|
| 73 |
class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm hidden">
|
| 74 |
</div>
|
| 75 |
+
<div>
|
| 76 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
|
| 77 |
+
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 78 |
+
</div>
|
| 79 |
<div>
|
| 80 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Error Contains</label>
|
| 81 |
+
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 82 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</div>
|
| 84 |
<div class="flex justify-end mt-4">
|
| 85 |
+
<button class="px-4 py-2 bg-primary-500 text-white rounded-md hover:bg-primary-600 transition">Apply Filters</button>
|
| 86 |
+
</div>
|
| 87 |
</div>
|
| 88 |
|
| 89 |
<!-- Logs Table -->
|
script.js
CHANGED
|
@@ -69,17 +69,6 @@ let currentLog = null;
|
|
| 69 |
function renderLogsTableWithFilter(filteredLogs) {
|
| 70 |
logsTable.innerHTML = '';
|
| 71 |
|
| 72 |
-
if (filteredLogs.length === 0) {
|
| 73 |
-
const row = document.createElement('tr');
|
| 74 |
-
row.innerHTML = `
|
| 75 |
-
<td colspan="7" class="py-4 text-gray-500 text-center">
|
| 76 |
-
No logs found matching your filters
|
| 77 |
-
</td>
|
| 78 |
-
`;
|
| 79 |
-
logsTable.appendChild(row);
|
| 80 |
-
return;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
filteredLogs.forEach(log => {
|
| 84 |
const row = document.createElement('tr');
|
| 85 |
row.className = 'hover:bg-gray-50';
|
|
@@ -114,6 +103,7 @@ function renderLogsTableWithFilter(filteredLogs) {
|
|
| 114 |
|
| 115 |
feather.replace();
|
| 116 |
}
|
|
|
|
| 117 |
function renderLogsTable(filter = '') {
|
| 118 |
logsTable.innerHTML = '';
|
| 119 |
|
|
@@ -378,9 +368,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 378 |
errorModal = createModalElements();
|
| 379 |
|
| 380 |
// Apply Filters button functionality
|
| 381 |
-
document.
|
| 382 |
-
const statusFilter = document.
|
| 383 |
-
const methodFilter = document.
|
| 384 |
const timeFilterSelect = document.getElementById('timeRangeSelect');
|
| 385 |
const customHoursInput = document.getElementById('customHoursInput');
|
| 386 |
|
|
@@ -391,32 +381,21 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 391 |
hours = parseInt(timeFilterSelect.value);
|
| 392 |
}
|
| 393 |
|
| 394 |
-
const urlFilter = document.
|
| 395 |
-
const errorFilter = document.
|
| 396 |
-
const now = new Date();
|
| 397 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
| 398 |
const filteredLogs = sampleLogs.filter(log => {
|
| 399 |
const logDate = new Date(log.time);
|
| 400 |
-
const timeMatch =
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
|
| 407 |
});
|
| 408 |
|
| 409 |
-
|
| 410 |
-
logsTable.innerHTML = `
|
| 411 |
-
<tr>
|
| 412 |
-
<td colspan="7" class="py-4 text-gray-500 text-center">
|
| 413 |
-
No logs found matching your filters
|
| 414 |
-
</td>
|
| 415 |
-
</tr>
|
| 416 |
-
`;
|
| 417 |
-
} else {
|
| 418 |
-
renderLogsTableWithFilter(filteredLogs);
|
| 419 |
-
}
|
| 420 |
});
|
| 421 |
// Setup event listeners for modal
|
| 422 |
errorModal.addEventListener('click', (e) => {
|
|
@@ -431,9 +410,9 @@ const now = new Date();
|
|
| 431 |
});
|
| 432 |
|
| 433 |
// Apply Filters button functionality
|
| 434 |
-
document.
|
| 435 |
-
const statusFilter = document.
|
| 436 |
-
const methodFilter = document.
|
| 437 |
const timeFilterSelect = document.getElementById('timeRangeSelect');
|
| 438 |
const customHoursInput = document.getElementById('customHoursInput');
|
| 439 |
|
|
@@ -443,34 +422,57 @@ const now = new Date();
|
|
| 443 |
} else {
|
| 444 |
hours = parseInt(timeFilterSelect.value);
|
| 445 |
}
|
| 446 |
-
|
| 447 |
-
const
|
| 448 |
-
const
|
| 449 |
-
const now = new Date();
|
| 450 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
|
|
|
| 451 |
const filteredLogs = sampleLogs.filter(log => {
|
| 452 |
const logDate = new Date(log.time);
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
return timeMatch && statusMatch && methodMatch && urlMatch && errorMatch;
|
| 461 |
});
|
| 462 |
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
`;
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 474 |
feather.replace();
|
| 475 |
});
|
| 476 |
});
|
|
|
|
| 69 |
function renderLogsTableWithFilter(filteredLogs) {
|
| 70 |
logsTable.innerHTML = '';
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
filteredLogs.forEach(log => {
|
| 73 |
const row = document.createElement('tr');
|
| 74 |
row.className = 'hover:bg-gray-50';
|
|
|
|
| 103 |
|
| 104 |
feather.replace();
|
| 105 |
}
|
| 106 |
+
|
| 107 |
function renderLogsTable(filter = '') {
|
| 108 |
logsTable.innerHTML = '';
|
| 109 |
|
|
|
|
| 368 |
errorModal = createModalElements();
|
| 369 |
|
| 370 |
// Apply Filters button functionality
|
| 371 |
+
document.querySelector('.container button').addEventListener('click', () => {
|
| 372 |
+
const statusFilter = document.querySelector('select:nth-of-type(1)').value;
|
| 373 |
+
const methodFilter = document.querySelector('select:nth-of-type(2)').value;
|
| 374 |
const timeFilterSelect = document.getElementById('timeRangeSelect');
|
| 375 |
const customHoursInput = document.getElementById('customHoursInput');
|
| 376 |
|
|
|
|
| 381 |
hours = parseInt(timeFilterSelect.value);
|
| 382 |
}
|
| 383 |
|
| 384 |
+
const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
|
| 385 |
+
const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
|
| 386 |
+
const now = new Date();
|
| 387 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
| 388 |
const filteredLogs = sampleLogs.filter(log => {
|
| 389 |
const logDate = new Date(log.time);
|
| 390 |
+
const timeMatch = hours === 'all' || logDate >= timeAgo;
|
| 391 |
+
return timeMatch &&
|
| 392 |
+
(statusFilter === 'All' || log.status.toString() === statusFilter) &&
|
| 393 |
+
(methodFilter === 'All' || log.method === methodFilter) &&
|
| 394 |
+
(urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
|
| 395 |
+
(errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
|
|
|
|
| 396 |
});
|
| 397 |
|
| 398 |
+
renderLogsTableWithFilter(filteredLogs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
});
|
| 400 |
// Setup event listeners for modal
|
| 401 |
errorModal.addEventListener('click', (e) => {
|
|
|
|
| 410 |
});
|
| 411 |
|
| 412 |
// Apply Filters button functionality
|
| 413 |
+
document.querySelector('.container button').addEventListener('click', () => {
|
| 414 |
+
const statusFilter = document.querySelector('select:nth-of-type(1)').value;
|
| 415 |
+
const methodFilter = document.querySelector('select:nth-of-type(2)').value;
|
| 416 |
const timeFilterSelect = document.getElementById('timeRangeSelect');
|
| 417 |
const customHoursInput = document.getElementById('customHoursInput');
|
| 418 |
|
|
|
|
| 422 |
} else {
|
| 423 |
hours = parseInt(timeFilterSelect.value);
|
| 424 |
}
|
| 425 |
+
const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
|
| 426 |
+
const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
|
| 427 |
+
const now = new Date();
|
|
|
|
| 428 |
const timeAgo = new Date(now.getTime() - (hours * 60 * 60 * 1000));
|
| 429 |
+
|
| 430 |
const filteredLogs = sampleLogs.filter(log => {
|
| 431 |
const logDate = new Date(log.time);
|
| 432 |
+
return logDate >= timeAgo;
|
| 433 |
+
return (statusFilter === 'All' || log.status.toString() === statusFilter) &&
|
| 434 |
+
(methodFilter === 'All' || log.method === methodFilter) &&
|
| 435 |
+
timeMatch &&
|
| 436 |
+
(urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
|
| 437 |
+
(errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
|
|
|
|
|
|
|
| 438 |
});
|
| 439 |
|
| 440 |
+
// Clear current logs
|
| 441 |
+
logsTable.innerHTML = '';
|
| 442 |
+
|
| 443 |
+
// Render filtered logs
|
| 444 |
+
filteredLogs.forEach(log => {
|
| 445 |
+
const row = document.createElement('tr');
|
| 446 |
+
row.className = 'hover:bg-gray-50';
|
| 447 |
+
row.innerHTML = `
|
| 448 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
| 449 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 450 |
+
<span class="status-badge ${getStatusClass(log.status)}">${log.status}</span>
|
| 451 |
+
</td>
|
| 452 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 453 |
+
<span class="status-badge ${getMethodClass(log.method)}">${log.method}</span>
|
| 454 |
+
</td>
|
| 455 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.time}</td>
|
| 456 |
+
<td class="px-6 py-4 text-sm text-gray-500 max-w-xs truncate">${log.url}</td>
|
| 457 |
+
<td class="px-6 py-4 text-sm text-gray-500 truncate max-w-xs">${log.errorMessage}</td>
|
| 458 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
| 459 |
+
<button class="view-btn p-1 rounded hover:bg-gray-200" data-id="${log.id}">
|
| 460 |
+
<i data-feather="eye" class="w-4 h-4 text-primary-500"></i>
|
| 461 |
+
</button>
|
| 462 |
+
</td>
|
| 463 |
`;
|
| 464 |
+
logsTable.appendChild(row);
|
| 465 |
+
});
|
| 466 |
+
|
| 467 |
+
// Add event listeners to new view buttons
|
| 468 |
+
document.querySelectorAll('.view-btn').forEach(btn => {
|
| 469 |
+
btn.addEventListener('click', (e) => {
|
| 470 |
+
const id = parseInt(e.currentTarget.getAttribute('data-id'));
|
| 471 |
+
currentLog = sampleLogs.find(log => log.id === id);
|
| 472 |
+
showErrorDetails(currentLog);
|
| 473 |
+
});
|
| 474 |
+
});
|
| 475 |
+
|
| 476 |
feather.replace();
|
| 477 |
});
|
| 478 |
});
|