From 8043c5c5e21f8e175010b7dcef74e73875fbbb93 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 24 Jan 2022 17:32:45 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D0=BD=D0=BE=D1=81=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=83=D1=82=D0=B8?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B0=D0=BB=D0=B8=D0=B0=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- craco.config.js | 14 ++- package-lock.json | 14 +++ package.json | 6 +- src/components/PageHeader.tsx | 18 ++-- src/components/WellTreeSelector.tsx | 10 +- src/components/factory.ts | 9 +- src/components/views/CompanyView.tsx | 4 +- src/components/views/MarkView.tsx | 2 +- src/components/views/PermissionView.tsx | 4 +- src/components/views/RoleView.tsx | 4 +- src/components/views/TelemetryView.tsx | 4 +- src/components/views/UserView.tsx | 4 +- src/pages/AdminPanel/TelemetryController.jsx | 10 +- src/pages/AdminPanel/VisitLog.jsx | 10 +- .../WellController/TelemetrySelect.jsx | 2 +- src/pages/Archive/ArchiveColumn.jsx | 7 +- src/pages/Archive/ArchiveDisplay.jsx | 8 +- src/pages/Cluster/ClusterWells.jsx | 26 ++--- src/pages/Cluster/WellOperationsTable.jsx | 48 +++++----- src/pages/Cluster/functions.jsx | 2 +- src/pages/Cluster/index.jsx | 22 +++-- src/pages/Deposit.jsx | 8 +- src/pages/Documents/DocumentsTemplate.jsx | 17 ++-- src/pages/Login.jsx | 22 +++-- src/pages/Measure/InclinometryTable.jsx | 6 +- src/pages/Measure/View.jsx | 6 +- src/pages/Measure/columnsCommon.js | 4 +- src/pages/Measure/drillingFluidData.js | 2 +- src/pages/Measure/index.jsx | 6 +- src/pages/Measure/mudDiagramData.js | 3 +- src/pages/Measure/nnbData.js | 2 +- src/pages/Messages.jsx | 94 ++++++++----------- src/pages/Register.jsx | 22 ++--- src/pages/Report/ReportCreationNotify.jsx | 3 +- src/pages/Report/Reports.jsx | 12 ++- .../TelemetryAnalysisDepthToDay.jsx | 19 ++-- .../TelemetryAnalysisDepthToInterval.jsx | 52 +++++----- .../TelemetryAnalysisOperationsSummary.jsx | 82 ++++++++-------- .../TelemetryView/ActiveMessagesOnline.jsx | 52 +++++----- .../TelemetryView/ChartTimeOnlineFooter.jsx | 9 +- src/pages/TelemetryView/CustomColumn.jsx | 64 +++++++------ src/pages/TelemetryView/ModeDisplay.jsx | 36 +++---- src/pages/TelemetryView/MonitoringColumn.jsx | 12 ++- src/pages/TelemetryView/SetpointSender.jsx | 13 +-- src/pages/TelemetryView/SetpointViewer.jsx | 8 +- src/pages/TelemetryView/UserOfWells.jsx | 16 ++-- src/pages/WellOperations/Tvd.jsx | 6 +- src/utils/storage.ts | 2 +- tsconfig.json | 8 +- tsconfig.paths.json | 19 ++++ 50 files changed, 445 insertions(+), 388 deletions(-) create mode 100644 tsconfig.paths.json diff --git a/craco.config.js b/craco.config.js index b9e1617..3df790e 100644 --- a/craco.config.js +++ b/craco.config.js @@ -1,4 +1,5 @@ -const CracoLessPlugin = require('craco-less'); +const CracoLessPlugin = require('craco-less') +const CracoAlias = require('craco-alias') module.exports = { plugins: [ @@ -12,6 +13,13 @@ module.exports = { }, }, }, - }, + }, { + plugin: CracoAlias, + options: { + source: 'tsconfig', + baseUrl: './src', + tsConfigPath: './tsconfig.paths.json' + } + } ], -}; \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 6160423..bd71549 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "devDependencies": { "@types/react": "^17.0.3", "@types/react-router-dom": "^5.3.2", + "craco-alias": "^3.0.1", "openapi-typescript": "^3.4.1", "openapi-typescript-codegen": "^0.9.3" } @@ -6035,6 +6036,12 @@ "node": ">=10" } }, + "node_modules/craco-alias": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/craco-alias/-/craco-alias-3.0.1.tgz", + "integrity": "sha512-N+Qaf/Gr/f3o5ZH2TQjMu5NhR9PnT1ZYsfejpNvZPpB0ujdrhsSr4Ct6GVjnV5ostCVquhTKJpIVBKyL9qDQYA==", + "dev": true + }, "node_modules/craco-less": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/craco-less/-/craco-less-1.17.1.tgz", @@ -27532,6 +27539,12 @@ "yaml": "^1.10.0" } }, + "craco-alias": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/craco-alias/-/craco-alias-3.0.1.tgz", + "integrity": "sha512-N+Qaf/Gr/f3o5ZH2TQjMu5NhR9PnT1ZYsfejpNvZPpB0ujdrhsSr4Ct6GVjnV5ostCVquhTKJpIVBKyL9qDQYA==", + "dev": true + }, "craco-less": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/craco-less/-/craco-less-1.17.1.tgz", @@ -39581,6 +39594,7 @@ }, "ssri": { "version": "6.0.1", + "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", "requires": { "figgy-pudding": "^3.5.1" } diff --git a/package.json b/package.json index d5c02e8..0424c65 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "start": "craco start", "build": "craco build", "test": "craco test", - "update_openapi":"npx openapi -i http://127.0.0.1:5000/swagger/v1/swagger.json -o src/services/api", - "update_openapi_server":"npx openapi -i http://192.168.1.70:5000/swagger/v1/swagger.json -o src/services/api", + "update_openapi": "npx openapi -i http://127.0.0.1:5000/swagger/v1/swagger.json -o src/services/api", + "update_openapi_server": "npx openapi -i http://192.168.1.70:5000/swagger/v1/swagger.json -o src/services/api", "react_start": "react-scripts start", "react_build": "react-scripts build", "react_test": "react-scripts test", @@ -55,6 +55,8 @@ }, "devDependencies": { "@types/react": "^17.0.3", + "@types/react-router-dom": "^5.3.2", + "craco-alias": "^3.0.1", "openapi-typescript": "^3.4.1", "openapi-typescript-codegen": "^0.9.3" } diff --git a/src/components/PageHeader.tsx b/src/components/PageHeader.tsx index 02dece4..6af290c 100644 --- a/src/components/PageHeader.tsx +++ b/src/components/PageHeader.tsx @@ -1,17 +1,19 @@ -import { Link } from 'react-router-dom' +import { memo } from 'react' import { Layout } from 'antd' -import { headerHeight } from '../utils' -import { UserMenu } from './UserMenu' -import logo from '../images/logo_32.png' +import { Link } from 'react-router-dom' -type PageHeaderProps = { +import logo from '@images/logo_32.png' +import { headerHeight } from '@utils' +import { UserMenu } from './UserMenu' +import { BasicProps } from 'antd/lib/layout/layout' + +export type PageHeaderProps = BasicProps & { title?: string isAdmin?: boolean children?: React.ReactNode - [other: string]: any } -export const PageHeader: React.FC = ({ title = 'Мониторинг', isAdmin, children, ...other }) => ( +export const PageHeader: React.FC = memo(({ title = 'Мониторинг', isAdmin, children, ...other }) => ( @@ -22,6 +24,6 @@ export const PageHeader: React.FC = ({ title = 'Монитор -) +)) export default PageHeader diff --git a/src/components/WellTreeSelector.tsx b/src/components/WellTreeSelector.tsx index dc2a4af..43a9ae6 100644 --- a/src/components/WellTreeSelector.tsx +++ b/src/components/WellTreeSelector.tsx @@ -3,16 +3,16 @@ import { DefaultValueType } from 'rc-tree-select/lib/interface' import { useState, useEffect, ReactNode } from 'react' import { useHistory, useRouteMatch } from 'react-router-dom' -import { isRawDate } from '../utils' +import { isRawDate } from '@utils' import LoaderPortal from './LoaderPortal' import { WellIcon, WellIconState } from './icons' import { invokeWebApiWrapperAsync } from './factory' -import { DepositService, DepositDto } from '../services/api' +import { DepositService, DepositDto } from '@api' -import { ReactComponent as DepositIcon } from '../images/DepositIcon.svg' -import { ReactComponent as ClusterIcon } from '../images/ClusterIcon.svg' +import { ReactComponent as DepositIcon } from '@images/DepositIcon.svg' +import { ReactComponent as ClusterIcon } from '@images/ClusterIcon.svg' -import '../styles/wellTreeSelect.css' +import '@styles/wellTreeSelect.css' export const getWellState = (idState?: number): WellIconState => idState === 1 ? 'active' : 'unknown' export const checkIsWellOnline = (lastTelemetryDate: unknown): boolean => diff --git a/src/components/factory.ts b/src/components/factory.ts index 5381f7c..282966b 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -1,7 +1,8 @@ import { notification } from 'antd' -import { Dispatch, SetStateAction } from 'react' -import { FileInfoDto } from '../services/api' -import { getUserToken } from '../utils/storage' +import { Dispatch, ReactNode, SetStateAction } from 'react' + +import { FileInfoDto } from '@api' +import { getUserToken } from '@utils/storage' const notificationTypeDictionary = new Map([ ['error' , { notifyInstance: notification.error , caption: 'Ошибка' }], @@ -15,7 +16,7 @@ const notificationTypeDictionary = new Map([ * @param body string или ReactNode * @param notifyType для параметра типа. Допустимые значение 'error', 'warning', 'info' */ -export const notify = (body: string | any, notifyType: string = 'info', other?: any) => { +export const notify = (body: ReactNode, notifyType: string = 'info', other?: any) => { if (!body) return const instance = notificationTypeDictionary.get(notifyType) ?? diff --git a/src/components/views/CompanyView.tsx b/src/components/views/CompanyView.tsx index e279e6e..db012a5 100644 --- a/src/components/views/CompanyView.tsx +++ b/src/components/views/CompanyView.tsx @@ -2,8 +2,8 @@ import { memo } from 'react' import { Tooltip } from 'antd' import { BankOutlined } from '@ant-design/icons' -import { CompanyDto } from '../../services/api' -import { Grid, GridItem } from '../Grid' +import { CompanyDto } from '@api' +import { Grid, GridItem } from '@components/Grid' export type CompanyViewProps = { company?: CompanyDto diff --git a/src/components/views/MarkView.tsx b/src/components/views/MarkView.tsx index ee0c7d1..f7eb4fa 100644 --- a/src/components/views/MarkView.tsx +++ b/src/components/views/MarkView.tsx @@ -1,7 +1,7 @@ import { Tooltip, Tag, Typography, Popconfirm, Button } from 'antd' import { memo } from 'react' -import { FileMarkDto } from '../../services/api' +import { FileMarkDto } from '@api' import { UserView } from './UserView' const markTypes: { [id: number]: {color: string, text: string} } = { diff --git a/src/components/views/PermissionView.tsx b/src/components/views/PermissionView.tsx index 3f2f5b9..7708be5 100644 --- a/src/components/views/PermissionView.tsx +++ b/src/components/views/PermissionView.tsx @@ -1,8 +1,8 @@ import { Tooltip } from 'antd' import { memo } from 'react' -import { PermissionDto } from '../../services/api' -import { Grid, GridItem } from '../Grid' +import { PermissionDto } from '@api' +import { Grid, GridItem } from '@components/Grid' export type PermissionViewProps = { info?: PermissionDto diff --git a/src/components/views/RoleView.tsx b/src/components/views/RoleView.tsx index 3011446..60e5452 100644 --- a/src/components/views/RoleView.tsx +++ b/src/components/views/RoleView.tsx @@ -1,8 +1,8 @@ import { memo } from 'react' import { Tag, Tooltip } from 'antd' -import { UserRoleDto } from '../../services/api' -import { Grid, GridItem } from '../Grid' +import { UserRoleDto } from '@api' +import { Grid, GridItem } from '@components/Grid' import PermissionView from './PermissionView' export type RoleViewProps = { diff --git a/src/components/views/TelemetryView.tsx b/src/components/views/TelemetryView.tsx index 99f991d..30401ff 100644 --- a/src/components/views/TelemetryView.tsx +++ b/src/components/views/TelemetryView.tsx @@ -1,8 +1,8 @@ import { Fragment, memo } from 'react' import { Tooltip } from 'antd' -import { TelemetryDto, TelemetryInfoDto } from '../../services/api' -import { Grid, GridItem } from '../Grid' +import { TelemetryDto, TelemetryInfoDto } from '@api' +import { Grid, GridItem } from '@components/Grid' const lables: Record = { timeZoneId: 'Временная зона', diff --git a/src/components/views/UserView.tsx b/src/components/views/UserView.tsx index d16ed06..51156f4 100644 --- a/src/components/views/UserView.tsx +++ b/src/components/views/UserView.tsx @@ -2,8 +2,8 @@ import { memo } from 'react' import { Tooltip } from 'antd' import { UserOutlined } from '@ant-design/icons' -import { UserDto } from '../../services/api' -import { Grid, GridItem } from '../Grid' +import { UserDto } from '@api' +import { Grid, GridItem } from '@components/Grid' import { CompanyView } from './CompanyView' export type UserViewProps = { diff --git a/src/pages/AdminPanel/TelemetryController.jsx b/src/pages/AdminPanel/TelemetryController.jsx index 2389ffc..3c726d6 100644 --- a/src/pages/AdminPanel/TelemetryController.jsx +++ b/src/pages/AdminPanel/TelemetryController.jsx @@ -1,7 +1,5 @@ import { useEffect, useState } from 'react' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' import { defaultPagination, makeDateSorter, @@ -9,9 +7,11 @@ import { makeNumericRender, makeTextColumn, Table -} from '../../components/Table' -import { AdminTelemetryService } from '../../services/api' -import { arrayOrDefault } from '../../utils' +} from '@components/Table' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { AdminTelemetryService } from '@api' +import { arrayOrDefault } from '@utils' const columns = [ makeNumericColumn('ID', 'id', null, null, makeNumericRender(0)), diff --git a/src/pages/AdminPanel/VisitLog.jsx b/src/pages/AdminPanel/VisitLog.jsx index 89b6f21..6b785a1 100644 --- a/src/pages/AdminPanel/VisitLog.jsx +++ b/src/pages/AdminPanel/VisitLog.jsx @@ -1,10 +1,10 @@ import { memo, useEffect, useState } from 'react' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import LoaderPortal from '../../components/LoaderPortal' -import { defaultPagination, makeColumn, makeDateSorter, makeStringSorter, Table } from '../../components/Table' -import { RequerstTrackerService } from '../../services/api' -import { arrayOrDefault, formatDate } from '../../utils' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { defaultPagination, makeColumn, makeDateSorter, makeStringSorter, Table } from '@components/Table' +import { RequerstTrackerService } from '@api' +import { arrayOrDefault, formatDate } from '@utils' const logRecordCount = 1000 diff --git a/src/pages/AdminPanel/WellController/TelemetrySelect.jsx b/src/pages/AdminPanel/WellController/TelemetrySelect.jsx index 9c2ba63..10d58ac 100644 --- a/src/pages/AdminPanel/WellController/TelemetrySelect.jsx +++ b/src/pages/AdminPanel/WellController/TelemetrySelect.jsx @@ -1,7 +1,7 @@ import { memo } from 'react' import { Select } from 'antd' -import { getTelemetryLabel } from '../../../components/views' +import { getTelemetryLabel } from '@components/views' export const TelemetrySelect = memo(({ telemetry, value, onChange }) => { const onSelectChange = (id) => { diff --git a/src/pages/Archive/ArchiveColumn.jsx b/src/pages/Archive/ArchiveColumn.jsx index 0118086..5e211e1 100644 --- a/src/pages/Archive/ArchiveColumn.jsx +++ b/src/pages/Archive/ArchiveColumn.jsx @@ -1,6 +1,7 @@ import { useEffect, useState } from 'react' -import { Grid, GridItem } from '../../components/Grid' -import { Column } from '../../components/charts/Column' + +import { Grid, GridItem } from '@components/Grid' +import { Column } from '@components/charts/Column' export const ArchiveColumn = ({ lineGroup, data, interval, style, headerHeight, yStart }) => { const [lineGroupWithoutShapes, setLineGroupWithoutShapes] = useState([]) @@ -33,3 +34,5 @@ export const ArchiveColumn = ({ lineGroup, data, interval, style, headerHeight, ) } + +export default ArchiveColumn diff --git a/src/pages/Archive/ArchiveDisplay.jsx b/src/pages/Archive/ArchiveDisplay.jsx index bcb6020..3b9cef3 100644 --- a/src/pages/Archive/ArchiveDisplay.jsx +++ b/src/pages/Archive/ArchiveDisplay.jsx @@ -1,7 +1,9 @@ import { useEffect, useState } from 'react' -import { Grid, GridItem } from '../../components/Grid' + +import { Grid, GridItem } from '@components/Grid' + +import { paramsGroups } from '@pages/TelemetryView' import { ArchiveColumn } from './ArchiveColumn' -import { paramsGroups } from '../TelemetryView' const interpolationSearch = (data, begin, end, accessor) => { const fy = (i) => new Date(data[i]?.[accessor] ?? 0) @@ -64,3 +66,5 @@ export const ArchiveDisplay = ({data, startDate, interval, onWheel}) => { ) } + +export default ArchiveDisplay diff --git a/src/pages/Cluster/ClusterWells.jsx b/src/pages/Cluster/ClusterWells.jsx index e3ba3d2..477c06b 100644 --- a/src/pages/Cluster/ClusterWells.jsx +++ b/src/pages/Cluster/ClusterWells.jsx @@ -10,13 +10,14 @@ import { makeDateSorter, makeNumericColumnPlanFact, Table, -} from '../../components/Table' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import LoaderPortal from '../../components/LoaderPortal' -import PointerIcon from '../../components/icons/PointerIcon' -import { CompanyView } from '../../components/views' + makeNumericRender, +} from '@components/Table' +import { CompanyView } from '@components/views' +import LoaderPortal from '@components/LoaderPortal' +import PointerIcon from '@components/icons/PointerIcon' +import { invokeWebApiWrapperAsync } from '@components/factory' -import { Tvd } from '../WellOperations/Tvd' +import { Tvd } from '@pages/WellOperations/Tvd' import { getOperations, calcAndUpdateStatsBySections, @@ -33,8 +34,7 @@ const filtersWellsType = [] const DAY_IN_MS = 86_400_000 const ONLINE_DEADTIME = 600_000 -export default function ClusterWells({statsWells}) { - +export const ClusterWells = ({ statsWells }) => { const [selectedWellId, setSelectedWellId] = useState(0) const [isTVDModalVisible, setIsTVDModalVisible] = useState(false) const [isOpsModalVisible, setIsOpsModalVisible] = useState(false) @@ -128,10 +128,10 @@ export default function ClusterWells({statsWells}) { makeColumn('начало', 'factStart', { sorter: makeDateSorter('factStart'), render: getDate }), makeColumn('окончание', 'factEnd', { sorter: makeDateSorter('factEnd'), render: getDate }), ]), - makeNumericColumnPlanFact('Продолжительность, сут', 'period', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('МСП, м/ч', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction), - makeNumericColumnPlanFact('НПВ, сут', 'notProductiveTime', filtersMinMax, makeFilterMinMaxFunction), + makeNumericColumnPlanFact('Продолжительность, сут', 'period', filtersMinMax, makeFilterMinMaxFunction, makeNumericRender(1)), + makeNumericColumnPlanFact('МСП, м/ч', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction, makeNumericRender(1)), + makeNumericColumnPlanFact('Рейсовая скорость, м/ч', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction, makeNumericRender(1)), + makeNumericColumnPlanFact('НПВ, сут', 'notProductiveTime', filtersMinMax, makeFilterMinMaxFunction, makeNumericRender(1)), { title: 'TVD', key: 'tvd', @@ -199,3 +199,5 @@ export default function ClusterWells({statsWells}) { ) } + +export default ClusterWells diff --git a/src/pages/Cluster/WellOperationsTable.jsx b/src/pages/Cluster/WellOperationsTable.jsx index daf4391..85f24a8 100644 --- a/src/pages/Cluster/WellOperationsTable.jsx +++ b/src/pages/Cluster/WellOperationsTable.jsx @@ -1,44 +1,42 @@ -import { Table } from 'antd'; -import { - makeTextColumn, - makeNumericColumnPlanFact - } from '../../components/Table' +import { Table } from 'antd' + +import { makeTextColumn, makeNumericColumnPlanFact } from '@components/Table' + import { getPrecision } from './functions' -export default function WellOperationsTable({wellOperations}) { - +export const WellOperationsTable = ({ wellOperations }) => { const columns = [ makeTextColumn('Конструкция секции','sectionType'), makeTextColumn('Операция','operationName'), makeNumericColumnPlanFact('Глубина забоя', 'depth', null, null, getPrecision), makeNumericColumnPlanFact('Часы', 'durationHours', null, null, getPrecision), makeNumericColumnPlanFact('Комментарий', 'comment', null, null, (text) => text ?? '-') - ]; + ] - const operations = wellOperations?.map(el => { - return { - key: el.plan?.id ?? el.fact.id, - sectionType: el.plan?.wellSectionTypeName ?? el.fact?.wellSectionTypeName, - operationName: `${el.plan?.categoryName ?? el.fact?.categoryName ?? ''} ${' '} - ${el.plan?.categoryInfo ?? el.fact?.categoryInfo ?? ''}`, - depthPlan: el.plan?.wellDepth, - depthFact: el.fact?.wellDepth, - durationHoursPlan: el.plan?.durationHours, - durationHoursFact: el.fact?.durationHours, - commentPlan: el.plan?.comment ?? '-', - commentFact: el.fact?.comment ?? '-' - } - }) + const operations = wellOperations?.map(el => ({ + key: el.plan?.id ?? el.fact.id, + sectionType: el.plan?.wellSectionTypeName ?? el.fact?.wellSectionTypeName, + operationName: `${el.plan?.categoryName ?? el.fact?.categoryName ?? ''} ${' '} + ${el.plan?.categoryInfo ?? el.fact?.categoryInfo ?? ''}`, + depthPlan: el.plan?.wellDepth, + depthFact: el.fact?.wellDepth, + durationHoursPlan: el.plan?.durationHours, + durationHoursFact: el.fact?.durationHours, + commentPlan: el.plan?.comment ?? '-', + commentFact: el.fact?.comment ?? '-' + })) return( record.key} + pagination={{ defaultPageSize: 10 }} /> ) } + +export default WellOperationsTable diff --git a/src/pages/Cluster/functions.jsx b/src/pages/Cluster/functions.jsx index 6b40102..e92d316 100644 --- a/src/pages/Cluster/functions.jsx +++ b/src/pages/Cluster/functions.jsx @@ -1,4 +1,4 @@ -import { OperationStatService } from '../../services/api' +import { OperationStatService } from '@api' const maxPrefix = 'isMax' const minPrefix = 'isMin' diff --git a/src/pages/Cluster/index.jsx b/src/pages/Cluster/index.jsx index e3f04b9..69f8d9c 100644 --- a/src/pages/Cluster/index.jsx +++ b/src/pages/Cluster/index.jsx @@ -1,24 +1,26 @@ -import { useParams } from 'react-router-dom' import { useState, useEffect } from 'react' -import ClusterWells from './ClusterWells' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { OperationStatService } from '../../services/api' +import { useParams } from 'react-router-dom' +import { arrayOrDefault } from '@utils' +import { OperationStatService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' + +import ClusterWells from './ClusterWells' export const Cluster = () => { - const { idClaster } = useParams() + const { idCluster } = useParams() const [data, setData] = useState([]) const [showLoader, setShowLoader] = useState(false) useEffect(() => invokeWebApiWrapperAsync( async () => { - const clusterData = await OperationStatService.getStatCluster(idClaster) - setData(clusterData?.statsWells ?? []) + const clusterData = await OperationStatService.getStatCluster(idCluster) + setData(arrayOrDefault(clusterData?.statsWells)) }, setShowLoader, - `Не удалось загрузить данные по кусту "${idClaster}"` - ), [idClaster]) + `Не удалось загрузить данные по кусту "${idCluster}"` + ), [idCluster]) return ( diff --git a/src/pages/Deposit.jsx b/src/pages/Deposit.jsx index e0f4ac6..463438c 100644 --- a/src/pages/Deposit.jsx +++ b/src/pages/Deposit.jsx @@ -2,10 +2,10 @@ import { Map, Overlay } from 'pigeon-maps' import { Link } from 'react-router-dom' import { useState, useEffect, memo } from 'react' -import { PointerIcon } from '../components/icons' -import LoaderPortal from '../components/LoaderPortal' -import { ClusterService } from '../services/api' -import { invokeWebApiWrapperAsync } from '../components/factory' +import { ClusterService } from '@api' +import { PointerIcon } from '@components/icons' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' const defaultViewParams = { center: [60.81226, 70.0562], zoom: 5 } diff --git a/src/pages/Documents/DocumentsTemplate.jsx b/src/pages/Documents/DocumentsTemplate.jsx index 182a5cc..d6d8d65 100644 --- a/src/pages/Documents/DocumentsTemplate.jsx +++ b/src/pages/Documents/DocumentsTemplate.jsx @@ -1,12 +1,13 @@ import moment from 'moment' import { useState, useEffect } from 'react' import { DatePicker, Button, Input } from 'antd' -import { FileService } from '../../services/api' -import { invokeWebApiWrapperAsync, downloadFile, formatBytes } from '../../components/factory' -import { EditableTable, makePaginationObject } from '../../components/Table' -import { UploadForm } from '../../components/UploadForm' -import LoaderPortal from '../../components/LoaderPortal' -import { CompanyView, UserView } from '../../components/views' + +import { FileService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { UploadForm } from '@components/UploadForm' +import { CompanyView, UserView } from '@components/views' +import { EditableTable, makePaginationObject } from '@components/Table' +import { invokeWebApiWrapperAsync, downloadFile, formatBytes } from '@components/factory' const pageSize = 12 const { RangePicker } = DatePicker @@ -44,7 +45,7 @@ const columns = [ } ] -export default function DocumentsTemplate({ idCategory, idWell, accept, headerChild, customColumns, beforeTable, onChange}) { +export const DocumentsTemplate = ({ idCategory, idWell, accept, headerChild, customColumns, beforeTable, onChange}) => { const [page, setPage] = useState(1) const [filterDataRange, setFilterDataRange] = useState([]) const [filterCompanyName, setFilterCompanyName] = useState([]) @@ -172,3 +173,5 @@ export default function DocumentsTemplate({ idCategory, idWell, accept, headerCh ) } + +export default DocumentsTemplate diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index ad72bea..09432fe 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -3,18 +3,18 @@ import { UserOutlined, LockOutlined } from '@ant-design/icons' import { useState } from 'react' import { Link, useHistory } from 'react-router-dom' -import { AuthService } from '../services/api/' -import LoaderPortal from '../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../components/factory' -import { loginRules, passwordRules } from '../utils/validationRules' -import { setUser } from '../utils/storage' +import { AuthService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { loginRules, passwordRules } from '@utils/validationRules' +import { setUser } from '@utils/storage' -import '../styles/index.css' -import logo from '../images/logo_32.png' +import '@styles/index.css' +import logo from '@images/logo_32.png' -const logoIcon = {'АСБ'} +const logoIcon = {'АСБ'} -export default function Login() { +export const Login = () => { const history = useHistory() const [showLoader, setShowLoader] = useState(false) @@ -51,4 +51,6 @@ export default function Login() { ) -} \ No newline at end of file +} + +export default Login diff --git a/src/pages/Measure/InclinometryTable.jsx b/src/pages/Measure/InclinometryTable.jsx index 5a692fb..5fc0837 100644 --- a/src/pages/Measure/InclinometryTable.jsx +++ b/src/pages/Measure/InclinometryTable.jsx @@ -1,8 +1,8 @@ import { Modal } from 'antd' import { memo, useEffect, useState } from 'react' -import { Table } from '../../components/Table' -import { formatDate } from '../../utils' +import { Table } from '@components/Table' +import { formatDate } from '@utils' import { v } from './columnsCommon' @@ -52,3 +52,5 @@ export const InclinometryTable = memo(({ group, visible, onClose }) => { ) }) + +export default InclinometryTable diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 1b68b57..f7213e8 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -1,10 +1,10 @@ import { memo, Fragment } from 'react' import { Empty, Form } from 'antd' -import { Grid, GridItem } from '../../components/Grid' +import { Grid, GridItem } from '@components/Grid' -import '../../styles/index.css' -import '../../styles/measure.css' +import '@styles/index.css' +import '@styles/measure.css' const colsCount = 3 diff --git a/src/pages/Measure/columnsCommon.js b/src/pages/Measure/columnsCommon.js index 8db90bd..8b512bd 100644 --- a/src/pages/Measure/columnsCommon.js +++ b/src/pages/Measure/columnsCommon.js @@ -1,8 +1,8 @@ import { Input } from 'antd' -import { RegExpIsFloat } from '../../components/Table' +import { RegExpIsFloat } from '@components/Table' -import '../../styles/measure.css' +import '@styles/measure.css' export const v = (text) => (
diff --git a/src/pages/Measure/drillingFluidData.js b/src/pages/Measure/drillingFluidData.js index f68b009..938ec99 100644 --- a/src/pages/Measure/drillingFluidData.js +++ b/src/pages/Measure/drillingFluidData.js @@ -1,4 +1,4 @@ -import { makeColumn } from '../../components/Table' +import { makeColumn } from '@components/Table' import { numericColumnOptions, textColumnOptions } from './columnsCommon' diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index a816065..06beb48 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -2,9 +2,9 @@ import { Button } from 'antd' import { useState, useEffect } from 'react' import { TableOutlined } from '@ant-design/icons' -import { MeasureService } from '../../services/api' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' +import { MeasureService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' import { MeasureTable } from './MeasureTable' import { InclinometryTable } from './InclinometryTable' diff --git a/src/pages/Measure/mudDiagramData.js b/src/pages/Measure/mudDiagramData.js index c3fa93d..ad65e72 100644 --- a/src/pages/Measure/mudDiagramData.js +++ b/src/pages/Measure/mudDiagramData.js @@ -1,4 +1,5 @@ -import { makeColumn } from '../../components/Table' +import { makeColumn } from '@components/Table' + import { numericColumnOptions, textColumnOptions } from './columnsCommon' export const columnsMudDiagram = [ diff --git a/src/pages/Measure/nnbData.js b/src/pages/Measure/nnbData.js index 69ff79b..34eb655 100644 --- a/src/pages/Measure/nnbData.js +++ b/src/pages/Measure/nnbData.js @@ -1,4 +1,4 @@ -import { makeColumn } from '../../components/Table' +import { makeColumn } from '@components/Table' import { numericColumnOptions, textColumnOptions } from './columnsCommon' export const columnsNnb = [ diff --git a/src/pages/Messages.jsx b/src/pages/Messages.jsx index 366206b..a3664c5 100644 --- a/src/pages/Messages.jsx +++ b/src/pages/Messages.jsx @@ -1,11 +1,12 @@ -import { Table, Select, DatePicker, Input } from 'antd' -import { useState, useEffect } from 'react' import moment from 'moment' +import { useState, useEffect, memo } from 'react' +import { Table, Select, DatePicker, Input } from 'antd' -import { MessageService } from '../services/api' -import LoaderPortal from '../components/LoaderPortal' -import { notify } from '../components/factory' -import '../styles/message.css' +import { MessageService } from '@api' +import { invokeWebApiWrapperAsync } from '@components/factory' +import LoaderPortal from '@components/LoaderPortal' + +import '@styles/message.css' const { Option } = Select const pageSize = 26 @@ -14,9 +15,9 @@ const { Search } = Input // Словарь категорий для строк таблицы const categoryDictionary = { - 1: {title: 'Важное'}, - 2: {title: 'Предупреждение'}, - 3: {title: 'Информация'}, + 1: { title: 'Важное' }, + 2: { title: 'Предупреждение' }, + 3: { title: 'Информация' }, } // Конфигурация таблицы @@ -59,13 +60,13 @@ export const columns = [ ] const filterOptions = [ - {label: 'Важное', value: 1}, - {label: 'Предупреждение', value: 2}, - {label: 'Информация', value: 3}, + { value: 1, label: 'Важное' }, + { value: 2, label: 'Предупреждение' }, + { value: 3, label: 'Информация' }, ] // Данные для таблицы -export default function Messages({idWell}) { +export const Messages = memo(({ idWell }) => { const [messages, setMessages] = useState([]) const [pagination, setPagination] = useState(null) const [page, setPage] = useState(1) @@ -76,47 +77,29 @@ export default function Messages({idWell}) { const children = filterOptions.map((line) => ) - const onChangeRange = (range) => setRange(range) const onChangeSearchString = (message) => setSearchString(message.length > 2 ? message : '') - useEffect(() => { - const GetMessages = async () => { - setShowLoader(true) + useEffect(() => invokeWebApiWrapperAsync( + async () => { + const [begin, end] = range?.length > 1 ? [range[0].toISOString(), range[1].toISOString()] : [null, null] + const skip = (page - 1) * pageSize + const paginatedMessages = await MessageService.getMessages(idWell, skip, pageSize, categories, begin, end, searchString) + if (!paginatedMessages) return - try { - const [begin, end] = range?.length > 1 ? [range[0].toISOString(), range[1].toISOString()] : [null, null] - let paginatedMessages = await MessageService.getMessages(idWell, - (page - 1) * pageSize, - pageSize, - categories, - begin, - end, - searchString) - if (paginatedMessages === null){ - notify(`Данных по скважине "${idWell}" нет`, 'warning') - setShowLoader(false) - return - } - - setMessages(paginatedMessages.items.map(m => ({ - key: m.id, - categoryids: categoryDictionary[m.categoryId], - begin: m.date, - ...m - }))) - setPagination({ - total: paginatedMessages.count, - current: Math.floor(paginatedMessages.skip / pageSize), - }) - - } catch (ex) { - console.log(ex) - notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') - } - setShowLoader(false) - } - GetMessages() - }, [idWell, page, categories, range, searchString]) + setMessages(paginatedMessages.items.map(m => ({ + key: m.id, + categoryids: categoryDictionary[m.categoryId], + begin: m.date, + ...m + }))) + setPagination({ + total: paginatedMessages.count, + current: Math.floor(paginatedMessages.skip / pageSize), + }) + }, + setShowLoader, + `Не удалось загрузить сообщения по скважине "${idWell}"` + ), [idWell, page, categories, range, searchString]) return ( <> @@ -131,10 +114,7 @@ export default function Messages({idWell}) { onChange={setCategories}> {children} - + setRange(range)} /> ) -} \ No newline at end of file +}) + +export default Messages diff --git a/src/pages/Register.jsx b/src/pages/Register.jsx index 25d4f23..6bf10f9 100644 --- a/src/pages/Register.jsx +++ b/src/pages/Register.jsx @@ -1,15 +1,16 @@ import { memo, useState } from 'react' import { Link, useHistory } from 'react-router-dom' -import { Card, Form, Input, Select, Button } from 'antd' +import { Card, Form, Input, Button } from 'antd' import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons' -import { AuthService } from '../services/api/' -import LoaderPortal from '../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../components/factory' + +import { AuthService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' import { createLoginRules, createPasswordRules, @@ -18,15 +19,9 @@ import { nameRules, passwordRules, phoneRules -} from '../utils/validationRules' -import logo from '../images/logo_32.png' +} from '@utils/validationRules' -const companies = [ - { label: 'ООО «Газпромнефть-Хантос» ', value: 1 }, - { label: 'АО «НафтаГаз»', value: 2 }, - { label: 'ООО «Нафтагаз Бурение»', value: 3 }, - { label: 'ООО «Газпромнефть-ННГ»', value: 4 } -] +import logo from '@images/logo_32.png' const surnameRules = [...nameRules, { required: true, message: 'Пожалуйста, введите фамилию!' }] const regEmailRules = [{ required: true, message: 'Пожалуйста, введите email!' }, ...emailRules] @@ -80,9 +75,6 @@ export const Register = memo(() => { {createInput('patronymic', 'Отчество', nameRules)} {createInput('email', 'Email', regEmailRules)} {createInput('phone', 'Номер телефона', phoneRules)} - - + + defaultValue={'86400'} + className={'ml-30px'} + />
) -} \ No newline at end of file +}) + +export default TelemetryAnalysisDepthToInterval diff --git a/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx index 64c4863..e8bff1c 100644 --- a/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx +++ b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx @@ -1,70 +1,66 @@ -import { ChartTelemetryOperationsSummary } from '../../components/charts/ChartTelemetryOperationsSummary' -import { useState, useEffect } from 'react' -import moment from "moment" -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { TelemetryAnalyticsService } from '../../services/api' -import { Form, DatePicker } from "antd" -import LoaderPortal from '../../components/LoaderPortal' +import moment from 'moment' +import { Form, DatePicker } from 'antd' +import { useState, useEffect, memo } from 'react' + +import { TelemetryAnalyticsService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { ChartTelemetryOperationsSummary } from '@components/charts/ChartTelemetryOperationsSummary' const { RangePicker } = DatePicker -export default function TelemetryAnalysisOperationsSummary({idWell}){ +export const TelemetryAnalysisOperationsSummary = memo(({ idWell }) => { const [avilableDatesRange, setAviableDatesRange] = useState([moment(),moment()]) - const [filterDateRange, setFilterDateRange] = useState([moment().subtract(1, "days"),moment()]) + const [filterDateRange, setFilterDateRange] = useState([moment().subtract(1, 'days'),moment()]) const [operationsData, setOperationsData] = useState([]) const [loader, setLoader] = useState(false) - const disabledDate = (current) => - current < avilableDatesRange[0] || current > avilableDatesRange[1] - - useEffect(() => invokeWebApiWrapperAsync(async() => { - const datesRange = await TelemetryAnalyticsService.getOperationsDateRange(idWell) - setAviableDatesRange(datesRange) - }), [idWell]) + const disabledDate = (current) => current < avilableDatesRange[0] || current > avilableDatesRange[1] - useEffect(() => { - setLoader(true) - invokeWebApiWrapperAsync( + useEffect(() => invokeWebApiWrapperAsync( + async() => { + const datesRange = await TelemetryAnalyticsService.getOperationsDateRange(idWell) + setAviableDatesRange(datesRange) + }, + setLoader, + `Не удалось загрузить диапозон дат для скважины "${idWell}"` + ), [idWell]) + + useEffect(() => invokeWebApiWrapperAsync( async () => { const operationsSummaryData = await TelemetryAnalyticsService.getOperationsSummary(idWell, filterDateRange[0].toISOString(), filterDateRange[1].toISOString()) - + setOperationsData(operationsSummaryData) }, - setLoader, - `Не удалось получить данные для анализа операций по скважине "${idWell}"`) - }, [idWell, filterDateRange]) - + setLoader, + `Не удалось получить данные для анализа операций по скважине "${idWell}"` + ), [idWell, filterDateRange]) + return ( -
-
-
+
+ +
{ - setFilterDateRange(dates) - }} showTime + allowClear={false} + disabledDate={disabledDate} + onCalendarChange={(dates) => setFilterDateRange(dates)} />
- + ) -} \ No newline at end of file +}) + +export default TelemetryAnalysisOperationsSummary diff --git a/src/pages/TelemetryView/ActiveMessagesOnline.jsx b/src/pages/TelemetryView/ActiveMessagesOnline.jsx index e112409..e33cefa 100644 --- a/src/pages/TelemetryView/ActiveMessagesOnline.jsx +++ b/src/pages/TelemetryView/ActiveMessagesOnline.jsx @@ -1,22 +1,22 @@ -import {useState, useEffect} from 'react' -import {Table} from 'antd' +import { Table } from 'antd' +import { useState, useEffect } from 'react' -import LoaderPortal from '../../components/LoaderPortal' -import {invokeWebApiWrapperAsync} from '../../components/factory' -import {columns} from '../Messages' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { Subscribe } from '@services/signalr' +import { MessageService } from '@api' -import {Subscribe} from '../../services/signalr' -import {MessageService} from '../../services/api' -import '../../styles/message.css' +import { columns } from '@pages/Messages' -export default function ActiveMessagesOnline({idWell}) { +import '@styles/message.css' + +export const ActiveMessagesOnline = ({ idWell }) => { const [messages, setMessages] = useState([]) const [loader, setLoader] = useState(false) const handleReceiveMessages = (messages) => { - if (messages) { + if (messages) setMessages(messages.items.splice(0, 4)) - } } useEffect(() => { @@ -31,16 +31,20 @@ export default function ActiveMessagesOnline({idWell}) { return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) }, [idWell]) - return ( -
`event_message_${record.categoryId} event_message`} - className={'message_table'} - size={'small'} - pagination={false} - rowKey={(record) => record.id} - /> - ) -} \ No newline at end of file + return ( + +
`event_message_${record.categoryId} event_message`} + className={'message_table'} + size={'small'} + pagination={false} + rowKey={(record) => record.id} + /> + + ) +} + +export default ActiveMessagesOnline diff --git a/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx b/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx index 8413355..253a384 100644 --- a/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx +++ b/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx @@ -1,6 +1,7 @@ -import {ValueDisplay} from '../../components/Display' -import {ControlOutlined} from '@ant-design/icons' -import {Popover} from 'antd' +import { Popover } from 'antd' +import { ControlOutlined } from '@ant-design/icons' + +import { ValueDisplay } from '@components/Display' export const ChartTimeOnlineFooter = ({ data, lineGroup }) => { const getFooterData = (name) => { @@ -8,7 +9,7 @@ export const ChartTimeOnlineFooter = ({ data, lineGroup }) => { return () } - let spValues = getFooterData('SP') + const spValues = getFooterData('SP') const idleValues = getFooterData('IDLE') const popContent = lineGroup?.filter(line => line.footer === true).map(line => ( diff --git a/src/pages/TelemetryView/CustomColumn.jsx b/src/pages/TelemetryView/CustomColumn.jsx index 4c996ca..f3ac368 100644 --- a/src/pages/TelemetryView/CustomColumn.jsx +++ b/src/pages/TelemetryView/CustomColumn.jsx @@ -1,36 +1,42 @@ -import {Display} from '../../components/Display' +import { memo } from 'react' + +import { Display } from '@components/Display' + import RigMnemo from './RigMnemo' const params = [ - {label:'Рот., об/мин', accessorName:'rotorSpeed', isArrowVisible:true}, - {label:'Долото, м', accessorName:'bitDepth', isArrowVisible:true, format:2}, - {label:'Забой, м', accessorName:'wellDepth', isArrowVisible:true, format:2}, - {label:'Расход, м³/ч', accessorName:'flow', isArrowVisible:true}, - {label:'Расход х.х., м³/ч', accessorName:'flowIdle', isArrowVisible:true}, - {label: 'Время', accessorName: 'date', format:'HH:mm:ss'}, + { label: 'Рот., об/мин', accessorName: 'rotorSpeed', isArrowVisible: true }, + { label: 'Долото, м', accessorName: 'bitDepth', isArrowVisible: true, format: 2 }, + { label: 'Забой, м', accessorName: 'wellDepth', isArrowVisible: true, format: 2 }, + { label: 'Расход, м³/ч', accessorName: 'flow', isArrowVisible: true }, + { label: 'Расход х.х., м³/ч', accessorName: 'flowIdle', isArrowVisible: true }, + { label: 'Время', accessorName: 'date', format: 'HH:mm:ss' }, ] -export const CustomColumn = ({data}) => { - const dataLast = data[data.length -1] - - if(dataLast) - params.forEach(param => param.value = dataLast[param.accessorName]) - else - params.forEach(param => param.value = '-' ) +export const CustomColumn = memo(({ data }) => { + const dataLast = data[data.length - 1] + params.forEach(param => param.value = dataLast?.[param.accessorName] ?? '-') - return (<> - {params.map(param => )} - + {params.map(param => ( + - ) -} \ No newline at end of file + ))} + + + ) +}) + +export default CustomColumn diff --git a/src/pages/TelemetryView/ModeDisplay.jsx b/src/pages/TelemetryView/ModeDisplay.jsx index a3e020a..50ee80e 100644 --- a/src/pages/TelemetryView/ModeDisplay.jsx +++ b/src/pages/TelemetryView/ModeDisplay.jsx @@ -1,22 +1,24 @@ -import { Display } from '../../components/Display' +import { memo } from 'react' + +import { Display } from '@components/Display' const modeNames = { - 0: "Ручной", - 1: "Бурение в роторе", - 2: "Проработка", - 3: "Бурение в слайде", - 4: "Спуск СПО", - 5: "Подъем СПО", - 6: "Подъем с проработкой", + 0: 'Ручной', + 1: 'Бурение в роторе', + 2: 'Проработка', + 3: 'Бурение в слайде', + 4: 'Спуск СПО', + 5: 'Подъем СПО', + 6: 'Подъем с проработкой', - 10: "БЛОКИРОВКА", + 10: 'БЛОКИРОВКА', } -export const ModeDisplay = ({data})=>{ - const dataLast = data[data.length - 1] - - return -} \ No newline at end of file +export const ModeDisplay = memo(({ data }) => ( + +)) diff --git a/src/pages/TelemetryView/MonitoringColumn.jsx b/src/pages/TelemetryView/MonitoringColumn.jsx index 4c84805..9698527 100644 --- a/src/pages/TelemetryView/MonitoringColumn.jsx +++ b/src/pages/TelemetryView/MonitoringColumn.jsx @@ -1,8 +1,10 @@ -import { Grid, GridItem } from '../../components/Grid' -import { Column, GetOrCreateDatasetByLineConfig } from '../../components/charts/Column' -import { ChartTimeOnlineFooter } from './ChartTimeOnlineFooter' import { useEffect, useState } from 'react' -import { makeDateSorter } from '../../components/Table' + +import { Grid, GridItem } from '@components/Grid' +import { makeDateSorter } from '@components/Table' +import { Column, GetOrCreateDatasetByLineConfig } from '@components/charts/Column' + +import { ChartTimeOnlineFooter } from './ChartTimeOnlineFooter' const GetLimitShape = (flowChartData, points, accessor) => { const min = [], max = [] @@ -118,3 +120,5 @@ export const MonitoringColumn = ({ lineGroup, data, flowChartData, interval, sho ) } + +export default MonitoringColumn diff --git a/src/pages/TelemetryView/SetpointSender.jsx b/src/pages/TelemetryView/SetpointSender.jsx index a45fc63..0bc26d1 100644 --- a/src/pages/TelemetryView/SetpointSender.jsx +++ b/src/pages/TelemetryView/SetpointSender.jsx @@ -1,11 +1,12 @@ import { useState } from 'react' import { Select, Modal, Input, InputNumber } from 'antd' -import { SetpointsService } from '../../services/api' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { makeNumericRender, EditableTable } from '../../components/Table' -import { PeriodPicker, defaultPeriod } from '../../components/PeriodPicker' -import { Grid, GridItem } from '../../components/Grid' + +import { SetpointsService } from '@api' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { makeNumericRender, EditableTable } from '@components/Table' +import { PeriodPicker, defaultPeriod } from '@components/PeriodPicker' +import { Grid, GridItem } from '@components/Grid' export const SetpointSender = ({ idWell, onClose, visible, setpointNames }) => { const [expirePeriod, setExpirePeriod] = useState(defaultPeriod) diff --git a/src/pages/TelemetryView/SetpointViewer.jsx b/src/pages/TelemetryView/SetpointViewer.jsx index a756ac4..7a0fa75 100644 --- a/src/pages/TelemetryView/SetpointViewer.jsx +++ b/src/pages/TelemetryView/SetpointViewer.jsx @@ -1,10 +1,10 @@ import { memo } from 'react' import { Modal, Input } from 'antd' -import { Table } from '../../components/Table' -import { UserView } from '../../components/views' -import { Grid, GridItem } from '../../components/Grid' -import { formatDate, periodToString } from '../../utils' +import { Table } from '@components/Table' +import { UserView } from '@components/views' +import { Grid, GridItem } from '@components/Grid' +import { formatDate, periodToString } from '@utils' export const setpointStatus = { 0: 'Неизвестно', diff --git a/src/pages/TelemetryView/UserOfWells.jsx b/src/pages/TelemetryView/UserOfWells.jsx index ab002dd..e2f1fcb 100644 --- a/src/pages/TelemetryView/UserOfWells.jsx +++ b/src/pages/TelemetryView/UserOfWells.jsx @@ -1,9 +1,11 @@ -import { Display } from '../../components/Display' +import { Display } from '@components/Display' -export const UserOfWell = ({ data }) => { - const dataLast = data[data.length - 1] +export const UserOfWell = ({ data }) => ( + +) - return -} \ No newline at end of file +export default UserOfWell diff --git a/src/pages/WellOperations/Tvd.jsx b/src/pages/WellOperations/Tvd.jsx index 6f34c34..d02d6e1 100644 --- a/src/pages/WellOperations/Tvd.jsx +++ b/src/pages/WellOperations/Tvd.jsx @@ -13,9 +13,9 @@ import 'chartjs-adapter-moment' import zoomPlugin from 'chartjs-plugin-zoom' import ChartDataLabels from 'chartjs-plugin-datalabels' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { getOperations } from '../Cluster/functions' -import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { getOperations } from '@pages/Cluster/functions' +import LoaderPortal from '@components/LoaderPortal' Chart.register(TimeScale, LinearScale, LineController, LineElement, PointElement, Legend, ChartDataLabels, zoomPlugin) diff --git a/src/utils/storage.ts b/src/utils/storage.ts index aca5a45..6b6cac7 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -1,4 +1,4 @@ -import { OpenAPI, UserTokenDto } from '../services/api' +import { OpenAPI, UserTokenDto } from '@api' import { Role, Permission } from './permissions' export enum StorageNames { diff --git a/tsconfig.json b/tsconfig.json index dec663b..ef7dbee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,11 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", + "baseUrl": "src" }, - "include": ["src"] + "include": [ + "src" + ], + "extends": "./tsconfig.paths.json" } diff --git a/tsconfig.paths.json b/tsconfig.paths.json new file mode 100644 index 0000000..8917952 --- /dev/null +++ b/tsconfig.paths.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "paths": { + "@asb/*": ["./*"], + "@api": ["./services/api"], + "@api/*": ["./services/api/*"], + "@components": ["./components"], + "@components/*": ["./components/*"], + "@services": ["./services"], + "@services/*": ["./services/*"], + "@images/*": ["./images/*"], + "@pages/*": ["./pages/*"], + "@utils": ["./utils"], + "@utils/*": ["./utils/*"], + "@styles/*": ["./styles/*"] + } + } +}