diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 48d3119..8f6b439 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -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 = '-' diff --git a/src/pages/AdminPanel/VisitLog.jsx b/src/pages/AdminPanel/VisitLog.jsx new file mode 100644 index 0000000..4c3165d --- /dev/null +++ b/src/pages/AdminPanel/VisitLog.jsx @@ -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 ( + + + + ) +} + +export default VisitLog diff --git a/src/pages/AdminPanel/index.jsx b/src/pages/AdminPanel/index.jsx index f5d1e0b..8a668f8 100644 --- a/src/pages/AdminPanel/index.jsx +++ b/src/pages/AdminPanel/index.jsx @@ -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 = () => { Права + + Журнал посещений + Loading...}> - - - - - - + + + + + + +