forked from ddrilling/asb_cloud_front
Добавлена страница со списком телеметрий
This commit is contained in:
parent
83d40e5396
commit
60480881d6
63
src/pages/AdminPanel/TelemetryController.jsx
Normal file
63
src/pages/AdminPanel/TelemetryController.jsx
Normal 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
|
@ -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`}/>
|
||||
|
Loading…
Reference in New Issue
Block a user