diff --git a/src/pages/AdminPanel/ClusterController.jsx b/src/pages/AdminPanel/ClusterController.jsx index a526197..776cbd0 100644 --- a/src/pages/AdminPanel/ClusterController.jsx +++ b/src/pages/AdminPanel/ClusterController.jsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react' + import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' import { @@ -10,6 +11,9 @@ import { } from '../../components/Table' import { AdminClusterService, AdminDepositService } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { min3 } from '../../utils/validationRules' + +import { coordsFixed } from './DepositController' export default function ClusterController() { const [deposits, setDeposits] = useState([]) @@ -25,10 +29,11 @@ export default function ClusterController() { makeColumn('Название', 'caption', { width: 200, editable: true, - sorter: makeStringSorter('caption') + sorter: makeStringSorter('caption'), + formItemRules: min3, }), - makeColumn('Широта', 'latitude', { width: 150, editable: true }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true }) + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }), ] const updateTable = () => invokeWebApiWrapperAsync( diff --git a/src/pages/AdminPanel/CompanyController.jsx b/src/pages/AdminPanel/CompanyController.jsx index 8faf0cd..b40df95 100644 --- a/src/pages/AdminPanel/CompanyController.jsx +++ b/src/pages/AdminPanel/CompanyController.jsx @@ -1,15 +1,18 @@ import { useEffect, useState } from 'react' + import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' import { EditableTable, makeColumn, makeActionHandler, makeStringSorter } from '../../components/Table' import { AdminCompanyService } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { min3 } from '../../utils/validationRules' const companyColumns = [ makeColumn('Название', 'caption', { width: 200, editable: true, - sorter: makeStringSorter('caption') + sorter: makeStringSorter('caption'), + formItemRules: min3, }), makeColumn('Тип компании', 'companyTypeCaption', { width: 200, diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 35244e7..941a59e 100644 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -4,11 +4,14 @@ import LoaderPortal from '../../components/LoaderPortal' import { EditableTable, makeColumn, makeActionHandler } from '../../components/Table' import { AdminDepositService } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { min3 } from '../../utils/validationRules' + +export const coordsFixed = (coords) => coords?.toPrecision(10) const depositColumns = [ - makeColumn('Название', 'caption', { width: 200, editable: true }), - makeColumn('Широта', 'latitude', { width: 150, editable: true }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true }) + makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min3 }), + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }) ] export default function DepositController() { diff --git a/src/pages/AdminPanel/PermissionController.jsx b/src/pages/AdminPanel/PermissionController.jsx index 6f87cf8..b40a596 100644 --- a/src/pages/AdminPanel/PermissionController.jsx +++ b/src/pages/AdminPanel/PermissionController.jsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react' + import { invokeWebApiWrapperAsync } from '../../components/factory' import LoaderPortal from '../../components/LoaderPortal' import { @@ -9,11 +10,13 @@ import { } from '../../components/Table' import { AdminPermissionService } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { min3 } from '../../utils/validationRules' const columns = [ makeColumn('Название', 'name', { editable: true, sorter: makeStringSorter('name'), + formItemRules: min3, }), makeColumn('Описание', 'description', { editable: true, diff --git a/src/pages/AdminPanel/RoleController.jsx b/src/pages/AdminPanel/RoleController.jsx index 934b1f2..7411de9 100644 --- a/src/pages/AdminPanel/RoleController.jsx +++ b/src/pages/AdminPanel/RoleController.jsx @@ -6,6 +6,7 @@ import { invokeWebApiWrapperAsync } from '../../components/factory' import { EditableTable, makeActionHandler, makeColumn, makeSelectColumn, makeTagColumn } from '../../components/Table' import { AdminPermissionService, AdminUserRoleService } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { min3 } from '../../utils/validationRules' export const RoleController = memo(() => { const [permissions, setPermissions] = useState([]) @@ -21,7 +22,7 @@ export const RoleController = memo(() => { useEffect(() => { const options = roles?.map((r) => ({ value: r.id, label: r.caption })) ?? [] setColumns([ - makeColumn('Название', 'caption', { width: 200, editable: true }), + makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min3 }), makeSelectColumn('Роль-родитель', 'idParent', options, options[0], { width: 200, editable: true diff --git a/src/pages/AdminPanel/VisitLog.jsx b/src/pages/AdminPanel/VisitLog.jsx index 54cf066..4da7d11 100644 --- a/src/pages/AdminPanel/VisitLog.jsx +++ b/src/pages/AdminPanel/VisitLog.jsx @@ -1,27 +1,34 @@ -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' -import { arrayOrDefault } from '../../utils' +import { arrayOrDefault, formatDate } from '../../utils' + +const logRecordCount = 1000 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'), + render: (date) => formatDate(date, false, 'DD MMM YYYY, HH:mm:ss'), sorter: makeDateSorter('lastDate'), }), ] +const pagination = { + pageSize: 16, + showSizeChanger: true, +} + export const VisitLog = () => { const [logData, setLogData] = useState([]) const [isLoading, setIsLoading] = useState(false) useEffect(() => invokeWebApiWrapperAsync( async () => { - const logData = arrayOrDefault(await RequerstTrackerService.getUsersStat(1000)) + const logData = arrayOrDefault(await RequerstTrackerService.getUsersStat(logRecordCount)) logData.forEach((log) => log.key = `${log.login}${log.ip}`) setLogData(logData) }, @@ -37,6 +44,7 @@ export const VisitLog = () => { bordered columns={columns} dataSource={logData} + pagination={pagination} /> ) diff --git a/src/pages/AdminPanel/WellController.jsx b/src/pages/AdminPanel/WellController.jsx index b22f064..839e6a2 100644 --- a/src/pages/AdminPanel/WellController.jsx +++ b/src/pages/AdminPanel/WellController.jsx @@ -21,6 +21,7 @@ import { AdminWellService, } from '../../services/api' import { arrayOrDefault } from '../../utils' +import { coordsFixed } from './DepositController' const wellTypes = [ { value: 1, label: 'Наклонно-направленная' }, @@ -83,12 +84,12 @@ export default function WellController() { setColumns([ makeSelectColumn('Куст', 'idCluster', clusters, '--', { - width: 200, + width: '5rem', editable: true, sorter: makeNumericSorter('idCluster'), }), makeColumn('Название', 'caption', { - width: 200, + width: '5rem', editable: true, sorter: makeStringSorter('caption'), }), @@ -97,16 +98,14 @@ export default function WellController() { editable: true, sorter: makeNumericSorter('idWellType'), }), - makeColumn('Широта', 'latitude', { width: 150, editable: true }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true }), + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }), makeColumn('Телеметрия', 'telemetry', { - width: 150, editable: true, render: (telemetry) => , input: , }), makeTagColumn('Компании', 'companies', companies, 'id', 'caption', { - width: 400, editable: true, render: (company) => , }), diff --git a/src/pages/Archive/index.jsx b/src/pages/Archive/index.jsx index 1f23d7c..d3d58b2 100644 --- a/src/pages/Archive/index.jsx +++ b/src/pages/Archive/index.jsx @@ -2,14 +2,16 @@ import moment from 'moment' import { DatePicker } from 'antd' import { useState, useEffect } from 'react' -import { TelemetryDataSaubService } from '../../services/api' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import LoaderPortal from '../../components/LoaderPortal' + import { Flex } from '../../components/Grid' -import { PeriodPicker, defaultPeriod } from '../../components/PeriodPicker' -import { ArchiveDisplay, cutData } from './ArchiveDisplay' -import { normalizeData } from '../TelemetryView' import { makeDateSorter } from '../../components/Table' +import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { PeriodPicker, defaultPeriod } from '../../components/PeriodPicker' +import { TelemetryDataSaubService } from '../../services/api' + +import { normalizeData } from '../TelemetryView' +import { ArchiveDisplay, cutData } from './ArchiveDisplay' const DATA_COUNT = 2048 // Колличество точек на подгрузку графика const ADDITIVE_PAGES = 2 // Дополнительные данные для графиков diff --git a/src/utils/validationRules.ts b/src/utils/validationRules.ts index fb0fdf3..931fe0e 100644 --- a/src/utils/validationRules.ts +++ b/src/utils/validationRules.ts @@ -1,10 +1,12 @@ import { Rule } from 'rc-field-form/lib/interface' -export const createLoginRules: Rule[] = [{ +export const min3: Rule[] = [{ min: 3, max: 255, message: 'Допустимая длина 3-255 символов' -}, { +}] + +export const createLoginRules: Rule[] = [...min3, { pattern: /^[A-Za-zА-Яа-я][А-Яа-я\w.-]+$/, whitespace: true, message: 'Логин должен начинаться с русской или латинской буквы, содержать только (А-яA-z0-9_-.)!'