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

Кол-во записей на странице уменьшено
Сортировка по координатам и округление вырезаны
Столбец "тип скважины" добавлен
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 { useEffect, useState } from 'react'
import { useHistory, useParams } from 'react-router'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { EditableTable, makeColumn, makeNumericColumn, makeSelectColumn } from '../../components/Table' import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table'
import { AdminClusterService, DepositService } from '../../services/api' import { AdminClusterService, AdminDepositService } from '../../services/api'
export const ClusterController = () => { export const ClusterController = () => {
const { page } = useParams()
const history = useHistory()
const [deposits, setDeposits] = useState([]) const [deposits, setDeposits] = useState([])
const [clusters, setClusters] = 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 [showLoader, setShowLoader] = useState(false)
const clusterColumns = [ const clusterColumns = [
makeSelectColumn('Месторождение', 'idDeposit', deposits, '--', { width: 200, editable: true }), makeSelectColumn('Месторождение', 'idDeposit', deposits, '--', { width: 200, editable: true }),
makeColumn('Название', 'caption', { width: 200, editable: true }), makeColumn('Название', 'caption', { width: 200, editable: true }),
makeColumn('Описание', 'description', { width: 500, editable: true }), makeColumn('Широта', 'latitude', { width: 150, editable: true }),
makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), makeColumn('Долгота', 'longitude', { width: 150, editable: true })
makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true })
] ]
const updateTable = () => invokeWebApiWrapperAsync( const updateTable = () => invokeWebApiWrapperAsync(
async () => { async () => {
history.push(`/admin/cluster/${pagination.current}`) const clusters = await AdminClusterService.getAll()
const skip = ((pagination.current - 1) * pagination.pageSize) || 0 if (!clusters)
const clusters = await AdminClusterService.getPage(skip, pagination.pageSize)
if (!clusters?.items)
throw Error(`Не удалось загрузить список кустов`) throw Error(`Не удалось загрузить список кустов`)
setClusters(clusters.items) setClusters(clusters)
setPagintaionTotal(clusters.count ?? clusters.items.length ?? 0)
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список кустов` `Не удалось загрузить список кустов`
@ -39,7 +29,7 @@ export const ClusterController = () => {
useEffect(() => invokeWebApiWrapperAsync( useEffect(() => invokeWebApiWrapperAsync(
async () => { async () => {
let deposits = await DepositService.getDeposits() let deposits = await AdminDepositService.getAll()
deposits = deposits?.map((deposit) => ({ value: deposit.id, label: deposit.caption })) deposits = deposits?.map((deposit) => ({ value: deposit.id, label: deposit.caption }))
setDeposits(deposits ?? []) setDeposits(deposits ?? [])
}, },
@ -47,7 +37,7 @@ export const ClusterController = () => {
`Не удалось загрузить список месторождений` `Не удалось загрузить список месторождений`
), []) ), [])
useEffect(updateTable, [pagination, history]) useEffect(updateTable, [])
const onAdd = async (cluster) => { const onAdd = async (cluster) => {
await AdminClusterService.insert(cluster) await AdminClusterService.insert(cluster)
@ -76,13 +66,6 @@ export const ClusterController = () => {
onRowAdd={onAdd} onRowAdd={onAdd}
onRowEdit={onEdit} onRowEdit={onEdit}
onRowDelete={onDelete} onRowDelete={onDelete}
pagination={{
current: pagination.current,
pageSize: pagination.pageSize,
total: pagintaionTotal,
showSizeChanger: false,
onChange: (current, pageSize) => setPagination({ current, pageSize })
}}
/> />
</LoaderPortal> </LoaderPortal>
) )

View File

@ -1,5 +1,4 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useHistory, useParams } from 'react-router'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { EditableTable, makeColumn } from '../../components/Table' import { EditableTable, makeColumn } from '../../components/Table'
@ -11,29 +10,20 @@ const companyColumns = [
] ]
export const CompanyController = () => { export const CompanyController = () => {
const { page } = useParams()
const history = useHistory()
const [companies, setCompanies] = useState([]) const [companies, setCompanies] = useState([])
const [pagination, setPagination] = useState({current: page ?? 1, pageSize: 20})
const [pagintaionTotal, setPagintaionTotal] = useState(0)
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const updateTable = () => invokeWebApiWrapperAsync( const updateTable = () => invokeWebApiWrapperAsync(
async() => { async() => {
history.push(`/admin/company/${pagination.current}`) const companies = await AdminCompanyService.getAll()
const skip = ((pagination.current - 1) * pagination.pageSize) || 0 if (!companies) throw Error(`Не удалось загрузить список кустов`)
const companies = await AdminCompanyService.getPage(skip, pagination.pageSize) setCompanies(companies)
if (!companies?.items)
throw Error(`Не удалось загрузить список кустов`)
setCompanies(companies.items)
setPagintaionTotal(companies.count ?? companies.items.length ?? 0)
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список кустов` `Не удалось загрузить список кустов`
) )
useEffect(updateTable, [pagination, history]) useEffect(updateTable, [])
const onAdd = async (company) => { const onAdd = async (company) => {
await AdminCompanyService.insert(company) await AdminCompanyService.insert(company)
@ -62,13 +52,6 @@ export const CompanyController = () => {
onRowAdd={onAdd} onRowAdd={onAdd}
onRowEdit={onEdit} onRowEdit={onEdit}
onRowDelete={onDelete} onRowDelete={onDelete}
pagination={{
current: pagination.current,
pageSize: pagination.pageSize,
total: pagintaionTotal,
showSizeChanger: false,
onChange: (current, pageSize) => setPagination({ current, pageSize })
}}
/> />
</LoaderPortal> </LoaderPortal>
) )

View File

@ -1,41 +1,30 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useHistory, useParams } from 'react-router'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { EditableTable, makeColumn, makeNumericColumn } from '../../components/Table' import { EditableTable, makeColumn } from '../../components/Table'
import { AdminDepositService } from '../../services/api' import { AdminDepositService } from '../../services/api'
const depositColumns = [ const depositColumns = [
makeColumn('Название', 'caption', { width: 200, editable: true }), makeColumn('Название', 'caption', { width: 200, editable: true }),
makeColumn('Описание', 'description', { width: 500, editable: true }), makeColumn('Широта', 'latitude', { width: 150, editable: true }),
makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), makeColumn('Долгота', 'longitude', { width: 150, editable: true })
makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true })
] ]
export const DepositController = () => { export const DepositController = () => {
const { page } = useParams()
const history = useHistory()
const [deposits, setDeposits] = useState([]) const [deposits, setDeposits] = useState([])
const [pagination, setPagination] = useState({current: page ?? 1, pageSize: 20})
const [pagintaionTotal, setPagintaionTotal] = useState(0)
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const updateTable = () => invokeWebApiWrapperAsync( const updateTable = () => invokeWebApiWrapperAsync(
async() => { async() => {
history.push(`/admin/deposit/${pagination.current}`) const deposits = await AdminDepositService.getAll()
const skip = ((pagination.current - 1) * pagination.pageSize) || 0 if (!deposits) throw Error(`Не удалось загрузить список месторождении`)
const deposits = await AdminDepositService.getPage(skip, pagination.pageSize) setDeposits(deposits)
if (!deposits?.items)
throw Error(`Не удалось загрузить список месторождении`)
setDeposits(deposits.items)
setPagintaionTotal(deposits.count ?? deposits.items.length ?? 0)
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список месторождении` `Не удалось загрузить список месторождении`
) )
useEffect(updateTable, [pagination, history]) useEffect(updateTable, [])
const onAdd = async (deposit) => { const onAdd = async (deposit) => {
await AdminDepositService.insert(deposit) await AdminDepositService.insert(deposit)
@ -64,13 +53,6 @@ export const DepositController = () => {
onRowAdd={onAdd} onRowAdd={onAdd}
onRowEdit={onEdit} onRowEdit={onEdit}
onRowDelete={onDelete} onRowDelete={onDelete}
pagination={{
current: pagination.current,
pageSize: pagination.pageSize,
total: pagintaionTotal,
showSizeChanger: false,
onChange: (current, pageSize) => setPagination({ current, pageSize })
}}
/> />
</LoaderPortal> </LoaderPortal>
) )

View File

@ -1,21 +1,13 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useHistory, useParams } from 'react-router'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table' import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table'
import { AdminCompanyService, AdminUserService } from '../../services/api' import { AdminCompanyService, AdminUserService } from '../../services/api'
import { loginRules, nameRules, phoneRules, emailRules } from '../../utils/validationRules' import { loginRules, nameRules, phoneRules, emailRules } from '../../utils/validationRules'
const maxCompaniesCount = 1500
export const UserController = () => { export const UserController = () => {
const { page } = useParams()
const history = useHistory()
const [companies, setCompanies] = useState([]) const [companies, setCompanies] = useState([])
const [users, setUsers] = 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 [showLoader, setShowLoader] = useState(false)
const userColumns = [ const userColumns = [
@ -40,13 +32,9 @@ export const UserController = () => {
const updateTable = () => invokeWebApiWrapperAsync( const updateTable = () => invokeWebApiWrapperAsync(
async() => { async() => {
history.push(`/admin/user/${pagination.current}`) const users = await AdminUserService.getAll()
const skip = ((pagination.current - 1) * pagination.pageSize) || 0 if (!users) throw Error(`Не удалось загрузить список пользователей`)
const users = await AdminUserService.getPage(skip, pagination.pageSize) setUsers(users)
if (!users?.items)
throw Error(`Не удалось загрузить список пользователей`)
setUsers(users.items)
setPagintaionTotal(users.count ?? users.items.length ?? 0)
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список пользователей` `Не удалось загрузить список пользователей`
@ -54,15 +42,15 @@ export const UserController = () => {
useEffect(() => invokeWebApiWrapperAsync( useEffect(() => invokeWebApiWrapperAsync(
async () => { async () => {
let companies = await AdminCompanyService.getPage(0, maxCompaniesCount) let companies = await AdminCompanyService.getAll()
companies = companies?.map((company) => ({ value: company.id, label: company.caption })) companies = companies?.map((company) => ({ value: company.id, label: company.caption }))
setCompanies(companies?.items ?? []) setCompanies(companies ?? [])
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список компаний` `Не удалось загрузить список компаний`
), []) ), [])
useEffect(updateTable, [pagination, history]) useEffect(updateTable, [])
const onAdd = async (user) => { const onAdd = async (user) => {
await AdminUserService.insert(user) await AdminUserService.insert(user)
@ -91,13 +79,6 @@ export const UserController = () => {
onRowAdd={onAdd} onRowAdd={onAdd}
onRowEdit={onEdit} onRowEdit={onEdit}
onRowDelete={onDelete} onRowDelete={onDelete}
pagination={{
current: pagination.current,
pageSize: pagination.pageSize,
total: pagintaionTotal,
showSizeChanger: false,
onChange: (current, pageSize) => setPagination({ current, pageSize })
}}
/> />
</LoaderPortal> </LoaderPortal>
) )

View File

@ -1,37 +1,33 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useHistory, useParams } from 'react-router'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { EditableTable, makeColumn, makeNumericColumn, makeSelectColumn } from '../../components/Table' import { EditableTable, makeColumn, makeSelectColumn } from '../../components/Table'
import { AdminWellService, ClusterService } from '../../services/api' import { AdminClusterService, AdminWellService } from '../../services/api'
const wellTypes = [
{ value: 1, label: 'Наклонно-направленная' },
{ value: 2, label: 'Горизонтальная' }
]
export const WellController = () => { export const WellController = () => {
const { page } = useParams()
const history = useHistory()
const [clusters, setClusters] = useState([]) const [clusters, setClusters] = useState([])
const [wells, setWells] = 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 [showLoader, setShowLoader] = useState(false)
const wellColumns = [ const wellColumns = [
makeSelectColumn('Куст', 'idCluster', clusters, '--', { width: 200 , editable: true }), makeSelectColumn('Куст', 'idCluster', clusters, '--', { width: 200 , editable: true }),
makeColumn('Название', 'caption', { width: 200, editable: true }), makeColumn('Название', 'caption', { width: 200, editable: true }),
makeColumn('Описание', 'description', { width: 500, editable: true }), makeSelectColumn('Тип', 'idWellType', wellTypes, '--', { width: 150, editable: true }),
makeNumericColumn('Широта', 'latitude', null, null, null, 150, { editable: true }), makeColumn('Широта', 'latitude', { width: 150, editable: true }),
makeNumericColumn('Долгота', 'longitude', null, null, null, 150, { editable: true }) makeColumn('Долгота', 'longitude', { width: 150, editable: true }),
makeColumn('Телеметрия', 'telemetry', { width: 150, editable: true, render: (t) => t?.id, input: <div /> })
] ]
const updateTable = () => invokeWebApiWrapperAsync( const updateTable = () => invokeWebApiWrapperAsync(
async () => { async () => {
history.push(`/admin/well/${pagination.current}`) const wells = await AdminWellService.getAll()
const skip = ((pagination.current - 1) * pagination.pageSize) || 0 if (!wells) throw Error(`Не удалось загрузить список скважин`)
const wells = await AdminWellService.getPage(skip, pagination.pageSize) setWells(wells)
if (!wells?.items)
throw Error(`Не удалось загрузить список скважин`)
setWells(wells.items)
setPagintaionTotal(wells.count ?? wells.items.length ?? 0)
}, },
setShowLoader, setShowLoader,
`Не удалось загрузить список скважин` `Не удалось загрузить список скважин`
@ -39,7 +35,7 @@ export const WellController = () => {
useEffect(() => invokeWebApiWrapperAsync( useEffect(() => invokeWebApiWrapperAsync(
async () => { async () => {
let clusters = await ClusterService.getClusters() let clusters = await AdminClusterService.getAll()
clusters = clusters?.map((cluster) => ({ value: cluster.id, label: cluster.caption })) clusters = clusters?.map((cluster) => ({ value: cluster.id, label: cluster.caption }))
setClusters(clusters ?? []) setClusters(clusters ?? [])
}, },
@ -47,7 +43,7 @@ export const WellController = () => {
`Не удалось загрузить список кустов` `Не удалось загрузить список кустов`
), []) ), [])
useEffect(updateTable, [pagination, history]) useEffect(updateTable, [])
const onAdd = async (well) => { const onAdd = async (well) => {
await AdminWellService.insert(well) await AdminWellService.insert(well)
@ -76,13 +72,6 @@ export const WellController = () => {
onRowAdd={onAdd} onRowAdd={onAdd}
onRowEdit={onEdit} onRowEdit={onEdit}
onRowDelete={onDelete} onRowDelete={onDelete}
pagination={{
current: pagination.current,
pageSize: pagination.pageSize,
total: pagintaionTotal,
showSizeChanger: false,
onChange: (current, pageSize) => setPagination({ current, pageSize })
}}
/> />
</LoaderPortal> </LoaderPortal>
) )

View File

@ -19,38 +19,38 @@ export const AdminPanel = () => {
selectedKeys={[tab]} selectedKeys={[tab]}
> >
<PrivateMenuItem roles={['deposit_admin']} key={'deposit'}> <PrivateMenuItem roles={['deposit_admin']} key={'deposit'}>
<Link to={`${rootPath}/deposit`}>Управление месторождениями</Link> <Link to={`${rootPath}/deposit`}>Месторождения</Link>
</PrivateMenuItem> </PrivateMenuItem>
<PrivateMenuItem roles={['cluster_admin']} key={'cluster'}> <PrivateMenuItem roles={['cluster_admin']} key={'cluster'}>
<Link to={`${rootPath}/cluster`}>Управление кустами</Link> <Link to={`${rootPath}/cluster`}>Кусты</Link>
</PrivateMenuItem> </PrivateMenuItem>
<PrivateMenuItem roles={['well_admin']} key={'well'}> <PrivateMenuItem roles={['well_admin']} key={'well'}>
<Link to={`${rootPath}/well`}>Управление скважинами</Link> <Link to={`${rootPath}/well`}>Скважины</Link>
</PrivateMenuItem> </PrivateMenuItem>
<PrivateMenuItem roles={['user_admin']} key={'user'}> <PrivateMenuItem roles={['user_admin']} key={'user'}>
<Link to={`${rootPath}/user`}>Управление пользователями</Link> <Link to={`${rootPath}/user`}>Пользователи</Link>
</PrivateMenuItem> </PrivateMenuItem>
<PrivateMenuItem roles={['company_admin']} key={'company'}> <PrivateMenuItem roles={['company_admin']} key={'company'}>
<Link to={`${rootPath}/company`}>Управление компаниями</Link> <Link to={`${rootPath}/company`}>Компании</Link>
</PrivateMenuItem> </PrivateMenuItem>
</Menu> </Menu>
<Layout> <Layout>
<Layout.Content className={'site-layout-background'}> <Layout.Content className={'site-layout-background'}>
<Switch> <Switch>
<PrivateRoute roles={['deposit_admin']} path={`${rootPath}/deposit/:page?`}> <PrivateRoute roles={['deposit_admin']} path={`${rootPath}/deposit`}>
<DepositController /> <DepositController />
</PrivateRoute> </PrivateRoute>
<PrivateRoute roles={['cluster_admin']} path={`${rootPath}/cluster/:page?`}> <PrivateRoute roles={['cluster_admin']} path={`${rootPath}/cluster`}>
<ClusterController /> <ClusterController />
</PrivateRoute> </PrivateRoute>
<PrivateRoute roles={['well_admin']} path={`${rootPath}/well/:page?`}> <PrivateRoute roles={['well_admin']} path={`${rootPath}/well`}>
<WellController /> <WellController />
</PrivateRoute> </PrivateRoute>
<PrivateRoute roles={['user_admin']} path={`${rootPath}/user/:page?`}> <PrivateRoute roles={['user_admin']} path={`${rootPath}/user`}>
<UserController /> <UserController />
</PrivateRoute> </PrivateRoute>
<PrivateRoute roles={['company_admin']} path={`${rootPath}/company/:page?`}> <PrivateRoute roles={['company_admin']} path={`${rootPath}/company`}>
<CompanyController /> <CompanyController />
</PrivateRoute> </PrivateRoute>
<Route path={'/'}> <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 ( return (
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<Grid style={{ gridTemplateColumns: 'auto repeat(6, 1fr)' }}> <Grid style={{ gridTemplateColumns: 'auto repeat(6, 1fr)' }}>
@ -407,10 +414,7 @@ export default function TelemetryView({ idWell }) {
interval={chartInterval * 1000} interval={chartInterval * 1000}
headerHeight={'50px'} headerHeight={'50px'}
showBorder={getIndexOfDrillingBy(dataSaub) === index} showBorder={getIndexOfDrillingBy(dataSaub) === index}
additionalLabels={rop && (index === 1) ? [ additionalLabels={columnAdditionalLabels[index]}
`ROP сред: ${rop.ropAverage.toFixed(2)} м/ч`,
`ROP макс: ${rop.ropMax.toFixed(2)} м/ч`
] : null}
/> />
</GridItem> </GridItem>
)} )}