Контексты выделены в отдельный файл

This commit is contained in:
goodmice 2022-04-28 17:13:43 +05:00
parent ec5b5e427b
commit d91815ebf2
35 changed files with 79 additions and 52 deletions

View File

@ -3,8 +3,8 @@ import { Menu, MenuItemProps, MenuProps } from 'antd'
import { Children, cloneElement, memo, ReactElement, useContext, useMemo } from 'react'
import { Link, useLocation } from 'react-router-dom'
import { RootPathContext } from '@asb/context'
import { isURLAvailable } from '@utils/permissions'
import { RootPathContext } from '@pages/Main'
export type PrivateMenuProps = MenuProps & { root?: string }

View File

@ -1,12 +1,12 @@
import { join } from 'path'
import { Location } from 'history'
import { Children, cloneElement, memo, ReactElement, ReactNode, useCallback, useContext, useMemo } from 'react'
import { Redirect, Route, Switch, SwitchProps, useLocation } from 'react-router-dom'
import { RootPathContext } from '@asb/context'
import { isURLAvailable } from '@utils/permissions'
import { getUserId } from '@utils/storage'
import { RootPathContext } from '@pages/Main'
export type PrivateSwitchProps = SwitchProps & {
root?: string

4
src/context.ts Normal file
View File

@ -0,0 +1,4 @@
import { createContext } from 'react'
export const IdWellContext = createContext<number | null>(null)
export const RootPathContext = createContext<string>('')

View File

@ -2,10 +2,10 @@ import { Layout } from 'antd'
import { lazy, memo, Suspense, useContext, useMemo } from 'react'
import { useParams } from 'react-router-dom'
import { RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import { SuspenseFallback } from '@pages/SuspenseFallback'
import { RootPathContext } from '@pages/Main'
const TelemetryViewer = lazy(() => import('./TelemetryViewer'))
const TelemetryMerger = lazy(() => import('./TelemetryMerger'))

View File

@ -2,9 +2,9 @@ import { Layout } from 'antd'
import { lazy, memo, Suspense, useContext, useMemo } from 'react'
import { useParams } from 'react-router-dom'
import { RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import { RootPathContext } from '@pages/Main'
import { SuspenseFallback } from '@pages/SuspenseFallback'
const ClusterController = lazy(() => import( './ClusterController'))

View File

@ -1,12 +1,12 @@
import { memo, useCallback, useContext, useEffect, useState } from 'react'
import { Button, Modal, Popconfirm } from 'antd'
import { IdWellContext } from '@asb/context'
import { Table } from '@components/Table'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { DrillParamsService } from '@api'
import { IdWellContext } from '@pages/Well'
import { getColumns } from '@pages/WellOperations/WellDrillParams'
export const NewParamsTable = memo(({ selectedWellsKeys }) => {

View File

@ -3,6 +3,7 @@ import { useState, useEffect, memo, useMemo, useContext } from 'react'
import { LineChartOutlined, ProfileOutlined } from '@ant-design/icons'
import { Table, Tag, Button, Badge, Divider, Modal, Row, Col } from 'antd'
import { IdWellContext } from '@asb/context'
import { CompanyView } from '@components/views'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
@ -15,7 +16,6 @@ import {
getOperations
} from '@utils/functions'
import { IdWellContext } from '@pages/Well'
import { Tvd } from '@pages/WellOperations/Tvd'
import WellOperationsTable from '@pages/Cluster/WellOperationsTable'
import NewParamsTable from './NewParamsTable'

View File

@ -2,14 +2,14 @@ import { useState, useEffect, memo, useContext } from 'react'
import { useParams } from 'react-router-dom'
import { Col, Layout, Row } from 'antd'
import { arrayOrDefault } from '@utils'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import WellSelector from '@components/selectors/WellSelector'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import { arrayOrDefault } from '@utils'
import { OperationStatService, WellCompositeService } from '@api'
import { IdWellContext } from '@pages/Well'
import ClusterWells from '@pages/Cluster/ClusterWells'
import { WellCompositeSections } from './WellCompositeSections'

View File

@ -2,11 +2,11 @@ import { memo, useContext, useMemo } from 'react'
import { useParams } from 'react-router-dom'
import { Layout } from 'antd'
import { RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import Statistics from './Statistics'
import WellCompositeEditor from './WellCompositeEditor'
import { RootPathContext } from '@pages/Main'
export const Analytics = memo(() => {
const { tab } = useParams()

View File

@ -1,15 +1,15 @@
import { useState, useEffect, useMemo, useCallback, useContext } from 'react'
import { DatePicker, Button, Input } from 'antd'
import { FileService } from '@api'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { UploadForm } from '@components/UploadForm'
import { CompanyView, UserView } from '@components/views'
import { EditableTable, makeColumn, makeDateColumn, makeNumericColumn, makePaginationObject } from '@components/Table'
import { invokeWebApiWrapperAsync, downloadFile, formatBytes } from '@components/factory'
import { EditableTable, makeColumn, makeDateColumn, makeNumericColumn, makePaginationObject } from '@components/Table'
import { hasPermission } from '@utils/permissions'
import { FileService } from '@api's
import { IdWellContext } from '@pages/Well'
const pageSize = 12
const { RangePicker } = DatePicker

View File

@ -3,10 +3,10 @@ import { memo, useContext, useMemo } from 'react'
import { FolderOutlined } from '@ant-design/icons'
import { Layout } from 'antd'
import { RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import DocumentsTemplate from './DocumentsTemplate'
import { RootPathContext } from '@pages/Main'
const { Content } = Layout

View File

@ -2,11 +2,11 @@ import { Form, Select } from 'antd'
import { FileAddOutlined } from '@ant-design/icons'
import { memo, useCallback, useContext, useEffect, useState } from 'react'
import { IdWellContext } from '@asb/context'
import Poprompt from '@components/selectors/Poprompt'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { DrillingProgramService } from '@api'
import { IdWellContext } from '@pages/Well'
import '@styles/drilling_program.less'

View File

@ -2,6 +2,7 @@ import { Input, Modal, Radio } from 'antd'
import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { BehaviorSubject, debounceTime, distinctUntilChanged, filter, map } from 'rxjs'
import { IdWellContext } from '@asb/context'
import { UserView } from '@components/views'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
@ -9,7 +10,6 @@ import { makeColumn, makeNumericSorter, Table } from '@components/Table'
import { DrillingProgramService } from '@api'
import { arrayOrDefault } from '@utils'
import { IdWellContext } from '@pages/Well'
const userRules = [
{ label: 'Нет', value: 0 },

View File

@ -1,6 +1,7 @@
import { useCallback, useContext, useEffect, useState } from 'react'
import { Button, DatePicker, Input, Modal } from 'antd'
import { IdWellContext } from '@asb/context'
import { CompanyView } from '@components/views'
import DownloadLink from '@components/DownloadLink'
import LoaderPortal from '@components/LoaderPortal'
@ -10,7 +11,6 @@ import { arrayOrDefault, formatDate } from '@utils'
import { FileService } from '@api'
import MarksCard from './MarksCard'
import { IdWellContext } from '@pages/Well'
import '@styles/drilling_program.less'

View File

@ -6,6 +6,7 @@ import {
TableOutlined,
} from '@ant-design/icons'
import { IdWellContext } from '@asb/context'
import { UserView } from '@components/views'
import UploadForm from '@components/UploadForm'
import DownloadLink from '@components/DownloadLink'
@ -16,7 +17,6 @@ import { DrillingProgramService } from '@api'
import { formatDate } from '@utils'
import MarksCard from './MarksCard'
import { IdWellContext } from '@pages/Well'
import '@styles/drilling_program.less'

View File

@ -10,6 +10,7 @@ import {
} from '@ant-design/icons'
import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { downloadFile, formatBytes, invokeWebApiWrapperAsync } from '@components/factory'
import { arrayOrDefault, formatDate } from '@utils'
@ -19,7 +20,6 @@ import CategoryAdder from './CategoryAdder'
import CategoryRender from './CategoryRender'
import CategoryEditor from './CategoryEditor'
import CategoryHistory from './CategoryHistory'
import { IdWellContext } from '@pages/Well'
import '@styles/drilling_program.less'

View File

@ -1,6 +1,7 @@
import { createContext, memo } from 'react'
import { memo } from 'react'
import { Route, Switch } from 'react-router-dom'
import { RootPathContext } from '@asb/context'
import { AdminLayoutPortal, LayoutPortal } from '@components/Layout'
import { PrivateDefaultRoute, PrivateRoute } from '@components/Private'
@ -10,8 +11,6 @@ import Deposit from './Deposit'
import AdminPanel from './AdminPanel'
import AccessDenied from './AccessDenied'
export const RootPathContext = createContext('')
export const Main = memo(() => (
<RootPathContext.Provider value={''}>
<Switch>

View File

@ -9,6 +9,7 @@ import {
DeleteOutlined
} from '@ant-design/icons'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { hasPermission } from '@utils/permissions'
@ -16,7 +17,6 @@ import { formatDate } from '@utils'
import { MeasureService } from '@api'
import { View } from './View'
import { IdWellContext } from '@pages/Well'
import '@styles/index.css'
import '@styles/measure.css'

View File

@ -2,16 +2,16 @@ import { Button } from 'antd'
import { useState, useEffect, memo, useContext } from 'react'
import { TableOutlined } from '@ant-design/icons'
import { MeasureService } from '@api'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { MeasureService } from '@api'
import { MeasureTable } from './MeasureTable'
import { InclinometryTable } from './InclinometryTable'
import { columnsNnb, nnbDefaultData } from './nnbData'
import { columnsMudDiagram, mudDiagramDefaultData } from './mudDiagramData'
import { columnsDrillingFluid, drillingFluidDefaultData } from './drillingFluidData'
import { IdWellContext } from '@pages/Well'
const defaultData = [
{

View File

@ -2,12 +2,12 @@ import { Button, Tooltip } from 'antd'
import { useState, useEffect, memo, useContext } from 'react'
import { FilePdfOutlined, FileTextOutlined } from '@ant-design/icons'
import { ReportService } from '@api'
import { formatDate, periodToString } from '@utils'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { Table, makeDateSorter, makeNumericSorter } from '@components/Table'
import { invokeWebApiWrapperAsync, downloadFile } from '@components/factory'
import { IdWellContext } from '@pages/Well'
import { formatDate, periodToString } from '@utils'
import { ReportService } from '@api'
const imgPaths = {
'.pdf': <FilePdfOutlined/>,

View File

@ -1,6 +1,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useState, useEffect, memo, useCallback, useContext } from 'react'
import { IdWellContext } from '@asb/context'
import { Flex } from '@components/Grid'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
@ -8,7 +9,6 @@ import { DatePickerWrapper, makeDateSorter } from '@components/Table'
import { PeriodPicker, defaultPeriod } from '@components/selectors/PeriodPicker'
import { TelemetryDataSaubService } from '@api'
import { IdWellContext } from '@pages/Well'
import { normalizeData } from '../TelemetryView'
import { ArchiveDisplay, cutData } from './ArchiveDisplay'

View File

@ -3,6 +3,7 @@ import { useHistory, useParams } from 'react-router-dom'
import { CloseOutlined } from '@ant-design/icons'
import { Button, Menu, Popconfirm } from 'antd'
import { IdWellContext, RootPathContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { BaseWidget, WidgetSettingsWindow } from '@components/widgets'
@ -19,8 +20,6 @@ import {
WitsRecord61Service,
} from '@api'
import { IdWellContext } from '@pages/Well'
import { RootPathContext } from '@pages/Main'
import AddGroupWindow from './AddGroupWindow'
import AddWidgetWindow, { makeWidgetFromWits } from './AddWidgetWindow'

View File

@ -0,0 +1,28 @@
import { memo, useContext, useEffect, useState } from 'react'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
export const Operations = memo(() => {
const idWell = useContext(IdWellContext)
const [isLoading, setIsLoading] = useState(false)
useEffect(() => invokeWebApiWrapperAsync(
async () => {
//
},
setIsLoading,
'Не удалось загрузить список определённых операций',
'Получение списка определённых операций',
))
return (
<LoaderPortal show={isLoading}>
</LoaderPortal>
)
})
export default Operations

View File

@ -1,13 +1,13 @@
import { Table } from 'antd'
import { useState, useEffect, useCallback, memo, useContext } from 'react'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { Subscribe } from '@services/signalr'
import { MessageService } from '@api'
import { columns } from '../Messages'
import { IdWellContext } from '@pages/Well'
import '@styles/message.css'

View File

@ -1,14 +1,14 @@
import { memo, useCallback, useContext, useMemo, useState } from 'react'
import { Select, Modal, Input, InputNumber } from 'antd'
import { SetpointsService } from '@api'
import { IdWellContext } from '@asb/context'
import { Grid, GridItem } from '@components/Grid'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { makeNumericRender, EditableTable } from '@components/Table'
import { PeriodPicker, defaultPeriod } from '@components/selectors/PeriodPicker'
import { SetpointsService } from '@api'
import { IdWellContext } from '@pages/Well'
export const SetpointSender = memo(({ onClose, visible, setpointNames }) => {
const [expirePeriod, setExpirePeriod] = useState(defaultPeriod)

View File

@ -1,6 +1,7 @@
import { Button, Modal } from 'antd'
import { useState, useEffect, memo, useCallback, useMemo, useContext } from 'react'
import { IdWellContext } from '@asb/context'
import { Table } from '@components/Table'
import { UserView } from '@components/views'
import LoaderPortal from '@components/LoaderPortal'
@ -10,7 +11,6 @@ import { makeStringCutter } from '@utils/string'
import { formatDate } from '@utils'
import { SetpointsService } from '@api'
import { IdWellContext } from '@pages/Well'
import SetpointSender from './SetpointSender'
import { SetpointViewer, getSetpointStatus } from './SetpointViewer'

View File

@ -1,10 +1,10 @@
import { memo, useCallback, useContext, useEffect, useState } from 'react'
import { TelemetryWirelineRunOutService } from '@api'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { IdWellContext } from '@asb/context'
import { WirelineView } from '@components/views'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { TelemetryWirelineRunOutService } from '@api'
import { IdWellContext } from '@pages/Well'
export const WirelineRunOut = memo(() => {
const [twro, setTwro] = useState({})

View File

@ -8,6 +8,7 @@ import {
TelemetryDataSpinService,
WellService
} from '@api'
import { IdWellContext } from '@asb/context'
import { makeDateSorter } from '@components/Table'
import LoaderPortal from '@components/LoaderPortal'
import { Grid, GridItem, Flex } from '@components/Grid'
@ -23,7 +24,6 @@ import { ModeDisplay } from './ModeDisplay'
import { UserOfWell } from './UserOfWells'
import { Setpoints } from './Setpoints'
import WirelineRunOut from './WirelineRunOut'
import { IdWellContext } from '@pages/Well'
import MomentStabPicEnabled from '@images/DempherOn.png'
import MomentStabPicDisabled from '@images/DempherOff.png'

View File

@ -3,13 +3,13 @@ import { memo, useContext, useMemo } from 'react'
import { Layout } from 'antd'
import { AlertOutlined, FundViewOutlined, DatabaseOutlined } from '@ant-design/icons'
import { RootPathContext } from '@asb/context'
import { PrivateSwitch, PrivateMenu } from '@components/Private'
import Archive from './Archive'
import Messages from './Messages'
import DashboardNNB from './DashboardNNB'
import TelemetryView from './TelemetryView'
import { RootPathContext } from '@pages/Main'
import '@styles/index.css'

View File

@ -1,11 +1,11 @@
import { useState, useEffect, memo, useContext } from 'react'
import { TelemetryAnalyticsService } from '@api'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { ChartTelemetryDepthToDay } from '@components/charts/ChartTelemetryDepthToDay'
import { TelemetryAnalyticsService } from '@api'
import { IdWellContext } from '@pages/Well'
export const TelemetryAnalysisDepthToDay = memo(() => {
const [depthData, setDepthData] = useState([])

View File

@ -1,13 +1,13 @@
import { Select } from 'antd'
import { useState, useEffect, memo, useContext } from 'react'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { ChartTelemetryDepthToInterval } from '@components/charts/ChartTelemetryDepthToInterval'
import { TelemetryAnalyticsService } from '@api'
import { arrayOrDefault } from '@utils'
import { IdWellContext } from '@pages/Well'
const timePeriodCollection = [
{ value: '3600', label: '1 час' },

View File

@ -2,12 +2,12 @@ import moment from 'moment'
import { Form, DatePicker } from 'antd'
import { useState, useEffect, memo, useContext } from 'react'
import { TelemetryAnalyticsService } from '@api'
import { IdWellContext } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { ChartTelemetryOperationsSummary } from '@components/charts/ChartTelemetryOperationsSummary'
import { TelemetryAnalyticsService } from '@api'
import { IdWellContext } from '@pages/Well'
const { RangePicker } = DatePicker

View File

@ -3,13 +3,13 @@ import { memo, useContext, useMemo } from 'react'
import { FolderOutlined } from '@ant-design/icons'
import { Layout } from 'antd'
import { RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import TelemetryAnalysisDepthToDay from './TelemetryAnalysisDepthToDay'
import TelemetryAnalysisDepthToInterval from './TelemetryAnalysisDepthToInterval'
import TelemetryAnalysisOperationsSummary from './TelemetryAnalysisOperationsSummary'
import TelemetryAnalysisOperationsToInterval from './TelemetryAnalysisOperationsToInterval'
import { RootPathContext } from '@pages/Main'
const { Content } = Layout

View File

@ -1,4 +1,4 @@
import { createContext, memo, useContext, useMemo } from 'react'
import { memo, useContext, useMemo } from 'react'
import {
FolderOutlined,
FundViewOutlined,
@ -9,6 +9,7 @@ import {
import { Layout } from 'antd'
import { useParams } from 'react-router-dom'
import { IdWellContext, RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import Report from './Report'
@ -19,14 +20,11 @@ import Telemetry from './Telemetry'
import WellOperations from './WellOperations'
import DrillingProgram from './DrillingProgram'
import TelemetryAnalysis from './TelemetryAnalysis'
import { RootPathContext } from './Main'
import '@styles/index.css'
const { Content } = Layout
export const IdWellContext = createContext(null)
export const Well = memo(() => {
const { idWell, tab } = useParams()
const root = useContext(RootPathContext)

View File

@ -9,6 +9,7 @@ import {
TableOutlined,
} from '@ant-design/icons'
import { IdWellContext, RootPathContext } from '@asb/context'
import { PrivateMenu, PrivateSwitch } from '@components/Private'
import { Tvd } from './Tvd'
@ -19,8 +20,6 @@ import { WellSectionsStat } from './WellSectionsStat'
import { WellOperationsEditor } from './WellOperationsEditor'
import { Flex } from '@components/Grid'
import { RootPathContext } from '@pages/Main'
import { IdWellContext } from '@pages/Well'
const { Content } = Layout