Navigate to report status page on table click

This commit is contained in:
Eli Ribble 2026-02-05 01:31:16 +00:00
parent d58a893651
commit f301feb537
No known key found for this signature in database
2 changed files with 21 additions and 1 deletions

View file

@ -202,7 +202,7 @@ class ReportTable extends HTMLElement {
const relativeTime = this.formatRelativeTime(report.created);
tableHTML += `
<tr class="clickable-row" onclick="window.location='/status/${report.id}'">
<tr class="clickable-row" data-report-id="${report.id}">
<td><strong>${formattedId}</strong></td>
<td>${relativeTime}</td>
<td><span class="badge ${typeClass} report-type-badge">${report.type}</span></td>
@ -224,6 +224,22 @@ class ReportTable extends HTMLElement {
// Set the shadow DOM content
this.shadowRoot.innerHTML = style + tableHTML;
// Add click handlers for the rows
this.shadowRoot.querySelectorAll("tr.clickable-row").forEach(el => {
el.addEventListener("click", e => {
let element = e.target
while (element.nodeName != "TR" ) {
element = element.parentElement;
}
this.dispatchEvent(new CustomEvent("row-clicked", {
bubbles: true,
composed: true, // Allows event to cross shadow DOM boundary
detail: {
reportId: element.dataset.reportId
}
}));
});
})
}
}

View file

@ -133,6 +133,10 @@ function onLoad() {
console.log("location error", error);
})
});
const report_table = document.querySelector('report-table');
report_table.addEventListener("row-clicked", (e) => {
window.location = "/status/" + e.detail.reportId;
})
}
document.addEventListener('DOMContentLoaded', onLoad);