From 2b227e9777450be9b384685c8df3bb4f7ec94692 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 3 Mar 2022 19:34:22 +0500 Subject: [PATCH] =?UTF-8?q?*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=88=D0=B8=D1=80=D0=B8=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BE=D0=BA=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=D0=B0=20=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=20*=20=D0=9F=D1=80=D0=BE=D0=B4=D0=BE=D0=BB?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B0=20=D0=BC=D0=B5=D0=BC=D0=BE=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AdminPanel/ClusterController.jsx | 8 ++++---- src/pages/AdminPanel/CompanyController.jsx | 8 ++++---- src/pages/AdminPanel/CompanyTypeController.jsx | 8 ++++---- src/pages/AdminPanel/DepositController.jsx | 8 ++++---- src/pages/AdminPanel/PermissionController.jsx | 8 ++++---- src/pages/AdminPanel/RoleController.jsx | 13 +++++++------ src/pages/AdminPanel/WellController/index.jsx | 14 +++++++------- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/pages/AdminPanel/ClusterController.jsx b/src/pages/AdminPanel/ClusterController.jsx index 002238d..0d5553b 100644 --- a/src/pages/AdminPanel/ClusterController.jsx +++ b/src/pages/AdminPanel/ClusterController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -40,7 +40,7 @@ export const ClusterController = memo(() => { makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ] - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async () => { const clusters = await AdminClusterService.getAll() setClusters(arrayOrDefault(clusters)) @@ -48,7 +48,7 @@ export const ClusterController = memo(() => { setShowLoader, `Не удалось загрузить список кустов`, 'Получение списка кустов' - ) + ), []) useEffect(() => invokeWebApiWrapperAsync( async () => { @@ -61,7 +61,7 @@ export const ClusterController = memo(() => { 'Получение списка месторождений' ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminClusterService, diff --git a/src/pages/AdminPanel/CompanyController.jsx b/src/pages/AdminPanel/CompanyController.jsx index 1479287..2381bda 100644 --- a/src/pages/AdminPanel/CompanyController.jsx +++ b/src/pages/AdminPanel/CompanyController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -21,10 +21,10 @@ export const CompanyController = memo(() => { const [companies, setCompanies] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = async () => { + const updateTable = useCallback(async () => { const companies = await AdminCompanyService.getAll() setCompanies(arrayOrDefault(companies)) - } + }, []) useEffect(() => invokeWebApiWrapperAsync( async() => { @@ -51,7 +51,7 @@ export const CompanyController = memo(() => { setShowLoader, `Не удалось загрузить список типов компаний`, 'Получение списка типов команд' - ), []) + ), [updateTable]) const handlerProps = { service: AdminCompanyService, diff --git a/src/pages/AdminPanel/CompanyTypeController.jsx b/src/pages/AdminPanel/CompanyTypeController.jsx index 6ee67bd..7c87d90 100644 --- a/src/pages/AdminPanel/CompanyTypeController.jsx +++ b/src/pages/AdminPanel/CompanyTypeController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -27,7 +27,7 @@ export const CompanyTypeController = memo(() => { const [companyTypes, setCompanyTypes] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async() => { const companyTypes = await AdminCompanyTypeService.getAll() setCompanyTypes(arrayOrDefault(companyTypes)) @@ -35,9 +35,9 @@ export const CompanyTypeController = memo(() => { setShowLoader, `Не удалось загрузить список типов компаний`, 'Получение списка типов компаний' - ) + ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminCompanyTypeService, diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 5a21b94..c472c30 100644 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' @@ -21,7 +21,7 @@ export const DepositController = memo(() => { const [deposits, setDeposits] = useState([]) const [showLoader, setShowLoader] = useState(false) - const updateTable = () => invokeWebApiWrapperAsync( + const updateTable = useCallback(() => invokeWebApiWrapperAsync( async() => { const deposits = await AdminDepositService.getAll() setDeposits(arrayOrDefault(deposits)) @@ -29,9 +29,9 @@ export const DepositController = memo(() => { setShowLoader, `Не удалось загрузить список месторождении`, 'Получение списка месторождений' - ) + ), []) - useEffect(updateTable, []) + useEffect(updateTable, [updateTable]) const handlerProps = { service: AdminDepositService, diff --git a/src/pages/AdminPanel/PermissionController.jsx b/src/pages/AdminPanel/PermissionController.jsx index d55e63a..5bbf24e 100644 --- a/src/pages/AdminPanel/PermissionController.jsx +++ b/src/pages/AdminPanel/PermissionController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import { EditableTable, @@ -30,7 +30,7 @@ export const PermissionController = memo(() => { const [showLoader, setShowLoader] = useState(false) const [permissions, setPermissions] = useState([]) - const updateTable = async () => invokeWebApiWrapperAsync( + const updateTable = useCallback(async () => invokeWebApiWrapperAsync( async () => { const permission = await AdminPermissionService.getAll() setPermissions(arrayOrDefault(permission)) @@ -38,9 +38,9 @@ export const PermissionController = memo(() => { setShowLoader, `Не удалось загрузить список прав`, 'Получение списка прав' - ) + ), []) - useEffect(() => updateTable(), []) + useEffect(() => updateTable(), [updateTable]) const handlerProps = { service: AdminPermissionService, diff --git a/src/pages/AdminPanel/RoleController.jsx b/src/pages/AdminPanel/RoleController.jsx index c5e6a30..dbfb0b2 100644 --- a/src/pages/AdminPanel/RoleController.jsx +++ b/src/pages/AdminPanel/RoleController.jsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useState } from 'react' import LoaderPortal from '@components/LoaderPortal' import { PermissionView, RoleView } from '@components/views' @@ -15,20 +15,21 @@ export const RoleController = memo(() => { const [showLoader, setShowLoader] = useState(false) const [columns, setColumns] = useState([]) - const loadRoles = async () => { + const loadRoles = useCallback(async () => { const roles = await AdminUserRoleService.getAll() setRoles(arrayOrDefault(roles)) - } + }, []) useEffect(() => { setColumns([ - makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }), + makeColumn('Название', 'caption', { width: 100, editable: true, formItemRules: min1 }), makeTagColumn('Включённые роли', 'roles', roles, 'id', 'caption', { - width: 200, + width: 400, editable: true, render: (role) => }, { allowClear: true }), makeTagColumn('Разрешения', 'permissions', permissions, 'id', 'name', { + width: 600, editable: true, render: (permission) => , }), @@ -44,7 +45,7 @@ export const RoleController = memo(() => { setShowLoader, `Не удалось загрузить список ролей`, 'Получение списка ролей' - ), []) + ), [loadRoles]) const handlerProps = { service: AdminUserRoleService, diff --git a/src/pages/AdminPanel/WellController/index.jsx b/src/pages/AdminPanel/WellController/index.jsx index 60265d6..0a5d8d6 100644 --- a/src/pages/AdminPanel/WellController/index.jsx +++ b/src/pages/AdminPanel/WellController/index.jsx @@ -35,6 +35,11 @@ const wellTypes = [ { value: 2, label: 'Горизонтальная' }, ] +const recordParser = (record) => ({ + ...record, + idTelemetry: record.telemetry?.id, +}) + export const WellController = memo(() => { const [columns, setColumns] = useState([]) const [wells, setWells] = useState([]) @@ -54,14 +59,14 @@ export const WellController = memo(() => { // TODO: Метод дубликации скважины } - const addititonalButtons = (record, editingKey) => ( + const addititonalButtons = memo((record, editingKey) => (