From efc7ae5e179728252053616f29f4e1d98591fd75 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Fri, 17 Dec 2021 17:08:15 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0?= =?UTF-8?q?=20VisitLog=20=D1=81=20=D0=BD=D0=B5=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D1=8E=D1=89=D0=B8=D0=BC=D0=B8=20=D1=81=D0=BE=D1=80?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/index.tsx | 6 ++--- src/pages/AdminPanel/VisitLog.jsx | 44 +++++++++++++++++++++++++++++++ src/pages/AdminPanel/index.jsx | 17 +++++++----- 3 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 src/pages/AdminPanel/VisitLog.jsx 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...}> - - - - - - + + + + + + +