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