Compare commits
2 Commits
2eeb8266c7
...
82c67f6b01
| Author | SHA1 | Date | |
|---|---|---|---|
| 82c67f6b01 | |||
| e2822a130f |
@ -1 +1 @@
|
||||
v20260103-01-reports-jobs-delete
|
||||
changes-v20260103-02-reports-delete
|
||||
|
||||
@ -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 @@
|
||||
'<button type="button" class="btn btn-sm btn-outline-primary me-1 rep-generate-btn" data-id="' + item.id + '">Generate</button>' +
|
||||
'<button type="button" class="btn btn-sm btn-outline-secondary me-1 rep-view-btn" data-id="' + item.id + '">View raw</button>' +
|
||||
'<a class="btn btn-sm btn-outline-success rep-download-btn" href="/api/reports/' + item.id + '/export.csv" target="_blank" rel="noopener">Download</a>' +
|
||||
(canDeleteReports ? '<button type="button" class="btn btn-sm btn-outline-danger ms-1 rep-delete-btn" data-id="' + item.id + '">Delete</button>' : '') +
|
||||
'</td>';;
|
||||
|
||||
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;
|
||||
|
||||
@ -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.
|
||||
|
||||
================================================================================================================================================
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user