Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c89f47321a | ||
|
|
38646e56df | ||
|
|
9dfb0ca7a3 | ||
|
|
cbc1f0f6cc | ||
|
|
c55fa2e7d6 | ||
|
|
1cdf65ff08 | ||
|
|
4306ffcf3d | ||
|
|
d006bf7628 | ||
|
|
554f1470c8 | ||
|
|
490e6168ff | ||
|
|
709e14e501 | ||
|
|
fe295beb7f | ||
|
|
39cf7159e4 | ||
|
|
e87ed7cd68 | ||
|
|
e54ce881b7 |
No files matched your search
@@ -13,7 +13,12 @@
|
|||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:import/typescript"
|
"plugin:import/typescript"
|
||||||
],
|
],
|
||||||
"ignorePatterns": ["node_modules", "build", "generateVersionFile.cjs"],
|
"ignorePatterns": [
|
||||||
|
"node_modules",
|
||||||
|
"build",
|
||||||
|
"generateVersionFile.cjs",
|
||||||
|
"config.template.js"
|
||||||
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
@@ -33,28 +38,48 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"import/default": "off",
|
"import/default": "off",
|
||||||
"import/no-named-as-default":"off",
|
"import/no-named-as-default": "off",
|
||||||
"prettier/prettier": "off",
|
"prettier/prettier": "off",
|
||||||
"quotes": ["error", "single"],
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
"react/jsx-filename-extension": [
|
"react/jsx-filename-extension": [
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"extensions": [".js", ".jsx", ".tsx"]
|
"extensions": [
|
||||||
|
".js",
|
||||||
|
".jsx",
|
||||||
|
".tsx"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"react/jsx-one-expression-per-line": "off",
|
"react/jsx-one-expression-per-line": "off",
|
||||||
"react/prop-types": 0,
|
"react/prop-types": 0,
|
||||||
"react/react-in-jsx-scope": "off",
|
"react/react-in-jsx-scope": "off",
|
||||||
"semi": ["error", "never"],
|
"semi": [
|
||||||
"@typescript-eslint/no-unused-vars": ["off"],
|
"error",
|
||||||
"@typescript-eslint/no-explicit-any": ["off", null],
|
"never"
|
||||||
"@typescript-eslint/no-non-null-assertion": ["off"],
|
],
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"off"
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-explicit-any": [
|
||||||
|
"off",
|
||||||
|
null
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-non-null-assertion": [
|
||||||
|
"off"
|
||||||
|
],
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
"no-unused-vars": "off"
|
"no-unused-vars": "off"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"import/parsers": {
|
"import/parsers": {
|
||||||
"@typescript-eslint/parser": [".ts", ".tsx"]
|
"@typescript-eslint/parser": [
|
||||||
|
".ts",
|
||||||
|
".tsx"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"react": {
|
"react": {
|
||||||
"version": "detect"
|
"version": "detect"
|
||||||
@@ -64,8 +89,16 @@
|
|||||||
"alwaysTryTypes": true
|
"alwaysTryTypes": true
|
||||||
},
|
},
|
||||||
"node": {
|
"node": {
|
||||||
"extensions": [".js", ".jsx", ".ts", ".tsx"],
|
"extensions": [
|
||||||
"moduleDirectory": ["node_modules", "src/"]
|
".js",
|
||||||
|
".jsx",
|
||||||
|
".ts",
|
||||||
|
".tsx"
|
||||||
|
],
|
||||||
|
"moduleDirectory": [
|
||||||
|
"node_modules",
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-23
@@ -1,23 +1,3 @@
|
|||||||
docker-build:
|
include:
|
||||||
image: docker:latest
|
- project: '$CI_PROJECT_PATH'
|
||||||
stage: build
|
file: '/ci-isp-ui.yml'
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
before_script:
|
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
||||||
- export VERSION=`sh version.sh`
|
|
||||||
- echo $VERSION
|
|
||||||
- echo $CI_DOCKER_FILE
|
|
||||||
- echo $CI_REGISTRY
|
|
||||||
script:
|
|
||||||
- set
|
|
||||||
- mkdir -p migrations
|
|
||||||
- docker build -f "$CI_DOCKER_FILE" --force-rm --build-arg="version=$VERSION" --build-arg="app_name=$CI_PROJECT_NAME" --pull -t "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" .
|
|
||||||
- |
|
|
||||||
docker tag "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
|
||||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
|
||||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
- docker logout $CI_REGISTRY
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
cfg
|
||||||
|
/config.template.js
|
||||||
@@ -1,3 +1,35 @@
|
|||||||
|
## 0.21.8
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(Добавленн поиск приложения по токену и поправлен баг скроллов по всему приоекту)
|
||||||
|
## 0.21.7
|
||||||
|
- Обновлена библиотека компонентов Antd
|
||||||
|
- Исправлено неверное поведение всплывающих подсказок
|
||||||
|
## 0.21.6
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(высота и скрол меню, сортировка и высота в Column)
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(По вкладке "Доступы приложений" по кнопке сохранить добавлено модальное окно)
|
||||||
|
## 0.21.5
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(Блокировка кнопки сохранить на странице редактирвоания конфига)
|
||||||
|
## 0.21.4
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(Добавлено редактирвоание ID приложений)
|
||||||
|
## 0.21.3
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit (Для переименования конфига использован новый метод)
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
(Добавлено редактирование ID приложений
|
||||||
|
Добавлено кол-во элементов в Column,
|
||||||
|
Добавлена возможность добавлять иконку в заголовок столбца,
|
||||||
|
Изменен тип label для всех компонентов формы, фикс скроллов)
|
||||||
|
## 0.21.2
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
## 0.21.1
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit
|
||||||
|
## 0.21.0
|
||||||
|
- Добавлены разрешения для страниц проекта
|
||||||
|
## 0.20.0
|
||||||
|
- Добавлена страница работы с переменными
|
||||||
|
## 0.19.1
|
||||||
|
- Обновлена версия ui библиотек
|
||||||
|
## 0.19.0
|
||||||
|
- Замена компонента App на компонент AdminBase из библиотеки
|
||||||
|
- Удален весь код, дублирующий компонент AdminBase
|
||||||
## 0.18.9
|
## 0.18.9
|
||||||
- Исправлены дополнительные параметры подключения в форме
|
- Исправлены дополнительные параметры подключения в форме
|
||||||
## 0.18.8
|
## 0.18.8
|
||||||
|
|||||||
@@ -26,3 +26,5 @@ RUN rm -f /etc/nginx/conf.d/default.conf
|
|||||||
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
||||||
COPY --from=build /usr/src/app/build /opt/msp/isp-admin-ui
|
COPY --from=build /usr/src/app/build /opt/msp/isp-admin-ui
|
||||||
|
|
||||||
|
COPY entrypoint.sh /opt/msp/isp-admin-ui/entrypoint.sh
|
||||||
|
ENTRYPOINT ["/opt/msp/isp-admin-ui/entrypoint.sh"]
|
||||||
@@ -28,3 +28,4 @@ export default {
|
|||||||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
||||||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
||||||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
||||||
|
1
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
CONFIG_PATH="/opt/msp/isp-admin-ui/config.js"
|
||||||
|
|
||||||
|
cat <<EOF > $CONFIG_PATH
|
||||||
|
// DON'T TOUCH
|
||||||
|
// THIS FILE FOR PRODUCTION BUILD
|
||||||
|
|
||||||
|
window.config = {
|
||||||
|
ENABLE_PASSWORD_LOGIN: ${ENABLE_PASSWORD_LOGIN:-true},
|
||||||
|
APP_TOKEN: '${APP_TOKEN:-"default_token"}',
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
exec nginx -g "daemon off;"
|
||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
window.AppVersion = APP_VERSION
|
window.AppVersion = APP_VERSION
|
||||||
</script>
|
</script>
|
||||||
<script type="module" src="/config.js"></script>
|
<script src="/config.js"></script>
|
||||||
<title>Панель администратора</title>
|
<title>Панель администратора</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Generated
+5218
-3228
File diff suppressed because it is too large.
Load diff
+10
-18
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.18.9",
|
"version": "0.21.8",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
@@ -14,24 +14,16 @@
|
|||||||
"prepare": "husky || true"
|
"prepare": "husky || true"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
"dayjs": "^1.11.10",
|
||||||
|
"isp-ui-kit": "^0.20.2",
|
||||||
|
"axios": "^1.7.7",
|
||||||
|
"react-hook-form": "^7.51.2",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"monaco-editor": "^0.52.0",
|
||||||
"@monaco-editor/react": "^4.6.0",
|
"@monaco-editor/react": "^4.6.0",
|
||||||
"@reduxjs/toolkit": "^2.2.3",
|
"@reduxjs/toolkit": "^2.2.3",
|
||||||
"@rjsf/antd": "^5.21.2",
|
"isp-admin-ui-kit": "^0.7.1",
|
||||||
"@rjsf/core": "^5.21.2",
|
|
||||||
"@rjsf/validator-ajv8": "^5.21.2",
|
|
||||||
"axios": "^1.7.7",
|
|
||||||
"clipboard": "^2.0.11",
|
|
||||||
"compare-versions": "^6.1.0",
|
|
||||||
"dayjs": "^1.11.10",
|
|
||||||
"deep-equal": "^2.2.3",
|
|
||||||
"isp-ui-kit": "^0.10.1",
|
|
||||||
"json-schema-view-js": "^2.0.1",
|
|
||||||
"lodash.clonedeep": "^4.5.0",
|
|
||||||
"monaco-editor": "^0.52.0",
|
|
||||||
"react": "^18.2.0",
|
|
||||||
"react-dom": "^18.2.0",
|
|
||||||
"react-hook-form": "^7.51.2",
|
|
||||||
"react-redux": "^9.1.0",
|
"react-redux": "^9.1.0",
|
||||||
"react-resizable": "^3.0.5",
|
"react-resizable": "^3.0.5",
|
||||||
"react-router-dom": "^6.22.3",
|
"react-router-dom": "^6.22.3",
|
||||||
@@ -52,7 +44,7 @@
|
|||||||
"@vitejs/plugin-legacy": "^5.3.2",
|
"@vitejs/plugin-legacy": "^5.3.2",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"@vitejs/plugin-react-swc": "^3.6.0",
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
||||||
"antd": "5.16.0",
|
"antd": "5.25.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
|
|||||||
Whitespace-only changes.
@@ -1,9 +0,0 @@
|
|||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<rect width="24" height="24" fill="url(#pattern0)"/>
|
|
||||||
<defs>
|
|
||||||
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
|
|
||||||
<use xlink:href="#image0_121_5920" transform="scale(0.0025)"/>
|
|
||||||
</pattern>
|
|
||||||
<image id="image0_121_5920" width="400" height="400" xlink:href="data:image/png;base64,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 truncated
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,3 +0,0 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M13.2118 12.3535L9.15396 8.29564C9.78364 7.48158 10.1243 6.48627 10.1243 5.43939C10.1243 4.18627 9.6352 3.01127 8.75083 2.12533C7.86645 1.23939 6.68833 0.751892 5.43677 0.751892C4.1852 0.751892 3.00708 1.24095 2.1227 2.12533C1.23677 3.0097 0.749268 4.18627 0.749268 5.43939C0.749268 6.69095 1.23833 7.86908 2.1227 8.75345C3.00708 9.63939 4.18364 10.1269 5.43677 10.1269C6.48364 10.1269 7.47739 9.78627 8.29146 9.15814L12.3493 13.2144C12.3612 13.2263 12.3753 13.2357 12.3908 13.2422C12.4064 13.2486 12.4231 13.2519 12.4399 13.2519C12.4567 13.2519 12.4734 13.2486 12.4889 13.2422C12.5045 13.2357 12.5186 13.2263 12.5305 13.2144L13.2118 12.5347C13.2237 12.5228 13.2331 12.5087 13.2396 12.4931C13.246 12.4776 13.2493 12.4609 13.2493 12.4441C13.2493 12.4272 13.246 12.4106 13.2396 12.395C13.2331 12.3795 13.2237 12.3654 13.2118 12.3535ZM7.91177 7.91439C7.24927 8.57533 6.37114 8.93939 5.43677 8.93939C4.50239 8.93939 3.62427 8.57533 2.96177 7.91439C2.30083 7.25189 1.93677 6.37377 1.93677 5.43939C1.93677 4.50502 2.30083 3.62533 2.96177 2.96439C3.62427 2.30345 4.50239 1.93939 5.43677 1.93939C6.37114 1.93939 7.25083 2.30189 7.91177 2.96439C8.57271 3.62689 8.93677 4.50502 8.93677 5.43939C8.93677 6.37377 8.57271 7.25346 7.91177 7.91439Z" fill="black" fill-opacity="0.85"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 382 KiB |
@@ -1,47 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
|
|
||||||
.active-configurations-table {
|
|
||||||
&__title {
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
&__name-field {
|
|
||||||
input {
|
|
||||||
color: #606060;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
color: var(--ant-color-text);
|
|
||||||
padding: $basic-padding;
|
|
||||||
border-radius: 4px;
|
|
||||||
outline: 1px solid $blue-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: $basic-margin;
|
|
||||||
|
|
||||||
&__actions {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.active-config {
|
|
||||||
tr {
|
|
||||||
background: var(--ant-color-info-bg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { ConfigType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ActiveConfigurationsTablePropsType {
|
|
||||||
isActiveTable?: boolean
|
|
||||||
data: ConfigType[]
|
|
||||||
handleShowConfig: (config: ConfigType) => void
|
|
||||||
handleShowCompareModal: (config: ConfigType) => void
|
|
||||||
currentModule?: ModuleType
|
|
||||||
}
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, message, Table, Tag, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { FC, useEffect, useRef, useState } from 'react'
|
|
||||||
import { useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
|
|
||||||
import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons'
|
|
||||||
|
|
||||||
import { ActiveConfigurationsTablePropsType } from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
|
||||||
import CanEdit from '@components/CanEdit'
|
|
||||||
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import configApi from '@services/configService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import './active-configurations-table.scss'
|
|
||||||
|
|
||||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> = ({
|
|
||||||
isActiveTable = false,
|
|
||||||
handleShowConfig,
|
|
||||||
handleShowCompareModal,
|
|
||||||
data,
|
|
||||||
currentModule = {}
|
|
||||||
}) => {
|
|
||||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
|
||||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
|
||||||
const inputRefs = useRef<Record<string, HTMLInputElement | null>>({})
|
|
||||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
|
||||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
|
||||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id: moduleId } = useParams()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (inputRefs.current[editKeyConfig]) {
|
|
||||||
inputRefs.current[editKeyConfig]?.focus()
|
|
||||||
}
|
|
||||||
}, [editKeyConfig])
|
|
||||||
const handleEditStart = (record: ConfigType) => {
|
|
||||||
setEditKeyConfig(record.id)
|
|
||||||
setTempEditValues({
|
|
||||||
...tempEditValues,
|
|
||||||
[record.id]: record.name
|
|
||||||
} as ConfigType)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCancelEdit = (record: ConfigType) => {
|
|
||||||
setEditKeyConfig('')
|
|
||||||
setTempEditValues({
|
|
||||||
...tempEditValues,
|
|
||||||
[record.id]: record.name
|
|
||||||
} as ConfigType)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSaveEdit = (record: ConfigType) => {
|
|
||||||
const sendData = { ...record, name: tempEditValues[record.id] }
|
|
||||||
createUpdateConfig(sendData)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент успешно сохранен')
|
|
||||||
setEditKeyConfig('')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Не удалось сохранить элемент')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleDeleteConfig = (record: ConfigType) => {
|
|
||||||
deleteConfig(record.id)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент успешно удален')
|
|
||||||
setEditKeyConfig('')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Не удалось удалить элемент')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleMarkConfigActive = (record: ConfigType) => {
|
|
||||||
markConfigAsActive(record.id)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент успешно обновлен')
|
|
||||||
setEditKeyConfig('')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Не удалось обновить элемент')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderNameField = (value: string, record: ConfigType) => {
|
|
||||||
const canEdit = editKeyConfig === record.id
|
|
||||||
const inputValue = canEdit ? tempEditValues[record.id] : value
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="active-configurations-table__table__name-field">
|
|
||||||
<input
|
|
||||||
ref={(inputRef) => (inputRefs.current[record.id] = inputRef)}
|
|
||||||
onChange={(event) => {
|
|
||||||
const { value } = event.target
|
|
||||||
setTempEditValues({ ...tempEditValues, [record.id]: value })
|
|
||||||
}}
|
|
||||||
disabled={!canEdit}
|
|
||||||
value={inputValue}
|
|
||||||
/>
|
|
||||||
{canEdit ? (
|
|
||||||
<div className="active-configurations-table__table__name-field__actions">
|
|
||||||
<Tooltip title="Сохранить">
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
onClick={() => handleSaveEdit(record)}
|
|
||||||
icon={<CheckOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Отменить">
|
|
||||||
<Button
|
|
||||||
onClick={() => handleCancelEdit(record)}
|
|
||||||
icon={<CloseOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<CanEdit>
|
|
||||||
<Tooltip title="Редактировать название">
|
|
||||||
<Button
|
|
||||||
onClick={() => handleEditStart(record)}
|
|
||||||
icon={<EditOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</CanEdit>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType<ConfigType> = [
|
|
||||||
{
|
|
||||||
title: 'Наименование',
|
|
||||||
dataIndex: 'name',
|
|
||||||
key: 'name',
|
|
||||||
render: renderNameField,
|
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Версия',
|
|
||||||
dataIndex: 'version',
|
|
||||||
key: 'version',
|
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Статус',
|
|
||||||
dataIndex: 'valid',
|
|
||||||
key: 'version',
|
|
||||||
align: 'center',
|
|
||||||
render: (value: boolean) => {
|
|
||||||
if (value) {
|
|
||||||
return <Tag color="success">Корректная</Tag>
|
|
||||||
}
|
|
||||||
return <Tag color="error">Некорректная</Tag>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Дата обновления',
|
|
||||||
dataIndex: 'updatedAt',
|
|
||||||
key: 'updatedAt',
|
|
||||||
align: 'center',
|
|
||||||
render: (value: string) => {
|
|
||||||
return dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Действия',
|
|
||||||
dataIndex: 'actions',
|
|
||||||
key: 'actions',
|
|
||||||
align: 'center',
|
|
||||||
render: (_: unknown, record: ConfigType) => (
|
|
||||||
<ActiveTableActionButtons
|
|
||||||
isActive={isActiveTable}
|
|
||||||
handleShowConfig={handleShowConfig}
|
|
||||||
handleShowCompareModal={handleShowCompareModal}
|
|
||||||
handleDeleteConfig={handleDeleteConfig}
|
|
||||||
handleMarkConfigActive={handleMarkConfigActive}
|
|
||||||
record={record}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
]
|
|
||||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
|
||||||
return (
|
|
||||||
<div className="active-configurations-table">
|
|
||||||
<div className="active-configurations-table__buttons">
|
|
||||||
<h2 className="active-configurations-table__title">
|
|
||||||
{isActiveTable ? 'Активная' : 'Остальные'}
|
|
||||||
</h2>
|
|
||||||
{!isActiveTable && (
|
|
||||||
<CanEdit>
|
|
||||||
<Button
|
|
||||||
className="configurations__buttons__new-config-brn"
|
|
||||||
onClick={() =>
|
|
||||||
navigate(`/${moduleId}/${routePaths.configEditor}/new`, {
|
|
||||||
state: currentModule
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Создать
|
|
||||||
</Button>
|
|
||||||
</CanEdit>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Table
|
|
||||||
rowHoverable={false}
|
|
||||||
className={className}
|
|
||||||
rowKey={(record) => record.id}
|
|
||||||
pagination={false}
|
|
||||||
columns={columns}
|
|
||||||
dataSource={data}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ActiveConfigurationsTable
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { ConfigProvider } from 'antd'
|
|
||||||
import ruRu from 'antd/locale/ru_RU'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useLocation } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { darkTheme, lightTheme } from '@constants/theme.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import Routers from '@routes/Routers'
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import './app.scss'
|
|
||||||
|
|
||||||
const App = () => {
|
|
||||||
const [themes, setTheme] = useState(lightTheme)
|
|
||||||
const [changeTheme, setChangeTheme] = useState(
|
|
||||||
localStorage.getItem('theme')
|
|
||||||
? JSON.parse(localStorage.getItem('theme') || '')
|
|
||||||
: true
|
|
||||||
)
|
|
||||||
|
|
||||||
const location = useLocation()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const prevRoute = sessionStorage.getItem('prevRoute')
|
|
||||||
if (
|
|
||||||
location.pathname !== routePaths.error &&
|
|
||||||
location.pathname !== routePaths.login &&
|
|
||||||
location.pathname !== prevRoute
|
|
||||||
) {
|
|
||||||
sessionStorage.setItem('prevRoute', location.pathname)
|
|
||||||
}
|
|
||||||
}, [location])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTheme(() => (changeTheme ? darkTheme : lightTheme))
|
|
||||||
}, [changeTheme])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="app">
|
|
||||||
<Context.Provider value={{ setTheme, setChangeTheme, changeTheme }}>
|
|
||||||
<ConfigProvider theme={themes} locale={ruRu}>
|
|
||||||
<Routers />
|
|
||||||
</ConfigProvider>
|
|
||||||
</Context.Provider>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
@import 'src/constants/style/styleConst';
|
|
||||||
|
|
||||||
.app-access-content {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 760px;
|
|
||||||
|
|
||||||
padding: $basic-padding * 1.8;
|
|
||||||
border: 1px solid $border-color;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
|
|
||||||
&__action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__main {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns:1fr 1fr;
|
|
||||||
|
|
||||||
|
|
||||||
&__tree-search-input {
|
|
||||||
width: 350px;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.unknown-label {
|
|
||||||
color: $error-red
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export interface AppAccessContentPropsType {
|
|
||||||
id: number
|
|
||||||
paramPrefix: string
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
import { SearchOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, Input, message, Spin, TreeProps } from 'antd'
|
|
||||||
import { ChangeEvent, FC, memo, useEffect, useState } from 'react'
|
|
||||||
import { Navigate, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import AccessListTree from '@widgets/AccessListTree'
|
|
||||||
import SelectedAccessMethod from '@widgets/SelectedAccessMethod'
|
|
||||||
|
|
||||||
import { AppAccessContentPropsType } from '@components/AppAccessContent/app-access-content.type.ts'
|
|
||||||
|
|
||||||
import { setSearchValue } from '@utils/columnLayoutUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import accessListApi from '@services/accessListService.ts'
|
|
||||||
import routeApi from '@services/routeService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { AccessListMethodType, EndpointType } from '@type/accessList.type.ts'
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './app-access-content.scss'
|
|
||||||
|
|
||||||
const unknownMethodKey = 'неизвестные методы'
|
|
||||||
|
|
||||||
const AppAccessContent: FC<AppAccessContentPropsType> = ({
|
|
||||||
id,
|
|
||||||
paramPrefix
|
|
||||||
}) => {
|
|
||||||
const [messageApi, contextHolder] = message.useMessage()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
const canWrite = hasPermission(PermissionKeysType.write)
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: methods = [],
|
|
||||||
isLoading: isMethodsLoading,
|
|
||||||
isError: isMethodsError,
|
|
||||||
isSuccess: isMethodsSuccess
|
|
||||||
} = accessListApi.useGetByIdQuery({ id })
|
|
||||||
const [setList] = accessListApi.useSetListMutation()
|
|
||||||
const [setOne] = accessListApi.useSetOneMutation()
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: routes = {
|
|
||||||
originalResponse: [],
|
|
||||||
moduleEndpoints: {},
|
|
||||||
allRouteMap: {}
|
|
||||||
},
|
|
||||||
isLoading: isRouteLoading,
|
|
||||||
isError: isRouteError,
|
|
||||||
isSuccess: isRouteSuccess
|
|
||||||
} = routeApi.useGetAllRoutesQuery()
|
|
||||||
const { moduleEndpoints, allRouteMap } = routes
|
|
||||||
const [defaultAllRoutes, setDefaultAllRoutes] = useState<
|
|
||||||
Record<string, EndpointType[]>
|
|
||||||
>({})
|
|
||||||
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const searchValue = searchParams.get(paramPrefix) || ''
|
|
||||||
|
|
||||||
const isLoading = isMethodsLoading || isRouteLoading
|
|
||||||
const isError = isMethodsError || isRouteError
|
|
||||||
const isSuccess = isMethodsSuccess && isRouteSuccess
|
|
||||||
|
|
||||||
const openSuccessMessage = (body: string) => {
|
|
||||||
messageApi.success(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
const openErrorMessage = (body: string) => {
|
|
||||||
messageApi.error(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
const createAllMethodList = (status: boolean) => {
|
|
||||||
return Object.keys(allRouteMap).map((key) => {
|
|
||||||
return {
|
|
||||||
method: key,
|
|
||||||
value: status
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const onCheck: TreeProps['onCheck'] = (_, info): void | never[] => {
|
|
||||||
const { node } = info
|
|
||||||
if (!node.children) {
|
|
||||||
const sendData = {
|
|
||||||
appId: id,
|
|
||||||
method: node.key as string,
|
|
||||||
value: !node.checked
|
|
||||||
}
|
|
||||||
setOne(sendData)
|
|
||||||
.then(() => {
|
|
||||||
openSuccessMessage('Статус метода успешно изменен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
openErrorMessage('Не удалось изменить статус метода')
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const newCheckedKeys = node.children.map((child) => ({
|
|
||||||
method: child.key as string,
|
|
||||||
value: !node.checked
|
|
||||||
}))
|
|
||||||
setListMethods(newCheckedKeys)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const { value } = e.target
|
|
||||||
setSearchValue(value.trim().toLowerCase(), setSearchParams, paramPrefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setListMethods = (methods: AccessListMethodType[]) => {
|
|
||||||
setList({
|
|
||||||
appId: id,
|
|
||||||
methods: methods
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
openSuccessMessage('Статус методов успешно изменен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
openErrorMessage('Не удалось изменить статус методов')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const setAllMethods = (status: boolean) => {
|
|
||||||
const methods = createAllMethodList(status)
|
|
||||||
setListMethods(methods)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getAllRoutes = () => {
|
|
||||||
const missingRoute: EndpointType[] = []
|
|
||||||
const copyAllRoutes = { ...moduleEndpoints }
|
|
||||||
|
|
||||||
methods.forEach((item) => {
|
|
||||||
if (!allRouteMap[item.method]) {
|
|
||||||
missingRoute.push({ path: item.method } as EndpointType)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (missingRoute.length) {
|
|
||||||
copyAllRoutes[unknownMethodKey] = missingRoute
|
|
||||||
}
|
|
||||||
return copyAllRoutes
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const allRoutes = getAllRoutes()
|
|
||||||
setDefaultAllRoutes(allRoutes)
|
|
||||||
}, [isSuccess])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return <Navigate to={routePaths.error} />
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="app-access-content">
|
|
||||||
{contextHolder}
|
|
||||||
<div className="app-access-content__header">
|
|
||||||
<Input
|
|
||||||
prefix={<SearchOutlined />}
|
|
||||||
allowClear
|
|
||||||
className="app-access-content__main__tree-search-input"
|
|
||||||
value={searchValue}
|
|
||||||
placeholder="Найти метод"
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
<div className="app-access-content__header__action-buttons">
|
|
||||||
<Button
|
|
||||||
disabled={!canWrite}
|
|
||||||
onClick={() => {
|
|
||||||
setAllMethods(false)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Запретить все
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
disabled={!canWrite}
|
|
||||||
onClick={() => {
|
|
||||||
setAllMethods(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Выбрать все
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="app-access-content__main">
|
|
||||||
<AccessListTree
|
|
||||||
searchValue={searchValue}
|
|
||||||
onCheck={onCheck}
|
|
||||||
defaultAllRoutes={defaultAllRoutes}
|
|
||||||
methods={methods}
|
|
||||||
/>
|
|
||||||
<SelectedAccessMethod
|
|
||||||
unknownMethodKey={unknownMethodKey}
|
|
||||||
methods={methods}
|
|
||||||
allRoutes={defaultAllRoutes}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(AppAccessContent)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
export type AppGroupModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
|
||||||
appGroup?: ApplicationsGroupType
|
|
||||||
onOk: (data: ApplicationsGroupType) => void
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { FC, useEffect } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
const { FormInput, FormTextArea } = FormComponents
|
|
||||||
|
|
||||||
const AppGroupModal: FC<AppGroupModalType> = ({
|
|
||||||
title,
|
|
||||||
onClose,
|
|
||||||
onOk,
|
|
||||||
open,
|
|
||||||
appGroup
|
|
||||||
}) => {
|
|
||||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
|
||||||
mode: 'onChange',
|
|
||||||
defaultValues: appGroup
|
|
||||||
})
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
reset(appGroup)
|
|
||||||
}, [open])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmit(onOk)}
|
|
||||||
title={title}
|
|
||||||
open={open}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormInput
|
|
||||||
control={control}
|
|
||||||
name="name"
|
|
||||||
label="Наименование"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormTextArea
|
|
||||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
|
||||||
control={control}
|
|
||||||
label="Описание"
|
|
||||||
name="description"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AppGroupModal
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
export type AppModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
|
||||||
app?: ApplicationAppType
|
|
||||||
onOk: (data: ApplicationAppType) => void
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { FC, useEffect } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { AppModalType } from '@components/AppModal/app-group-modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
const { FormInput, FormTextArea } = FormComponents
|
|
||||||
|
|
||||||
const AppModal: FC<AppModalType> = ({ title, onOk, onClose, open, app }) => {
|
|
||||||
const { handleSubmit, control, reset } = useForm<ApplicationAppType>({
|
|
||||||
mode: 'onChange',
|
|
||||||
defaultValues: app
|
|
||||||
})
|
|
||||||
useEffect(() => {
|
|
||||||
reset(app)
|
|
||||||
}, [open])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmit(onOk)}
|
|
||||||
title={title}
|
|
||||||
open={open}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormInput
|
|
||||||
control={control}
|
|
||||||
name="name"
|
|
||||||
label="Наименование"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormTextArea
|
|
||||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
|
||||||
control={control}
|
|
||||||
label="Описание"
|
|
||||||
name="description"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AppModal
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.applications-content {
|
|
||||||
height: 100%;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns:min-content 1fr;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.column-content {
|
|
||||||
margin-left: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__add-btn {
|
|
||||||
display: flex;
|
|
||||||
max-width: 240px;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__update-btn {
|
|
||||||
margin-right: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__addToken-btn {
|
|
||||||
display: flex;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link-btn {
|
|
||||||
color: $blue-color;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $text-color-blue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.column {
|
|
||||||
border-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
import { FileProtectOutlined } from '@ant-design/icons'
|
|
||||||
import { List, message, Spin, Tooltip } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
|
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import AppModal from '@components/AppModal'
|
|
||||||
import TokenContent from '@components/TokenContent'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApplicationAppType,
|
|
||||||
ApplicationsServiceType,
|
|
||||||
NewApplicationAppType,
|
|
||||||
UpdateApplicationAppType
|
|
||||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import applicationsApi from '@services/applicationsService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import './applications-content.scss'
|
|
||||||
|
|
||||||
const { EmptyData, Column } = Layout
|
|
||||||
|
|
||||||
interface ApplicationsContentPropTypes {
|
|
||||||
selectedItemId: number
|
|
||||||
currentApplicationsApp: number
|
|
||||||
setCurrentApplicationsApp: Dispatch<SetStateAction<number>>
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
|
||||||
selectedItemId,
|
|
||||||
setCurrentApplicationsApp
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
data: applications = [],
|
|
||||||
isLoading: isLoadingApplicationsContent = []
|
|
||||||
} = applicationsApi.useGetApplicationsByServiceIdQuery({
|
|
||||||
id: selectedItemId
|
|
||||||
})
|
|
||||||
|
|
||||||
const [createApplicationService] =
|
|
||||||
applicationsApi.useCreateApplicationServiceMutation()
|
|
||||||
const [updateApplication] =
|
|
||||||
applicationsApi.useUpdateApplicationsServiceMutation()
|
|
||||||
const [removeApplicationsService] =
|
|
||||||
applicationsApi.useRemoveApplicationsServiceMutation()
|
|
||||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
|
||||||
addModal: false,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams('')
|
|
||||||
const searchAppValue = searchParams.get('appSearch') || ''
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { appId = '' } = useParams()
|
|
||||||
|
|
||||||
const currentApp = useMemo(() => {
|
|
||||||
const element = applications.find(
|
|
||||||
(application) => application.app.id.toString() === appId
|
|
||||||
)
|
|
||||||
return element ? element.app : undefined
|
|
||||||
}, [applications, appId])
|
|
||||||
|
|
||||||
const updateApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const addApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const renderTokenContent = () => {
|
|
||||||
if (!appId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
return <TokenContent key={appId} id={Number(appId)} />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUpdateApplicationApp = (data: ApplicationAppType) => {
|
|
||||||
if (currentApp) {
|
|
||||||
const updateApplications: UpdateApplicationAppType = {
|
|
||||||
id: currentApp.id,
|
|
||||||
name: data.name,
|
|
||||||
description: data.description
|
|
||||||
? data.description
|
|
||||||
: currentApp.description,
|
|
||||||
serviceId: selectedItemId,
|
|
||||||
type: 'SYSTEM'
|
|
||||||
}
|
|
||||||
updateApplication({ ...currentApp, ...updateApplications })
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
message.success('Элемент сохранен')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка обновления элемента'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCreateApplicationApp = (data: ApplicationAppType) => {
|
|
||||||
const newApplicationApp: NewApplicationAppType = {
|
|
||||||
name: data.name,
|
|
||||||
description: data.description,
|
|
||||||
serviceId: selectedItemId,
|
|
||||||
type: 'SYSTEM'
|
|
||||||
}
|
|
||||||
|
|
||||||
createApplicationService(newApplicationApp)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент сохранен')
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка добавления элемента'))
|
|
||||||
}
|
|
||||||
const handleRemoveApplicationApp = (id: number) =>
|
|
||||||
removeApplicationsService([id])
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент удален')
|
|
||||||
navigate(
|
|
||||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка удаления элемента'))
|
|
||||||
|
|
||||||
const renderColumnItems = (item: ColumnItem<any>) => {
|
|
||||||
return (
|
|
||||||
<List.Item>
|
|
||||||
<Tooltip mouseEnterDelay={1.3} title={item.name}>
|
|
||||||
<List.Item.Meta
|
|
||||||
title={item.name}
|
|
||||||
description={<span>id: {item.id}</span>}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
className="link-btn"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
navigate(`/appAccess/${item.id}`)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Tooltip title="Доступы приложений">
|
|
||||||
<FileProtectOutlined />
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
</List.Item>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedItemId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
if (selectedItemId)
|
|
||||||
if (isLoadingApplicationsContent) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="applications-content">
|
|
||||||
<Column
|
|
||||||
title="Приложения"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
onUpdateItem={updateApplicationModal}
|
|
||||||
showUpdateBtn={true}
|
|
||||||
onAddItem={addApplicationModal}
|
|
||||||
onRemoveItem={() => handleRemoveApplicationApp(Number(appId))}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
applications?.map((el) => {
|
|
||||||
return el.app
|
|
||||||
}) as unknown as ColumnItem<ApplicationsServiceType>[],
|
|
||||||
searchAppValue
|
|
||||||
)}
|
|
||||||
renderItems={renderColumnItems}
|
|
||||||
searchValue={searchAppValue}
|
|
||||||
selectedItemId={appId}
|
|
||||||
setSelectedItemId={(itemId: string) => {
|
|
||||||
setCurrentApplicationsApp(Number(itemId))
|
|
||||||
setSelectedItemId(
|
|
||||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`,
|
|
||||||
itemId.toString(),
|
|
||||||
searchAppValue,
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
onChangeSearchValue={(value: string) => {
|
|
||||||
setSearchValue(
|
|
||||||
value.trim().toLowerCase(),
|
|
||||||
setSearchParams,
|
|
||||||
'appSearch'
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{renderTokenContent()}
|
|
||||||
<AppModal
|
|
||||||
app={currentApp}
|
|
||||||
onOk={handleUpdateApplicationApp}
|
|
||||||
title="Редактировать приложение"
|
|
||||||
open={showApplicationsModal.updateModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<AppModal
|
|
||||||
onOk={handleCreateApplicationApp}
|
|
||||||
title="Добавить приложение"
|
|
||||||
open={showApplicationsModal.addModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ApplicationsContent
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { PropsWithChildren } from 'react'
|
|
||||||
|
|
||||||
import { useRole } from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
const CanEdit = ({ children }: PropsWithChildren) => {
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
if (hasPermission(PermissionKeysType.write)) {
|
|
||||||
return <>{children}</>
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CanEdit
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
export type ChangePasswordModalType = {
|
|
||||||
oldPassword: string
|
|
||||||
newPassword: string
|
|
||||||
confirmPassword: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ChangePasswordModalProps = {
|
|
||||||
open: boolean
|
|
||||||
onClose: () => void
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import { message } from 'antd'
|
|
||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { FC, useEffect, useState } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ChangePasswordModalProps,
|
|
||||||
ChangePasswordModalType
|
|
||||||
} from '@components/ChangePasswordModal/change-password-modal.type.ts'
|
|
||||||
|
|
||||||
import { ChangeProfilePassword } from '@pages/ProfilePage/profile-page.type.ts'
|
|
||||||
|
|
||||||
import useLogout from '@hooks/useLogout.tsx'
|
|
||||||
|
|
||||||
import { apiService } from '@services/apiService.ts'
|
|
||||||
|
|
||||||
const { FormInputPassword } = FormComponents
|
|
||||||
const ChangePasswordModal: FC<ChangePasswordModalProps> = ({
|
|
||||||
open,
|
|
||||||
onClose
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
control,
|
|
||||||
handleSubmit,
|
|
||||||
setError,
|
|
||||||
clearErrors,
|
|
||||||
watch,
|
|
||||||
reset,
|
|
||||||
trigger
|
|
||||||
} = useForm<ChangePasswordModalType>({
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
const [loading, setLoading] = useState(false)
|
|
||||||
const { logoutUser } = useLogout()
|
|
||||||
|
|
||||||
const onSubmit = async (formValue: ChangePasswordModalType) => {
|
|
||||||
setLoading(true)
|
|
||||||
try {
|
|
||||||
await apiService.post<ChangeProfilePassword>(apiPaths.changePassword, {
|
|
||||||
oldPassword: formValue.oldPassword,
|
|
||||||
newPassword: formValue.newPassword
|
|
||||||
})
|
|
||||||
await logoutUser()
|
|
||||||
message.success('Пароль успешно изменен')
|
|
||||||
clearErrors('oldPassword')
|
|
||||||
onClose()
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error.response.data.errorCode === 1001) {
|
|
||||||
setError('oldPassword', {
|
|
||||||
message: 'Не верный текущий пароль'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
|
||||||
onClose()
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmPassword = watch('confirmPassword')
|
|
||||||
const newPassword = watch('newPassword')
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
trigger('newPassword')
|
|
||||||
trigger('confirmPassword')
|
|
||||||
}, [newPassword, confirmPassword])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
title="Сменить пароль"
|
|
||||||
open={open}
|
|
||||||
onClose={handleCloseModal}
|
|
||||||
onOk={handleSubmit(onSubmit)}
|
|
||||||
footer={{ onOkText: 'Изменить пароль', onCanselText: 'Отмена' }}
|
|
||||||
loading={loading}
|
|
||||||
>
|
|
||||||
<form key="change-pass-modal">
|
|
||||||
<FormInputPassword
|
|
||||||
rules={{
|
|
||||||
required: { value: true, message: 'Поле не может быть пустым' }
|
|
||||||
}}
|
|
||||||
label="Текущий пароль"
|
|
||||||
control={control}
|
|
||||||
name="oldPassword"
|
|
||||||
/>
|
|
||||||
<FormInputPassword
|
|
||||||
rules={{
|
|
||||||
required: { value: true, message: 'Поле не может быть пустым' },
|
|
||||||
validate: (value) => {
|
|
||||||
return value === confirmPassword || 'Пароли не совпадают'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
label="Новый пароль"
|
|
||||||
control={control}
|
|
||||||
name="newPassword"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormInputPassword
|
|
||||||
rules={{
|
|
||||||
required: { value: true, message: 'Поле не может быть пустым' },
|
|
||||||
validate: (value) => {
|
|
||||||
if (value !== newPassword) return 'Пароли не совпадают'
|
|
||||||
if (!value) return 'Поле не может быть пустым'
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
label="Подтвердите пароль"
|
|
||||||
control={control}
|
|
||||||
name="confirmPassword"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default ChangePasswordModal
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.compare-version-modal {
|
|
||||||
.modal__wrap {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
justify-content: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__content {
|
|
||||||
overflow: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
margin-top: $basic-margin;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
.monaco-diff-editor {
|
|
||||||
overflow-y: scroll;
|
|
||||||
height: calc(90vh - 150px) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow-y: auto;
|
|
||||||
height: calc(90vh - 50px);
|
|
||||||
|
|
||||||
&__row {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
export interface CompareVersionModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
config: Record<string, any>
|
|
||||||
currentConfigId: string
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import { DiffEditor } from '@monaco-editor/react'
|
|
||||||
import { Button, Spin, Table } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { FC, memo, useContext, useState } from 'react'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { CompareVersionModalPropsType } from '@components/CompareVersionModal/compare-version-modal.type'
|
|
||||||
|
|
||||||
import { sortObject } from '@utils/objectUtils.ts'
|
|
||||||
|
|
||||||
import { useAppSelector } from '@hooks/redux.ts'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
import userServiceApi from '@services/userService.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import { VersionType } from '@type/version.type'
|
|
||||||
|
|
||||||
import './compare-version-modal.scss'
|
|
||||||
|
|
||||||
const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
config,
|
|
||||||
currentConfigId
|
|
||||||
}) => {
|
|
||||||
const [selectedItem, setSelectedItem] = useState<VersionType>()
|
|
||||||
const { data: versions = [], isLoading: isVersionLoading } =
|
|
||||||
configServiceApi.useGetAllVersionQuery(currentConfigId)
|
|
||||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
|
||||||
userServiceApi.useGetAllUsersQuery()
|
|
||||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
|
||||||
const { changeTheme } = useContext(Context)
|
|
||||||
const isLoading = isVersionLoading || isUsersLoading
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType<VersionType> = [
|
|
||||||
{
|
|
||||||
key: 'configVersion',
|
|
||||||
title: 'Версия',
|
|
||||||
dataIndex: 'configVersion'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'createdAt',
|
|
||||||
title: 'Создано',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
render: (value: string) => {
|
|
||||||
return dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'user',
|
|
||||||
title: 'Автор',
|
|
||||||
dataIndex: 'adminId',
|
|
||||||
render: (value: number) => {
|
|
||||||
const user = allUsers.find((user) => user.id === value)
|
|
||||||
if (user) {
|
|
||||||
return `${user.lastName} ${user.firstName}`
|
|
||||||
}
|
|
||||||
return `${profile.lastName} ${profile.firstName}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
return (
|
|
||||||
<div className="compare-version-modal">
|
|
||||||
<Modal
|
|
||||||
title="Выберите версию для сравнения"
|
|
||||||
open={open}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{selectedItem ? (
|
|
||||||
<div className="compare-version-modal__content">
|
|
||||||
<Button onClick={() => setSelectedItem(undefined)}>Назад</Button>
|
|
||||||
<div className="compare-version-modal__header">
|
|
||||||
<span> Версия: {selectedItem.configVersion}</span>
|
|
||||||
<span>
|
|
||||||
{config?.version
|
|
||||||
? `Текущая версия : ${config?.version}`
|
|
||||||
: `Версия: ${config?.configVersion}`}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<DiffEditor
|
|
||||||
original={JSON.stringify(sortObject(selectedItem.data), null, 2)}
|
|
||||||
modified={JSON.stringify(sortObject(config?.data), null, 2)}
|
|
||||||
theme={changeTheme ? 'vs-dark' : 'vs-white'}
|
|
||||||
options={{
|
|
||||||
readOnly: true,
|
|
||||||
domReadOnly: true,
|
|
||||||
renderOverviewRuler: false,
|
|
||||||
autoClosingOvertype: 'auto'
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="compare-version-modal__content__table">
|
|
||||||
<Table
|
|
||||||
size="small"
|
|
||||||
columns={columns}
|
|
||||||
pagination={{ pageSize: 30 }}
|
|
||||||
dataSource={versions}
|
|
||||||
rowKey={(record) => record.id}
|
|
||||||
onRow={(record) => {
|
|
||||||
return {
|
|
||||||
onClick: () => setSelectedItem(record)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(CompareVersionModal)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ConfigSchemaModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
schema?: JSONSchema
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.config-schema-modal {
|
|
||||||
.modal__wrap {
|
|
||||||
min-width: 880px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-schema-view {
|
|
||||||
padding: $basic-padding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import { FC, memo } from 'react'
|
|
||||||
|
|
||||||
import JsonSchemaViewer from '@widgets/JSONViewer'
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts'
|
|
||||||
|
|
||||||
import './config-schema-modal.scss'
|
|
||||||
|
|
||||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
schema = {}
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<div className="config-schema-modal">
|
|
||||||
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
|
||||||
<JsonSchemaViewer schema={schema} />
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ConfigSchemaModal)
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import Editor from '@monaco-editor/react'
|
|
||||||
import { FC, useContext } from 'react'
|
|
||||||
|
|
||||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({
|
|
||||||
setDisableBtn = () => {},
|
|
||||||
bufConfig,
|
|
||||||
setBufConfig
|
|
||||||
}) => {
|
|
||||||
const { changeTheme } = useContext(Context)
|
|
||||||
|
|
||||||
const handleChange = (data: string | undefined) => {
|
|
||||||
if (data) {
|
|
||||||
try {
|
|
||||||
const newData = {
|
|
||||||
...bufConfig,
|
|
||||||
data: { ...JSON.parse(data) }
|
|
||||||
} as ConfigType
|
|
||||||
setDisableBtn(false)
|
|
||||||
setBufConfig(newData)
|
|
||||||
} catch (error) {
|
|
||||||
setDisableBtn(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Editor
|
|
||||||
width="auto"
|
|
||||||
height="100vh"
|
|
||||||
language="json"
|
|
||||||
theme={changeTheme ? 'vs-dark' : 'vs-white'}
|
|
||||||
value={editorValue}
|
|
||||||
onChange={handleChange}
|
|
||||||
options={{
|
|
||||||
minimap: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
fontSize: 16
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ConfigurationEditorCode
|
|
||||||
@@ -1,317 +0,0 @@
|
|||||||
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'
|
|
||||||
import { Theme as AntDTheme } from '@rjsf/antd'
|
|
||||||
import { withTheme } from '@rjsf/core'
|
|
||||||
import { UiSchema } from '@rjsf/utils'
|
|
||||||
import validator from '@rjsf/validator-ajv8'
|
|
||||||
import {
|
|
||||||
Badge,
|
|
||||||
Button,
|
|
||||||
Tabs,
|
|
||||||
Tooltip,
|
|
||||||
Collapse,
|
|
||||||
Typography,
|
|
||||||
Space
|
|
||||||
} from 'antd'
|
|
||||||
import equal from 'deep-equal'
|
|
||||||
import { createRef, FC, memo, useEffect, useState } from 'react'
|
|
||||||
import { useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ArrayFieldTemplatePropsType,
|
|
||||||
ConfigurationEditorPropsType,
|
|
||||||
DescriptionPropsType,
|
|
||||||
ErrorsObjType,
|
|
||||||
ObjectFieldTemplatePropertyType,
|
|
||||||
ObjectFieldTemplatePropsType,
|
|
||||||
RemoveButtonProps,
|
|
||||||
SortPropType
|
|
||||||
} from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
|
||||||
import { ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import { cleanEmptyParamsObject } from '@utils/objectUtils.ts'
|
|
||||||
|
|
||||||
const { Text: AntdText } = Typography
|
|
||||||
|
|
||||||
const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
|
||||||
bufConfig = {},
|
|
||||||
jsonSchema = {},
|
|
||||||
submitRef
|
|
||||||
}) => {
|
|
||||||
const Form = withTheme(AntDTheme)
|
|
||||||
const sortProps = (a: SortPropType, b: SortPropType) =>
|
|
||||||
a.name.localeCompare(b.name)
|
|
||||||
|
|
||||||
const [formState, setFormState] = useState(bufConfig.data)
|
|
||||||
const { id } = useParams()
|
|
||||||
const formRef = createRef<any>()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!equal(formState, bufConfig.data)) {
|
|
||||||
setFormState(bufConfig.data)
|
|
||||||
}
|
|
||||||
}, [bufConfig.data])
|
|
||||||
|
|
||||||
const uiSchema: UiSchema = {
|
|
||||||
'ui:submitButtonOptions': {
|
|
||||||
norender: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSubmit = (data: any) => {
|
|
||||||
if (!submitRef) return
|
|
||||||
if (
|
|
||||||
!formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
|
||||||
) {
|
|
||||||
submitRef.current = data
|
|
||||||
} else {
|
|
||||||
submitRef.current = data.formData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const forceSubmit = () => {
|
|
||||||
if (formRef.current) {
|
|
||||||
const formData = formRef.current.state.formData
|
|
||||||
|
|
||||||
onSubmit(cleanEmptyParamsObject(formData))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onFormChange = () => {
|
|
||||||
if (!formRef.current) return
|
|
||||||
if (
|
|
||||||
formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
|
||||||
) {
|
|
||||||
formRef?.current?.submit()
|
|
||||||
} else {
|
|
||||||
forceSubmit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Description: FC<DescriptionPropsType> = ({ description }) =>
|
|
||||||
description ? (
|
|
||||||
<span>
|
|
||||||
|
|
||||||
<Tooltip title={description}></Tooltip>
|
|
||||||
</span>
|
|
||||||
) : null
|
|
||||||
|
|
||||||
const getDepth = (id: string) => {
|
|
||||||
if (!id) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return id.split('_').length
|
|
||||||
}
|
|
||||||
|
|
||||||
const ArrayFieldTemplate: FC<ArrayFieldTemplatePropsType> = ({
|
|
||||||
items,
|
|
||||||
onAddClick,
|
|
||||||
canAdd,
|
|
||||||
title,
|
|
||||||
idSchema
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<Collapse defaultActiveKey={idSchema.$id}>
|
|
||||||
<Collapse.Panel
|
|
||||||
key={idSchema.$id}
|
|
||||||
className="collapseArray"
|
|
||||||
header={
|
|
||||||
<Space
|
|
||||||
direction="horizontal"
|
|
||||||
style={{ justifyContent: 'space-between', width: '100%' }}
|
|
||||||
>
|
|
||||||
<Space direction="horizontal">
|
|
||||||
<Tooltip title={title}>
|
|
||||||
<AntdText>{title}</AntdText>
|
|
||||||
</Tooltip>
|
|
||||||
<Badge count={items ? items.length : 0} showZero />
|
|
||||||
<Description description={title} />
|
|
||||||
</Space>
|
|
||||||
{canAdd && (
|
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
icon={<PlusOutlined />}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
onAddClick(e as unknown as MouseEvent)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{items &&
|
|
||||||
items.map((element) => (
|
|
||||||
<div key={element.index} className="collapseArray_item">
|
|
||||||
<div className="collapseArray_item_content">
|
|
||||||
{element.children}
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
icon={<DeleteOutlined />}
|
|
||||||
onClick={element.onDropIndexClick(element.index)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</Collapse.Panel>
|
|
||||||
</Collapse>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const RemoveButton = (props: RemoveButtonProps) => {
|
|
||||||
const { icon, iconType, ...btnProps } = props
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
icon={<DeleteOutlined />}
|
|
||||||
{...btnProps}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const ObjectFieldTemplate: FC<ObjectFieldTemplatePropsType> = (props) => {
|
|
||||||
const { properties, schema, idSchema, onAddClick, activeTabKey, handleTabsChange, title } = props
|
|
||||||
const depth = getDepth(idSchema.$id)
|
|
||||||
|
|
||||||
const renderComplexTabs = (propsComplex: any[]) => {
|
|
||||||
return (
|
|
||||||
propsComplex.map((element) => ({
|
|
||||||
label: schema.properties[element.name]?.title || element.name,
|
|
||||||
key: element.name,
|
|
||||||
children: schema.additionalProperties
|
|
||||||
? (properties.map((element: any) => (
|
|
||||||
<div key={element.content.key} className="collapseArray_item">
|
|
||||||
<div className="collapseArray_item_content">{element.content}</div>
|
|
||||||
</div>
|
|
||||||
)))
|
|
||||||
: <>{element.content}</>
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const propsComplex: ObjectFieldTemplatePropertyType[] = []
|
|
||||||
const propsSimple: ObjectFieldTemplatePropertyType[] = []
|
|
||||||
|
|
||||||
const processProperties = (properties: any) => {
|
|
||||||
properties.forEach((prop: any) => {
|
|
||||||
const fieldType = schema.properties[prop.name]?.type
|
|
||||||
const isComplex = !fieldType || fieldType === 'array' || fieldType === 'object'
|
|
||||||
if (isComplex) {
|
|
||||||
propsComplex.push(prop)
|
|
||||||
} else {
|
|
||||||
propsSimple.push(prop)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!schema.additionalProperties) {
|
|
||||||
properties.sort(sortProps)
|
|
||||||
}
|
|
||||||
processProperties(properties)
|
|
||||||
|
|
||||||
if (idSchema.$id === 'root') {
|
|
||||||
return (
|
|
||||||
<Tabs
|
|
||||||
activeKey={activeTabKey}
|
|
||||||
tabPosition="right"
|
|
||||||
onChange={handleTabsChange}
|
|
||||||
items={[
|
|
||||||
...(propsSimple.length ? [{
|
|
||||||
label: 'Остальные',
|
|
||||||
key: 'General',
|
|
||||||
children: propsSimple.map((element) => element.content)
|
|
||||||
}] : []),
|
|
||||||
...renderComplexTabs(propsComplex)
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (schema.additionalProperties) {
|
|
||||||
return (
|
|
||||||
<Collapse className="collapse" defaultActiveKey={depth > 1 ? '' : idSchema.$id}>
|
|
||||||
<Collapse.Panel
|
|
||||||
key={idSchema.$id}
|
|
||||||
className="configEditor_collapseObject"
|
|
||||||
header={
|
|
||||||
<Space direction="horizontal" style={{ justifyContent: 'space-between', width: '100%' }}>
|
|
||||||
<Space direction="horizontal">
|
|
||||||
<Tooltip title={title}>
|
|
||||||
<AntdText>{title}</AntdText>
|
|
||||||
</Tooltip>
|
|
||||||
</Space>
|
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
icon={<PlusOutlined />}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
onAddClick(schema)()
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{properties.map((element: any) => (
|
|
||||||
<div key={element.content.key} className="collapseArray_item">
|
|
||||||
<div className="collapseArray_item_content">{element.content}</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</Collapse.Panel>
|
|
||||||
</Collapse>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (depth > 2) {
|
|
||||||
return (
|
|
||||||
<Collapse className="collapse" defaultActiveKey={depth > 1 ? '' : idSchema.$id}>
|
|
||||||
<Collapse.Panel
|
|
||||||
key={idSchema.$id}
|
|
||||||
className="configEditor_collapseObject"
|
|
||||||
header={<><Tooltip title={title}>{title}</Tooltip></>}
|
|
||||||
>
|
|
||||||
<>{properties.map((element) => element.content)}</>
|
|
||||||
</Collapse.Panel>
|
|
||||||
</Collapse>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return properties.map((element) => element.content)
|
|
||||||
}
|
|
||||||
|
|
||||||
const transformErrors = (errors: ErrorsObjType[]): ErrorsObjType[] => {
|
|
||||||
if (errors.length > 0) {
|
|
||||||
errors.forEach((error) => {
|
|
||||||
error.message = 'Поле является обязательным'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="configuration-editor-page__form">
|
|
||||||
<Form
|
|
||||||
formContext={{
|
|
||||||
labelCol: { span: 8 },
|
|
||||||
wrapperCol: { span: 30 },
|
|
||||||
layout: 'vertical'
|
|
||||||
}}
|
|
||||||
uiSchema={uiSchema}
|
|
||||||
templates={{
|
|
||||||
ObjectFieldTemplate: ObjectFieldTemplate as any,
|
|
||||||
ArrayFieldTemplate: ArrayFieldTemplate as any,
|
|
||||||
ButtonTemplates: { RemoveButton } as any
|
|
||||||
}}
|
|
||||||
ref={formRef}
|
|
||||||
transformErrors={transformErrors as any}
|
|
||||||
schema={jsonSchema?.schema as ResponseSchemaType}
|
|
||||||
onSubmit={onSubmit}
|
|
||||||
validator={validator}
|
|
||||||
formData={id === 'new' ? {} : formState}
|
|
||||||
onChange={onFormChange}
|
|
||||||
showErrorList={false}
|
|
||||||
></Form>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ConfigurationEditorForm)
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import { Spin } from 'antd'
|
|
||||||
import { ReactJsonView } from 'isp-ui-kit'
|
|
||||||
import { FC, useContext } from 'react'
|
|
||||||
|
|
||||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({
|
|
||||||
bufConfig,
|
|
||||||
setBufConfig,
|
|
||||||
isCurrentConfigLoading
|
|
||||||
}) => {
|
|
||||||
const { changeTheme } = useContext(Context)
|
|
||||||
if (isCurrentConfigLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleEdit = (updated_src: any) => {
|
|
||||||
const newData = {
|
|
||||||
...bufConfig,
|
|
||||||
data: { ...updated_src }
|
|
||||||
}
|
|
||||||
setBufConfig(newData)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ReactJsonView
|
|
||||||
theme={changeTheme ? 'twilight' : ''}
|
|
||||||
onAdd={({ updated_src }: any) => handleEdit(updated_src)}
|
|
||||||
onDelete={({ updated_src }: any) => handleEdit(updated_src)}
|
|
||||||
displayDataTypes={false}
|
|
||||||
displayObjectSize={false}
|
|
||||||
name={null}
|
|
||||||
enableClipboard={true}
|
|
||||||
iconStyle="square"
|
|
||||||
onEdit={({ updated_src }: any) => handleEdit(updated_src)}
|
|
||||||
src={bufConfig?.data}
|
|
||||||
sortKeys={true}
|
|
||||||
collapsed={1}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ConfigurationEditorJson
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
.configuration-preview-modal {
|
|
||||||
.react-json-view {
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
export interface ConfigurationPreviewModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
config: Record<string, any>
|
|
||||||
versionCompare?: boolean
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { ReactJsonView } from 'isp-ui-kit'
|
|
||||||
import { FC, memo, useContext } from 'react'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { ConfigurationPreviewModalPropsType } from '@components/ConfigurationPreviewModal/configuration-preview-modal.type.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import './configuration-preview-modal.scss'
|
|
||||||
|
|
||||||
const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
|
||||||
versionCompare = false,
|
|
||||||
config,
|
|
||||||
open,
|
|
||||||
onClose
|
|
||||||
}) => {
|
|
||||||
const { changeTheme } = useContext(Context)
|
|
||||||
const data = JSON.parse(JSON.stringify(config.data || {}))
|
|
||||||
const configName = versionCompare
|
|
||||||
? `Версия: ${config.configVersion}`
|
|
||||||
: config.name
|
|
||||||
return (
|
|
||||||
<div className="configuration-preview-modal">
|
|
||||||
<Modal title={configName || ''} open={open} onClose={onClose}>
|
|
||||||
<ReactJsonView
|
|
||||||
theme={changeTheme ? 'twilight' : ''}
|
|
||||||
src={data}
|
|
||||||
name={false}
|
|
||||||
sortKeys={true}
|
|
||||||
displayDataTypes={false}
|
|
||||||
editKeys={false}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ConfigurationPreviewModal)
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import { Button } from 'antd'
|
|
||||||
import { Dispatch, FC, SetStateAction } from 'react'
|
|
||||||
import { useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
|
|
||||||
import './confirm-config-modal.scss'
|
|
||||||
|
|
||||||
interface ConfirmModalProps extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
handleSaveClick: (upVersion?: number, unsafe?: boolean) => void
|
|
||||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
|
||||||
currentConfig: ConfigType | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
const ConfirmConfigModal: FC<ConfirmModalProps> = ({
|
|
||||||
currentConfig,
|
|
||||||
setBufConfig,
|
|
||||||
handleSaveClick,
|
|
||||||
onClose = () => null,
|
|
||||||
open
|
|
||||||
}) => {
|
|
||||||
const { id = '' } = useParams()
|
|
||||||
const isNew = id === 'new' ? '' : id
|
|
||||||
|
|
||||||
const { data } = configServiceApi.useGetConfigByIdQuery(isNew)
|
|
||||||
|
|
||||||
const onConfirmHandler = () => {
|
|
||||||
setBufConfig(currentConfig)
|
|
||||||
onClose()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="confirm-config-modal">
|
|
||||||
<Modal
|
|
||||||
title="Версия конфигурации была кем-то изменена"
|
|
||||||
open={open}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
className="confirm-btn danger"
|
|
||||||
type="primary"
|
|
||||||
danger
|
|
||||||
onClick={() => {
|
|
||||||
handleSaveClick(data && data.version)
|
|
||||||
onClose()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Сохранить принудительно
|
|
||||||
</Button>
|
|
||||||
<Button className="confirm-btn" type="primary" onClick={onConfirmHandler}>
|
|
||||||
Принять изменения
|
|
||||||
</Button>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default ConfirmConfigModal
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
.confirm-config-modal {
|
|
||||||
.modal__content {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import { Table } from 'antd'
|
|
||||||
import { FC } from 'react'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
interface ErrorConfigModalProps
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
details?: { [key: string]: string }
|
|
||||||
}
|
|
||||||
|
|
||||||
const ErrorConfigModal: FC<ErrorConfigModalProps> = ({
|
|
||||||
details = {},
|
|
||||||
onClose,
|
|
||||||
open
|
|
||||||
}) => {
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
dataIndex: 'key',
|
|
||||||
key: 'key',
|
|
||||||
render: (text: string) => <span style={{ color: 'red' }}>{text}</span>
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataIndex: 'value',
|
|
||||||
key: 'value'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const data = Object.keys(details).map((key) => ({
|
|
||||||
key,
|
|
||||||
value: details[key]
|
|
||||||
}))
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
title="Несоотвествия схемы конфигурации"
|
|
||||||
open={open}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
dataSource={data}
|
|
||||||
showHeader={false}
|
|
||||||
pagination={false}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ErrorConfigModal
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
const DefaultUser = () => {
|
|
||||||
return (
|
|
||||||
<span role="img" className="anticon ant-menu-item-icon">
|
|
||||||
<svg
|
|
||||||
data-icon="appstore"
|
|
||||||
width="1.5em"
|
|
||||||
height="1.5em"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
||||||
>
|
|
||||||
<rect width="24" height="24" fill="url(#pattern0)" />
|
|
||||||
<defs>
|
|
||||||
<pattern
|
|
||||||
id="pattern0"
|
|
||||||
patternContentUnits="objectBoundingBox"
|
|
||||||
width="1"
|
|
||||||
height="1"
|
|
||||||
>
|
|
||||||
<use xlinkHref="#image0_121_5920" transform="scale(0.0025)" />
|
|
||||||
</pattern>
|
|
||||||
<image
|
|
||||||
id="image0_121_5920"
|
|
||||||
width="400"
|
|
||||||
height="400"
|
|
||||||
xlinkHref="data:image/png;base64,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 truncated
|
|
||||||
/>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DefaultUser
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
import {
|
|
||||||
AppstoreAddOutlined,
|
|
||||||
FileProtectOutlined,
|
|
||||||
ProductOutlined,
|
|
||||||
ProfileOutlined
|
|
||||||
} from '@ant-design/icons'
|
|
||||||
import type { MenuProps } from 'antd'
|
|
||||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
|
||||||
import { useContext, useEffect, useState } from 'react'
|
|
||||||
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
|
|
||||||
import Header from '@widgets/Header'
|
|
||||||
|
|
||||||
import DefaultUser from '@components/Icons/DefaultUser.tsx'
|
|
||||||
import {
|
|
||||||
MenuItemKeysType,
|
|
||||||
MenuItemType,
|
|
||||||
menuKeys
|
|
||||||
} from '@components/Layout/layout.type.ts'
|
|
||||||
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { fetchProfile, fetchUI } from '@stores/redusers/ActionCreators.ts'
|
|
||||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './layout.scss'
|
|
||||||
|
|
||||||
const { Content, Sider } = Layout
|
|
||||||
|
|
||||||
const LayoutComponent = () => {
|
|
||||||
const [collapsed, setCollapsed] = useState<boolean>(
|
|
||||||
LocalStorage.get('menu') === null ? true : LocalStorage.get('menu')
|
|
||||||
)
|
|
||||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
|
||||||
const [loading, setLoading] = useState(true)
|
|
||||||
const dispatch = useAppDispatch()
|
|
||||||
const {
|
|
||||||
status,
|
|
||||||
profile: { firstName }
|
|
||||||
} = useAppSelector((state) => state.profileReducer)
|
|
||||||
const location = useLocation()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
const { theme } = useContext(ConfigProvider.ConfigContext)
|
|
||||||
|
|
||||||
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
|
|
||||||
|
|
||||||
const hideItem = (permission: PermissionKeysType | PermissionKeysType[]) => {
|
|
||||||
if (Array.isArray(permission)) {
|
|
||||||
const result = permission.reduce((acc, currentValue) => {
|
|
||||||
const hasPermissionFunc = hasPermission(currentValue)
|
|
||||||
return hasPermissionFunc || acc
|
|
||||||
}, false)
|
|
||||||
return result ? '' : 'hide-item'
|
|
||||||
}
|
|
||||||
return hasPermission(permission) ? '' : 'hide-item'
|
|
||||||
}
|
|
||||||
const menuItems: MenuItemType[] = [
|
|
||||||
{
|
|
||||||
label: firstName || '',
|
|
||||||
key: 'profile',
|
|
||||||
className: 'user-item',
|
|
||||||
icon: <DefaultUser />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Приложения',
|
|
||||||
key: 'applications_group',
|
|
||||||
className: hideItem([PermissionKeysType.read]),
|
|
||||||
icon: <AppstoreAddOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Доступы приложений',
|
|
||||||
key: 'appAccess',
|
|
||||||
className: hideItem([PermissionKeysType.read]),
|
|
||||||
icon: <FileProtectOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Модули',
|
|
||||||
key: 'modules',
|
|
||||||
className: hideItem(PermissionKeysType.read),
|
|
||||||
icon: <ProductOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Пользователи и роли',
|
|
||||||
key: 'sessionManagement',
|
|
||||||
className: hideItem([
|
|
||||||
PermissionKeysType.user_view,
|
|
||||||
PermissionKeysType.session_view,
|
|
||||||
PermissionKeysType.role_view
|
|
||||||
]),
|
|
||||||
icon: <ProfileOutlined />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: 'Пользователи',
|
|
||||||
key: 'users',
|
|
||||||
className: hideItem(PermissionKeysType.user_view)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Пользовательские сессии',
|
|
||||||
key: 'sessions',
|
|
||||||
className: hideItem(PermissionKeysType.session_view)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Просмотр журналов ИБ',
|
|
||||||
key: 'securityLog',
|
|
||||||
className: hideItem(PermissionKeysType.security_log_view)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Роли',
|
|
||||||
key: 'roles',
|
|
||||||
className: hideItem(PermissionKeysType.role_view)
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
ConfigProvider.config({
|
|
||||||
holderRender: (children) => (
|
|
||||||
<ConfigProvider prefixCls="static" theme={theme}>
|
|
||||||
{children}
|
|
||||||
</ConfigProvider>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}, [theme])
|
|
||||||
useEffect(() => {
|
|
||||||
if (userToken && status === StateProfileStatus.notInit) {
|
|
||||||
dispatch(fetchProfile())
|
|
||||||
dispatch(fetchUI())
|
|
||||||
}
|
|
||||||
}, [userToken, status])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
status === StateProfileStatus.resolved ||
|
|
||||||
status === StateProfileStatus.rejected
|
|
||||||
) {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}, [status])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const menuKey = location.pathname.split('/')[1] as MenuItemKeysType
|
|
||||||
const selectedKey = selectedMenuKeys[0] || ''
|
|
||||||
const menuItem = menuKeys[menuKey]
|
|
||||||
|
|
||||||
if (menuItem && menuKey !== selectedKey) {
|
|
||||||
setSelectedMenuKeys([menuItem.key])
|
|
||||||
if (selectedKey) {
|
|
||||||
setOpenKeys(menuItem.parent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [location.pathname])
|
|
||||||
|
|
||||||
const handlerOnClickMenu: MenuProps['onClick'] = ({ key }): void => {
|
|
||||||
switch (key) {
|
|
||||||
case MenuItemKeysType.profile: {
|
|
||||||
navigate(routePaths.profile)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case MenuItemKeysType.users:
|
|
||||||
navigate(routePaths.users)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.sessions:
|
|
||||||
navigate(routePaths.sessions)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.securityLog:
|
|
||||||
navigate(routePaths.securityLog)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.appAccess:
|
|
||||||
navigate(routePaths.appAccess)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.roles:
|
|
||||||
navigate(routePaths.roles)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.modules:
|
|
||||||
navigate(routePaths.modules)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.applicationsGroup:
|
|
||||||
navigate(routePaths.applicationsGroup)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loading || status === StateProfileStatus.pending) {
|
|
||||||
return <Spin size="large" fullscreen />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status === StateProfileStatus.rejected) {
|
|
||||||
return <Navigate to={routePaths.error} replace />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section>
|
|
||||||
<Layout className="layout" data-cy="homePage">
|
|
||||||
<Sider
|
|
||||||
width="250px"
|
|
||||||
data-cy="aside"
|
|
||||||
theme="light"
|
|
||||||
collapsible
|
|
||||||
collapsed={collapsed}
|
|
||||||
onCollapse={(value) => {
|
|
||||||
LocalStorage.set('menu', value)
|
|
||||||
setCollapsed(value)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Header collapsed={collapsed} />
|
|
||||||
<Menu
|
|
||||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
|
||||||
openKeys={openKeys}
|
|
||||||
selectedKeys={selectedMenuKeys}
|
|
||||||
onClick={handlerOnClickMenu}
|
|
||||||
theme="light"
|
|
||||||
mode="inline"
|
|
||||||
items={menuItems}
|
|
||||||
/>
|
|
||||||
</Sider>
|
|
||||||
<Layout className="site-layout">
|
|
||||||
<Content className="site-layout__content">
|
|
||||||
<Outlet />
|
|
||||||
</Content>
|
|
||||||
</Layout>
|
|
||||||
</Layout>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LayoutComponent
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
@import 'src/constants/style/styleConst';
|
|
||||||
|
|
||||||
.layout {
|
|
||||||
min-height: 100vh !important;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.hide-item {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-spin {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu {
|
|
||||||
border-inline-end: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-title-content {
|
|
||||||
padding-left: 10px
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-item {
|
|
||||||
padding-left: 21px !important;
|
|
||||||
& .ant-menu-submenu-arrow {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
border-bottom: 1px solid var(--ant-color-border);
|
|
||||||
border-radius: 0 !important;
|
|
||||||
|
|
||||||
& .ant-menu-title-content {
|
|
||||||
margin: 0 !important;
|
|
||||||
padding-left: 17px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-inline-collapsed {
|
|
||||||
& .user-item {
|
|
||||||
padding-left: 24px !important;
|
|
||||||
padding-top: 5px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-submenu {
|
|
||||||
.hide-item {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import { MenuProps } from 'antd'
|
|
||||||
|
|
||||||
export enum MenuItemKeysType {
|
|
||||||
users = 'users',
|
|
||||||
sessions = 'sessions',
|
|
||||||
securityLog = 'securityLog',
|
|
||||||
appAccess = 'appAccess',
|
|
||||||
roles = 'roles',
|
|
||||||
logout = 'logout',
|
|
||||||
profile = 'profile',
|
|
||||||
modules = 'modules',
|
|
||||||
applicationsGroup = 'applications_group'
|
|
||||||
}
|
|
||||||
export enum MenuItemLabelsType {
|
|
||||||
users = 'Пользователи',
|
|
||||||
sessions = 'Пользовательские сессии',
|
|
||||||
securityLog = 'Просмотр журналов ИБ',
|
|
||||||
appAccess = 'Доступы приложений',
|
|
||||||
roles = 'Роли',
|
|
||||||
profile = 'Профиль',
|
|
||||||
modules = 'Модули',
|
|
||||||
logout = 'Выход',
|
|
||||||
applications_group = 'Группы приложений'
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MenuItem {
|
|
||||||
key: MenuItemKeysType
|
|
||||||
parent: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
|
|
||||||
[MenuItemKeysType.users]: {
|
|
||||||
key: MenuItemKeysType.users,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.sessions]: {
|
|
||||||
key: MenuItemKeysType.sessions,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.securityLog]: {
|
|
||||||
key: MenuItemKeysType.securityLog,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.appAccess]: {
|
|
||||||
key: MenuItemKeysType.appAccess,
|
|
||||||
parent: ['appAccess']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.roles]: {
|
|
||||||
key: MenuItemKeysType.roles,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.logout]: {
|
|
||||||
key: MenuItemKeysType.logout,
|
|
||||||
parent: ['']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.profile]: {
|
|
||||||
key: MenuItemKeysType.profile,
|
|
||||||
parent: ['']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.modules]: {
|
|
||||||
key: MenuItemKeysType.modules,
|
|
||||||
parent: ['modules']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.applicationsGroup]: {
|
|
||||||
key: MenuItemKeysType.applicationsGroup,
|
|
||||||
parent: ['applicationsGroup']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MenuItemType = Required<MenuProps>['items'][number]
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import { Tabs } from 'antd'
|
|
||||||
import { memo } from 'react'
|
|
||||||
import { useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ModuleTabContent from '@widgets/ModuleTabContent'
|
|
||||||
|
|
||||||
import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts'
|
|
||||||
|
|
||||||
const secondColumnItems = [
|
|
||||||
{
|
|
||||||
key: 'configurations',
|
|
||||||
name: 'Конфигурации'
|
|
||||||
},
|
|
||||||
{ key: 'connections', name: 'Подключения' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const ModuleTabs = ({
|
|
||||||
activeTab,
|
|
||||||
setActiveTab,
|
|
||||||
currentModule
|
|
||||||
}: ModuleTabsPropsType) => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
return (
|
|
||||||
<Tabs
|
|
||||||
activeKey={activeTab}
|
|
||||||
onChange={(activeKey) => {
|
|
||||||
setActiveTab(activeKey)
|
|
||||||
const path = `${selectedItemId}/${activeKey}`
|
|
||||||
navigate(path)
|
|
||||||
}}
|
|
||||||
className="modules-page__tabs"
|
|
||||||
items={secondColumnItems.map((item) => {
|
|
||||||
return {
|
|
||||||
disabled: selectedItemId === '',
|
|
||||||
label: item.name,
|
|
||||||
key: item.key,
|
|
||||||
children: (
|
|
||||||
<div className="modules-page__content">
|
|
||||||
<ModuleTabContent
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
currentModule={currentModule}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ModuleTabs)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ModuleTabsPropsType {
|
|
||||||
activeTab: string
|
|
||||||
setActiveTab: (key: string) => void
|
|
||||||
currentModule: ModuleType | undefined
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import { Descriptions, Spin } from 'antd'
|
|
||||||
|
|
||||||
import { RoleListProps } from '@components/RoleList/role-list.type.ts'
|
|
||||||
|
|
||||||
import roleApi from '@services/roleService.ts'
|
|
||||||
|
|
||||||
import './role-list.scss'
|
|
||||||
|
|
||||||
const RoleList = ({ userRoles }: RoleListProps) => {
|
|
||||||
const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery()
|
|
||||||
const roleIds = new Set(userRoles)
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Descriptions layout="vertical" className="role-list">
|
|
||||||
<Descriptions.Item label="Список ролей">
|
|
||||||
{isLoading ? (
|
|
||||||
<Spin className="spin" />
|
|
||||||
) : (
|
|
||||||
<ul>
|
|
||||||
{roles.map((roleData) => {
|
|
||||||
if (roleIds.has(roleData.id) && roleData.name) {
|
|
||||||
return <li key={roleData.id}>{roleData.name}</li>
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RoleList
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.role-list {
|
|
||||||
.ant-descriptions-item-label {
|
|
||||||
font-size: $text-size-header2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spin {
|
|
||||||
position: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul, li {
|
|
||||||
list-style-position: inside
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
font-size: $text-size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export type RoleListProps = {
|
|
||||||
userRoles: number[]
|
|
||||||
}
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
import { Divider, message, Table } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { Controller, useForm } from 'react-hook-form'
|
|
||||||
import { useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import SaveButton from '@ui/SaveButton'
|
|
||||||
|
|
||||||
import AgreementModal from '@widgets/AgreementModal'
|
|
||||||
|
|
||||||
import { RolesContentPropsType } from '@components/RolesContent/roles-content.type.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './roles-content.scss'
|
|
||||||
|
|
||||||
const newRole: Partial<RoleType> = {
|
|
||||||
externalGroup: '',
|
|
||||||
name: '',
|
|
||||||
permissions: []
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType = [
|
|
||||||
{
|
|
||||||
title: 'Действие',
|
|
||||||
dataIndex: 'name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Ключ в системе',
|
|
||||||
dataIndex: 'key'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
const { FormInput } = FormComponents
|
|
||||||
const RolesContent = ({
|
|
||||||
role,
|
|
||||||
permissions,
|
|
||||||
saveRole,
|
|
||||||
title = 'Редактировать',
|
|
||||||
immutable = false
|
|
||||||
}: RolesContentPropsType) => {
|
|
||||||
const {
|
|
||||||
control,
|
|
||||||
formState: { isDirty },
|
|
||||||
setError,
|
|
||||||
getValues,
|
|
||||||
reset
|
|
||||||
} = useForm<RoleType>({
|
|
||||||
defaultValues: role,
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
const { id: selectedItemId } = useParams()
|
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState<boolean>(false)
|
|
||||||
const isUpdateRole = hasPermission(PermissionKeysType.role_update)
|
|
||||||
const isCreateRole = hasPermission(PermissionKeysType.role_add)
|
|
||||||
|
|
||||||
const isSaveBtnAvailable =
|
|
||||||
selectedItemId === 'new' ? isCreateRole : isUpdateRole
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
reset(newRole)
|
|
||||||
} else {
|
|
||||||
reset(role)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
const handleSubmitForm = (changeMessage: string) => {
|
|
||||||
if (!changeMessage) {
|
|
||||||
message.error('Поле не может быть пустым')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const formValue = getValues()
|
|
||||||
formValue.changeMessage = changeMessage
|
|
||||||
saveRole(formValue, setError)
|
|
||||||
setOpenModal(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderFormTable = () => (
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
name="permissions"
|
|
||||||
render={({ field: { value, onChange } }) => (
|
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
dataSource={permissions}
|
|
||||||
pagination={{ pageSize: 10 }}
|
|
||||||
scroll={{
|
|
||||||
y: 'calc(100vh - 270px)'
|
|
||||||
}}
|
|
||||||
rowSelection={{
|
|
||||||
selectedRowKeys: value,
|
|
||||||
type: 'checkbox',
|
|
||||||
onChange: (selectedRowKeys) => {
|
|
||||||
onChange(selectedRowKeys)
|
|
||||||
},
|
|
||||||
getCheckboxProps: () => ({
|
|
||||||
disabled: immutable
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{openModal && (
|
|
||||||
<AgreementModal
|
|
||||||
open
|
|
||||||
destroyOnClose
|
|
||||||
onCancel={() => setOpenModal(false)}
|
|
||||||
okText="Сохранить"
|
|
||||||
title="Для подтверждения изменений укажите причину"
|
|
||||||
description="Основание для измений"
|
|
||||||
onConfirm={handleSubmitForm}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<form className="roles-content">
|
|
||||||
<div className="roles-content__header">
|
|
||||||
<h2
|
|
||||||
data-cy="roles-content__header__title"
|
|
||||||
className="roles-content__header__title"
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</h2>
|
|
||||||
<SaveButton
|
|
||||||
disabled={!isDirty || !isSaveBtnAvailable}
|
|
||||||
type="primary"
|
|
||||||
data-cy="roles-content__header__save-button"
|
|
||||||
onClick={() => setOpenModal(true)}
|
|
||||||
className="roles-content__header__save-button"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Divider />
|
|
||||||
<div className="roles-content__wrap-input">
|
|
||||||
<FormInput
|
|
||||||
data-cy="roles-content__input__name"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
label="Наименование роли"
|
|
||||||
name="name"
|
|
||||||
control={control}
|
|
||||||
/>
|
|
||||||
<FormInput
|
|
||||||
data-cy="roles-content__input__external-group"
|
|
||||||
label="Группы ЕСК"
|
|
||||||
name="externalGroup"
|
|
||||||
control={control}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{renderFormTable()}
|
|
||||||
</form>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RolesContent
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.roles-content {
|
|
||||||
padding: $basic-padding*2 $basic-padding*3 0;
|
|
||||||
min-width: 400px;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__wrap-input {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-pagination {
|
|
||||||
margin: 8px 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-divider-horizontal {
|
|
||||||
margin: 14px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { UseFormSetError } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
export interface RolesContentPropsType {
|
|
||||||
role?: Partial<RoleType>
|
|
||||||
title?: string
|
|
||||||
immutable?: boolean
|
|
||||||
permissions: PermissionType[]
|
|
||||||
saveRole: (
|
|
||||||
formValue: RoleType | NewRoleType,
|
|
||||||
setError: UseFormSetError<RoleType | NewRoleType>
|
|
||||||
) => void
|
|
||||||
}
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import ClipboardJS from 'clipboard'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import 'dayjs/locale/ru'
|
|
||||||
import duration from 'dayjs/plugin/duration'
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
||||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import CanEdit from '@components/CanEdit'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApplicationTokenType,
|
|
||||||
NewApplicationTokenType
|
|
||||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
import tokensApi from '@services/tokensService.ts'
|
|
||||||
|
|
||||||
import './tokens.scss'
|
|
||||||
|
|
||||||
const { FormSelect } = FormComponents
|
|
||||||
const { EmptyData } = Layout
|
|
||||||
|
|
||||||
interface TokenPropTypes {
|
|
||||||
id: number
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-named-as-default-member
|
|
||||||
dayjs.locale('ru')
|
|
||||||
dayjs.extend(duration)
|
|
||||||
dayjs.extend(relativeTime)
|
|
||||||
|
|
||||||
const TokenContent = ({ id }: TokenPropTypes) => {
|
|
||||||
const [showApplicationsModal, setShowApplicationsModal] = useState(false)
|
|
||||||
const {
|
|
||||||
handleSubmit: handleSubmitTokens,
|
|
||||||
control: controlTokens,
|
|
||||||
reset
|
|
||||||
} = useForm<ApplicationTokenType>({
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data, isLoading } = tokensApi.useGetTokensByAppIdQuery({ id })
|
|
||||||
const [createToken] = tokensApi.useCreateTokenMutation()
|
|
||||||
const [revokeToken] = tokensApi.useRevokeTokensMutation()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const clipboard = new ClipboardJS('.copy-btn')
|
|
||||||
clipboard.on('success', () => {
|
|
||||||
message.success('Токен скопирован в буфер обмена')
|
|
||||||
})
|
|
||||||
clipboard.on('error', () => {
|
|
||||||
message.error('Ошибка копирования')
|
|
||||||
})
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clipboard.destroy()
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleCreateToken = (data: any) => {
|
|
||||||
if (id) {
|
|
||||||
const newToken: NewApplicationTokenType = {
|
|
||||||
expireTimeMs: data.expireTime,
|
|
||||||
appId: Number(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
createToken(newToken)
|
|
||||||
.then(() => {
|
|
||||||
setShowApplicationsModal(false)
|
|
||||||
reset()
|
|
||||||
message.success('Элемент добавлен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Ошибка добавления элемента')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shortenString(longString: string) {
|
|
||||||
if (longString.length <= 6) {
|
|
||||||
return <span>{longString}</span>
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<span>
|
|
||||||
{longString.slice(0, 3)}...{longString.slice(-3)}
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRevokeToken = (elem: ApplicationTokenType) => {
|
|
||||||
const currentRemoveToken = {
|
|
||||||
appId: id,
|
|
||||||
tokens: [elem.token]
|
|
||||||
}
|
|
||||||
|
|
||||||
revokeToken(currentRemoveToken)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => message.success('Элемент удален'))
|
|
||||||
.catch(() => message.error('Ошибка удаления элемента'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType<ApplicationTokenType> = [
|
|
||||||
{
|
|
||||||
title: 'Токен',
|
|
||||||
dataIndex: 'token',
|
|
||||||
key: 'token',
|
|
||||||
render: (value) => <div>{shortenString(value)}</div>
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Дата/Время выпуска',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
key: 'createdAt',
|
|
||||||
render: (value) => {
|
|
||||||
const formatTime = dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
return <div>{formatTime}</div>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Истекает',
|
|
||||||
dataIndex: 'expireTime',
|
|
||||||
key: 'expireTime',
|
|
||||||
render: (value, record) => {
|
|
||||||
if (value === -1) {
|
|
||||||
return <span>Никогда</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
const dateNow = dayjs()
|
|
||||||
const expireTime = dayjs(record.createdAt).add(value)
|
|
||||||
if (expireTime.isBefore(dateNow)) {
|
|
||||||
return <span>Просрочен</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatTime = expireTime.format(dateFormats.fullFormat)
|
|
||||||
return <span>{formatTime}</span>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Действия',
|
|
||||||
dataIndex: 'token',
|
|
||||||
key: 'actions',
|
|
||||||
render: (value, record) => {
|
|
||||||
return (
|
|
||||||
<Button.Group>
|
|
||||||
<Tooltip title="Скопировать">
|
|
||||||
<Button
|
|
||||||
className="copy-btn"
|
|
||||||
icon={<CopyOutlined />}
|
|
||||||
data-clipboard-text={value}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Удалить">
|
|
||||||
<Popconfirm
|
|
||||||
title="Закончить эту сессию?"
|
|
||||||
onConfirm={() => handleRevokeToken(record)}
|
|
||||||
>
|
|
||||||
<Button icon={<DeleteOutlined />} />
|
|
||||||
</Popconfirm>
|
|
||||||
</Tooltip>
|
|
||||||
</Button.Group>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const tokensOptions = useMemo(
|
|
||||||
() => [
|
|
||||||
{
|
|
||||||
value: -1,
|
|
||||||
label: 'Бессрочно'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 3600000,
|
|
||||||
label: 'Один час'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 86400000,
|
|
||||||
label: 'Один день'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 2592000000,
|
|
||||||
label: '30 дней'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 31536000000,
|
|
||||||
label: 'Один год'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
if (!id) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleShowAddModalToken = () => {
|
|
||||||
setShowApplicationsModal(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="token-content">
|
|
||||||
<div className="token-content__wrap">
|
|
||||||
<header className="token-content__header">
|
|
||||||
<h3>Токены</h3>
|
|
||||||
<CanEdit>
|
|
||||||
<Button
|
|
||||||
className="applications-content__add-btn"
|
|
||||||
type="primary"
|
|
||||||
onClick={handleShowAddModalToken}
|
|
||||||
>
|
|
||||||
Добавить токен
|
|
||||||
</Button>
|
|
||||||
</CanEdit>
|
|
||||||
</header>
|
|
||||||
<div className="token-content__table">
|
|
||||||
<Table
|
|
||||||
className="appliactions-tokent__table"
|
|
||||||
rowKey={(record) => record.createdAt}
|
|
||||||
pagination={false}
|
|
||||||
columns={columns}
|
|
||||||
dataSource={data}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmitTokens(handleCreateToken)}
|
|
||||||
title="Добавить"
|
|
||||||
open={showApplicationsModal}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={() => setShowApplicationsModal(false)}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormSelect
|
|
||||||
options={tokensOptions}
|
|
||||||
name="expireTime"
|
|
||||||
control={controlTokens}
|
|
||||||
label="Время действия"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TokenContent
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.token-content {
|
|
||||||
overflow-x: scroll;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow-x: scroll;
|
|
||||||
height: calc(100vh - 100px);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__wrap {
|
|
||||||
padding: $basic-padding*1.25 $basic-padding*3;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 19px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
font-family: PT Sans, sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
*, html {
|
|
||||||
margin:0;
|
|
||||||
padding:0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app{
|
|
||||||
overflow: hidden;
|
|
||||||
height: 100vh;
|
|
||||||
min-height: 0;
|
|
||||||
min-width: 500px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-btn:focus-visible{
|
|
||||||
outline: none !important;
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
type PathKeys =
|
|
||||||
| 'baseUrl'
|
|
||||||
| 'baseSystemUrl'
|
|
||||||
| 'baseConfigUrl'
|
|
||||||
| 'getAllRoles'
|
|
||||||
| 'createRole'
|
|
||||||
| 'updateRole'
|
|
||||||
| 'deleteRole'
|
|
||||||
| 'login'
|
|
||||||
| 'logout'
|
|
||||||
| 'getProfile'
|
|
||||||
| 'getUsers'
|
|
||||||
| 'createUser'
|
|
||||||
| 'updateUser'
|
|
||||||
| 'blockUser'
|
|
||||||
| 'deleteUser'
|
|
||||||
| 'getRoles'
|
|
||||||
| 'getAllPermissions'
|
|
||||||
| 'baseUserUrl'
|
|
||||||
| 'baseAdminUrl'
|
|
||||||
| 'getAllSession'
|
|
||||||
| 'revokeSession'
|
|
||||||
| 'getAllLogs'
|
|
||||||
| 'getLogEvents'
|
|
||||||
| 'setLogEvents'
|
|
||||||
| 'getSystemTree'
|
|
||||||
| 'getById'
|
|
||||||
| 'setList'
|
|
||||||
| 'setOne'
|
|
||||||
| 'getAllRoutes'
|
|
||||||
| 'getModules'
|
|
||||||
| 'deleteModule'
|
|
||||||
| 'createUpdateService'
|
|
||||||
| 'deleteService'
|
|
||||||
| 'getAllService'
|
|
||||||
| 'getServiceById'
|
|
||||||
| 'getServicesByDomainId'
|
|
||||||
| 'createUpdateApplication'
|
|
||||||
| 'deleteApplication'
|
|
||||||
| 'getApplicationById'
|
|
||||||
| 'getAllApplications'
|
|
||||||
| 'getApplicationsByServiceId'
|
|
||||||
| 'createToken'
|
|
||||||
| 'getTokensByAppId'
|
|
||||||
| 'revokeTokens'
|
|
||||||
| 'revokeTokensForApp'
|
|
||||||
| 'getConfigsByModuleId'
|
|
||||||
| 'getConfigById'
|
|
||||||
| 'getAllVersions'
|
|
||||||
| 'createUpdateConfig'
|
|
||||||
| 'deleteVersion'
|
|
||||||
| 'deleteConfig'
|
|
||||||
| 'markConfigAsActive'
|
|
||||||
| 'getUI'
|
|
||||||
| 'getByModuleId'
|
|
||||||
| 'changePassword'
|
|
||||||
|
|
||||||
export const apiPaths: Record<PathKeys, string> = {
|
|
||||||
baseUrl: '/api/kkd-configuration-service',
|
|
||||||
baseAdminUrl: '/api/admin',
|
|
||||||
baseUserUrl: '/api/admin/user',
|
|
||||||
baseSystemUrl: '/api/system',
|
|
||||||
baseConfigUrl: '/api/config',
|
|
||||||
// ======= ROLES ======
|
|
||||||
getAllRoles: '/role/all',
|
|
||||||
createRole: '/role/create',
|
|
||||||
updateRole: '/role/update',
|
|
||||||
deleteRole: '/role/delete',
|
|
||||||
// ======= AUTH ======
|
|
||||||
login: '/api/admin/auth/login',
|
|
||||||
logout: '/api/admin/auth/logout',
|
|
||||||
// ======= PROFILE ======
|
|
||||||
getProfile: '/api/admin/user/get_profile',
|
|
||||||
getUI: '/api/admin/user/get_design',
|
|
||||||
changePassword: '/api/admin/user/change_password',
|
|
||||||
// ======= USERS ======
|
|
||||||
getUsers: '/get_users',
|
|
||||||
createUser: '/create_user',
|
|
||||||
updateUser: '/update_user',
|
|
||||||
blockUser: '/block_user',
|
|
||||||
deleteUser: '/delete_user',
|
|
||||||
getRoles: '/get_roles',
|
|
||||||
getAllPermissions: '/get_permissions',
|
|
||||||
// ======= SESSIONS ======
|
|
||||||
getAllSession: '/session/all',
|
|
||||||
revokeSession: '/session/revoke',
|
|
||||||
// ======= LOGS ======
|
|
||||||
getAllLogs: '/log/all',
|
|
||||||
getLogEvents: '/log/events',
|
|
||||||
setLogEvents: '/log/set_events',
|
|
||||||
// ======= APPLICATIONS ======
|
|
||||||
getSystemTree: '/application/get_system_tree',
|
|
||||||
getAllApplications: '/application/get_applications',
|
|
||||||
createUpdateApplication: '/application/create_update_application',
|
|
||||||
getApplicationsByServiceId: '/application/get_applications_by_service_id',
|
|
||||||
deleteApplication: '/application/delete_applications',
|
|
||||||
getApplicationById: '/application/get_application_by_id',
|
|
||||||
// ======= ACCESS_LIST ======
|
|
||||||
getById: '/access_list/get_by_id',
|
|
||||||
setList: '/access_list/set_list',
|
|
||||||
setOne: '/access_list/set_one',
|
|
||||||
getAllRoutes: '/routing/get_routes',
|
|
||||||
// ======= MODULES ======
|
|
||||||
getModules: '/module/get_modules_info',
|
|
||||||
deleteModule: '/module/delete_module',
|
|
||||||
getByModuleId: '/schema/get_by_module_id',
|
|
||||||
// ======= SERVICE ======
|
|
||||||
getServiceById: '/service/get_service_by_id',
|
|
||||||
getAllService: '/service/get_service',
|
|
||||||
deleteService: '/service/delete_service',
|
|
||||||
createUpdateService: '/service/create_update_service',
|
|
||||||
getServicesByDomainId: '/service/get_services_by_domain_id',
|
|
||||||
// ======= TOKENS ======
|
|
||||||
createToken: '/token/create_token',
|
|
||||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
|
||||||
revokeTokens: '/token/revoke_tokens',
|
|
||||||
revokeTokensForApp: '/token/revoke_tokens_for_app',
|
|
||||||
// ======= CONFIGS ======
|
|
||||||
getConfigsByModuleId: '/config/get_configs_by_module_id',
|
|
||||||
getConfigById: '/config/get_config_by_id',
|
|
||||||
getAllVersions: '/config/get_all_version',
|
|
||||||
createUpdateConfig: '/config/create_update_config',
|
|
||||||
deleteVersion: '/config/delete_version',
|
|
||||||
deleteConfig: '/config/delete_config',
|
|
||||||
markConfigAsActive: '/config/mark_config_as_active'
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
type FormattersKey = 'fullFormat'
|
|
||||||
|
|
||||||
export const dateFormats: Record<FormattersKey, string> = {
|
|
||||||
fullFormat: 'DD.MM.YYYY HH:mm:ss'
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
type ValidationRulesKeys = 'required'
|
|
||||||
|
|
||||||
export const ValidationRules: Record<ValidationRulesKeys, any> = {
|
|
||||||
required: { value: true, message: 'Поле не может быть пустым' }
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type LocalStorageKeys = 'HEADER_NAME' | 'USER_TOKEN'
|
|
||||||
|
|
||||||
export const localStorageKeys: Record<LocalStorageKeys, string> = {
|
|
||||||
HEADER_NAME: 'HEADER_NAME',
|
|
||||||
USER_TOKEN: 'USER_TOKEN'
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type MessagesKey = 'serverError' | 'loginError'
|
|
||||||
|
|
||||||
export const messages: Record<MessagesKey, string> = {
|
|
||||||
serverError: 'Внутренняя ошибка сервиса',
|
|
||||||
loginError: 'Неверный логин или пароль'
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
export enum SessionStatusKeysType {
|
|
||||||
allowed = 'ALLOWED',
|
|
||||||
revoked = 'REVOKED',
|
|
||||||
expired = 'EXPIRED'
|
|
||||||
}
|
|
||||||
|
|
||||||
export const sessionStatuses: Record<SessionStatusKeysType, string> = {
|
|
||||||
[SessionStatusKeysType.allowed]: 'Активная',
|
|
||||||
[SessionStatusKeysType.revoked]: 'Отмененная',
|
|
||||||
[SessionStatusKeysType.expired]: 'Истекшая'
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
$basic-margin: 8px;
|
|
||||||
$basic-padding: 8px;
|
|
||||||
|
|
||||||
$text-size: 1rem;
|
|
||||||
$text-size-header1: 1.7rem;
|
|
||||||
$text-size-header2: 1.25rem;
|
|
||||||
|
|
||||||
$text-color-gray: var(--ant-layout-header-color);
|
|
||||||
$background-color: var(--ant-layout-light-sider-bg);
|
|
||||||
$grey: #606060;
|
|
||||||
$border-color: var(--ant-color-border);
|
|
||||||
$error-red: #cf1322;
|
|
||||||
|
|
||||||
$blue-color: #40A9FF;
|
|
||||||
$blue-light: #E6F7FF;
|
|
||||||
$text-color-blue: #1890FF;
|
|
||||||
|
|
||||||
$blue-color-2: #bae0ff;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { theme } from 'antd'
|
|
||||||
|
|
||||||
export const darkTheme = {
|
|
||||||
algorithm: theme.darkAlgorithm,
|
|
||||||
cssVar: true,
|
|
||||||
token: {
|
|
||||||
colorBgLayout: '#000000'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const lightTheme = {
|
|
||||||
algorithm: theme.defaultAlgorithm,
|
|
||||||
cssVar: true,
|
|
||||||
token: {
|
|
||||||
colorBgLayout: '#FFFFFF'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
|
||||||
|
|
||||||
import { AppDispatch, RootState } from '../stores'
|
|
||||||
|
|
||||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
|
||||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { useAuth } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
|
|
||||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
const useLogout = () => {
|
|
||||||
const { logout, isLoading } = useAuth()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME)
|
|
||||||
|
|
||||||
const logoutUser = () =>
|
|
||||||
logout(apiPaths.logout, {
|
|
||||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
|
||||||
'APP_TOKEN',
|
|
||||||
import.meta.env.VITE_APP_TOKEN
|
|
||||||
),
|
|
||||||
[headerName]: LocalStorage.get(localStorageKeys.USER_TOKEN)
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
LocalStorage.remove(localStorageKeys.USER_TOKEN)
|
|
||||||
LocalStorage.remove(localStorageKeys.HEADER_NAME)
|
|
||||||
navigate(routePaths.login, { replace: true })
|
|
||||||
})
|
|
||||||
.catch(() => {})
|
|
||||||
return { isLoading, logoutUser }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default useLogout
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { useMemo } from 'react'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import { useAppSelector } from './redux.ts'
|
|
||||||
|
|
||||||
export const useRole = () => {
|
|
||||||
const { profile } = useAppSelector((state: any) => state.profileReducer)
|
|
||||||
const role: string = useMemo(() => profile && profile.role, [profile])
|
|
||||||
|
|
||||||
const hasPermission = (permission: PermissionKeysType) => {
|
|
||||||
const userPermission = profile.permissions || []
|
|
||||||
return userPermission.includes(permission)
|
|
||||||
}
|
|
||||||
|
|
||||||
return { role, hasPermission }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default useRole
|
|
||||||
+3
-5
@@ -10,12 +10,10 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
|
|||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
|
import { AdminBase, baseSetupStore } from 'isp-admin-ui-kit'
|
||||||
|
|
||||||
import App from './components/App.tsx'
|
|
||||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
||||||
|
|
||||||
import { setupStore } from './stores'
|
|
||||||
|
|
||||||
import 'react-resizable/css/styles.css'
|
import 'react-resizable/css/styles.css'
|
||||||
import 'simplebar-react/dist/simplebar.min.css'
|
import 'simplebar-react/dist/simplebar.min.css'
|
||||||
|
|
||||||
@@ -42,14 +40,14 @@ loader.config({ monaco })
|
|||||||
loader.init().then()
|
loader.init().then()
|
||||||
|
|
||||||
dayjs.locale('ru')
|
dayjs.locale('ru')
|
||||||
const store = setupStore()
|
const store = baseSetupStore()
|
||||||
setupListeners(store.dispatch)
|
setupListeners(store.dispatch)
|
||||||
const root = createRoot(document.getElementById('root') as HTMLElement)
|
const root = createRoot(document.getElementById('root') as HTMLElement)
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<App />
|
<AdminBase />
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.all-version-page {
|
|
||||||
padding: $basic-padding*2 0;
|
|
||||||
|
|
||||||
&__back-btn {
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow: auto;
|
|
||||||
height: calc(100vh - 150px);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions-field {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,221 +0,0 @@
|
|||||||
import {
|
|
||||||
DeleteOutlined,
|
|
||||||
EyeOutlined,
|
|
||||||
ReloadOutlined,
|
|
||||||
SwapOutlined
|
|
||||||
} from '@ant-design/icons'
|
|
||||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { Navigate, useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
|
|
||||||
import CanEdit from '@components/CanEdit'
|
|
||||||
import CompareVersionModal from '@components/CompareVersionModal'
|
|
||||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
|
||||||
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import { useAppSelector } from '@hooks/redux.ts'
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
import userServiceApi from '@services/userService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
import { VersionType } from '@type/version.type.ts'
|
|
||||||
|
|
||||||
import './all-versions-page.scss'
|
|
||||||
|
|
||||||
const AllVersionsPage = () => {
|
|
||||||
const [showCompareModal, setShowCompareModal] = useState<boolean>(false)
|
|
||||||
const [showPreviewModal, setShowPreviewModal] = useState<boolean>(false)
|
|
||||||
|
|
||||||
const [currentClickVersion, setCurrentClickVersion] = useState<VersionType>(
|
|
||||||
{} as VersionType
|
|
||||||
)
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id = '', configId = '' } = useParams()
|
|
||||||
const {
|
|
||||||
data: versions = [],
|
|
||||||
isLoading: isVersionLoading,
|
|
||||||
isError: isVersionError
|
|
||||||
} = configServiceApi.useGetAllVersionQuery(configId)
|
|
||||||
const {
|
|
||||||
data: currentConfig,
|
|
||||||
isLoading: isCurrentConfigLoading,
|
|
||||||
isError: isCurrentConfigError
|
|
||||||
} = configServiceApi.useGetConfigByIdQuery(configId)
|
|
||||||
const [deleteVersion] = configServiceApi.useDeleteVersionMutation()
|
|
||||||
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: allUsers = [],
|
|
||||||
isLoading: isUsersLoading,
|
|
||||||
isError: isUsersError
|
|
||||||
} = userServiceApi.useGetAllUsersQuery()
|
|
||||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
|
||||||
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
|
|
||||||
const isLoading = isVersionLoading || isCurrentConfigLoading || isUsersLoading
|
|
||||||
const isError = isVersionError || isCurrentConfigError || isUsersError
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
if (isError) {
|
|
||||||
return <Navigate to={routePaths.error} />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handeRemoveVersion = (versionId: string) => {
|
|
||||||
deleteVersion(versionId)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент успешно удален')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Не удалось удалить элемент')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleRevertVersion = (newData: Record<string, unknown>) => {
|
|
||||||
const sendData = { ...currentConfig, data: newData } as ConfigType
|
|
||||||
createUpdateConfig(sendData)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Версия успешно восстановлена')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Не удалось восстановить версию')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const renderActionsField = (_: unknown, record: VersionType) => {
|
|
||||||
return (
|
|
||||||
<div className="all-version-page__actions-field">
|
|
||||||
<Button.Group className="button_group">
|
|
||||||
<CanEdit>
|
|
||||||
<Tooltip title="Установить выбранную версию">
|
|
||||||
<Popconfirm
|
|
||||||
title="Вы действительно хотите установить выбранную версию ?"
|
|
||||||
onConfirm={() => handleRevertVersion(record.data)}
|
|
||||||
>
|
|
||||||
<Button icon={<ReloadOutlined />} />
|
|
||||||
</Popconfirm>
|
|
||||||
</Tooltip>
|
|
||||||
</CanEdit>
|
|
||||||
<Tooltip title="Просмотр версии">
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentClickVersion(record)
|
|
||||||
setShowPreviewModal(true)
|
|
||||||
}}
|
|
||||||
icon={<EyeOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Сравнение версий">
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setCurrentClickVersion(record)
|
|
||||||
setShowCompareModal(true)
|
|
||||||
}}
|
|
||||||
icon={<SwapOutlined />}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<CanEdit>
|
|
||||||
<Popconfirm
|
|
||||||
title="Вы действительно хотите удалить выбранную версию ?"
|
|
||||||
onConfirm={() => handeRemoveVersion(record.id)}
|
|
||||||
>
|
|
||||||
<Button danger icon={<DeleteOutlined />} />
|
|
||||||
</Popconfirm>
|
|
||||||
</CanEdit>
|
|
||||||
</Button.Group>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
const columns: ColumnsType<VersionType> = [
|
|
||||||
{
|
|
||||||
key: 'configVersion',
|
|
||||||
title: 'Версия',
|
|
||||||
dataIndex: 'configVersion'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'createdAt',
|
|
||||||
title: 'Создано',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
render: (value: string) => {
|
|
||||||
return dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'user',
|
|
||||||
title: 'Автор',
|
|
||||||
dataIndex: 'adminId',
|
|
||||||
render: (value: number) => {
|
|
||||||
const user = allUsers.find((user) => user.id === value)
|
|
||||||
if (user) {
|
|
||||||
return `${user.lastName} ${user.firstName}`
|
|
||||||
}
|
|
||||||
return `${profile.lastName} ${profile.firstName}`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'actions',
|
|
||||||
title: 'Действия',
|
|
||||||
dataIndex: 'actions',
|
|
||||||
render: renderActionsField
|
|
||||||
}
|
|
||||||
]
|
|
||||||
return (
|
|
||||||
<section className="all-version-page">
|
|
||||||
{showPreviewModal && (
|
|
||||||
<ConfigurationPreviewModal
|
|
||||||
versionCompare={true}
|
|
||||||
config={currentClickVersion}
|
|
||||||
open={showPreviewModal}
|
|
||||||
onClose={() => setShowPreviewModal(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showCompareModal && (
|
|
||||||
<CompareVersionModal
|
|
||||||
currentConfigId={currentConfig?.id || ''}
|
|
||||||
config={currentClickVersion}
|
|
||||||
open={showCompareModal}
|
|
||||||
onClose={() => setShowCompareModal(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
className="all-version-page__back-btn"
|
|
||||||
onClick={() => navigate(`${routePaths.modules}/${id}/configurations`)}
|
|
||||||
>
|
|
||||||
Назад
|
|
||||||
</Button>
|
|
||||||
<div className="all-version-page__table">
|
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
dataSource={versions}
|
|
||||||
pagination={{ pageSize: 30 }}
|
|
||||||
rowKey={(record) => record.id}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AllVersionsPage
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.app-access-page {
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
.ant-tree {
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content-wrap {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,113 +0,0 @@
|
|||||||
import { Spin } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { memo, useEffect } from 'react'
|
|
||||||
import {
|
|
||||||
createSearchParams,
|
|
||||||
Navigate,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import ListItem from '@widgets/ListItem'
|
|
||||||
|
|
||||||
import AppAccessContent from '@components/AppAccessContent'
|
|
||||||
|
|
||||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import appApi from '@services/appService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { SystemTreeAppType } from '@type/app.type.ts'
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './app-access-page.scss'
|
|
||||||
|
|
||||||
const { Column, EmptyData } = Layout
|
|
||||||
|
|
||||||
const firstColumnSearchParam = 'search'
|
|
||||||
const findMethodParam = 'method'
|
|
||||||
|
|
||||||
const AppAccessPage = () => {
|
|
||||||
const {
|
|
||||||
data = { originalResponse: [], appList: [] },
|
|
||||||
isLoading,
|
|
||||||
isError
|
|
||||||
} = appApi.useGetSystemTreeQuery()
|
|
||||||
|
|
||||||
const { appList } = data
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const searchValue = searchParams.get(firstColumnSearchParam) || ''
|
|
||||||
const canRead = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!canRead) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [canRead])
|
|
||||||
|
|
||||||
const handleOnChangeSearchValue = (value: string): void => {
|
|
||||||
setSearchValue(value, setSearchParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSelectedItemId = (id: string): void => {
|
|
||||||
setSearchValue('', setSearchParams, findMethodParam)
|
|
||||||
setSelectedItemId(
|
|
||||||
routePaths.appAccess,
|
|
||||||
id,
|
|
||||||
createSearchParams(searchParams).toString(),
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return <Navigate to={routePaths.error} />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="app-access-page">
|
|
||||||
<Column
|
|
||||||
title="Приложения"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
showUpdateBtn={false}
|
|
||||||
showAddBtn={false}
|
|
||||||
showRemoveBtn={false}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
appList as ColumnItem<SystemTreeAppType>,
|
|
||||||
searchValue
|
|
||||||
)}
|
|
||||||
renderItems={(item) => <ListItem item={item} />}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={onSelectedItemId}
|
|
||||||
onChangeSearchValue={handleOnChangeSearchValue}
|
|
||||||
/>
|
|
||||||
<div className="app-access-page__content-wrap">
|
|
||||||
{selectedItemId ? (
|
|
||||||
<AppAccessContent
|
|
||||||
paramPrefix={findMethodParam}
|
|
||||||
key={`content-${selectedItemId}`}
|
|
||||||
id={Number(selectedItemId)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<EmptyData />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(AppAccessPage)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.applications-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
&__list {
|
|
||||||
.ant-list-item {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: self-start;
|
|
||||||
|
|
||||||
.applications-page__list__desc {
|
|
||||||
width: auto !important;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.column-content {
|
|
||||||
max-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__wrap{
|
|
||||||
min-width: 380px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
export interface ApplicationsGroupType {
|
|
||||||
createdAt: string
|
|
||||||
description: string
|
|
||||||
domainId: number
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
updatedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NewApplicationsGroupType = Omit<
|
|
||||||
ApplicationsGroupType,
|
|
||||||
'id' | 'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type UpdateApplicationsGroupType = Omit<
|
|
||||||
ApplicationsGroupType,
|
|
||||||
'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
|
|
||||||
export interface ApplicationsServiceType {
|
|
||||||
app: ApplicationAppType
|
|
||||||
tokens: ApplicationTokenType[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NewApplicationTokenType = {
|
|
||||||
appId: number
|
|
||||||
expireTimeMs: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationAppType {
|
|
||||||
createdAt: string
|
|
||||||
description: string
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
serviceId: number
|
|
||||||
type: string
|
|
||||||
updatedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UpdateApplicationAppType = Omit<
|
|
||||||
ApplicationAppType,
|
|
||||||
'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type NewApplicationAppType = Omit<
|
|
||||||
ApplicationAppType,
|
|
||||||
'id' | 'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type RevokeTokenType = {
|
|
||||||
appId: number
|
|
||||||
tokens: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationTokenType {
|
|
||||||
appId: number
|
|
||||||
createdAt: string
|
|
||||||
expireTime: number
|
|
||||||
token: string
|
|
||||||
}
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
import { message, Spin } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ListItem from '@widgets/ListItem'
|
|
||||||
|
|
||||||
import ApplicationsContent from '@components/ApplicationsContent'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApplicationsGroupType,
|
|
||||||
NewApplicationsGroupType,
|
|
||||||
UpdateApplicationsGroupType
|
|
||||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import AppGroupModal from 'src/components/AppGroupModal'
|
|
||||||
|
|
||||||
import './applications-page.scss'
|
|
||||||
|
|
||||||
const { Column, EmptyData } = Layout
|
|
||||||
|
|
||||||
const ApplicationsPage = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams('')
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
const [currentApplicationsApp, setCurrentApplicationsApp] = useState(0)
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: applicationsGroup = [],
|
|
||||||
isError: isErrorApplicationsGroup,
|
|
||||||
isLoading: isLoadingApplicationsGroup
|
|
||||||
} = applicationsGroupApi.useGetApplicationsGroupByDomainIdQuery({ id: 1 })
|
|
||||||
|
|
||||||
const [createApplicationsGroup] =
|
|
||||||
applicationsGroupApi.useCreateApplicationsGroupMutation()
|
|
||||||
const [updateApplicationsGroup] =
|
|
||||||
applicationsGroupApi.useUpdateApplicationsGroupMutation()
|
|
||||||
|
|
||||||
const [deleteApplicationsGroup] =
|
|
||||||
applicationsGroupApi.useRemoveApplicationsGroupMutation()
|
|
||||||
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
// const hasRevokePermission = hasPermission(PermissionKeysType.write)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
|
|
||||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
|
||||||
addModal: false,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
const searchValue = searchParams.get('search') || ''
|
|
||||||
|
|
||||||
const currentAppGroup = useMemo(
|
|
||||||
() =>
|
|
||||||
applicationsGroup.find((group) => group.id.toString() === selectedItemId),
|
|
||||||
[applicationsGroup, selectedItemId]
|
|
||||||
)
|
|
||||||
|
|
||||||
if (isErrorApplicationsGroup) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoadingApplicationsGroup) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
const addApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddApplicationGroup = (data: ApplicationsGroupType) => {
|
|
||||||
const newService: NewApplicationsGroupType = {
|
|
||||||
name: data.name,
|
|
||||||
description: data.description,
|
|
||||||
domainId: 1
|
|
||||||
}
|
|
||||||
createApplicationsGroup(newService)
|
|
||||||
.unwrap()
|
|
||||||
.then((res) => {
|
|
||||||
setSelectedItemId(
|
|
||||||
`${routePaths.applicationsGroup}`,
|
|
||||||
res.id.toString(),
|
|
||||||
searchValue,
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
message.success('Группа приложений успешно создана')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Не удалось создать группу приложений'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUpdateApplicationsGroup = (data: ApplicationsGroupType) => {
|
|
||||||
const updateService: UpdateApplicationsGroupType = {
|
|
||||||
name: data.name,
|
|
||||||
description: data.description,
|
|
||||||
domainId: 1,
|
|
||||||
id: Number(selectedItemId)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateApplicationsGroup(updateService)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
message.success('Группа приложений успешно отредактирована')
|
|
||||||
})
|
|
||||||
.catch(() =>
|
|
||||||
message.error('Не удалось отредактировать группу приложений')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRemoveApplicationsGtoup = () => {
|
|
||||||
deleteApplicationsGroup([Number(selectedItemId)])
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент удален')
|
|
||||||
navigate(routePaths.applicationsGroup)
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка удаления элемента'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderMainContent = () => {
|
|
||||||
if (!selectedItemId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ApplicationsContent
|
|
||||||
selectedItemId={Number(selectedItemId)}
|
|
||||||
currentApplicationsApp={currentApplicationsApp}
|
|
||||||
setCurrentApplicationsApp={setCurrentApplicationsApp}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<main className="applications-page">
|
|
||||||
<Column
|
|
||||||
title="Группы приложений"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
onUpdateItem={updateApplicationModal}
|
|
||||||
showUpdateBtn={true}
|
|
||||||
onAddItem={addApplicationModal}
|
|
||||||
onRemoveItem={handleRemoveApplicationsGtoup}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
|
|
||||||
searchValue
|
|
||||||
)}
|
|
||||||
renderItems={(item) => <ListItem item={item} />}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={(itemId) => {
|
|
||||||
setCurrentApplicationsApp(0)
|
|
||||||
setSelectedItemId(
|
|
||||||
`${routePaths.applicationsGroup}`,
|
|
||||||
itemId,
|
|
||||||
searchValue,
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
onChangeSearchValue={(value) => setSearchValue(value, setSearchParams)}
|
|
||||||
/>
|
|
||||||
{renderMainContent()}
|
|
||||||
<AppGroupModal
|
|
||||||
onOk={handleAddApplicationGroup}
|
|
||||||
title="Добавить группу приложений"
|
|
||||||
open={showApplicationsModal.addModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<AppGroupModal
|
|
||||||
appGroup={currentAppGroup}
|
|
||||||
title="Редактировать группу приложений"
|
|
||||||
onOk={handleUpdateApplicationsGroup}
|
|
||||||
open={showApplicationsModal.updateModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ApplicationsPage
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
import {
|
|
||||||
ComponentType,
|
|
||||||
Dispatch,
|
|
||||||
MutableRefObject,
|
|
||||||
ReactNode,
|
|
||||||
SetStateAction
|
|
||||||
} from 'react'
|
|
||||||
import { ButtonProps } from 'antd'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ConfigType,
|
|
||||||
ResponseSchemaType
|
|
||||||
} from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ConfigurationEditorPropsType {
|
|
||||||
jsonSchema?: ResponseSchemaType
|
|
||||||
bufConfig: ConfigType
|
|
||||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
|
||||||
isCurrentConfigLoading: boolean
|
|
||||||
setDisableBtn?: Dispatch<SetStateAction<boolean>>
|
|
||||||
submitRef?: MutableRefObject<null>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DescriptionPropsType {
|
|
||||||
description?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Schema {
|
|
||||||
type: string
|
|
||||||
dynamic?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FieldTemplatePropsType {
|
|
||||||
id: string
|
|
||||||
classNames?: string
|
|
||||||
label?: string
|
|
||||||
rawHelp?: string
|
|
||||||
required?: boolean
|
|
||||||
rawDescription?: string
|
|
||||||
rawErrors?: string[]
|
|
||||||
children: ReactNode
|
|
||||||
displayLabel?: boolean
|
|
||||||
schema: Schema
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ArrayFieldTemplatePropsType {
|
|
||||||
items: {
|
|
||||||
index: number
|
|
||||||
children: ReactNode
|
|
||||||
onDropIndexClick: (index: number) => () => void
|
|
||||||
}[]
|
|
||||||
onAddClick: (event: MouseEvent) => void
|
|
||||||
canAdd: boolean
|
|
||||||
title: string
|
|
||||||
titleField?: ComponentType<any>
|
|
||||||
idSchema: { $id: string }
|
|
||||||
schema: { description?: string }
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ObjectFieldTemplatePropertyType {
|
|
||||||
name: string
|
|
||||||
content: ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SchemaPropertiesType {
|
|
||||||
[key: string]: {
|
|
||||||
type?: string
|
|
||||||
title?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ObjectFieldTemplatePropsType {
|
|
||||||
properties: ObjectFieldTemplatePropertyType[]
|
|
||||||
idSchema: {
|
|
||||||
$id: string
|
|
||||||
}
|
|
||||||
schema: {
|
|
||||||
properties: SchemaPropertiesType,
|
|
||||||
additionalProperties: boolean | {type: string}
|
|
||||||
},
|
|
||||||
onAddClick: (schema: any) => () => void,
|
|
||||||
title: string,
|
|
||||||
activeTabKey: string
|
|
||||||
handleTabsChange: (key: string) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RemoveButtonProps extends ButtonProps {
|
|
||||||
icon?: ReactNode;
|
|
||||||
iconType?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ErrorsObjType {
|
|
||||||
message: string
|
|
||||||
name: string
|
|
||||||
params: {
|
|
||||||
missingProperty?: string
|
|
||||||
}
|
|
||||||
property: string
|
|
||||||
schemaPath: string
|
|
||||||
stack: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SortPropType {
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.configuration-editor-page {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
-ms-overflow-style: none; /* IE и Edge */
|
|
||||||
scrollbar-width: none;
|
|
||||||
border-left: 1px solid $border-color;
|
|
||||||
height: 100vh;
|
|
||||||
overflow: scroll;
|
|
||||||
padding-bottom: 80px;
|
|
||||||
|
|
||||||
.ant-tabs-nav {
|
|
||||||
width: 250px;
|
|
||||||
|
|
||||||
.ant-tabs-tab-btn {
|
|
||||||
text-align: left;
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.react-json-view {
|
|
||||||
margin: $basic-margin *3 0 $basic-margin *2 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: $basic-padding *2 $basic-padding;
|
|
||||||
border-bottom: 1px solid $border-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__controll {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__save-btn {
|
|
||||||
width: auto;
|
|
||||||
margin-left: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
padding: $basic-padding * 3 $basic-padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rjsf {
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item-label {
|
|
||||||
text-align: start;
|
|
||||||
max-width: 100%;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
|
|
||||||
label {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-tabs-right {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-col-8 .ant-form-item-label {
|
|
||||||
margin-right: $basic-margin *2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item-row {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapseArray_item_content {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.ant-btn {
|
|
||||||
position: relative;
|
|
||||||
top: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-collapse-header {
|
|
||||||
align-items: center;
|
|
||||||
padding: 4px 11px;
|
|
||||||
|
|
||||||
.ant-collapse-header-text {
|
|
||||||
display: inline;
|
|
||||||
max-width: 100%;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
.ant-btn {
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapseArray_item {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
|
|
||||||
.ant-form-item {
|
|
||||||
height: 100%;
|
|
||||||
align-items: baseline;
|
|
||||||
align-content: end;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.anticon-delete {
|
|
||||||
margin-left: auto;
|
|
||||||
padding-left: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-col-sm-16 {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-col .ant-form-item-control {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item-control-input-content {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 100%;
|
|
||||||
flex: auto;
|
|
||||||
|
|
||||||
.ant-collapse {
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-space-between {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row !important;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
&__plus {
|
|
||||||
margin-left: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.collapseArray_item {
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapse {
|
|
||||||
.configEditor_collapseObject {
|
|
||||||
border-radius: 6px;
|
|
||||||
.ant-row {
|
|
||||||
display: grid;
|
|
||||||
|
|
||||||
grid-template-columns: minmax(0, 30%) minmax(0, 70%) auto;
|
|
||||||
.ant-col {
|
|
||||||
height: 100%;
|
|
||||||
align-content: center;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
|
|
||||||
.ant-form-item {
|
|
||||||
height: 100%;
|
|
||||||
align-items: baseline;
|
|
||||||
align-content: end;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.ant-form-item-row {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-btn-group {
|
|
||||||
margin-top: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-row .ant-row-end {
|
|
||||||
width: 60px;
|
|
||||||
margin: 0 0 $basic-margin auto !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__form {
|
|
||||||
padding: $basic-padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__wrap {
|
|
||||||
min-height: 110px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.confirm-btn {
|
|
||||||
width: auto;
|
|
||||||
min-width: 190px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-data {
|
|
||||||
color: red;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
import { RollbackOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, Dropdown, MenuProps, message, Radio, RadioChangeEvent, Spin } from 'antd'
|
|
||||||
import { FC, useEffect, useRef, useState} from 'react'
|
|
||||||
import { useLocation, useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ConfigurationEditorCode from '@components/ConfigurationEditorCode'
|
|
||||||
import ConfigurationEditorJson from '@components/ConfigurationEditorJson'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import './configuration-editor-page.scss'
|
|
||||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
|
||||||
import { cleanEmptyParamsObject, sortObject } from '@utils/objectUtils.ts'
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
import ConfirmConfigModal from '@components/ConfirmConfigModal/ConfirmConfigModal.tsx'
|
|
||||||
import ErrorConfigModal from '@components/ErrorConfigModal/ErrorConfigModal.tsx'
|
|
||||||
import ConfigurationEditorForm from '@components/ConfigurationEditorForm'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ConfigurationEditorPage: FC = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { moduleId = '' } = useParams()
|
|
||||||
const { id = '' } = useParams()
|
|
||||||
const isNew = id === 'new'
|
|
||||||
const { data: jsonSchema, isLoading: isLoadingJsonSchema } =
|
|
||||||
modulesServiceApi.useGetByModuleIdQuery(moduleId)
|
|
||||||
const {
|
|
||||||
data: currentConfig,
|
|
||||||
isLoading: isCurrentConfigLoading,
|
|
||||||
} = configServiceApi.useGetConfigByIdQuery(id)
|
|
||||||
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
|
||||||
const { state } = useLocation()
|
|
||||||
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
|
||||||
const [showSchemeModal, setShowSchemeModal] = useState(false)
|
|
||||||
const [radioValue, setRadioValue] = useState('json')
|
|
||||||
const [bufConfig, setBufConfig] = useState<ConfigType>()
|
|
||||||
const [detailsErrors, setDetailsError] = useState({ details: {}, isOpenDetailsErrorModal: false })
|
|
||||||
const [disableBtn, setDisableBtn] = useState(false)
|
|
||||||
const submitRef = useRef<any>(null)
|
|
||||||
|
|
||||||
const formRadio = 'form'
|
|
||||||
const codeRadio = 'code'
|
|
||||||
const jsonRadio = 'json'
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setBufConfig(isNew ? {} : sortObject(currentConfig))
|
|
||||||
}, [isCurrentConfigLoading])
|
|
||||||
|
|
||||||
const itemsSaveBtn = [
|
|
||||||
{
|
|
||||||
key: 'save',
|
|
||||||
label: 'Сохранить'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'unsafe',
|
|
||||||
label: 'Сохранить небезопасно'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const onSaveBtn: MenuProps['onClick'] = (e, upVersion = undefined) => {
|
|
||||||
const isUnsafe = e.key === 'unsafe'
|
|
||||||
handleSaveClick(upVersion, isUnsafe, false)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const onRadioChange = (e: RadioChangeEvent) => {
|
|
||||||
if (!bufConfig) return
|
|
||||||
if (submitRef.current && radioValue === formRadio) {
|
|
||||||
setBufConfig({ ...bufConfig, data: { ...submitRef.current } })
|
|
||||||
}
|
|
||||||
setRadioValue(e.target.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSaveClick = (upVersion?: number, unsafe?: boolean, isGoBack?: boolean) => {
|
|
||||||
let newData = {}
|
|
||||||
const sentData =
|
|
||||||
radioValue === formRadio
|
|
||||||
? { ...bufConfig, data: { ...submitRef.current } }
|
|
||||||
: { ...bufConfig }
|
|
||||||
if (bufConfig) {
|
|
||||||
if (isNew) {
|
|
||||||
newData = {
|
|
||||||
name: state.name,
|
|
||||||
moduleId: moduleId,
|
|
||||||
id: '',
|
|
||||||
version: 0,
|
|
||||||
data: sentData.data,
|
|
||||||
unsafe: unsafe
|
|
||||||
} as ConfigType
|
|
||||||
}
|
|
||||||
if (currentConfig) {
|
|
||||||
newData = {
|
|
||||||
...sentData,
|
|
||||||
version: upVersion ? upVersion : currentConfig.version,
|
|
||||||
unsafe: unsafe
|
|
||||||
} as ConfigType
|
|
||||||
}
|
|
||||||
}
|
|
||||||
createUpdateConfig(cleanEmptyParamsObject(newData))
|
|
||||||
.unwrap()
|
|
||||||
.then(({ id }) => {
|
|
||||||
isNew && navigate(`/${moduleId}/configEditor/${id}`)
|
|
||||||
isGoBack && navigate(`/modules/${moduleId}/configurations`)
|
|
||||||
message.success('Конфигурация успешно сохранена')
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
if (e.data.errorCode === 2004) {
|
|
||||||
setShowConfirmModal(true)
|
|
||||||
}
|
|
||||||
if (e.data.errorCode === 2003) {
|
|
||||||
setDetailsError({ details: e.data.details, isOpenDetailsErrorModal: true })
|
|
||||||
}
|
|
||||||
if (e.data.errorCode === 400) {
|
|
||||||
message.error('Невалидный JSON объект')
|
|
||||||
}
|
|
||||||
message.error('Ошибка обновления элемента')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (isLoadingJsonSchema || isCurrentConfigLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const renderContent = () => {
|
|
||||||
|
|
||||||
switch (radioValue) {
|
|
||||||
case formRadio:
|
|
||||||
return (
|
|
||||||
<ConfigurationEditorForm
|
|
||||||
submitRef={submitRef}
|
|
||||||
bufConfig={bufConfig as ConfigType}
|
|
||||||
setBufConfig={setBufConfig}
|
|
||||||
jsonSchema={jsonSchema}
|
|
||||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
|
||||||
setDisableBtn={setDisableBtn}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
case jsonRadio:
|
|
||||||
return (
|
|
||||||
<ConfigurationEditorJson
|
|
||||||
bufConfig={bufConfig as ConfigType}
|
|
||||||
setBufConfig={setBufConfig}
|
|
||||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
case codeRadio:
|
|
||||||
return (
|
|
||||||
<ConfigurationEditorCode
|
|
||||||
setDisableBtn={setDisableBtn}
|
|
||||||
bufConfig={bufConfig as ConfigType}
|
|
||||||
setBufConfig={setBufConfig}
|
|
||||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<main className="configuration-editor-page">
|
|
||||||
<section className="configuration-editor-page__header">
|
|
||||||
<Button onClick={() => navigate(-1)}>
|
|
||||||
<RollbackOutlined />
|
|
||||||
Назад
|
|
||||||
</Button>
|
|
||||||
<h1>{bufConfig?.name}</h1>
|
|
||||||
<div className="configuration-editor-page__controll">
|
|
||||||
<Button
|
|
||||||
disabled={!jsonSchema}
|
|
||||||
className="configurations____buttons__show-schema-btn"
|
|
||||||
onClick={() => setShowSchemeModal(true)}
|
|
||||||
>
|
|
||||||
Текущая схема конфигурации
|
|
||||||
</Button>
|
|
||||||
<Dropdown.Button
|
|
||||||
onClick={() => handleSaveClick(undefined, undefined, true)}
|
|
||||||
disabled={disableBtn}
|
|
||||||
type="primary"
|
|
||||||
className="configuration-editor-page__save-btn"
|
|
||||||
menu={{ items: itemsSaveBtn, onClick: onSaveBtn }}
|
|
||||||
>
|
|
||||||
Сохранить и выйти
|
|
||||||
</Dropdown.Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<div className="configuration-editor-page__content">
|
|
||||||
<Radio.Group defaultValue={jsonRadio} disabled={disableBtn} size="large" onChange={onRadioChange}>
|
|
||||||
<Radio.Button value={formRadio}>Форма</Radio.Button>
|
|
||||||
<Radio.Button disabled={disableBtn} value={jsonRadio}>
|
|
||||||
JSON
|
|
||||||
</Radio.Button>
|
|
||||||
<Radio.Button value={codeRadio}>Редактор кода</Radio.Button>
|
|
||||||
</Radio.Group>
|
|
||||||
|
|
||||||
{renderContent()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<ConfigSchemaModal
|
|
||||||
schema={jsonSchema?.schema}
|
|
||||||
open={showSchemeModal}
|
|
||||||
onClose={() => setShowSchemeModal(false)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ConfirmConfigModal
|
|
||||||
currentConfig={currentConfig}
|
|
||||||
setBufConfig={setBufConfig}
|
|
||||||
open={showConfirmModal}
|
|
||||||
handleSaveClick={handleSaveClick}
|
|
||||||
onClose={() => setShowConfirmModal(false)} />
|
|
||||||
|
|
||||||
<ErrorConfigModal details={detailsErrors.details} open={detailsErrors.isOpenDetailsErrorModal}
|
|
||||||
onClose={() => setDetailsError({details: {}, isOpenDetailsErrorModal: false })} />
|
|
||||||
|
|
||||||
</main>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ConfigurationEditorPage
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.configurations {
|
|
||||||
height: calc(100vh - 80px);
|
|
||||||
width: 100%;
|
|
||||||
overflow-y: auto;
|
|
||||||
min-width: 700px;
|
|
||||||
|
|
||||||
&__buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.active-configurations-table:last-child {
|
|
||||||
margin-top: $basic-margin*3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
import { Button, Spin } from 'antd'
|
|
||||||
import { memo, useEffect, useMemo, useState } from 'react'
|
|
||||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
|
||||||
import CompareVersionModal from '@components/CompareVersionModal'
|
|
||||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
|
||||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
|
||||||
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './configurations.scss'
|
|
||||||
|
|
||||||
const Configurations = () => {
|
|
||||||
const {
|
|
||||||
data: modulesList = [],
|
|
||||||
isLoading: isModulesLoading,
|
|
||||||
isError: isModulesError
|
|
||||||
} = modulesServiceApi.useGetModulesQuery('configurations')
|
|
||||||
const { id: selectedItemId = '', configId = '' } = useParams()
|
|
||||||
const {
|
|
||||||
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
|
||||||
isLoading: isConfigsLoading,
|
|
||||||
isError: isConfigsError
|
|
||||||
} = configServiceApi.useGetConfigsByModuleIdQuery(selectedItemId)
|
|
||||||
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
||||||
const [isShowModalOpen, setisShowModalOpen] = useState(false)
|
|
||||||
const [isCompareModalOpen, setIsCompareModalOpen] = useState(false)
|
|
||||||
|
|
||||||
const [currentConfig, setCurrentConfig] = useState<ConfigType>(
|
|
||||||
{} as ConfigType
|
|
||||||
)
|
|
||||||
const { activeConfigs, inactiveConfigs } = data
|
|
||||||
const currentModule = useMemo(
|
|
||||||
() => modulesList.find((module) => module.id === selectedItemId),
|
|
||||||
[selectedItemId, modulesList]
|
|
||||||
)
|
|
||||||
const isLoading = isModulesLoading || isConfigsLoading
|
|
||||||
const isError = isModulesError || isConfigsError
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configId) {
|
|
||||||
return <Outlet />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="configurations">
|
|
||||||
<ConfigurationPreviewModal
|
|
||||||
config={currentConfig}
|
|
||||||
open={isShowModalOpen}
|
|
||||||
onClose={() => setisShowModalOpen(false)}
|
|
||||||
/>
|
|
||||||
<ConfigSchemaModal
|
|
||||||
schema={currentModule?.configSchema || {}}
|
|
||||||
open={isModalOpen}
|
|
||||||
onClose={() => setIsModalOpen(false)}
|
|
||||||
/>
|
|
||||||
{isCompareModalOpen && (
|
|
||||||
<CompareVersionModal
|
|
||||||
currentConfigId={currentConfig.id}
|
|
||||||
config={currentConfig}
|
|
||||||
open={isCompareModalOpen}
|
|
||||||
onClose={() => setIsCompareModalOpen(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="configurations__buttons">
|
|
||||||
<Button
|
|
||||||
disabled={!currentModule?.configSchema}
|
|
||||||
className="configurations____buttons__show-schema-btn"
|
|
||||||
onClick={() => setIsModalOpen(true)}
|
|
||||||
>
|
|
||||||
Текущая схема
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ActiveConfigurationsTable
|
|
||||||
currentModule={currentModule}
|
|
||||||
isActiveTable
|
|
||||||
data={isError ? [] : activeConfigs}
|
|
||||||
handleShowConfig={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setisShowModalOpen(true)
|
|
||||||
}}
|
|
||||||
handleShowCompareModal={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setIsCompareModalOpen(true)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<ActiveConfigurationsTable
|
|
||||||
currentModule={currentModule}
|
|
||||||
data={isError ? [] : inactiveConfigs}
|
|
||||||
handleShowConfig={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setisShowModalOpen(true)
|
|
||||||
}}
|
|
||||||
handleShowCompareModal={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setIsCompareModalOpen(true)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(Configurations)
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.connection-page {
|
|
||||||
&__content {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__wrap-table {
|
|
||||||
overflow-x: scroll;
|
|
||||||
height: calc(100vh - 70px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__endpoint-list {
|
|
||||||
&__item {
|
|
||||||
height: 25px;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__inner-marker {
|
|
||||||
font-size: 11px;
|
|
||||||
border: 1px solid var(--ant-color-border);
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 0 4px;
|
|
||||||
margin: 4px
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__no-data {
|
|
||||||
user-select: none;
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
font-size: 1.5em;
|
|
||||||
overflow: hidden;
|
|
||||||
font-family: PT Sans, sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
padding: 8px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
|
||||||
&__inner-tag{
|
|
||||||
margin-left: $basic-margin !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
import { Spin, Table, Tag, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
||||||
import { memo, useEffect, useState } from 'react'
|
|
||||||
import { useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
|
|
||||||
import {
|
|
||||||
AddressType,
|
|
||||||
EndpointType,
|
|
||||||
ModuleStatusType,
|
|
||||||
ModuleType
|
|
||||||
} from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './connections.scss'
|
|
||||||
|
|
||||||
const Connections = () => {
|
|
||||||
const { data: ConnectionsList = [], isLoading: isModulesLoading } =
|
|
||||||
modulesServiceApi.useGetModulesQuery('modules')
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id } = useParams()
|
|
||||||
const [obj, setObj] = useState<ModuleStatusType[] | []>([])
|
|
||||||
|
|
||||||
const isLoading = isModulesLoading
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const filterId = ConnectionsList.find((item: ModuleType) => item.id === id)
|
|
||||||
if (filterId && filterId.status) {
|
|
||||||
setObj(filterId.status)
|
|
||||||
}
|
|
||||||
}, [ConnectionsList, id])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatFullDate = (obj: string) =>
|
|
||||||
dayjs(obj).format(dateFormats.fullFormat)
|
|
||||||
|
|
||||||
const renderEndpoints = ({ endpoints }: ModuleStatusType) => {
|
|
||||||
if (endpoints && endpoints.length) {
|
|
||||||
return (
|
|
||||||
<ul className="connection-page__endpoint-list">
|
|
||||||
{endpoints.map(({ path, inner }) => (
|
|
||||||
<li className="connection-page__endpoint-list__item" key={path}>
|
|
||||||
{path}
|
|
||||||
{inner && (
|
|
||||||
<Tag
|
|
||||||
className="connection-page__inner-tag"
|
|
||||||
color="processing"
|
|
||||||
bordered={false}
|
|
||||||
>
|
|
||||||
Внутренний
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="connection-page__no-data">Нет реализованных методов</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType = [
|
|
||||||
{
|
|
||||||
title: '#',
|
|
||||||
dataIndex: '',
|
|
||||||
key: 'num',
|
|
||||||
render: (
|
|
||||||
_val: ModuleStatusType,
|
|
||||||
_record: ModuleStatusType,
|
|
||||||
index: number
|
|
||||||
) => index + 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Версия',
|
|
||||||
dataIndex: 'version',
|
|
||||||
key: 'version'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Версия библиотеки',
|
|
||||||
dataIndex: 'libVersion',
|
|
||||||
key: 'libVersion'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Адрес',
|
|
||||||
dataIndex: 'address',
|
|
||||||
key: 'address',
|
|
||||||
render: (value: AddressType) => `${value.ip}:${value.port}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Соединение установлено',
|
|
||||||
dataIndex: 'establishedAt',
|
|
||||||
key: 'establishedAt',
|
|
||||||
render: (val: string) => {
|
|
||||||
dayjs.extend(relativeTime)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip title={formatFullDate(val)}>{dayjs(val).fromNow()}</Tooltip>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Реализованные методы',
|
|
||||||
dataIndex: 'endpoints',
|
|
||||||
key: 'endpoints',
|
|
||||||
render: (value: EndpointType[]) => (value && value.length) || '0'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="connection-page">
|
|
||||||
<div className="connection-page__content">
|
|
||||||
<div className="connection-page__content__wrap-table">
|
|
||||||
<Table
|
|
||||||
rowKey={(record) => record.id}
|
|
||||||
pagination={false}
|
|
||||||
dataSource={obj}
|
|
||||||
columns={columns}
|
|
||||||
expandable={{
|
|
||||||
expandedRowRender: (i) => renderEndpoints(i)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(Connections)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Button } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
const { ErrorPage } = Layout
|
|
||||||
|
|
||||||
const ErrorWrapperPage = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ErrorPage>
|
|
||||||
<Button type="primary" onClick={() => navigate(routePaths.modules)}>
|
|
||||||
На главную
|
|
||||||
</Button>
|
|
||||||
</ErrorPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ErrorWrapperPage
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
.home-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
background-image: url("/src/assets/images/home-background.png");
|
|
||||||
font-size: calc(1.5vw + 1.5vh);
|
|
||||||
font-family: 'Roboto',sans-serif;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 56px;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import './home-page.scss'
|
|
||||||
|
|
||||||
const HomePage = () => {
|
|
||||||
return <div className="home-page">Добро пожаловать!</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HomePage
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import { LockOutlined, UserOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, Divider, Layout } from 'antd'
|
|
||||||
import { AxiosError } from 'axios'
|
|
||||||
import { FormComponents, useAuth } from 'isp-ui-kit'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
import { messages } from '@constants/messages.ts'
|
|
||||||
|
|
||||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { MSPError } from '@type/index.ts'
|
|
||||||
import { LoginRequest } from '@type/login.type.ts'
|
|
||||||
|
|
||||||
import './login-page.scss'
|
|
||||||
|
|
||||||
const passwordLoginEnabled = getConfigProperty('ENABLE_PASSWORD_LOGIN', true)
|
|
||||||
|
|
||||||
const LoginPage = () => {
|
|
||||||
const { login, isLoading } = useAuth()
|
|
||||||
const { handleSubmit, control, setError } = useForm<LoginRequest>({
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
const setFormError = (statusText: string, message: string): void => {
|
|
||||||
setError('email', {})
|
|
||||||
setError('password', {
|
|
||||||
message,
|
|
||||||
type: statusText
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleError = (err: AxiosError<MSPError>): void => {
|
|
||||||
const { response, status } = err
|
|
||||||
if (response && status === 401) {
|
|
||||||
setFormError(response.statusText, messages.loginError)
|
|
||||||
} else {
|
|
||||||
setFormError('serverError', messages.serverError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmitForm = (data: LoginRequest): void => {
|
|
||||||
login(apiPaths.login, data, {
|
|
||||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
|
||||||
'APP_TOKEN',
|
|
||||||
import.meta.env.VITE_APP_TOKEN
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
LocalStorage.set(localStorageKeys.HEADER_NAME, response.headerName)
|
|
||||||
LocalStorage.set(localStorageKeys.USER_TOKEN, response.token)
|
|
||||||
const redirectUrl =
|
|
||||||
sessionStorage.getItem('prevRoute') || routePaths.home
|
|
||||||
navigate(redirectUrl, { replace: true })
|
|
||||||
})
|
|
||||||
.catch((err: AxiosError<MSPError>) => handleError(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderInternalAuthForm = () => {
|
|
||||||
if (!passwordLoginEnabled) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<FormComponents.FormInput
|
|
||||||
data-cy="email-input"
|
|
||||||
control={control}
|
|
||||||
name="email"
|
|
||||||
className="login-page__content__email-field"
|
|
||||||
prefix={<UserOutlined className="color" />}
|
|
||||||
placeholder="Логин"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormComponents.FormInput
|
|
||||||
data-cy="password-input"
|
|
||||||
control={control}
|
|
||||||
name="password"
|
|
||||||
className="login-page__content__password-field"
|
|
||||||
prefix={<LockOutlined className="color" />}
|
|
||||||
type="password"
|
|
||||||
placeholder="Пароль"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
data-cy="submit-btn"
|
|
||||||
disabled={isLoading}
|
|
||||||
loading={isLoading}
|
|
||||||
type="primary"
|
|
||||||
className="login-page__content__submit-btn"
|
|
||||||
onClick={handleSubmit(handleSubmitForm)}
|
|
||||||
htmlType="submit"
|
|
||||||
>
|
|
||||||
Войти
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Layout>
|
|
||||||
<section className="login-page">
|
|
||||||
<form className="login-page__content">
|
|
||||||
<h1 data-cy="login-title" className="login-page__content__title">
|
|
||||||
Вход в систему
|
|
||||||
</h1>
|
|
||||||
<Divider />
|
|
||||||
{renderInternalAuthForm()}
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
</Layout>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LoginPage
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.login-page {
|
|
||||||
height: 100vh;
|
|
||||||
background: $background-color;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.ant-input {
|
|
||||||
width: 300px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-divider-horizontal {
|
|
||||||
margin-top: $basic-margin !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item-explain-error {
|
|
||||||
margin-bottom: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color {
|
|
||||||
color: $text-color-gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
max-width: 360px;
|
|
||||||
margin: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
&__title {
|
|
||||||
text-align: center;
|
|
||||||
font-family: 'Roboto', sans-serif;
|
|
||||||
font-size: $text-size;
|
|
||||||
line-height: 20px;
|
|
||||||
color: $text-color-gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__submit-sudir-btn {
|
|
||||||
background: #0000000f;
|
|
||||||
margin-top: 4 * $basic-margin;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.09) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.requiredInput::after {
|
|
||||||
content: "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
|
||||||
import { Badge, List, message, Spin, Tag, Tooltip } from 'antd'
|
|
||||||
import { compareVersions } from 'compare-versions'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import {
|
|
||||||
createSearchParams,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import ModuleTabs from '@components/ModuleTabs'
|
|
||||||
|
|
||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './modules-page.scss'
|
|
||||||
|
|
||||||
const { Column } = Layout
|
|
||||||
|
|
||||||
const ModulesPage = () => {
|
|
||||||
const [activeTab, setActiveTab] = useState('configurations')
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const { data: ModulesList = [], isLoading: isModulesLoading } =
|
|
||||||
modulesServiceApi.useGetModulesQuery('modules', {
|
|
||||||
pollingInterval: 5000,
|
|
||||||
skipPollingIfUnfocused: true
|
|
||||||
})
|
|
||||||
const [removeModule] = modulesServiceApi.useRemoveModuleMutation()
|
|
||||||
const location = useLocation()
|
|
||||||
|
|
||||||
const searchValue = searchParams.get('search') || ''
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
const isRemoveModule = hasPermission(PermissionKeysType.write)
|
|
||||||
const isLoading = isModulesLoading
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.profile)
|
|
||||||
message.error('Страница не найдена')
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const url = location.pathname.substring(
|
|
||||||
location.pathname.lastIndexOf('/') + 1
|
|
||||||
)
|
|
||||||
switch (url) {
|
|
||||||
case 'configurations':
|
|
||||||
return setActiveTab('configurations')
|
|
||||||
case 'connections':
|
|
||||||
return setActiveTab('connections')
|
|
||||||
}
|
|
||||||
}, [location])
|
|
||||||
|
|
||||||
const setSelectedItemId = (id: string): void => {
|
|
||||||
if (id) {
|
|
||||||
navigate(
|
|
||||||
{
|
|
||||||
pathname: `${routePaths.modules}/${id}/${activeTab}`,
|
|
||||||
search: createSearchParams(searchParams).toString()
|
|
||||||
},
|
|
||||||
{ replace: true }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOnChangeSearchValue = (value: string): void => {
|
|
||||||
setSearchParams((prev) => {
|
|
||||||
if (!value) {
|
|
||||||
prev.delete('search')
|
|
||||||
} else {
|
|
||||||
prev.set('search', value)
|
|
||||||
}
|
|
||||||
return prev
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRemoveModule = (id: string) => {
|
|
||||||
removeModule(id)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
navigate(routePaths.modules)
|
|
||||||
message.success('Модуль успешно удален').then()
|
|
||||||
setSelectedItemId('')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Не удалось удалить модуль'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const versionCompare = (versions: string[]) => {
|
|
||||||
const sorted = (versions || ['']).sort(compareVersions)
|
|
||||||
const firstVersion = sorted[0]
|
|
||||||
for (let i = 1; i < sorted.length; i++) {
|
|
||||||
if (compareVersions(firstVersion, sorted[i]) !== 0) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const getLastVersion = (versions: string[]) => {
|
|
||||||
const sorted = (versions || ['']).sort(compareVersions)
|
|
||||||
return sorted[sorted.length - 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentModule = ModulesList.find(
|
|
||||||
(item: ModuleType) => item.id.toString() === selectedItemId
|
|
||||||
)
|
|
||||||
|
|
||||||
const renderItems = (item: ModuleType) => {
|
|
||||||
const isSame = versionCompare(item?.status?.map((i) => i.version))
|
|
||||||
const textTooltip = isSame
|
|
||||||
? 'Активны экземпляры одинаковых версий'
|
|
||||||
: 'Активны экземпляры разных версий'
|
|
||||||
const lastVersion = getLastVersion(item.status?.map((i) => i.version))
|
|
||||||
|
|
||||||
const renderVersion = () => {
|
|
||||||
if (!isSame && lastVersion) {
|
|
||||||
return (
|
|
||||||
<Tag icon={<ExclamationCircleOutlined />} color="warning">
|
|
||||||
{lastVersion}
|
|
||||||
</Tag>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (isSame && lastVersion) {
|
|
||||||
return <Tag color="default">{lastVersion}</Tag>
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<List.Item>
|
|
||||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
|
||||||
<List.Item.Meta
|
|
||||||
title={
|
|
||||||
<div className="module-item__name">
|
|
||||||
<span>{item.name}</span>
|
|
||||||
<Tooltip
|
|
||||||
overlayInnerStyle={{ width: '300px' }}
|
|
||||||
title={textTooltip}
|
|
||||||
>
|
|
||||||
{renderVersion()}
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
description={
|
|
||||||
<div className="module-item__content">
|
|
||||||
<span className="module-item__content__description">
|
|
||||||
активные экземпляры:
|
|
||||||
</span>
|
|
||||||
<Badge
|
|
||||||
size="small"
|
|
||||||
showZero
|
|
||||||
count={(item.status && item.status.length) || 0}
|
|
||||||
color={!item.status || !item.status.length ? '' : 'cyan'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</List.Item>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="modules-page">
|
|
||||||
<Column
|
|
||||||
title="Модули"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
items={filterFirstColumnItems(ModulesList, searchValue)}
|
|
||||||
showAddBtn={false}
|
|
||||||
showUpdateBtn={false}
|
|
||||||
showRemoveBtn={isRemoveModule}
|
|
||||||
onRemoveItem={handleRemoveModule}
|
|
||||||
onChangeSearchValue={handleOnChangeSearchValue}
|
|
||||||
renderItems={renderItems}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={setSelectedItemId}
|
|
||||||
/>
|
|
||||||
<ModuleTabs
|
|
||||||
currentModule={currentModule}
|
|
||||||
activeTab={activeTab}
|
|
||||||
setActiveTab={setActiveTab}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ModulesPage
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
export interface RequiredModuleType {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
required: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AddressType {
|
|
||||||
ip: string
|
|
||||||
port: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EndpointType {
|
|
||||||
extra: Record<string, unknown>
|
|
||||||
inner: boolean
|
|
||||||
path: string
|
|
||||||
userAuthRequired: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleStatusType {
|
|
||||||
establishedAt: string
|
|
||||||
libVersion: string
|
|
||||||
version: string
|
|
||||||
address: AddressType
|
|
||||||
endpoints: EndpointType[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConfigType {
|
|
||||||
active: boolean
|
|
||||||
commonConfigs: string[]
|
|
||||||
createdAt: string
|
|
||||||
data: Record<string, unknown>
|
|
||||||
description: string
|
|
||||||
id: string
|
|
||||||
moduleId: string
|
|
||||||
name: string
|
|
||||||
updatedAt: string
|
|
||||||
valid: boolean
|
|
||||||
version: number
|
|
||||||
unsafe?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JSONSchema {
|
|
||||||
$ref?: string
|
|
||||||
$schema?: string
|
|
||||||
additionalItems?: boolean | JSONSchema
|
|
||||||
additionalProperties?: boolean | JSONSchema
|
|
||||||
allOf?: JSONSchema[]
|
|
||||||
anyOf?: JSONSchema[]
|
|
||||||
default?: any
|
|
||||||
definitions?: Record<string, JSONSchema>
|
|
||||||
dependencies?: Record<string, string | string[] | JSONSchema>
|
|
||||||
description?: string
|
|
||||||
enum?: any[]
|
|
||||||
exclusiveMaximum?: boolean
|
|
||||||
exclusiveMinimum?: boolean
|
|
||||||
format?: string
|
|
||||||
items?: JSONSchema | JSONSchema[]
|
|
||||||
maxItems?: number
|
|
||||||
maxLength?: number
|
|
||||||
maxProperties?: number
|
|
||||||
maximum?: number
|
|
||||||
media?: JSONSchema
|
|
||||||
minItems?: number
|
|
||||||
minLength?: number
|
|
||||||
minProperties?: number
|
|
||||||
minimum?: number
|
|
||||||
multipleOf?: number
|
|
||||||
not?: JSONSchema
|
|
||||||
oneOf?: JSONSchema[]
|
|
||||||
pattern?: string
|
|
||||||
patternProperties?: Record<string, JSONSchema>
|
|
||||||
properties?: Record<string, JSONSchema>
|
|
||||||
required?: string[]
|
|
||||||
title?: string
|
|
||||||
type?: string | string[]
|
|
||||||
uniqueItems?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleType {
|
|
||||||
active: boolean
|
|
||||||
configs: ConfigType[]
|
|
||||||
createdAt: string
|
|
||||||
id: string
|
|
||||||
lastConnectedAt: string
|
|
||||||
lastDisconnectedAt: string
|
|
||||||
name: string
|
|
||||||
requiredModules: RequiredModuleType[]
|
|
||||||
status: ModuleStatusType[]
|
|
||||||
configSchema: JSONSchema
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResponseSchemaType {
|
|
||||||
createdAt: string
|
|
||||||
id: string
|
|
||||||
moduleId: string
|
|
||||||
schema: JSONSchema
|
|
||||||
updatedAt: string
|
|
||||||
version: string
|
|
||||||
}
|
|
||||||
export interface ConfigResponse {
|
|
||||||
originalResponse: ConfigType[]
|
|
||||||
activeConfigs: ConfigType[]
|
|
||||||
inactiveConfigs: ConfigType[]
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.modules-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
&__tabs {
|
|
||||||
padding: 0 $basic-padding*2;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-tag {
|
|
||||||
height: 22px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.module-item {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
display: flex;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
&__description {
|
|
||||||
color: $grey;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
overflow-x: scroll;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.column .column__items__item span {
|
|
||||||
width: fit-content !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import { Button } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
const { NotFoundPage } = Layout
|
|
||||||
|
|
||||||
const NotFound = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
return (
|
|
||||||
<NotFoundPage>
|
|
||||||
<Button type="primary" onClick={() => navigate(routePaths.home)}>
|
|
||||||
На главную
|
|
||||||
</Button>
|
|
||||||
</NotFoundPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NotFound
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
import { Button, Descriptions, Popconfirm } from 'antd'
|
|
||||||
import { useContext, useEffect, useState } from 'react'
|
|
||||||
|
|
||||||
import PermissionList from '@widgets/PermissionList'
|
|
||||||
|
|
||||||
import ChangePasswordModal from '@components/ChangePasswordModal'
|
|
||||||
import RoleList from '@components/RoleList'
|
|
||||||
|
|
||||||
import { useAppSelector } from '@hooks/redux.ts'
|
|
||||||
import useLogout from '@hooks/useLogout.tsx'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import './profile-page.scss'
|
|
||||||
|
|
||||||
const ProfilePage = () => {
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false)
|
|
||||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
|
||||||
const { logoutUser, isLoading } = useLogout()
|
|
||||||
const { changeTheme, setChangeTheme } = useContext(Context)
|
|
||||||
|
|
||||||
const onChangeTheme = () => {
|
|
||||||
setChangeTheme((prev: any) => !prev)
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
localStorage.setItem('theme', JSON.stringify(changeTheme))
|
|
||||||
}, [changeTheme])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="profile-page">
|
|
||||||
<ChangePasswordModal
|
|
||||||
onClose={() => setIsModalOpen(false)}
|
|
||||||
open={isModalOpen}
|
|
||||||
/>
|
|
||||||
<header className="profile-page__header">
|
|
||||||
<h1 className="profile-page__title">{`${profile.lastName} ${profile.firstName}`}</h1>
|
|
||||||
<Button onClick={onChangeTheme}>Сменить тему</Button>
|
|
||||||
</header>
|
|
||||||
<div className="profile-page__user-info">
|
|
||||||
<div className="profile-page__user-info__email-wrapper">
|
|
||||||
<Descriptions>
|
|
||||||
<Descriptions.Item label="Email">{profile.email}</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<RoleList userRoles={profile.roles} />
|
|
||||||
<PermissionList permissions={profile.permissions} />
|
|
||||||
<div className="profile-page__actions">
|
|
||||||
<Popconfirm
|
|
||||||
okText="Выйти"
|
|
||||||
cancelText="Отмена"
|
|
||||||
title="Вы действительно хотите выйти из профиля?"
|
|
||||||
onConfirm={logoutUser}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
loading={isLoading}
|
|
||||||
disabled={isLoading}
|
|
||||||
className="profile-page__actions__exit-btn"
|
|
||||||
>
|
|
||||||
Выход
|
|
||||||
</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
<Button
|
|
||||||
className="profile-page__actions__change-pass-btn"
|
|
||||||
onClick={() => setIsModalOpen(true)}
|
|
||||||
>
|
|
||||||
Сменить пароль
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProfilePage
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
@import '../../constants/style/styleConst';
|
|
||||||
|
|
||||||
.profile-page {
|
|
||||||
height: 100vh;
|
|
||||||
overflow: auto;
|
|
||||||
border: 1px solid var(--ant-color-border);
|
|
||||||
padding: $basic-padding * 2;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: start;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__title {
|
|
||||||
font-size: $text-size-header1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__user-info {
|
|
||||||
margin-top: $basic-padding;
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: $text-size !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
|
||||||
|
|
||||||
export type ProfileDataType = {
|
|
||||||
email: string
|
|
||||||
firstName: string
|
|
||||||
lastName: string
|
|
||||||
role: string
|
|
||||||
roles: number[]
|
|
||||||
permissions: string[]
|
|
||||||
idleTimeoutMs: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ProfileType = {
|
|
||||||
profile: ProfileDataType
|
|
||||||
status: StateProfileStatus
|
|
||||||
error: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ChangeProfilePassword = {
|
|
||||||
oldPassword: string
|
|
||||||
newPassword: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UIDataType = {
|
|
||||||
name: string
|
|
||||||
primaryColor: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UIType = {
|
|
||||||
ui: UIDataType
|
|
||||||
status: StateProfileStatus
|
|
||||||
error: string
|
|
||||||
}
|
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
import { List, message, Spin, Tooltip } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useEffect } from 'react'
|
|
||||||
import { UseFormSetError } from 'react-hook-form'
|
|
||||||
import {
|
|
||||||
createSearchParams,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import RolesContent from '@components/RolesContent'
|
|
||||||
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import roleApi from '@services/roleService.ts'
|
|
||||||
import userServiceApi from '@services/userService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { NewRoleType, PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './roles-page.scss'
|
|
||||||
import { useAppDispatch } from '@hooks/redux.ts'
|
|
||||||
import { fetchProfile } from '@stores/redusers/ActionCreators.ts'
|
|
||||||
|
|
||||||
const { Column, EmptyData, NoData } = Layout
|
|
||||||
|
|
||||||
const RolesPage = () => {
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const location = useLocation()
|
|
||||||
const fromApp = location.state?.fromApp || false
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const dispatch = useAppDispatch()
|
|
||||||
const searchValue = searchParams.get('search') || ''
|
|
||||||
const { data: permissionList = [], isLoading: isPermissionLoading } =
|
|
||||||
userServiceApi.useGetAllPermissionsQuery()
|
|
||||||
const { data = [], isLoading: isRolesLoading } = roleApi.useGetAllRolesQuery()
|
|
||||||
const [createRole] = roleApi.useCreateRoleMutation()
|
|
||||||
const [updateRole] = roleApi.useUpdateRoleMutation()
|
|
||||||
const [removeRole] = roleApi.useRemoveRoleMutation()
|
|
||||||
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.role_view)
|
|
||||||
const isAddRolePermissions = hasPermission(PermissionKeysType.role_add)
|
|
||||||
const isRemoveRolePermissions = hasPermission(PermissionKeysType.role_delete)
|
|
||||||
const isLoading = isPermissionLoading || isRolesLoading
|
|
||||||
|
|
||||||
const isNew = selectedItemId === 'new'
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!fromApp) {
|
|
||||||
navigate(routePaths.roles)
|
|
||||||
}
|
|
||||||
}, [fromApp])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
const setSelectedItemId = (id: string): void => {
|
|
||||||
navigate(
|
|
||||||
{
|
|
||||||
pathname: `${routePaths.roles}/${id}`,
|
|
||||||
search: createSearchParams(searchParams).toString()
|
|
||||||
},
|
|
||||||
{ replace: true, state: { fromApp: true } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOnChangeSearchValue = (value: string): void => {
|
|
||||||
setSearchParams((prev) => {
|
|
||||||
if (!value) {
|
|
||||||
prev.delete('search')
|
|
||||||
} else {
|
|
||||||
prev.set('search', value)
|
|
||||||
}
|
|
||||||
return prev
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handeOnAddItem = () => setSelectedItemId('new')
|
|
||||||
|
|
||||||
const handleUpdateRole = (
|
|
||||||
formValue: RoleType | NewRoleType,
|
|
||||||
setError: UseFormSetError<RoleType>
|
|
||||||
) => {
|
|
||||||
updateRole(formValue as RoleType)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
dispatch(fetchProfile())
|
|
||||||
message.success('Элемент успешно добавлен').then()
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
const { status } = error
|
|
||||||
if (status === 409) {
|
|
||||||
setError('name', {
|
|
||||||
message: 'Роль с таким названием уже существует'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
message.error('Не удалось сохранить роль')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCreateRole = (
|
|
||||||
formValue: NewRoleType,
|
|
||||||
setError: UseFormSetError<NewRoleType>
|
|
||||||
) => {
|
|
||||||
createRole(formValue)
|
|
||||||
.unwrap()
|
|
||||||
.then((res) => {
|
|
||||||
message.success('Элемент успешно добавлен').then()
|
|
||||||
setSelectedItemId(res.id.toString())
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
const { status } = error
|
|
||||||
if (status === 409) {
|
|
||||||
setError('name', {
|
|
||||||
message: 'Роль с таким названием уже существует'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
message.error('Не удалось добавить роль').then()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRemoveRole = (id: string) => {
|
|
||||||
const idAsNumber = parseInt(id, 10)
|
|
||||||
removeRole(idAsNumber)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент успешно удален').then()
|
|
||||||
setSelectedItemId('')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Не удалось удалить роль'))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentRole = data
|
|
||||||
? data.find((item) => item.id.toString() === selectedItemId)
|
|
||||||
: null
|
|
||||||
const renderItems = (item: RoleType) => (
|
|
||||||
<List.Item data-cy="role-item">
|
|
||||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
|
||||||
<List.Item.Meta
|
|
||||||
title={item.name}
|
|
||||||
description={<span>id: {item.id}</span>}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</List.Item>
|
|
||||||
)
|
|
||||||
|
|
||||||
const renderMainContent = () => {
|
|
||||||
if (isNew) {
|
|
||||||
return (
|
|
||||||
<RolesContent
|
|
||||||
saveRole={handleCreateRole}
|
|
||||||
permissions={permissionList}
|
|
||||||
title="Добавить"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedItemId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentRole) {
|
|
||||||
return <NoData />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<RolesContent
|
|
||||||
immutable={currentRole.immutable}
|
|
||||||
saveRole={handleUpdateRole}
|
|
||||||
permissions={permissionList}
|
|
||||||
role={currentRole}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="roles-page">
|
|
||||||
<Column
|
|
||||||
title="Роли пользователей"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
showUpdateBtn={false}
|
|
||||||
items={filterFirstColumnItems(data, searchValue)}
|
|
||||||
showAddBtn={isAddRolePermissions}
|
|
||||||
showRemoveBtn={isRemoveRolePermissions}
|
|
||||||
onAddItem={handeOnAddItem}
|
|
||||||
onRemoveItem={handleRemoveRole}
|
|
||||||
onChangeSearchValue={handleOnChangeSearchValue}
|
|
||||||
renderItems={renderItems}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={setSelectedItemId}
|
|
||||||
/>
|
|
||||||
<div className="roles-page__content">{renderMainContent()}</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RolesPage
|
|
||||||
Loaded 100 of 177 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user