From e084727c7224a02e966f6b2a337d423c7e3c562e Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 27 Dec 2021 18:06:26 +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=20view=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=9A=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8E=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D0=B5=D0=BC=D0=B5=D1=82=D1=80=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20id=20?= =?UTF-8?q?=D0=90=D0=BA=D1=82=D1=83=D0=B0=D0=BB=D0=B8=D0=B7=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=20=D1=80=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BA=D0=BD=D0=BE?= =?UTF-8?q?=D0=BF=D0=BA=D0=B0=20=D1=81=D0=BC=D0=B5=D0=BD=D1=8B=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=20=D0=9E=D0=BA=D0=BD=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BC=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=8B=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ChangePassword.tsx | 63 ++++++++++ src/components/Table/EditableTable.jsx | 6 +- src/components/Table/index.tsx | 67 ++++++++++- src/components/UserMenu.tsx | 56 ++------- src/components/Views/PermissionView.tsx | 27 +++++ src/components/Views/TelemetryView.tsx | 38 +++--- src/components/Views/index.ts | 4 +- src/pages/AdminPanel/RoleController.jsx | 139 ++++++++------------- src/pages/AdminPanel/UserController.jsx | 153 ++++++++++++++---------- src/pages/AdminPanel/WellController.jsx | 87 +++++++------- src/pages/AdminPanel/index.jsx | 2 +- 11 files changed, 380 insertions(+), 262 deletions(-) create mode 100644 src/components/ChangePassword.tsx create mode 100644 src/components/Views/PermissionView.tsx diff --git a/src/components/ChangePassword.tsx b/src/components/ChangePassword.tsx new file mode 100644 index 0000000..07ee96e --- /dev/null +++ b/src/components/ChangePassword.tsx @@ -0,0 +1,63 @@ +import { memo, useState } from 'react' +import { useForm } from 'antd/lib/form/Form' +import { Form, Input, Modal, FormProps } from 'antd' + +import { AuthService } from '../services/api' +import { passwordRules } from '../utils/validationRules' + +import LoaderPortal from './LoaderPortal' +import { invokeWebApiWrapperAsync } from './factory' + +const formLayout: FormProps = { labelCol: { span: 11 }, wrapperCol: { span: 16 } } + +export type ChangePasswordProps = { + userId?: number + visible?: boolean + onCancel?: () => void + onOk?: () => void +} + + +export const ChangePassword = memo(({ userId, visible, onCancel, onOk }) => { + const [showLoader, setShowLoader] = useState(false) + const [password, setPassword] = useState('') + + const [form] = useForm() + + const onModalCancel = () => { + form.resetFields() + onCancel?.() + } + + const onFormFinish = () => invokeWebApiWrapperAsync( + async() => { + await AuthService.changePassword(userId ?? localStorage['userId'], `"${password}"`) + onOk?.() + }, + setShowLoader, + `Не удалось сменить пароль пользователя ${localStorage['login']}` + ) + + return ( + form.submit()} + > + +
+ + setPassword(e.target.value)} value={password} /> + +
+
+
+ ) +}) diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index 5e0e8fa..5715e48 100644 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -49,6 +49,8 @@ export const EditableTable = ({ onRowAdd, // Метод вызывается с новой добавленной записью. Если метод не определен, то кнопка добавления строки не показывается onRowEdit, // Метод вызывается с новой отредактированной записью. Если метод не поределен, то кнопка редактирования строки не показывается onRowDelete, // Метод вызывается с удаленной записью. Если метод не поределен, то кнопка удаления строки не показывается + additionalButtons, + buttonsWidth, ...otherTableProps }) => { @@ -144,7 +146,7 @@ export const EditableTable = ({ } const operationColumn = { - width: 82, + width: buttonsWidth ?? 82, title: !!onRowAdd && (