Load fileUrl on demand for evidence

Fix #168

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Jonathan
2025-07-08 10:33:27 +02:00
committed by Sacha Al Himdani
parent 0a5524ce5d
commit 25b330f948
12 changed files with 323 additions and 99 deletions

View File

@@ -5,3 +5,18 @@ export function withViewTransition(fn: () => void) {
}
document.startViewTransition(fn);
}
export function downloadFile(url: string | undefined | null, filename: string) {
if (!url) {
alert("Cannot download this file, fileUrl is not provided");
return;
}
const link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("hidden", "hidden");
link.setAttribute("download", filename);
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

View File

@@ -6,7 +6,7 @@ export {
getRiskLikelihoods,
getSeverity,
} from "./risk";
export { withViewTransition } from "./dom";
export { withViewTransition, downloadFile } from "./dom";
export { times, groupBy, isEmpty } from "./array";
export { randomInt } from "./number";
export { getMeasureStateLabel, measureStates } from "./measure";