Добавлена страница со списком телеметрий

This commit is contained in:
Александр Сироткин 2022-01-13 20:41:27 +05:00
parent 83d40e5396
commit 60480881d6
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,63 @@
import { useEffect, useState } from 'react'
import LoaderPortal from '../../components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '../../components/factory'
import {
defaultPagination,
makeDateSorter,
makeNumericColumn,
makeNumericRender,
makeTextColumn,
Table
} from '../../components/Table'
import { AdminTelemetryService } from '../../services/api'
import { arrayOrDefault } from '../../utils'
const columns = [
makeNumericColumn('ID', 'id', null, null, makeNumericRender(0)),
makeTextColumn('UID', 'remoteUid'),
makeTextColumn('Назначена на скважину', 'realWell'),
makeTextColumn('Дата начала бурения', 'drillingStartDate', null, makeDateSorter('drillingStartDate')),
makeTextColumn('Часовой пояс', 'timeZoneId'),
makeTextColumn('Скважина', 'well'),
makeTextColumn('Куст', 'cluster'),
makeTextColumn('Месторождение', 'deposit'),
makeTextColumn('Заказчик', 'customer'),
makeTextColumn('Комментарий', 'comment'),
makeTextColumn('Версия HMI', 'hmiVersion'),
makeTextColumn('Версия САУБ', 'saubPlcVersion'),
makeTextColumn('Версия Спин Мастер', 'spinPlcVersion'),
]
export const TelemetryController = () => {
const [telemetryData, setTelemetryData] = useState([])
const [isLoading, setIsLoading] = useState(false)
useEffect(() => invokeWebApiWrapperAsync(
async () => {
const telemetryData = arrayOrDefault(await AdminTelemetryService.getAll())
setTelemetryData(telemetryData.map((telemetry) => ({
...(telemetry?.info ?? []),
id: telemetry?.id,
remoteUid: telemetry?.remoteUid,
realWell: telemetry?.well?.caption,
})))
},
setIsLoading,
`Не удалось загрузить список телеметрии скважин`
), [])
return (
<LoaderPortal show={isLoading}>
<Table
size={'small'}
bordered
columns={columns}
dataSource={telemetryData}
pagination={defaultPagination}
/>
</LoaderPortal>
)
}
export default TelemetryController

View File

@ -12,6 +12,7 @@ const WellController = lazy(() => import('./WellController'))
const RoleController = lazy(() => import('./RoleController'))
const CompanyTypeController = lazy(() => import('./CompanyTypeController'))
const PermissionController = lazy(() => import('./PermissionController'))
const TelemetryController = lazy(() => import('./TelemetryController'))
const VisitLog = lazy(() => import('./VisitLog'))
export const AdminPanel = () => {
@ -45,6 +46,9 @@ export const AdminPanel = () => {
<PrivateMenuItem key={'permission'} permission={'permission_editor'}>
<Link to={`${rootPath}/permission`}>Разрешения</Link>
</PrivateMenuItem>
<PrivateMenuItem key={'telemetry'}>
<Link to={`${rootPath}/telemetry`}>Телеметрия</Link>
</PrivateMenuItem>
<PrivateMenuItem key={'visit_log'}>
<Link to={`${rootPath}/visit_log`}>Журнал посещений</Link>
</PrivateMenuItem>
@ -62,6 +66,7 @@ export const AdminPanel = () => {
<PrivateRoute path={`${rootPath}/company_type`} component={CompanyTypeController} />
<PrivateRoute permission={ 'role_editor'} path={`${rootPath}/role` } component={ RoleController} />
<PrivateRoute permission={'permission_editor'} path={`${rootPath}/permission`} component={PermissionController} />
<PrivateRoute path={`${rootPath}/telemetry`} component={TelemetryController} />
<PrivateRoute path={`${rootPath}/visit_log`} component={VisitLog} />
<Route path={'/'}>
<Redirect to={`${rootPath}/visit_log`}/>