From a149aaffe30a2d37408758a4e749f2587a140d40 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Tue, 21 Dec 2021 10:04:01 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=81=D1=82=D0=BE=D0=BB=D0=B1=D0=B5=D1=86=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BC=D0=B5=D1=82=D1=80=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Views/TelemetryView.tsx | 34 +++++++++++++++++++++ src/components/Views/index.ts | 2 ++ src/pages/AdminPanel/VisitLog.jsx | 2 -- src/pages/AdminPanel/WellController.jsx | 40 +++++++++++++++++++++---- src/pages/AdminPanel/index.jsx | 16 +++++----- 5 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 src/components/Views/TelemetryView.tsx diff --git a/src/components/Views/TelemetryView.tsx b/src/components/Views/TelemetryView.tsx new file mode 100644 index 0000000..bc0c229 --- /dev/null +++ b/src/components/Views/TelemetryView.tsx @@ -0,0 +1,34 @@ +import { memo } from 'react' +import { Tooltip } from 'antd' +import { TelemetryInfoDto } from '../../services/api' +import { Grid, GridItem } from '../Grid' + +const lables: { [labelKey: string]: string } = { + timeZoneOffsetTotalHours: 'Сдвиг временной зоны', + drillingStartDate: 'Начало бурения', + deposit: 'Месторождение', + cluster: 'Куст', + well: 'Скважина', + customer: 'Заказчик', +} + +export type TelemetryViewProps = { + info?: TelemetryInfoDto +} + +export const TelemetryView = memo(({ info }) => info ? ( + + {(Object.keys(info) as Array).map((key, i) => ( + <> + {lables[key] ?? key}: + {info[key]} + + ))} + + }> + {info.deposit}/{info.cluster}/{info.well} + +) : ( + - +)) diff --git a/src/components/Views/index.ts b/src/components/Views/index.ts index c74969e..9d815c1 100644 --- a/src/components/Views/index.ts +++ b/src/components/Views/index.ts @@ -1,7 +1,9 @@ export type { CompanyViewProps } from './CompanyView' export type { MarkViewProps } from './MarkView' +export type { TelemetryViewProps } from './TelemetryView' export type { UserViewProps } from './UserView' export { CompanyView } from './CompanyView' export { MarkView } from './MarkView' +export { TelemetryView } from './TelemetryView' export { UserView } from './UserView' diff --git a/src/pages/AdminPanel/VisitLog.jsx b/src/pages/AdminPanel/VisitLog.jsx index f858534..40b6512 100644 --- a/src/pages/AdminPanel/VisitLog.jsx +++ b/src/pages/AdminPanel/VisitLog.jsx @@ -21,9 +21,7 @@ export const VisitLog = () => { useEffect(() => invokeWebApiWrapperAsync( async () => { const logData = await RequerstTrackerService.getUsersStat(1000) - logData.forEach((log) => log.key = `${log.login}${log.ip}`) - setLogData(logData) }, setIsLoading, diff --git a/src/pages/AdminPanel/WellController.jsx b/src/pages/AdminPanel/WellController.jsx index f788331..da3cc56 100644 --- a/src/pages/AdminPanel/WellController.jsx +++ b/src/pages/AdminPanel/WellController.jsx @@ -1,18 +1,40 @@ -import { useEffect, useState } from 'react' -import { invokeWebApiWrapperAsync } from '../../components/factory' +import { Select } from 'antd' +import { memo, useEffect, useState } from 'react' +import { TelemetryView } from '../../components/Views' import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '../../components/factory' import { EditableTable, makeColumn, makeSelectColumn, makeActionHandler } from '../../components/Table' -import { AdminClusterService, AdminWellService } from '../../services/api' +import { AdminClusterService, AdminTelemetryService, AdminWellService } from '../../services/api' const wellTypes = [ { value: 1, label: 'Наклонно-направленная' }, - { value: 2, label: 'Горизонтальная' } + { value: 2, label: 'Горизонтальная' }, ] +const TelemetrySelect = memo(({ telemetry, value, onChange }) => { + const [options, setOptions] = useState([]) + + useEffect(() => { + const options = telemetry.map((row) => ({ + value: row.id, + label: `${row.info.deposit}/${row.info.cluster}/${row.info.well}` + })) + setOptions(options) + }, [telemetry]) + + const onSelectChange = (id) => { + const value = telemetry.find((row) => row.id === id) + onChange?.(value) + } + + return