remove Filters option and filter from UI
Browse files- index.html +1 -51
- script.js +0 -109
index.html
CHANGED
|
@@ -36,57 +36,7 @@
|
|
| 36 |
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
-
|
| 40 |
-
<!-- Filters -->
|
| 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>
|
| 59 |
-
<option>DELETE</option>
|
| 60 |
-
</select>
|
| 61 |
-
</div>
|
| 62 |
-
<div>
|
| 63 |
-
<label class="block text-sm font-medium text-gray-700 mb-1">Time Range</label>
|
| 64 |
-
<select id="timeRangeSelect" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm mb-2">
|
| 65 |
-
<option value="all">All time</option>
|
| 66 |
-
<option value="1">Last hour</option>
|
| 67 |
-
<option value="24" selected>Last 24 hours</option>
|
| 68 |
-
<option value="168">Last week</option>
|
| 69 |
-
<option value="720">Last month</option>
|
| 70 |
-
<option value="custom">Custom hours</option>
|
| 71 |
-
</select>
|
| 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 -->
|
| 90 |
<div class="bg-white rounded-lg shadow overflow-hidden">
|
| 91 |
<div class="overflow-x-auto">
|
| 92 |
<table class="min-w-full divide-y divide-gray-200">
|
|
|
|
| 36 |
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
+
<!-- Logs Table -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
<div class="bg-white rounded-lg shadow overflow-hidden">
|
| 41 |
<div class="overflow-x-auto">
|
| 42 |
<table class="min-w-full divide-y divide-gray-200">
|
script.js
CHANGED
|
@@ -358,123 +358,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 358 |
searchInput.addEventListener('input', (e) => {
|
| 359 |
renderLogsTable(e.target.value);
|
| 360 |
});
|
| 361 |
-
|
| 362 |
-
// Show/hide custom hours input based on selection
|
| 363 |
-
document.getElementById('timeRangeSelect').addEventListener('change', function() {
|
| 364 |
-
const customHoursInput = document.getElementById('customHoursInput');
|
| 365 |
-
customHoursInput.classList.toggle('hidden', this.value !== 'custom');
|
| 366 |
-
});
|
| 367 |
// Initialize modal (but don't show it yet)
|
| 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 |
-
|
| 377 |
-
let hours;
|
| 378 |
-
if (timeFilterSelect.value === 'custom') {
|
| 379 |
-
hours = parseInt(customHoursInput.value) || 1; // Default to 1 hour if invalid input
|
| 380 |
-
} else {
|
| 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) => {
|
| 402 |
if (e.target === errorModal) {
|
| 403 |
closeErrorModal();
|
| 404 |
}
|
| 405 |
});
|
| 406 |
-
// Show/hide custom hours input based on selection
|
| 407 |
-
document.getElementById('timeRangeSelect').addEventListener('change', function() {
|
| 408 |
-
const customHoursInput = document.getElementById('customHoursInput');
|
| 409 |
-
customHoursInput.classList.toggle('hidden', this.value !== 'custom');
|
| 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 |
-
|
| 419 |
-
let hours;
|
| 420 |
-
if (timeFilterSelect.value === 'custom') {
|
| 421 |
-
hours = parseInt(customHoursInput.value) || 1; // Default to 1 hour if invalid input
|
| 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 |
});
|
| 479 |
// Global event delegation for modal buttons
|
| 480 |
document.addEventListener('click', (e) => {
|
|
|
|
| 358 |
searchInput.addEventListener('input', (e) => {
|
| 359 |
renderLogsTable(e.target.value);
|
| 360 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
// Initialize modal (but don't show it yet)
|
| 362 |
errorModal = createModalElements();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
// Setup event listeners for modal
|
| 364 |
errorModal.addEventListener('click', (e) => {
|
| 365 |
if (e.target === errorModal) {
|
| 366 |
closeErrorModal();
|
| 367 |
}
|
| 368 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
});
|
| 370 |
// Global event delegation for modal buttons
|
| 371 |
document.addEventListener('click', (e) => {
|