diff --git a/.last-branch b/.last-branch
index bde91c1..48fd3f9 100644
--- a/.last-branch
+++ b/.last-branch
@@ -1 +1 @@
-v20260103-01-reports-jobs-delete
+changes-v20260103-02-reports-delete
diff --git a/containers/backupchecks/src/templates/main/reports.html b/containers/backupchecks/src/templates/main/reports.html
index a24da4c..c40cb20 100644
--- a/containers/backupchecks/src/templates/main/reports.html
+++ b/containers/backupchecks/src/templates/main/reports.html
@@ -147,6 +147,8 @@
var rawLimit = 100;
var rawOffset = 0;
+ var canDeleteReports = {{ 'true' if active_role in ('admin','operator','reporter') else 'false' }};
+
function qs(id) { return document.getElementById(id); }
function fmtPeriod(item) {
@@ -341,6 +343,7 @@
'' +
'' +
'Download' +
+ (canDeleteReports ? '' : '') +
'';;
body.appendChild(tr);
@@ -361,6 +364,12 @@
});
}
+ body.querySelectorAll('.rep-delete-btn').forEach(function (btn) {
+ btn.addEventListener('click', function () {
+ var id = btn.getAttribute('data-id');
+ deleteReport(id, btn);
+ });
+ });
function loadReports() {
setTableLoading('Loading…');
fetch('/api/reports', { credentials: 'same-origin' })
@@ -373,6 +382,33 @@
});
}
+ function deleteReport(id, btnEl) {
+ if (!id) return;
+ if (!confirm('Delete this report definition? This cannot be undone.')) return;
+ var oldText = btnEl ? btnEl.textContent : '';
+ if (btnEl) { btnEl.disabled = true; btnEl.textContent = 'Deleting…'; }
+
+ fetch('/api/reports/' + id, { method: 'DELETE', credentials: 'same-origin' })
+ .then(function (r) { return r.json().then(function (j) { return { ok: r.ok, json: j }; }); })
+ .then(function (res) {
+ if (btnEl) { btnEl.disabled = false; btnEl.textContent = oldText; }
+ if (!res.ok) {
+ alert((res.json && res.json.error) ? res.json.error : 'Delete failed.');
+ return;
+ }
+ // If the raw modal is open for this report, close it.
+ if (rawReportId && String(rawReportId) === String(id) && rawModal) {
+ rawModal.hide();
+ rawReportId = null;
+ }
+ loadReports();
+ })
+ .catch(function () {
+ if (btnEl) { btnEl.disabled = false; btnEl.textContent = oldText; }
+ alert('Delete failed.');
+ });
+ }
+
function generateReport(id, btnEl) {
if (!id) return;
var oldText = btnEl.textContent;
@@ -435,4 +471,4 @@
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/docs/changelog.md b/docs/changelog.md
index 0a78569..826d051 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -4,6 +4,13 @@
- Updated report generation logic to build snapshots and summaries based on job runs.
- Added the ability to delete reports, including removal of all associated report data.
+---
+
+## v20260103-02-reports-delete
+
+- Added the ability to delete reports from the Reports overview.
+- Introduced a Delete action per report, available to authorized roles (admin/operator/reporter).
+- Implemented backend deletion handling and automatic refresh of the reports list after removal.
================================================================================================================================================