diff --git a/html/static/js/report-table.js b/html/static/js/report-table.js index a66e5f12..5dcdcb07 100644 --- a/html/static/js/report-table.js +++ b/html/static/js/report-table.js @@ -202,7 +202,7 @@ class ReportTable extends HTMLElement { const relativeTime = this.formatRelativeTime(report.created); tableHTML += ` - + ${formattedId} ${relativeTime} ${report.type} @@ -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 + } + })); + }); + }) } } diff --git a/rmo/template/status.html b/rmo/template/status.html index e439104f..53257a00 100644 --- a/rmo/template/status.html +++ b/rmo/template/status.html @@ -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);