Add structured JSON evidence export workflow
Dieser Commit ist enthalten in:
@@ -13,6 +13,12 @@ const evidenceLockedCount = document.getElementById("evidence-locked-count");
|
||||
const evidenceDashboardButton = document.getElementById(
|
||||
"evidence-dashboard-button"
|
||||
);
|
||||
const evidenceExportJsonButton = document.getElementById(
|
||||
"evidence-export-json-button"
|
||||
);
|
||||
const evidenceExportJsonStatus = document.getElementById(
|
||||
"evidence-export-json-status"
|
||||
);
|
||||
const evidenceRetentionStatus = document.getElementById(
|
||||
"evidence-retention-status"
|
||||
);
|
||||
@@ -61,6 +67,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
url: browser.runtime.getURL("src/dashboard/dashboard.html")
|
||||
});
|
||||
});
|
||||
|
||||
evidenceExportJsonButton.addEventListener("click", exportEvidenceJsonFile);
|
||||
});
|
||||
|
||||
async function renderSettings() {
|
||||
@@ -134,3 +142,70 @@ function formatStatusValue(value) {
|
||||
function renderEvidenceRetentionMessage(message) {
|
||||
evidenceRetentionStatus.textContent = message;
|
||||
}
|
||||
|
||||
async function exportEvidenceJsonFile() {
|
||||
evidenceExportJsonButton.disabled = true;
|
||||
renderEvidenceExportJsonMessage("Export läuft…");
|
||||
|
||||
try {
|
||||
const result = await browser.runtime.sendMessage({
|
||||
type: "export_evidence_json"
|
||||
});
|
||||
|
||||
if (!result?.success || !result.export) {
|
||||
throw new Error(result?.error ?? "export_evidence_json_failed");
|
||||
}
|
||||
|
||||
downloadJsonExport(result.export);
|
||||
renderEvidenceExportJsonMessage(buildExportSuccessMessage(result.export));
|
||||
} catch (error) {
|
||||
renderEvidenceExportJsonMessage("Export fehlgeschlagen");
|
||||
console.warn("VendorGet-IV evidence JSON export failed", error);
|
||||
} finally {
|
||||
evidenceExportJsonButton.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadJsonExport(exportContainer) {
|
||||
const json = JSON.stringify(exportContainer, null, 2);
|
||||
const blob = new Blob([json], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const downloadLink = document.createElement("a");
|
||||
|
||||
downloadLink.href = url;
|
||||
downloadLink.download = `vendorget-evidence-export-${formatExportTimestamp(
|
||||
new Date()
|
||||
)}.json`;
|
||||
document.body.append(downloadLink);
|
||||
downloadLink.click();
|
||||
downloadLink.remove();
|
||||
|
||||
setTimeout(() => URL.revokeObjectURL(url), 0);
|
||||
}
|
||||
|
||||
function buildExportSuccessMessage(exportContainer) {
|
||||
const storeCount = exportContainer?.metadata?.stores?.length ?? 0;
|
||||
const totalRecordCount =
|
||||
exportContainer?.metadata?.summary?.totalRecordCount ?? 0;
|
||||
|
||||
return `Export gespeichert: ${storeCount} Stores, ${totalRecordCount} Records`;
|
||||
}
|
||||
|
||||
function formatExportTimestamp(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = padDatePart(date.getMonth() + 1);
|
||||
const day = padDatePart(date.getDate());
|
||||
const hours = padDatePart(date.getHours());
|
||||
const minutes = padDatePart(date.getMinutes());
|
||||
const seconds = padDatePart(date.getSeconds());
|
||||
|
||||
return `${year}${month}${day}-${hours}${minutes}${seconds}`;
|
||||
}
|
||||
|
||||
function padDatePart(value) {
|
||||
return String(value).padStart(2, "0");
|
||||
}
|
||||
|
||||
function renderEvidenceExportJsonMessage(message) {
|
||||
evidenceExportJsonStatus.textContent = message;
|
||||
}
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren