Fix Set Driver button click handler

- Fixed JavaScript template literal issue preventing button clicks from working
- Changed from inline onclick with template variables to data attributes + event delegation
- Added event listener for .set-driver-btn class buttons
- Buttons now properly read hostname and token from data attributes
- Modal should now open when clicking Set Driver buttons
parent 13ffc88e
...@@ -204,7 +204,7 @@ function renderNodesTable() { ...@@ -204,7 +204,7 @@ function renderNodesTable() {
<td>${node.active_jobs || 0}</td> <td>${node.active_jobs || 0}</td>
<td>${node.completed_jobs || 0}</td> <td>${node.completed_jobs || 0}</td>
<td> <td>
<button class="btn btn-sm" onclick="openDriverModal('${node.hostname}', '${node.token}', '${node.hostname}')">Set Driver</button> <button class="btn btn-sm set-driver-btn" data-hostname="${node.hostname}" data-token="${node.token}">Set Driver</button>
</td> </td>
</tr> </tr>
`).join(''); `).join('');
...@@ -317,6 +317,15 @@ setInterval(updateNodesTable, 10000); ...@@ -317,6 +317,15 @@ setInterval(updateNodesTable, 10000);
// Initial load // Initial load
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
updateNodesTable(); updateNodesTable();
// Add event listeners for set driver buttons
document.addEventListener('click', function(e) {
if (e.target.classList.contains('set-driver-btn')) {
const hostname = e.target.getAttribute('data-hostname');
const token = e.target.getAttribute('data-token');
openDriverModal(hostname, token, hostname);
}
});
}); });
// Close modal when clicking outside // Close modal when clicking outside
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment