Apply Filters not working
Browse files- index.html +1 -58
- script.js +56 -0
index.html
CHANGED
|
@@ -105,64 +105,7 @@
|
|
| 105 |
</main>
|
| 106 |
<!-- Error Details Modal - Removed modal content since it's created in script.js -->
|
| 107 |
<div id="errorModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"></div>
|
| 108 |
-
|
| 109 |
-
<div class="p-6">
|
| 110 |
-
<div class="flex justify-between items-center mb-4">
|
| 111 |
-
<h2 class="text-xl font-bold text-gray-800">Error Details</h2>
|
| 112 |
-
<button id="closeModal" class="text-gray-500 hover:text-gray-700 p-2">
|
| 113 |
-
<i data-feather="x" class="w-5 h-5"></i>
|
| 114 |
-
</button>
|
| 115 |
-
</div>
|
| 116 |
-
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 117 |
-
<div>
|
| 118 |
-
<h3 class="font-medium text-gray-700 mb-2">Request Information</h3>
|
| 119 |
-
<div class="space-y-2">
|
| 120 |
-
<p><span class="font-medium">Status:</span> <span id="modalStatus" class="px-2 py-1 rounded text-xs"></span></p>
|
| 121 |
-
<p><span class="font-medium">Method:</span> <span id="modalMethod" class="px-2 py-1 rounded text-xs"></span></p>
|
| 122 |
-
<p><span class="font-medium">Endpoint:</span> <span id="modalEndpoint" class="break-all"></span></p>
|
| 123 |
-
<p><span class="font-medium">Timestamp:</span> <span id="modalTime" class="font-mono"></span></p>
|
| 124 |
-
<p><span class="font-medium">Request Duration:</span> <span id="modalDuration" class="font-mono">-</span></p>
|
| 125 |
-
</div>
|
| 126 |
-
</div>
|
| 127 |
-
|
| 128 |
-
<div>
|
| 129 |
-
<h3 class="font-medium text-gray-700 mb-2">Error Information</h3>
|
| 130 |
-
<div class="space-y-2">
|
| 131 |
-
<p><span class="font-medium">Error Code:</span> <span id="modalErrorCode" class="font-mono"></span></p>
|
| 132 |
-
<p><span class="font-medium">Error Type:</span> <span id="modalErrorType" class="px-2 py-1 rounded text-xs"></span></p>
|
| 133 |
-
<p><span class="font-medium">Occurrences:</span> <span id="modalOccurrences" class="font-mono">1</span></p>
|
| 134 |
-
<p><span class="font-medium">First Occurred:</span> <span id="modalFirstOccurred" class="font-mono">-</span></p>
|
| 135 |
-
<p><span class="font-medium">Last Occurred:</span> <span id="modalLastOccurred" class="font-mono">-</span></p>
|
| 136 |
-
</div>
|
| 137 |
-
</div>
|
| 138 |
-
</div>
|
| 139 |
-
<div class="mb-6">
|
| 140 |
-
<h3 class="font-medium text-gray-700 mb-2">Full Error Message</h3>
|
| 141 |
-
<div class="bg-gray-50 p-4 rounded">
|
| 142 |
-
<pre id="modalErrorMessage" class="text-sm whitespace-pre-wrap overflow-x-auto font-mono"></pre>
|
| 143 |
-
</div>
|
| 144 |
-
</div>
|
| 145 |
-
<div class="mb-6 hidden" id="requestDetails">
|
| 146 |
-
<h3 class="font-medium text-gray-700 mb-2">Request Details</h3>
|
| 147 |
-
<div class="bg-gray-50 p-4 rounded">
|
| 148 |
-
<pre id="modalRequestDetails" class="text-sm whitespace-pre-wrap overflow-x-auto font-mono"></pre>
|
| 149 |
-
</div>
|
| 150 |
-
</div>
|
| 151 |
-
<div class="mb-6">
|
| 152 |
-
<h3 class="font-medium text-gray-700 mb-2">Resolution Steps</h3>
|
| 153 |
-
<div id="modalResolution" class="bg-blue-50 p-4 rounded text-sm"></div>
|
| 154 |
-
</div>
|
| 155 |
-
|
| 156 |
-
<div class="flex justify-end space-x-3">
|
| 157 |
-
<button id="submitTicket" class="px-4 py-2 bg-secondary-500 text-white rounded-md hover:bg-secondary-600 transition flex items-center">
|
| 158 |
-
<i data-feather="plus" class="mr-2 w-4 h-4"></i> Submit Ticket
|
| 159 |
-
</button>
|
| 160 |
-
<button id="closeModalBtn" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 transition">
|
| 161 |
-
Close
|
| 162 |
-
</button>
|
| 163 |
-
</div>
|
| 164 |
-
</div>
|
| 165 |
-
</div>
|
| 166 |
</div>
|
| 167 |
|
| 168 |
<script src="components/navbar.js"></script>
|
|
|
|
| 105 |
</main>
|
| 106 |
<!-- Error Details Modal - Removed modal content since it's created in script.js -->
|
| 107 |
<div id="errorModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"></div>
|
| 108 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
|
| 111 |
<script src="components/navbar.js"></script>
|
script.js
CHANGED
|
@@ -331,8 +331,64 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 331 |
closeErrorModal();
|
| 332 |
}
|
| 333 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
});
|
| 335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
// Global event delegation for modal buttons
|
| 337 |
document.addEventListener('click', (e) => {
|
| 338 |
if (e.target.closest('#closeModal, #closeModalBtn')) {
|
|
|
|
| 331 |
closeErrorModal();
|
| 332 |
}
|
| 333 |
});
|
| 334 |
+
|
| 335 |
+
// Apply Filters button functionality
|
| 336 |
+
document.querySelector('.container button').addEventListener('click', () => {
|
| 337 |
+
const statusFilter = document.querySelector('select:nth-of-type(1)').value;
|
| 338 |
+
const methodFilter = document.querySelector('select:nth-of-type(2)').value;
|
| 339 |
+
const timeFilter = document.querySelector('select:nth-of-type(3)').value;
|
| 340 |
+
const urlFilter = document.querySelector('input[placeholder="URL Contains"]').value;
|
| 341 |
+
const errorFilter = document.querySelector('input[placeholder="Error Contains"]').value;
|
| 342 |
+
|
| 343 |
+
const filteredLogs = sampleLogs.filter(log => {
|
| 344 |
+
return (statusFilter === 'All' || log.status.toString() === statusFilter) &&
|
| 345 |
+
(methodFilter === 'All' || log.method === methodFilter) &&
|
| 346 |
+
(timeFilter === 'Last 24 hours' || true) && // Time filter would need date comparison in real app
|
| 347 |
+
(urlFilter === '' || log.url.toLowerCase().includes(urlFilter.toLowerCase())) &&
|
| 348 |
+
(errorFilter === '' || log.errorMessage.toLowerCase().includes(errorFilter.toLowerCase()));
|
| 349 |
+
});
|
| 350 |
+
|
| 351 |
+
renderFilteredLogs(filteredLogs);
|
| 352 |
+
});
|
| 353 |
});
|
| 354 |
|
| 355 |
+
function renderFilteredLogs(filteredLogs) {
|
| 356 |
+
logsTable.innerHTML = '';
|
| 357 |
+
|
| 358 |
+
filteredLogs.forEach(log => {
|
| 359 |
+
const row = document.createElement('tr');
|
| 360 |
+
row.className = 'hover:bg-gray-50';
|
| 361 |
+
row.innerHTML = `
|
| 362 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
| 363 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 364 |
+
<span class="status-badge ${getStatusClass(log.status)}">${log.status}</span>
|
| 365 |
+
</td>
|
| 366 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 367 |
+
<span class="status-badge ${getMethodClass(log.method)}">${log.method}</span>
|
| 368 |
+
</td>
|
| 369 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.time}</td>
|
| 370 |
+
<td class="px-6 py-4 text-sm text-gray-500 max-w-xs truncate">${log.url}</td>
|
| 371 |
+
<td class="px-6 py-4 text-sm text-gray-500 truncate max-w-xs">${log.errorMessage}</td>
|
| 372 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
| 373 |
+
<button class="view-btn p-1 rounded hover:bg-gray-200" data-id="${log.id}">
|
| 374 |
+
<i data-feather="eye" class="w-4 h-4 text-primary-500"></i>
|
| 375 |
+
</button>
|
| 376 |
+
</td>
|
| 377 |
+
`;
|
| 378 |
+
logsTable.appendChild(row);
|
| 379 |
+
});
|
| 380 |
+
|
| 381 |
+
// Add event listeners to view buttons
|
| 382 |
+
document.querySelectorAll('.view-btn').forEach(btn => {
|
| 383 |
+
btn.addEventListener('click', (e) => {
|
| 384 |
+
const id = parseInt(e.currentTarget.getAttribute('data-id'));
|
| 385 |
+
currentLog = sampleLogs.find(log => log.id === id);
|
| 386 |
+
showErrorDetails(currentLog);
|
| 387 |
+
});
|
| 388 |
+
});
|
| 389 |
+
|
| 390 |
+
feather.replace();
|
| 391 |
+
}
|
| 392 |
// Global event delegation for modal buttons
|
| 393 |
document.addEventListener('click', (e) => {
|
| 394 |
if (e.target.closest('#closeModal, #closeModalBtn')) {
|