Название вкладок исправлено

Кол-во записей на странице уменьшено
Сортировка по координатам и округление вырезаны
Столбец "тип скважины" добавлен
This commit is contained in:
goodmice 2021-12-06 14:10:42 +05:00
parent 5a6931cb43
commit 7b8e5dcf9a
7 changed files with 64 additions and 142 deletions

View File

@ -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 })
}}
/>
</LoaderPortal>
)

View File

@ -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,29 +10,20 @@ 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)
@ -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 })
}}
/>
</LoaderPortal>
)

View File

@ -1,41 +1,30 @@
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)
@ -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 })
}}
/>
</LoaderPortal>
)

View File

@ -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 })
}}
/>
</LoaderPortal>
)

View File

@ -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: <div /> })
]
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 })
}}
/>
</LoaderPortal>
)

View File

@ -19,38 +19,38 @@ export const AdminPanel = () => {
selectedKeys={[tab]}
>
<PrivateMenuItem roles={['deposit_admin']} key={'deposit'}>
<Link to={`${rootPath}/deposit`}>Управление месторождениями</Link>
<Link to={`${rootPath}/deposit`}>Месторождения</Link>
</PrivateMenuItem>
<PrivateMenuItem roles={['cluster_admin']} key={'cluster'}>
<Link to={`${rootPath}/cluster`}>Управление кустами</Link>
<Link to={`${rootPath}/cluster`}>Кусты</Link>
</PrivateMenuItem>
<PrivateMenuItem roles={['well_admin']} key={'well'}>
<Link to={`${rootPath}/well`}>Управление скважинами</Link>
<Link to={`${rootPath}/well`}>Скважины</Link>
</PrivateMenuItem>
<PrivateMenuItem roles={['user_admin']} key={'user'}>
<Link to={`${rootPath}/user`}>Управление пользователями</Link>
<Link to={`${rootPath}/user`}>Пользователи</Link>
</PrivateMenuItem>
<PrivateMenuItem roles={['company_admin']} key={'company'}>
<Link to={`${rootPath}/company`}>Управление компаниями</Link>
<Link to={`${rootPath}/company`}>Компании</Link>
</PrivateMenuItem>
</Menu>
<Layout>
<Layout.Content className={'site-layout-background'}>
<Switch>
<PrivateRoute roles={['deposit_admin']} path={`${rootPath}/deposit/:page?`}>
<PrivateRoute roles={['deposit_admin']} path={`${rootPath}/deposit`}>
<DepositController />
</PrivateRoute>
<PrivateRoute roles={['cluster_admin']} path={`${rootPath}/cluster/:page?`}>
<PrivateRoute roles={['cluster_admin']} path={`${rootPath}/cluster`}>
<ClusterController />
</PrivateRoute>
<PrivateRoute roles={['well_admin']} path={`${rootPath}/well/:page?`}>
<PrivateRoute roles={['well_admin']} path={`${rootPath}/well`}>
<WellController />
</PrivateRoute>
<PrivateRoute roles={['user_admin']} path={`${rootPath}/user/:page?`}>
<PrivateRoute roles={['user_admin']} path={`${rootPath}/user`}>
<UserController />
</PrivateRoute>
<PrivateRoute roles={['company_admin']} path={`${rootPath}/company/:page?`}>
<PrivateRoute roles={['company_admin']} path={`${rootPath}/company`}>
<CompanyController />
</PrivateRoute>
<Route path={'/'}>

View File

@ -367,6 +367,13 @@ export default function TelemetryView({ idWell }) {
)
}
const columnAdditionalLabels = {
1: rop && [
`ROP сред: ${rop.ropAverage.toFixed(2)} м/ч`,
`ROP макс: ${rop.ropMax.toFixed(2)} м/ч`
]
}
return (
<LoaderPortal show={showLoader}>
<Grid style={{ gridTemplateColumns: 'auto repeat(6, 1fr)' }}>
@ -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]}
/>
</GridItem>
)}