<div>
Browse files<label class="block text-sm font-medium text-gray-700 mb-1">Time Range</label>
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
<option>Last 24 hours</option>
<option>Last week</option>
<option>Last month</option>
</select>
</div>
chnage to last n hours , n is editable and filter accordingly
- index.html +9 -5
- script.js +74 -4
index.html
CHANGED
|
@@ -61,13 +61,17 @@
|
|
| 61 |
</div>
|
| 62 |
<div>
|
| 63 |
<label class="block text-sm font-medium text-gray-700 mb-1">Time Range</label>
|
| 64 |
-
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 65 |
-
<option>Last
|
| 66 |
-
<option>Last
|
| 67 |
-
<option>Last
|
|
|
|
|
|
|
| 68 |
</select>
|
|
|
|
|
|
|
| 69 |
</div>
|
| 70 |
-
|
| 71 |
<label class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
|
| 72 |
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 73 |
</div>
|
|
|
|
| 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="1">Last hour</option>
|
| 66 |
+
<option value="24" selected>Last 24 hours</option>
|
| 67 |
+
<option value="168">Last week</option>
|
| 68 |
+
<option value="720">Last month</option>
|
| 69 |
+
<option value="custom">Custom hours</option>
|
| 70 |
</select>
|
| 71 |
+
<input id="customHoursInput" type="number" min="1" placeholder="Enter hours"
|
| 72 |
+
class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm hidden">
|
| 73 |
</div>
|
| 74 |
+
<div>
|
| 75 |
<label class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
|
| 76 |
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 77 |
</div>
|
script.js
CHANGED
|
@@ -316,16 +316,86 @@ function closeErrorModal() {
|
|
| 316 |
// Initialize the page
|
| 317 |
document.addEventListener('DOMContentLoaded', () => {
|
| 318 |
renderLogsTable();
|
| 319 |
-
|
| 320 |
// Search functionality
|
| 321 |
searchInput.addEventListener('input', (e) => {
|
| 322 |
renderLogsTable(e.target.value);
|
| 323 |
});
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
// Initialize modal (but don't show it yet)
|
| 326 |
errorModal = createModalElements();
|
| 327 |
-
|
| 328 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
errorModal.addEventListener('click', (e) => {
|
| 330 |
if (e.target === errorModal) {
|
| 331 |
closeErrorModal();
|
|
|
|
| 316 |
// Initialize the page
|
| 317 |
document.addEventListener('DOMContentLoaded', () => {
|
| 318 |
renderLogsTable();
|
|
|
|
| 319 |
// Search functionality
|
| 320 |
searchInput.addEventListener('input', (e) => {
|
| 321 |
renderLogsTable(e.target.value);
|
| 322 |
});
|
| 323 |
+
|
| 324 |
+
// Show/hide custom hours input based on selection
|
| 325 |
+
document.getElementById('timeRangeSelect').addEventListener('change', function() {
|
| 326 |
+
const customHoursInput = document.getElementById('customHoursInput');
|
| 327 |
+
customHoursInput.classList.toggle('hidden', this.value !== 'custom');
|
| 328 |
+
});
|
| 329 |
// Initialize modal (but don't show it yet)
|
| 330 |
errorModal = createModalElements();
|
| 331 |
+
|
| 332 |
+
// Apply Filters button functionality
|
| 333 |
+
document.querySelector('.container button').addEventListener('click', () => {
|
| 334 |
+
const statusFilter = document.querySelector('select:nth-of-type(1)').value;
|
| 335 |
+
const methodFilter = document.querySelector('select:nth-of-type(2)').value;
|
| 336 |
+
const timeFilterSelect = document.getElementById('timeRangeSelect');
|
| 337 |
+
const customHoursInput = document.getElementById('customHoursInput');
|
| 338 |
+
|
| 339 |
+
let hours;
|
| 340 |
+
if (timeFilterSelect.value === 'custom') {
|
| 341 |
+
hours = parseInt(customHoursInput.value) || 1; // Default to 1 hour if invalid input
|
| 342 |
+
} else {
|
| 343 |
+
hours = parseInt(timeFilterSelect.value);
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
|
| 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 |
+
return logDate >= timeAgo &&
|
| 354 |
+
(statusFilter === 'All' || log.status.toString() === statusFilter) &&
|
| 355 |
+
(methodFilter === 'All' || log.method === methodFilter) &&
|
| 356 |
+
(urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
|
| 357 |
+
(errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
|
| 358 |
+
});
|
| 359 |
+
|
| 360 |
+
// Clear current logs
|
| 361 |
+
logsTable.innerHTML = '';
|
| 362 |
+
|
| 363 |
+
// Render filtered logs
|
| 364 |
+
filteredLogs.forEach(log => {
|
| 365 |
+
const row = document.createElement('tr');
|
| 366 |
+
row.className = 'hover:bg-gray-50';
|
| 367 |
+
row.innerHTML = `
|
| 368 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
| 369 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 370 |
+
<span class="status-badge ${getStatusClass(log.status)}">${log.status}</span>
|
| 371 |
+
</td>
|
| 372 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 373 |
+
<span class="status-badge ${getMethodClass(log.method)}">${log.method}</span>
|
| 374 |
+
</td>
|
| 375 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.time}</td>
|
| 376 |
+
<td class="px-6 py-4 text-sm text-gray-500 max-w-xs truncate">${log.url}</td>
|
| 377 |
+
<td class="px-6 py-4 text-sm text-gray-500 truncate max-w-xs">${log.errorMessage}</td>
|
| 378 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
| 379 |
+
<button class="view-btn p-1 rounded hover:bg-gray-200" data-id="${log.id}">
|
| 380 |
+
<i data-feather="eye" class="w-4 h-4 text-primary-500"></i>
|
| 381 |
+
</button>
|
| 382 |
+
</td>
|
| 383 |
+
`;
|
| 384 |
+
logsTable.appendChild(row);
|
| 385 |
+
});
|
| 386 |
+
|
| 387 |
+
// Add event listeners to new view buttons
|
| 388 |
+
document.querySelectorAll('.view-btn').forEach(btn => {
|
| 389 |
+
btn.addEventListener('click', (e) => {
|
| 390 |
+
const id = parseInt(e.currentTarget.getAttribute('data-id'));
|
| 391 |
+
currentLog = sampleLogs.find(log => log.id === id);
|
| 392 |
+
showErrorDetails(currentLog);
|
| 393 |
+
});
|
| 394 |
+
});
|
| 395 |
+
|
| 396 |
+
feather.replace();
|
| 397 |
+
});
|
| 398 |
+
// Setup event listeners for modal
|
| 399 |
errorModal.addEventListener('click', (e) => {
|
| 400 |
if (e.target === errorModal) {
|
| 401 |
closeErrorModal();
|