Добавлена страница VisitLog с неработающими сортировками

This commit is contained in:
Александр Сироткин 2021-12-17 17:08:15 +05:00
parent df0fe53049
commit efc7ae5e17
3 changed files with 58 additions and 9 deletions

View File

@ -2,15 +2,15 @@ import { ReactNode } from 'react'
import { InputNumber, Select, Table as RawTable } from 'antd'
import { OptionsType } from 'rc-select/lib/interface'
import { tryAddKeys } from './EditableTable'
import { makeNumericSorter, makeStringSorter} from './sorters'
import { makeNumericSorter, makeStringSorter } from './sorters'
import { Rule } from 'rc-field-form/lib/interface'
export { makeDateSorter, makeNumericSorter, makeStringSorter} from './sorters'
export { makeDateSorter, makeNumericSorter, makeStringSorter } from './sorters'
export { EditableTable, makeActionHandler } from './EditableTable'
export { DatePickerWrapper } from './DatePickerWrapper'
export { SelectFromDictionary } from './SelectFromDictionary'
export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/
export const formatDate='YYYY.MM.DD HH:mm'
export const formatDate = 'YYYY.MM.DD HH:mm'
export const makeNumericRender = (fixed?: number) => (value: any, row: object): ReactNode => {
let val = '-'

View File

@ -0,0 +1,44 @@
import moment from 'moment'
import { useEffect, useState } from 'react'
import { invokeWebApiWrapperAsync } from '../../components/factory'
import LoaderPortal from '../../components/LoaderPortal'
import { makeColumn, makeDateSorter, makeStringSorter, Table } from '../../components/Table'
import { RequerstTrackerService } from '../../services/api'
const columns = [
makeColumn('Логин', 'login', { sorter: makeStringSorter('login') }),
makeColumn('IP', 'ip', { sorter: makeStringSorter('ip') }),
makeColumn('Дата посещения', 'lastDate', {
render: (date) => moment(date).format('DD MMM YYYY, HH:mm:ss'),
sorter: makeDateSorter('lastDate'),
}),
]
export const VisitLog = () => {
const [logData, setLogData] = useState([])
const [isLoading, setIsLoading] = useState(false)
useEffect(() => invokeWebApiWrapperAsync(
async () => {
const logData = await RequerstTrackerService.getUsersStat(1000)
setLogData(logData)
},
setIsLoading,
`Не удалось загрузить список последних посещений пользователей`
), [])
return (
<LoaderPortal show={isLoading}>
<Table
size={'small'}
bordered
columns={columns}
dataSource={logData}
/>
</LoaderPortal>
)
}
export default VisitLog

View File

@ -9,6 +9,7 @@ const DepositController = React.lazy(() => import('./DepositController'))
const UserController = React.lazy(() => import('./UserController'))
const WellController = React.lazy(() => import('./WellController'))
const RoleController = React.lazy(() => import('./RoleController'))
const VisitLog = React.lazy(() => import('./VisitLog'))
export const AdminPanel = () => {
const { tab } = useParams()
@ -35,18 +36,22 @@ export const AdminPanel = () => {
<PrivateMenuItem key={'role'} permission={'role_editor'}>
<Link to={`${rootPath}/role`}>Права</Link>
</PrivateMenuItem>
<PrivateMenuItem key={'visit_log'} permission={'visit_log'}>
<Link to={`${rootPath}/visit_log`}>Журнал посещений</Link>
</PrivateMenuItem>
</Menu>
<Layout>
<Layout.Content className={'site-layout-background'}>
<Suspense fallback={<div>Loading...</div>}>
<Switch>
<PrivateRoute permission={'deposit_editor'} path={`${rootPath}/deposit`} component={DepositController} />
<PrivateRoute permission={'cluster_editor'} path={`${rootPath}/cluster`} component={ClusterController} />
<PrivateRoute permission={'deposit_editor'} path={`${rootPath}/deposit` } component={DepositController} />
<PrivateRoute permission={'cluster_editor'} path={`${rootPath}/cluster` } component={ClusterController} />
<PrivateRoute permission={ 'well_editor'} path={`${rootPath}/well` } component={ WellController} />
<PrivateRoute permission={ 'user_editor'} path={`${rootPath}/user` } component={ UserController} />
<PrivateRoute permission={'company_editor'} path={`${rootPath}/company`} component={CompanyController} />
<PrivateRoute permission={'company_editor'} path={`${rootPath}/company` } component={CompanyController} />
<PrivateRoute permission={ 'role_editor'} path={`${rootPath}/role` } component={ RoleController} />
<PrivateRoute permission={ 'visit_log'} path={`${rootPath}/visit_log`} component={ VisitLog} />
<Route path={'/'}>
<Redirect to={`${rootPath}/deposit`}/>
</Route>