Search functionality is not working
Browse files
script.js
CHANGED
|
@@ -56,23 +56,30 @@ const sampleLogs = [
|
|
| 56 |
resolution: 'Check the payment gateway status. Verify network connectivity. Implement retry logic with exponential backoff.'
|
| 57 |
}
|
| 58 |
];
|
| 59 |
-
|
| 60 |
// DOM elements
|
| 61 |
const logsTable = document.getElementById('logsTable');
|
| 62 |
const errorModal = document.getElementById('errorModal');
|
| 63 |
const closeModal = document.getElementById('closeModal');
|
| 64 |
const closeModalBtn = document.getElementById('closeModalBtn');
|
| 65 |
const submitTicket = document.getElementById('submitTicket');
|
| 66 |
-
|
| 67 |
// Current selected log
|
| 68 |
let currentLog = null;
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
function renderLogsTable() {
|
| 72 |
logsTable.innerHTML = '';
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
row.className = 'hover:bg-gray-50';
|
| 77 |
row.innerHTML = `
|
| 78 |
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
|
@@ -149,7 +156,6 @@ submitTicket.addEventListener('click', () => {
|
|
| 149 |
alert(`Ticket submitted for error: ${currentLog.errorCode}\nAn engineer will review this issue shortly.`);
|
| 150 |
closeErrorModal();
|
| 151 |
});
|
| 152 |
-
|
| 153 |
// Initialize the page
|
| 154 |
document.addEventListener('DOMContentLoaded', () => {
|
| 155 |
renderLogsTable();
|
|
@@ -160,4 +166,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 160 |
closeErrorModal();
|
| 161 |
}
|
| 162 |
});
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
resolution: 'Check the payment gateway status. Verify network connectivity. Implement retry logic with exponential backoff.'
|
| 57 |
}
|
| 58 |
];
|
|
|
|
| 59 |
// DOM elements
|
| 60 |
const logsTable = document.getElementById('logsTable');
|
| 61 |
const errorModal = document.getElementById('errorModal');
|
| 62 |
const closeModal = document.getElementById('closeModal');
|
| 63 |
const closeModalBtn = document.getElementById('closeModalBtn');
|
| 64 |
const submitTicket = document.getElementById('submitTicket');
|
| 65 |
+
const searchInput = document.querySelector('input[type="text"]');
|
| 66 |
// Current selected log
|
| 67 |
let currentLog = null;
|
| 68 |
+
// Function to render logs table with optional filter
|
| 69 |
+
function renderLogsTable(filter = '') {
|
|
|
|
| 70 |
logsTable.innerHTML = '';
|
| 71 |
|
| 72 |
+
const filteredLogs = filter
|
| 73 |
+
? sampleLogs.filter(log =>
|
| 74 |
+
log.url.toLowerCase().includes(filter.toLowerCase()) ||
|
| 75 |
+
log.errorMessage.toLowerCase().includes(filter.toLowerCase()) ||
|
| 76 |
+
log.status.toString().includes(filter) ||
|
| 77 |
+
log.method.toLowerCase().includes(filter.toLowerCase())
|
| 78 |
+
)
|
| 79 |
+
: sampleLogs;
|
| 80 |
+
|
| 81 |
+
filteredLogs.forEach(log => {
|
| 82 |
+
const row = document.createElement('tr');
|
| 83 |
row.className = 'hover:bg-gray-50';
|
| 84 |
row.innerHTML = `
|
| 85 |
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
|
|
|
| 156 |
alert(`Ticket submitted for error: ${currentLog.errorCode}\nAn engineer will review this issue shortly.`);
|
| 157 |
closeErrorModal();
|
| 158 |
});
|
|
|
|
| 159 |
// Initialize the page
|
| 160 |
document.addEventListener('DOMContentLoaded', () => {
|
| 161 |
renderLogsTable();
|
|
|
|
| 166 |
closeErrorModal();
|
| 167 |
}
|
| 168 |
});
|
| 169 |
+
|
| 170 |
+
// Search functionality
|
| 171 |
+
searchInput.addEventListener('input', (e) => {
|
| 172 |
+
renderLogsTable(e.target.value);
|
| 173 |
+
});
|
| 174 |
+
});
|