Load fileUrl on demand for evidence
Fix #168 Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
committed by
Sacha Al Himdani
parent
0a5524ce5d
commit
25b330f948
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user