diff --git a/backend/app/templates/report_detail.html b/backend/app/templates/report_detail.html index c623f6a..acc6813 100644 --- a/backend/app/templates/report_detail.html +++ b/backend/app/templates/report_detail.html @@ -51,6 +51,10 @@ Back to Domain + @@ -247,6 +251,27 @@ function reportDetailApp(reportId) { } }, + async deleteReport(domain, reportId) { + if (!confirm(`Delete report "${reportId}" for domain "${domain}"?\n\nThis will remove the report from the system. You can re-import it afterwards.`)) { + return; + } + try { + const response = await fetch( + `/api/v1/reports/domain/${encodeURIComponent(domain)}/reports/${encodeURIComponent(reportId)}`, + { method: 'DELETE' } + ); + if (response.ok) { + window.location.href = '/reports'; + } else { + const data = await response.json().catch(() => ({})); + alert('Failed to delete report: ' + (data.detail || response.statusText)); + } + } catch (error) { + console.error('Error deleting report:', error); + alert('Network error — could not delete report.'); + } + }, + formatDate(timestamp) { if (!timestamp) return '—'; return new Date(timestamp * 1000).toLocaleString(); diff --git a/backend/app/templates/reports.html b/backend/app/templates/reports.html index ed0bb71..087d70d 100644 --- a/backend/app/templates/reports.html +++ b/backend/app/templates/reports.html @@ -95,11 +95,17 @@ {% endcall %} {% call td("text-right") %} - - {% call button(variant="outline", size="sm") %} - View Details - {% endcall %} - +
+ + {% call button(variant="outline", size="sm") %} + View Details + {% endcall %} + + +
{% endcall %} {% endcall %} @@ -174,6 +180,32 @@ function reportsApp() { } finally { this.loading = false; } + }, + + async deleteReport(domain, reportId) { + if (!confirm(`Delete report "${reportId}" for domain "${domain}"?\n\nThis will remove the report from the system. You can re-import it afterwards.`)) { + return; + } + try { + const response = await fetch( + `/api/v1/reports/domain/${encodeURIComponent(domain)}/reports/${encodeURIComponent(reportId)}`, + { method: 'DELETE' } + ); + if (response.ok) { + this.reports = this.reports.filter( + r => !(r.domain === domain && r.report_id === reportId) + ); + if (!this.reports.some(r => r.domain === domain)) { + this.domains = this.domains.filter(d => d !== domain); + } + } else { + const data = await response.json().catch(() => ({})); + alert('Failed to delete report: ' + (data.detail || response.statusText)); + } + } catch (error) { + console.error('Error deleting report:', error); + alert('Network error — could not delete report.'); + } } } }