diff --git a/src/pages/AdminPanel/ClusterController.jsx b/src/pages/AdminPanel/ClusterController.jsx index d271b40..a6227ed 100644 --- a/src/pages/AdminPanel/ClusterController.jsx +++ b/src/pages/AdminPanel/ClusterController.jsx @@ -1,37 +1,27 @@ import { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router' import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' -import { EditableTable, makeColumn, makeNumericColumn, makeSelectColumn } from '../../components/Table' -import { AdminClusterService, DepositService } from '../../services/api' +import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table' +import { AdminClusterService, AdminDepositService } from '../../services/api' export const ClusterController = () => { - const { page } = useParams() - const history = useHistory() - const [deposits, setDeposits] = useState([]) const [clusters, setClusters] = useState([]) - const [pagination, setPagination] = useState({ current: page ?? 1, pageSize: 20 }) - const [pagintaionTotal, setPagintaionTotal] = useState(0) const [showLoader, setShowLoader] = useState(false) const clusterColumns = [ makeSelectColumn('Месторождение', 'idDeposit', deposits, '--', { width: 200, editable: true }), makeColumn('Название', 'caption', { width: 200, editable: true }), - makeColumn('Описание', 'description', { width: 500, editable: true }), - makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), - makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true }) + makeColumn('Широта', 'latitude', { width: 150, editable: true }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true }) ] const updateTable = () => invokeWebApiWrapperAsync( async () => { - history.push(`/admin/cluster/${pagination.current}`) - const skip = ((pagination.current - 1) * pagination.pageSize) || 0 - const clusters = await AdminClusterService.getPage(skip, pagination.pageSize) - if (!clusters?.items) + const clusters = await AdminClusterService.getAll() + if (!clusters) throw Error(`Не удалось загрузить список кустов`) - setClusters(clusters.items) - setPagintaionTotal(clusters.count ?? clusters.items.length ?? 0) + setClusters(clusters) }, setShowLoader, `Не удалось загрузить список кустов` @@ -39,7 +29,7 @@ export const ClusterController = () => { useEffect(() => invokeWebApiWrapperAsync( async () => { - let deposits = await DepositService.getDeposits() + let deposits = await AdminDepositService.getAll() deposits = deposits?.map((deposit) => ({ value: deposit.id, label: deposit.caption })) setDeposits(deposits ?? []) }, @@ -47,7 +37,7 @@ export const ClusterController = () => { `Не удалось загрузить список месторождений` ), []) - useEffect(updateTable, [pagination, history]) + useEffect(updateTable, []) const onAdd = async (cluster) => { await AdminClusterService.insert(cluster) @@ -76,13 +66,6 @@ export const ClusterController = () => { onRowAdd={onAdd} onRowEdit={onEdit} onRowDelete={onDelete} - pagination={{ - current: pagination.current, - pageSize: pagination.pageSize, - total: pagintaionTotal, - showSizeChanger: false, - onChange: (current, pageSize) => setPagination({ current, pageSize }) - }} /> ) diff --git a/src/pages/AdminPanel/CompanyController.jsx b/src/pages/AdminPanel/CompanyController.jsx index b4eafb1..0412c5a 100644 --- a/src/pages/AdminPanel/CompanyController.jsx +++ b/src/pages/AdminPanel/CompanyController.jsx @@ -1,5 +1,4 @@ import { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router' import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' import { EditableTable, makeColumn } from '../../components/Table' @@ -11,42 +10,33 @@ const companyColumns = [ ] export const CompanyController = () => { - const { page } = useParams() - const history = useHistory() - const [companies, setCompanies] = useState([]) - const [pagination, setPagination] = useState({current: page ?? 1, pageSize: 20}) - const [pagintaionTotal, setPagintaionTotal] = useState(0) const [showLoader, setShowLoader] = useState(false) const updateTable = () => invokeWebApiWrapperAsync( async() => { - history.push(`/admin/company/${pagination.current}`) - const skip = ((pagination.current - 1) * pagination.pageSize) || 0 - const companies = await AdminCompanyService.getPage(skip, pagination.pageSize) - if (!companies?.items) - throw Error(`Не удалось загрузить список кустов`) - setCompanies(companies.items) - setPagintaionTotal(companies.count ?? companies.items.length ?? 0) + const companies = await AdminCompanyService.getAll() + if (!companies) throw Error(`Не удалось загрузить список кустов`) + setCompanies(companies) }, setShowLoader, `Не удалось загрузить список кустов` ) - useEffect(updateTable, [pagination, history]) + useEffect(updateTable, []) const onAdd = async (company) => { await AdminCompanyService.insert(company) updateTable() } - const onEdit= async (company) => { + const onEdit = async (company) => { if(!company.id) return await AdminCompanyService.put(company.id, company) updateTable() } - const onDelete= async (company) => { + const onDelete = async (company) => { if(!company.id) return await AdminCompanyService.delete(company.id) updateTable() @@ -62,13 +52,6 @@ export const CompanyController = () => { onRowAdd={onAdd} onRowEdit={onEdit} onRowDelete={onDelete} - pagination={{ - current: pagination.current, - pageSize: pagination.pageSize, - total: pagintaionTotal, - showSizeChanger: false, - onChange: (current, pageSize) => setPagination({ current, pageSize }) - }} /> ) diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 67a7bcc..a4687bf 100644 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -1,54 +1,43 @@ import { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router' import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' -import { EditableTable, makeColumn, makeNumericColumn } from '../../components/Table' +import { EditableTable, makeColumn } from '../../components/Table' import { AdminDepositService } from '../../services/api' const depositColumns = [ makeColumn('Название', 'caption', { width: 200, editable: true }), - makeColumn('Описание', 'description', { width: 500, editable: true }), - makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), - makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true }) + makeColumn('Широта', 'latitude', { width: 150, editable: true }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true }) ] export const DepositController = () => { - const { page } = useParams() - const history = useHistory() - const [deposits, setDeposits] = useState([]) - const [pagination, setPagination] = useState({current: page ?? 1, pageSize: 20}) - const [pagintaionTotal, setPagintaionTotal] = useState(0) const [showLoader, setShowLoader] = useState(false) const updateTable = () => invokeWebApiWrapperAsync( async() => { - history.push(`/admin/deposit/${pagination.current}`) - const skip = ((pagination.current - 1) * pagination.pageSize) || 0 - const deposits = await AdminDepositService.getPage(skip, pagination.pageSize) - if (!deposits?.items) - throw Error(`Не удалось загрузить список месторождении`) - setDeposits(deposits.items) - setPagintaionTotal(deposits.count ?? deposits.items.length ?? 0) + const deposits = await AdminDepositService.getAll() + if (!deposits) throw Error(`Не удалось загрузить список месторождении`) + setDeposits(deposits) }, setShowLoader, `Не удалось загрузить список месторождении` ) - useEffect(updateTable, [pagination, history]) + useEffect(updateTable, []) const onAdd = async (deposit) => { await AdminDepositService.insert(deposit) updateTable() } - const onEdit= async (deposit) => { + const onEdit = async (deposit) => { if(!deposit.id) return await AdminDepositService.put(deposit.id, deposit) updateTable() } - const onDelete= async (deposit) => { + const onDelete = async (deposit) => { if(!deposit.id) return await AdminDepositService.delete(deposit.id) updateTable() @@ -64,13 +53,6 @@ export const DepositController = () => { onRowAdd={onAdd} onRowEdit={onEdit} onRowDelete={onDelete} - pagination={{ - current: pagination.current, - pageSize: pagination.pageSize, - total: pagintaionTotal, - showSizeChanger: false, - onChange: (current, pageSize) => setPagination({ current, pageSize }) - }} /> ) diff --git a/src/pages/AdminPanel/UserController.jsx b/src/pages/AdminPanel/UserController.jsx index 7d211e6..52ce350 100644 --- a/src/pages/AdminPanel/UserController.jsx +++ b/src/pages/AdminPanel/UserController.jsx @@ -1,21 +1,13 @@ import { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router' import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table' import { AdminCompanyService, AdminUserService } from '../../services/api' import { loginRules, nameRules, phoneRules, emailRules } from '../../utils/validationRules' -const maxCompaniesCount = 1500 - export const UserController = () => { - const { page } = useParams() - const history = useHistory() - const [companies, setCompanies] = useState([]) const [users, setUsers] = useState([]) - const [pagination, setPagination] = useState({current: page ?? 1, pageSize: 20}) - const [pagintaionTotal, setPagintaionTotal] = useState(0) const [showLoader, setShowLoader] = useState(false) const userColumns = [ @@ -40,13 +32,9 @@ export const UserController = () => { const updateTable = () => invokeWebApiWrapperAsync( async() => { - history.push(`/admin/user/${pagination.current}`) - const skip = ((pagination.current - 1) * pagination.pageSize) || 0 - const users = await AdminUserService.getPage(skip, pagination.pageSize) - if (!users?.items) - throw Error(`Не удалось загрузить список пользователей`) - setUsers(users.items) - setPagintaionTotal(users.count ?? users.items.length ?? 0) + const users = await AdminUserService.getAll() + if (!users) throw Error(`Не удалось загрузить список пользователей`) + setUsers(users) }, setShowLoader, `Не удалось загрузить список пользователей` @@ -54,15 +42,15 @@ export const UserController = () => { useEffect(() => invokeWebApiWrapperAsync( async () => { - let companies = await AdminCompanyService.getPage(0, maxCompaniesCount) + let companies = await AdminCompanyService.getAll() companies = companies?.map((company) => ({ value: company.id, label: company.caption })) - setCompanies(companies?.items ?? []) + setCompanies(companies ?? []) }, setShowLoader, `Не удалось загрузить список компаний` ), []) - useEffect(updateTable, [pagination, history]) + useEffect(updateTable, []) const onAdd = async (user) => { await AdminUserService.insert(user) @@ -91,13 +79,6 @@ export const UserController = () => { onRowAdd={onAdd} onRowEdit={onEdit} onRowDelete={onDelete} - pagination={{ - current: pagination.current, - pageSize: pagination.pageSize, - total: pagintaionTotal, - showSizeChanger: false, - onChange: (current, pageSize) => setPagination({ current, pageSize }) - }} /> ) diff --git a/src/pages/AdminPanel/WellController.jsx b/src/pages/AdminPanel/WellController.jsx index 586d3aa..1157325 100644 --- a/src/pages/AdminPanel/WellController.jsx +++ b/src/pages/AdminPanel/WellController.jsx @@ -1,37 +1,33 @@ import { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router' import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' -import { EditableTable, makeColumn, makeNumericColumn, makeSelectColumn } from '../../components/Table' -import { AdminWellService, ClusterService } from '../../services/api' +import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table' +import { AdminClusterService, AdminWellService } from '../../services/api' + +const wellTypes = [ + { value: 1, label: 'Наклонно-направленная' }, + { value: 2, label: 'Горизонтальная' } +] export const WellController = () => { - const { page } = useParams() - const history = useHistory() - const [clusters, setClusters] = useState([]) const [wells, setWells] = useState([]) - const [pagination, setPagination] = useState({ current: page ?? 1, pageSize: 20 }) - const [pagintaionTotal, setPagintaionTotal] = useState(0) const [showLoader, setShowLoader] = useState(false) const wellColumns = [ makeSelectColumn('Куст', 'idCluster', clusters, '--', { width: 200 , editable: true }), makeColumn('Название', 'caption', { width: 200, editable: true }), - makeColumn('Описание', 'description', { width: 500, editable: true }), - makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), - makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true }) + makeSelectColumn('Тип', 'idWellType', wellTypes, '--', { width: 150, editable: true }), + makeColumn('Широта', 'latitude', { width: 150, editable: true }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true }), + makeColumn('Телеметрия', 'telemetry', { width: 150, editable: true, render: (t) => t?.id, input:
}) ] const updateTable = () => invokeWebApiWrapperAsync( async () => { - history.push(`/admin/well/${pagination.current}`) - const skip = ((pagination.current - 1) * pagination.pageSize) || 0 - const wells = await AdminWellService.getPage(skip, pagination.pageSize) - if (!wells?.items) - throw Error(`Не удалось загрузить список скважин`) - setWells(wells.items) - setPagintaionTotal(wells.count ?? wells.items.length ?? 0) + const wells = await AdminWellService.getAll() + if (!wells) throw Error(`Не удалось загрузить список скважин`) + setWells(wells) }, setShowLoader, `Не удалось загрузить список скважин` @@ -39,7 +35,7 @@ export const WellController = () => { useEffect(() => invokeWebApiWrapperAsync( async () => { - let clusters = await ClusterService.getClusters() + let clusters = await AdminClusterService.getAll() clusters = clusters?.map((cluster) => ({ value: cluster.id, label: cluster.caption })) setClusters(clusters ?? []) }, @@ -47,7 +43,7 @@ export const WellController = () => { `Не удалось загрузить список кустов` ), []) - useEffect(updateTable, [pagination, history]) + useEffect(updateTable, []) const onAdd = async (well) => { await AdminWellService.insert(well) @@ -76,13 +72,6 @@ export const WellController = () => { onRowAdd={onAdd} onRowEdit={onEdit} onRowDelete={onDelete} - pagination={{ - current: pagination.current, - pageSize: pagination.pageSize, - total: pagintaionTotal, - showSizeChanger: false, - onChange: (current, pageSize) => setPagination({ current, pageSize }) - }} /> ) diff --git a/src/pages/AdminPanel/index.jsx b/src/pages/AdminPanel/index.jsx index b850a3a..580ab93 100644 --- a/src/pages/AdminPanel/index.jsx +++ b/src/pages/AdminPanel/index.jsx @@ -19,38 +19,38 @@ export const AdminPanel = () => { selectedKeys={[tab]} > - Управление месторождениями + Месторождения - Управление кустами + Кусты - Управление скважинами + Скважины - Управление пользователями + Пользователи - Управление компаниями + Компании - + - + - + - + - + diff --git a/src/pages/TelemetryView/index.jsx b/src/pages/TelemetryView/index.jsx index 0be2bcf..159d671 100644 --- a/src/pages/TelemetryView/index.jsx +++ b/src/pages/TelemetryView/index.jsx @@ -367,6 +367,13 @@ export default function TelemetryView({ idWell }) { ) } + const columnAdditionalLabels = { + 1: rop && [ + `ROP сред: ${rop.ropAverage.toFixed(2)} м/ч`, + `ROP макс: ${rop.ropMax.toFixed(2)} м/ч` + ] + } + return ( @@ -407,10 +414,7 @@ export default function TelemetryView({ idWell }) { interval={chartInterval * 1000} headerHeight={'50px'} showBorder={getIndexOfDrillingBy(dataSaub) === index} - additionalLabels={rop && (index === 1) ? [ - `ROP сред: ${rop.ropAverage.toFixed(2)} м/ч`, - `ROP макс: ${rop.ropMax.toFixed(2)} м/ч` - ] : null} + additionalLabels={columnAdditionalLabels[index]} /> )}