diff --git a/src/pages/AdminPanel/TelemetryController.jsx b/src/pages/AdminPanel/TelemetryController.jsx new file mode 100644 index 0000000..2389ffc --- /dev/null +++ b/src/pages/AdminPanel/TelemetryController.jsx @@ -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 ( + + + + ) +} + +export default TelemetryController diff --git a/src/pages/AdminPanel/index.jsx b/src/pages/AdminPanel/index.jsx index c699e3c..6b05d8e 100644 --- a/src/pages/AdminPanel/index.jsx +++ b/src/pages/AdminPanel/index.jsx @@ -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 = () => { Разрешения + + Телеметрия + Журнал посещений @@ -62,6 +66,7 @@ export const AdminPanel = () => { +