2021-09-23 14:18:46 +05:00
|
|
|
|
import { Progress, Button } from "antd"
|
2021-08-20 10:49:20 +05:00
|
|
|
|
import { download, notify } from "../../components/factory"
|
2021-08-18 10:35:39 +05:00
|
|
|
|
|
2021-09-23 14:18:46 +05:00
|
|
|
|
export const getReportFile = async (fileInfo) => {
|
2021-08-18 10:35:39 +05:00
|
|
|
|
try {
|
2021-09-23 14:18:46 +05:00
|
|
|
|
await download(`/api/well/${fileInfo.idWell}/files/${fileInfo.id}`)
|
2021-08-18 10:35:39 +05:00
|
|
|
|
} catch (error) {
|
2021-09-23 14:18:46 +05:00
|
|
|
|
notify(`Не удалось скачать отчет ${fileInfo.name} по скважине (${fileInfo.idWell})`, 'error')
|
2021-08-18 10:35:39 +05:00
|
|
|
|
console.log(error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 14:18:46 +05:00
|
|
|
|
export const ReportCreationNotify = ({progressData}) => {
|
|
|
|
|
progressData = progressData ?? {progress: 0.0, operation: 'Создание отчета'}
|
2021-08-18 10:35:39 +05:00
|
|
|
|
|
2021-09-23 14:18:46 +05:00
|
|
|
|
let downloadButton = null
|
|
|
|
|
if (progressData.file)
|
|
|
|
|
downloadButton = <Button
|
|
|
|
|
type="link"
|
|
|
|
|
onClick={_ => {getReportFile(progressData.file)}}
|
|
|
|
|
download={progressData.file.name}>
|
|
|
|
|
{progressData.file.name}
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
const progressText = `${progressData.operation} стр ${progressData.currentPage} из ${progressData.totalPages}`
|
2021-08-18 10:35:39 +05:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Progress percent={ progressData.progress } />
|
2021-09-23 14:18:46 +05:00
|
|
|
|
<br/>
|
|
|
|
|
<span>{progressText}</span>
|
|
|
|
|
{downloadButton}
|
2021-08-18 10:35:39 +05:00
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|