forked from ddrilling/asb_cloud_front
Reports download fix
This commit is contained in:
parent
0ea895e1f6
commit
e341362f92
@ -100,31 +100,31 @@ export default function Report(props) {
|
||||
}
|
||||
|
||||
const getReportFile = async (event, reportFileName) => {
|
||||
const element = event.target
|
||||
|
||||
if(!element.href.length) {
|
||||
try {
|
||||
await fetch(`/api/report/${wellId}/${reportFileName}`, {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + localStorage['token']
|
||||
}
|
||||
})
|
||||
.then(async (response) => {
|
||||
const blob = await response.blob();
|
||||
try {
|
||||
await fetch(`/api/report/${wellId}/${reportFileName}`, {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + localStorage['token']
|
||||
}
|
||||
})
|
||||
.then(async (response) => {
|
||||
const blob = await response.blob();
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
reader.onload = function (e) {
|
||||
element.href = e.target.result
|
||||
element.click()
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
notify(`Не удалось скачать отчет по скважине (${wellId}) c
|
||||
${rangeDate[0].format("DD.MM.YYYY hh:mm:ss")} по
|
||||
${rangeDate[1].format("DD.MM.YYYY hh:mm:ss")}`, 'error')
|
||||
console.log(error)
|
||||
}
|
||||
let reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
reader.onload = function (e) {
|
||||
var link = document.createElement("a");
|
||||
link.download = reportFileName;
|
||||
link.href = e.target.result
|
||||
link.click();
|
||||
link.remove();
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
notify(`Не удалось скачать отчет по скважине (${wellId}) c
|
||||
${rangeDate[0].format("DD.MM.YYYY hh:mm:ss")} по
|
||||
${rangeDate[1].format("DD.MM.YYYY hh:mm:ss")}`, 'error')
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user