forked from ddrilling/asb_cloud_front
Reports download fix
This commit is contained in:
parent
0ea895e1f6
commit
e341362f92
@ -100,9 +100,7 @@ export default function Report(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getReportFile = async (event, reportFileName) => {
|
const getReportFile = async (event, reportFileName) => {
|
||||||
const element = event.target
|
|
||||||
|
|
||||||
if(!element.href.length) {
|
|
||||||
try {
|
try {
|
||||||
await fetch(`/api/report/${wellId}/${reportFileName}`, {
|
await fetch(`/api/report/${wellId}/${reportFileName}`, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -115,8 +113,11 @@ export default function Report(props) {
|
|||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
element.href = e.target.result
|
var link = document.createElement("a");
|
||||||
element.click()
|
link.download = reportFileName;
|
||||||
|
link.href = e.target.result
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -126,7 +127,6 @@ export default function Report(props) {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const handleReportCreation = async (values) => {
|
const handleReportCreation = async (values) => {
|
||||||
let begin = rangeDate[0].toISOString()
|
let begin = rangeDate[0].toISOString()
|
||||||
|
Loading…
Reference in New Issue
Block a user