forked from ddrilling/asb_cloud_front
Исправлено наложение телеметрий при смене скважины
* Добавлено отображение загрузки графика
This commit is contained in:
parent
83d535c305
commit
c8050b91e5
@ -53,7 +53,7 @@ export const copyToClipboard = (value: string, successText?: string, errorText?:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type asyncFunction = (...args: any) => Promise<any|void>
|
type asyncFunction = (signal: AbortSignal, ...args: any) => Promise<any|void>
|
||||||
|
|
||||||
type InvokeOptions = {
|
type InvokeOptions = {
|
||||||
actionName?: string,
|
actionName?: string,
|
||||||
@ -75,23 +75,30 @@ const parseApiEror = (err: unknown, options?: InvokeOptions) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const invokeWebApiWrapperAsync = async (
|
export const invokeWebApiWrapperAsync = (
|
||||||
funcAsync: asyncFunction,
|
funcAsync: asyncFunction,
|
||||||
setShowLoader?: Dispatch<SetStateAction<boolean>>,
|
setShowLoader?: Dispatch<SetStateAction<boolean>>,
|
||||||
errorNotifyText?: FunctionalValue<(err: unknown) => ReactNode>,
|
errorNotifyText?: FunctionalValue<(err: unknown) => ReactNode>,
|
||||||
options?: InvokeOptions,
|
options?: InvokeOptions,
|
||||||
) => {
|
) => {
|
||||||
|
const controller = new AbortController()
|
||||||
|
const signal = controller.signal
|
||||||
|
|
||||||
setShowLoader?.(true)
|
setShowLoader?.(true)
|
||||||
try{
|
funcAsync(signal)
|
||||||
await funcAsync()
|
.then((data) => {
|
||||||
} catch (ex) {
|
if (data !== false)
|
||||||
if(isDev())
|
setShowLoader?.(false)
|
||||||
console.error(ex)
|
})
|
||||||
if (!parseApiEror(ex, options))
|
.catch((ex) => {
|
||||||
|
setShowLoader?.(false)
|
||||||
|
if(isDev())
|
||||||
|
console.error(ex)
|
||||||
|
if (parseApiEror(ex, options)) return
|
||||||
notify(getFunctionalValue(errorNotifyText)(ex), 'error', options?.well)
|
notify(getFunctionalValue(errorNotifyText)(ex), 'error', options?.well)
|
||||||
} finally {
|
})
|
||||||
setShowLoader?.(false)
|
|
||||||
}
|
return () => controller.abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const download = async (url: string, fileName?: string) => {
|
export const download = async (url: string, fileName?: string) => {
|
||||||
|
@ -143,6 +143,7 @@ const TelemetryView = memo(() => {
|
|||||||
const [dataSpin, setDataSpin] = useState([])
|
const [dataSpin, setDataSpin] = useState([])
|
||||||
const [chartInterval, setChartInterval] = useState(defaultPeriod)
|
const [chartInterval, setChartInterval] = useState(defaultPeriod)
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
const [isDataLoading, setIsDataLoading] = useState(false)
|
||||||
const [flowChartData, setFlowChartData] = useState([])
|
const [flowChartData, setFlowChartData] = useState([])
|
||||||
const [rop, setRop] = useState(null)
|
const [rop, setRop] = useState(null)
|
||||||
const [domain, setDomain] = useState({})
|
const [domain, setDomain] = useState({})
|
||||||
@ -183,19 +184,23 @@ const TelemetryView = memo(() => {
|
|||||||
}, [spinSubject$])
|
}, [spinSubject$])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
const cancel = invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async (signal) => {
|
||||||
|
if (signal.aborted) return false
|
||||||
const flowChart = await DrillFlowChartService.getByIdWell(well.id)
|
const flowChart = await DrillFlowChartService.getByIdWell(well.id)
|
||||||
const dataSaub = await TelemetryDataSaubService.getData(well.id, null, chartInterval)
|
const dataSaub = await TelemetryDataSaubService.getData(well.id, null, chartInterval)
|
||||||
const dataSpin = await TelemetryDataSpinService.getData(well.id, null, chartInterval)
|
const dataSpin = await TelemetryDataSpinService.getData(well.id, null, chartInterval)
|
||||||
|
if (signal.aborted) return false
|
||||||
setFlowChartData(flowChart ?? [])
|
setFlowChartData(flowChart ?? [])
|
||||||
handleDataSaub(dataSaub)
|
handleDataSaub(dataSaub)
|
||||||
handleDataSpin(dataSpin)
|
handleDataSpin(dataSpin)
|
||||||
},
|
},
|
||||||
null,
|
setIsDataLoading,
|
||||||
`Не удалось получить данные`,
|
`Не удалось получить данные`,
|
||||||
{ actionName: 'Получение данных по скважине', well }
|
{ actionName: 'Получение данных по скважине', well }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return () => cancel()
|
||||||
}, [well, chartInterval, handleDataSpin, handleDataSaub])
|
}, [well, chartInterval, handleDataSpin, handleDataSaub])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -282,6 +287,7 @@ const TelemetryView = memo(() => {
|
|||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem col={2} row={2} colSpan={8} rowSpan={2}>
|
<GridItem col={2} row={2} colSpan={8} rowSpan={2}>
|
||||||
<D3MonitoringCharts
|
<D3MonitoringCharts
|
||||||
|
loading={!showLoader && isDataLoading}
|
||||||
methods={setChartMethods}
|
methods={setChartMethods}
|
||||||
chartName={'monitoring'}
|
chartName={'monitoring'}
|
||||||
datasetGroups={chartGroups}
|
datasetGroups={chartGroups}
|
||||||
|
@ -57,6 +57,8 @@ const Well = memo(() => {
|
|||||||
{ actionName: 'Изменение данных скважины', well }
|
{ actionName: 'Изменение данных скважины', well }
|
||||||
), [well])
|
), [well])
|
||||||
|
|
||||||
|
const wellContext = useMemo(() => [well, updateWell], [well, updateWell])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutPortal>
|
<LayoutPortal>
|
||||||
<RootPathContext.Provider value={rootPath}>
|
<RootPathContext.Provider value={rootPath}>
|
||||||
@ -70,7 +72,7 @@ const Well = memo(() => {
|
|||||||
<PrivateMenu.Link content={DrillingProgram} icon={<FolderOutlined />} />
|
<PrivateMenu.Link content={DrillingProgram} icon={<FolderOutlined />} />
|
||||||
</PrivateMenu>
|
</PrivateMenu>
|
||||||
|
|
||||||
<WellContext.Provider value={[well, updateWell]}>
|
<WellContext.Provider value={wellContext}>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Content className={'site-layout-background'}>
|
<Content className={'site-layout-background'}>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
Loading…
Reference in New Issue
Block a user