Compare commits
23
Commits
deploy_branch
...
v0.13.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10347e8e18 | ||
|
|
83a1cd2205 | ||
|
|
5f4a3c55cc | ||
|
|
9be06cd305 | ||
|
|
2ebeb14f0e | ||
|
|
0dbf4b0b07 | ||
|
|
096c2d401d | ||
|
|
2d08128cb7 | ||
|
|
a7906026d5 | ||
|
|
10b4a7223c | ||
|
|
1e3a0edb7d | ||
|
|
6b782f3538 | ||
|
|
19d3a12469 | ||
|
|
151be0e635 | ||
|
|
031a92db3f | ||
|
|
e8dfc2e552 | ||
|
|
36c13e159d | ||
|
|
a922f7e914 | ||
|
|
98ad434b36 | ||
|
|
739a9a3a4b | ||
|
|
2989c66a65 | ||
|
|
a6f4c85231 | ||
|
|
a31c44eb7b |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
PROXY_URL=
|
||||
VITE_APP_TOKEN=
|
||||
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
tsconfig.json
|
||||
public/config.js
|
||||
vite.config.ts
|
||||
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:import/errors",
|
||||
"plugin:import/warnings",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"ignorePatterns": ["node_modules", "build", "generateVersionFile.cjs"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json",
|
||||
"tsconfigRootDir": "./"
|
||||
},
|
||||
"plugins": [
|
||||
"react",
|
||||
"import",
|
||||
"@typescript-eslint",
|
||||
"react-hooks",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"import/no-named-as-default":"off",
|
||||
"prettier/prettier": "off",
|
||||
"quotes": ["error", "single"],
|
||||
"react/jsx-filename-extension": [
|
||||
1,
|
||||
{
|
||||
"extensions": [".js", ".jsx", ".tsx"]
|
||||
}
|
||||
],
|
||||
"react/jsx-one-expression-per-line": "off",
|
||||
"react/prop-types": 0,
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"semi": ["error", "never"],
|
||||
"@typescript-eslint/no-unused-vars": ["off"],
|
||||
"@typescript-eslint/no-explicit-any": ["off", null],
|
||||
"@typescript-eslint/no-non-null-assertion": ["off"],
|
||||
"import/no-unresolved": "error",
|
||||
"no-unused-vars": "off"
|
||||
},
|
||||
"settings": {
|
||||
"import/parsers": {
|
||||
"@typescript-eslint/parser": [".ts", ".tsx"]
|
||||
},
|
||||
"react": {
|
||||
"version": "detect"
|
||||
},
|
||||
"import/resolver": {
|
||||
"typescript": {
|
||||
"alwaysTryTypes": true
|
||||
},
|
||||
"node": {
|
||||
"extensions": [".js", ".jsx", ".ts", ".tsx"],
|
||||
"moduleDirectory": ["node_modules", "src/"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
.idea/
|
||||
dist/
|
||||
build/
|
||||
node_modules/
|
||||
src/**/*.jsx
|
||||
tests/__coverage__/
|
||||
tests/**/*.jsx
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/releases
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
.pnp.*
|
||||
.env
|
||||
version.json
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"quoteProps": "preserve",
|
||||
"arrowParens": "always",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": false,
|
||||
"proseWrap": "never",
|
||||
"htmlWhitespaceSensitivity": "strict",
|
||||
"plugins": ["@trivago/prettier-plugin-sort-imports"],
|
||||
"useTabs": false,
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.tsx",
|
||||
"options": {
|
||||
"parser": "typescript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"importOrder": [
|
||||
"^@core/(.*)$",
|
||||
"^@assets/(.*)$",
|
||||
"^@constants/(.*)$",
|
||||
"^@ui/(.*)$",
|
||||
"^@widgets/(.*)$",
|
||||
"^@components/(.*)$",
|
||||
"^@modules/(.*)$",
|
||||
"^@pages/(.*)$",
|
||||
"^@utils/(.*)$",
|
||||
"^@hooks/(.*)$",
|
||||
"^@services/(.*)$",
|
||||
"^@stores/(.*)$",
|
||||
"^@routes/(.*)$",
|
||||
"^@type/(.*)$",
|
||||
"^./*.*.ts",
|
||||
"^[./]",
|
||||
"^./*.*.(scss|css)"
|
||||
],
|
||||
"importOrderSeparation": true
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
## 0.13.3
|
||||
- Добавлено отображение id приложения на экранах страниц 'Приложения' и 'Доступы приложений'
|
||||
- Добавлено фиксирование в localStorage открытое или закрытое меню
|
||||
- Исправлена очистка localStorage после протухания или удаления токена
|
||||
- Исправлены стили для субменю, которые влияли на отображение разрешенных и неразрешенных пунктов меню
|
||||
## 0.13.2
|
||||
- Обновление пермишенов
|
||||
## 0.13.1
|
||||
- В LoginPage исправлен background для темной темы
|
||||
## 0.13.0
|
||||
- Добавлена темная тема
|
||||
## 0.12.6
|
||||
- Добавлены кропки "удалить/добавть" в JsonView
|
||||
- Добавлен скролл к JsonView
|
||||
- Добавлена обработка ошибок к изменению конфига
|
||||
## 0.12.5
|
||||
- Исправлено неверное поведение показа меню
|
||||
- Добавлена страница NotFoundPage
|
||||
## 0.12.4
|
||||
- Уменьшен размер бандла
|
||||
## 0.12.3
|
||||
- Добавлена логика изменения пароля
|
||||
## 0.12.2
|
||||
- Добавлена возможность копирования конфига
|
||||
## 0.12.1
|
||||
- Исправлен шрифт в редакторах кода
|
||||
- Исправлены перерисовки экрана "Модули"
|
||||
## 0.12.0
|
||||
- Добавлена страница редактирования/создания конфига
|
||||
## 0.11.5
|
||||
- Обновлена библиотека isp-ui-kit
|
||||
- Убраны лишние столбцы на странице токенов
|
||||
- Исправлено поведение модального окна на странице Группы приложений
|
||||
- Убран лишний скролл
|
||||
- Различные улучшения дизайна страницы Приложений
|
||||
- Убран Ховер в таблицах на экране Модули
|
||||
- Улучшена ui-логика блокировки/разблокировки пользователя
|
||||
- Добавлена обработка ошибок с существующими значения на экране "Пользователи", "Роли"
|
||||
- Исправлена обработки ошибки 401 на экране логина
|
||||
- Исправлено моргание страницы Модулей
|
||||
## 0.11.4
|
||||
- Правки для прода
|
||||
## 0.11.3
|
||||
- Обновлена версия библиотеки isp-ui-kit
|
||||
## 0.11.2
|
||||
- Обновлен Column
|
||||
- Перенесен Header
|
||||
- Правки стилей для прода
|
||||
## 0.11.1
|
||||
- Проверка на пермишены заменена на компонент CanEdit
|
||||
## 0.11.0
|
||||
- Добавлена страница Конфигураций
|
||||
- Добавлена страница сравнения версий
|
||||
- Исправлен цвет фона на Страницах профиля и Доступов приложения
|
||||
- Исправлен отступ от тега "Внутренний"
|
||||
## 0.10.1
|
||||
- В index.html добавлен config.js
|
||||
- Добавлены динамические стили для админок
|
||||
## 0.10.0
|
||||
- Добавлена страница 'Модули'
|
||||
## 0.9.0
|
||||
- Добавлена страница приложений
|
||||
## 0.8.1
|
||||
- Перенос UserMenu в список главного меню в Layout
|
||||
## 0.8.0
|
||||
- Добавлена страница 'Роли'
|
||||
## 0.7.0
|
||||
- Добавлена страница 'Сессии'
|
||||
## 0.6.0
|
||||
- Добавлена страница 'Просмотр журналов ИБ'
|
||||
## 0.5.0
|
||||
- Добавлена страница 'Пользователи' и страница редактирования пользователя
|
||||
## 0.4.0
|
||||
- Добавлен экран управления доступами приложений
|
||||
- Исправлены корневые стили приложения
|
||||
- Обновлена поддержка пользовательских разрешений для страниц
|
||||
- Добавлена локализация Antd
|
||||
## 0.3.2
|
||||
- Добавлен generateVersionFile.cjs
|
||||
## 0.3.1
|
||||
-Добавлена обработка ошибок в интерсепторсе
|
||||
## 0.3.0
|
||||
- Добавлен экран Профиля
|
||||
- Добавлено хранилище ролей
|
||||
- Изменен пакетный менеджер на npm
|
||||
- Улучшения стилей приложения
|
||||
## 0.2.6
|
||||
- Добавлено модальное окно
|
||||
## 0.2.5
|
||||
- UserMenu изменен и перенесен из Header в Menu из Layout, удален Header
|
||||
## 0.2.4
|
||||
- Изменен Layout
|
||||
## 0.2.3
|
||||
- Добавлен экран входа
|
||||
## 0.2.2
|
||||
- Добавлен редирект после логина
|
||||
## 0.2.1
|
||||
- ThemeProvider заменен на ConfigProvider в компоненте <App>
|
||||
## 0.2.0
|
||||
- Добавлены роли и приватный роутер
|
||||
## 0.1.0
|
||||
- Инициализирован проект
|
||||
- Добавлена темная тема antd
|
||||
- Добавлен layout
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
FROM node:20-alpine as build-deps
|
||||
WORKDIR /usr/src/app
|
||||
COPY . ./
|
||||
RUN apk add git
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.25-alpine-slim
|
||||
EXPOSE 8001
|
||||
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 --from=build-deps /usr/src/app/build /opt/msp/isp-admin-ui
|
||||
|
||||
@@ -1,93 +1,30 @@
|
||||
# isp-admin-ui
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
## Getting started
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
||||
|
||||
## Add your files
|
||||
- Configure the top-level `parserOptions` property like this:
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://gitlab.txix.ru/isp/isp-admin-ui.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```js
|
||||
export default {
|
||||
// other rules...
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
project: ['./tsconfig.json', './tsconfig.node.json'],
|
||||
tsconfigRootDir: __dirname
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://gitlab.txix.ru/isp/isp-admin-ui/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
- 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`
|
||||
- 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
|
||||
@@ -0,0 +1,18 @@
|
||||
server {
|
||||
listen 8001;
|
||||
server_name localhost;
|
||||
root /opt/msp/isp-admin-ui/;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
client_max_body_size 10M;
|
||||
|
||||
proxy_pass http://isp-gate-service:9003;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
const fs = require('fs');
|
||||
const packageJson = require('./package.json');
|
||||
|
||||
function writeJsonFile(filePath, data) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(data));
|
||||
}
|
||||
|
||||
function readHtmlFile(filePath) {
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
}
|
||||
|
||||
function writeHtmlFile(filePath, data) {
|
||||
fs.writeFileSync(filePath, data);
|
||||
}
|
||||
|
||||
const welcomePagePath = 'build/index.html';
|
||||
|
||||
let indexHtml = readHtmlFile(welcomePagePath);
|
||||
|
||||
const scriptTagRegex = /<script type="module">window\.AppVersion\s*=\s*'.*';<\/script>/;
|
||||
const scriptTag = `<script type="module">window.AppVersion = '${packageJson.version}';</script>`;
|
||||
indexHtml = indexHtml
|
||||
.replace(scriptTagRegex, '')
|
||||
.replace('</head>', `${scriptTag}</head>`);
|
||||
|
||||
writeHtmlFile(welcomePagePath, indexHtml);
|
||||
|
||||
const versionData = {
|
||||
version: packageJson.version,
|
||||
};
|
||||
|
||||
writeJsonFile('build/version.json', versionData);
|
||||
writeJsonFile('version.json', versionData);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Панель Администратора</title>
|
||||
<script type="module" src="/src/index.tsx"></script>
|
||||
<script type="module">
|
||||
window.AppVersion = APP_VERSION
|
||||
</script>
|
||||
<script type="module" src="/config.js"></script>
|
||||
<title>Панель администратора</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+11665
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"private": true,
|
||||
"version": "0.13.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "vite build && node generateVersionFile.cjs",
|
||||
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"preview": "vite preview",
|
||||
"fix:prettier": "prettier --write \"src/**/*.{ts,tsx, js}\"",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"@codemirror/lang-json": "^6.0.1",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@uiw/react-codemirror": "^4.21.25",
|
||||
"axios": "^1.6.8",
|
||||
"clipboard": "^2.0.11",
|
||||
"compare-versions": "^6.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-ui-kit": "github:txix-open/isp-ui-kit",
|
||||
"json-schema-view-js": "^2.0.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"react": "^18.2.0",
|
||||
"react-codemirror-merge": "^4.21.25",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.51.2",
|
||||
"react-redux": "^9.1.0",
|
||||
"react-resizable": "^3.0.5",
|
||||
"react-router-dom": "^6.22.3",
|
||||
"simplebar": "^6.2.5",
|
||||
"simplebar-react": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
"@types/lodash.clonedeep": "^4.5.9",
|
||||
"@types/node": "^20.12.4",
|
||||
"@types/react": "^18.2.74",
|
||||
"@types/react-dom": "^18.2.24",
|
||||
"@types/react-resizable": "^3.0.7",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^7.5.0",
|
||||
"@vitejs/plugin-legacy": "^5.3.2",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"@vitejs/plugin-react-swc": "^3.6.0",
|
||||
"antd": "5.16.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"husky": "^9.0.11",
|
||||
"prettier": "^3.2.5",
|
||||
"sass": "^1.74.1",
|
||||
"terser": "^5.30.3",
|
||||
"typescript": "^5.4.3",
|
||||
"vite": "^5.2.8",
|
||||
"vite-bundle-visualizer": "^1.2.1",
|
||||
"vite-plugin-node-polyfills": "^0.21.0",
|
||||
"vite-plugin-style-import": "^2.0.0",
|
||||
"vite-plugin-svgr": "^4.2.0",
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-coomit": "eslint --fix .",
|
||||
"pre-push": "eslint --fix ."
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,9 @@
|
||||
<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>
|
||||
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,3 @@
|
||||
<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>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 382 KiB |
@@ -0,0 +1,47 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Table, Tag, Tooltip } from 'antd'
|
||||
import { FC, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons'
|
||||
|
||||
import {
|
||||
ActiveConfigurationsTablePropsType
|
||||
} from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
||||
|
||||
import configApi from '@services/configService.ts'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
|
||||
import './active-configurations-table.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
|
||||
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="#4fc14f">Корректная</Tag>
|
||||
}
|
||||
return <Tag color="red">Некорректная</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
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ConfigProvider } from 'antd'
|
||||
import ruRu from 'antd/locale/ru_RU'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import { darkTheme, lightTheme } from '@constants/theme.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import Routers from '@routes/Routers'
|
||||
|
||||
import './app.scss'
|
||||
|
||||
const App = () => {
|
||||
const [themes, setTheme] = useState(lightTheme)
|
||||
const [changeTheme, setChangeTheme] = useState(
|
||||
localStorage.getItem('theme')
|
||||
? JSON.parse(localStorage.getItem('theme') || '')
|
||||
: true
|
||||
)
|
||||
|
||||
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
|
||||
@@ -0,0 +1,36 @@
|
||||
@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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface AppAccessContentPropsType {
|
||||
id: number
|
||||
paramPrefix: string
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
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)
|
||||
@@ -0,0 +1,11 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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
|
||||
@@ -0,0 +1,39 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
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="Приложения"
|
||||
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
|
||||
@@ -0,0 +1,16 @@
|
||||
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
|
||||
@@ -0,0 +1,10 @@
|
||||
export type ChangePasswordModalType = {
|
||||
oldPassword: string
|
||||
newPassword: string
|
||||
confirmPassword: string
|
||||
}
|
||||
|
||||
export type ChangePasswordModalProps = {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import {
|
||||
ChangePasswordModalProps,
|
||||
ChangePasswordModalType
|
||||
} from '@components/ChangePasswordModal/change-password-modal.type.ts'
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
import { ChangeProfilePassword } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
import { message } from 'antd'
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
|
||||
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')
|
||||
} 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
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
@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 {
|
||||
.cm-merge-theme {
|
||||
overflow-y: scroll;
|
||||
height: calc(90vh - 150px);
|
||||
}
|
||||
|
||||
&__table {
|
||||
overflow-y: auto;
|
||||
height: calc(90vh - 50px);
|
||||
|
||||
&__row {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface CompareVersionModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
currentConfigId: string
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { EditorState, EditorView } from '@uiw/react-codemirror'
|
||||
import { Button, Spin, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import { FC, memo, useContext, useState } from 'react'
|
||||
import CodeMirrorMerge from 'react-codemirror-merge'
|
||||
|
||||
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 { VersionType } from '@type/version.type'
|
||||
|
||||
import './compare-version-modal.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
|
||||
const Original = CodeMirrorMerge.Original
|
||||
const Modified = CodeMirrorMerge.Modified
|
||||
|
||||
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>
|
||||
<CodeMirrorMerge
|
||||
orientation="a-b"
|
||||
theme={changeTheme ? 'dark' : 'light'}
|
||||
>
|
||||
<Original
|
||||
value={JSON.stringify(sortObject(selectedItem.data), null, 2)}
|
||||
/>
|
||||
<Modified
|
||||
value={JSON.stringify(sortObject(config?.data), null, 2)}
|
||||
extensions={[
|
||||
EditorView.editable.of(false),
|
||||
EditorState.readOnly.of(true)
|
||||
]}
|
||||
/>
|
||||
</CodeMirrorMerge>
|
||||
</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)
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.config-schema-modal {
|
||||
.modal__wrap {
|
||||
min-width: 880px;
|
||||
}
|
||||
|
||||
.json-schema-view {
|
||||
padding: $basic-padding
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
@@ -0,0 +1,64 @@
|
||||
import { FC, useContext } from 'react'
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
||||
import Editor from '@monaco-editor/react'
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { message } from 'antd'
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBtn= () => {}, bufConfig, setBufConfig }) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
const debounce = (func: (...args: any[]) => void, wait: number) => {
|
||||
let timeout: NodeJS.Timeout
|
||||
return (...args: []) => {
|
||||
clearTimeout(timeout)
|
||||
timeout = setTimeout(() => {
|
||||
func.apply(this, [...args])
|
||||
}, wait)
|
||||
}
|
||||
}
|
||||
|
||||
const debouncedHandleError = debounce(() => {
|
||||
message.error('Невалидный JSON объект')
|
||||
}, 500)
|
||||
|
||||
const handleChange = (data: string | undefined) => {
|
||||
|
||||
if (data) {
|
||||
try {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: {...JSON.parse(data) }
|
||||
} as ConfigType
|
||||
setDisableBtn(false)
|
||||
setBufConfig(newData)
|
||||
} catch (error) {
|
||||
debouncedHandleError()
|
||||
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
|
||||
@@ -0,0 +1,112 @@
|
||||
import { Theme as AntDTheme } from '@rjsf/antd'
|
||||
import { withTheme } from '@rjsf/core'
|
||||
import { UiSchema } from '@rjsf/utils'
|
||||
import validator from '@rjsf/validator-ajv8'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
||||
import { Tabs } from 'antd'
|
||||
import equal from 'deep-equal'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||
bufConfig ={},
|
||||
JsonSchema,
|
||||
setBufConfig,
|
||||
}) => {
|
||||
const Form = withTheme(AntDTheme)
|
||||
const sortProps = (a, b) => a.name.localeCompare(b.name)
|
||||
|
||||
const [formState, setFormState] = useState(bufConfig.data)
|
||||
const [activeTabKey, setActiveTabKey] = useState()
|
||||
const {id} = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
if(!equal(formState, bufConfig.data)) {
|
||||
setFormState(bufConfig.data)
|
||||
}
|
||||
}, [bufConfig.data])
|
||||
|
||||
const uiSchema: UiSchema = {
|
||||
'ui:submitButtonOptions': {
|
||||
norender: true
|
||||
}
|
||||
}
|
||||
|
||||
const onFormChange = data => {
|
||||
if(!equal(data.formData, bufConfig.data)) {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: { ...data.formData }
|
||||
}
|
||||
if(!equal(newData, bufConfig.data)) {
|
||||
setBufConfig(newData)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const handleTabsChange = e => {
|
||||
setActiveTabKey(e)
|
||||
}
|
||||
|
||||
const ObjectFieldTemplate = (props) => {
|
||||
const {
|
||||
properties,
|
||||
idSchema,
|
||||
schema: { properties: schemaProperties }
|
||||
} = props
|
||||
properties.sort(sortProps)
|
||||
|
||||
if (idSchema.$id === 'root') {
|
||||
const propsComplex: [] = []
|
||||
const propsSimple: [] = []
|
||||
|
||||
properties.forEach((prop) => {
|
||||
const fieldType = schemaProperties[prop.name].type
|
||||
if (!fieldType || fieldType === 'array' || fieldType === 'object') {
|
||||
propsComplex.push(prop)
|
||||
} else {
|
||||
propsSimple.push(prop)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<Tabs activeKey={activeTabKey} tabPosition="right" onChange={handleTabsChange} items={[
|
||||
...(propsSimple.length ? [{
|
||||
label: 'Остальные',
|
||||
key: 'General',
|
||||
children: propsSimple.map((element) => element.content),
|
||||
}] : []),
|
||||
...propsComplex.map((element) => ({
|
||||
label: schemaProperties[element.name]?.title || element.name,
|
||||
key: element.name,
|
||||
children: element.content,
|
||||
})),
|
||||
]} />
|
||||
)
|
||||
}
|
||||
|
||||
return properties.map((element) => element.content)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="configuration-editor-page__form">
|
||||
<Form
|
||||
formContext={{
|
||||
// labelCol: { span: 8 },
|
||||
// wrapperCol: { span: 30 },
|
||||
// layout: 'horizontal'
|
||||
}}
|
||||
uiSchema={uiSchema}
|
||||
templates={{ ObjectFieldTemplate }}
|
||||
validator={validator}
|
||||
schema={JsonSchema?.schema}
|
||||
formData={id === 'new' ? {} : formState}
|
||||
onChange={onFormChange}
|
||||
></Form>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorForm
|
||||
@@ -0,0 +1,40 @@
|
||||
import { FC, useContext } from 'react'
|
||||
import {ConfigurationEditorPropsType} from '@pages/ConfigurationEditorPage'
|
||||
import { ReactJsonView } from 'isp-ui-kit'
|
||||
import {Spin} from 'antd'
|
||||
import { cleanEmptyParamsObject } from '@utils/objectUtils.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(cleanEmptyParamsObject(newData))
|
||||
}
|
||||
|
||||
return (
|
||||
<ReactJsonView
|
||||
theme={ changeTheme ? 'twilight' : ''}
|
||||
onAdd={true}
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
.configuration-preview-modal {
|
||||
.react-json-view {
|
||||
width: 100vw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface ConfigurationPreviewModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
versionCompare?: boolean
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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 './configuration-preview-modal.scss'
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,48 @@
|
||||
import { Button } from 'antd'
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
import { Dispatch, FC, SetStateAction } from 'react'
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
|
||||
|
||||
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 (
|
||||
<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>
|
||||
)
|
||||
}
|
||||
export default ConfirmConfigModal
|
||||
@@ -0,0 +1,40 @@
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
import { FC } from 'react'
|
||||
import { Table } from 'antd'
|
||||
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
.error-page {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
const ErrorPage = () => {
|
||||
return (
|
||||
<section className="error-page">
|
||||
<p>Извините, ошибка</p>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ErrorPage
|
||||
@@ -0,0 +1,35 @@
|
||||
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
|
||||
@@ -0,0 +1,235 @@
|
||||
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 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) {
|
||||
dispatch(fetchProfile())
|
||||
dispatch(fetchUI())
|
||||
}
|
||||
}, [])
|
||||
|
||||
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 (status === StateProfileStatus.rejected) {
|
||||
return <Navigate to={routePaths.error} replace />
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
{status === StateProfileStatus.pending ? (
|
||||
<Spin size="large" />
|
||||
) : (
|
||||
<>
|
||||
<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
|
||||
@@ -0,0 +1,52 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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]
|
||||
@@ -0,0 +1,53 @@
|
||||
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)
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ModuleTabsPropsType {
|
||||
activeTab: string
|
||||
setActiveTab: (key: string) => void
|
||||
currentModule: ModuleType | undefined
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
@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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export type RoleListProps = {
|
||||
userRoles: number[]
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
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, 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: (record) => <div>{shortenString(record)}</div>
|
||||
},
|
||||
{
|
||||
title: 'Дата/Время выпуска',
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (record) => {
|
||||
const formatTime = dayjs(record.createdAt).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 = [
|
||||
{
|
||||
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
|
||||
@@ -0,0 +1,35 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
@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;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
type FormattersKey = 'fullFormat'
|
||||
|
||||
|
||||
export const dateFormats:Record<FormattersKey,string> = {
|
||||
fullFormat: 'DD.MM.YYYY HH:mm:ss'
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
type ValidationRulesKeys = 'required'
|
||||
|
||||
export const ValidationRules: Record<ValidationRulesKeys, any> = {
|
||||
required: { value: true, message: 'Поле не может быть пустым' }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
type LocalStorageKeys = 'HEADER_NAME' | 'USER_TOKEN'
|
||||
|
||||
export const localStorageKeys: Record<LocalStorageKeys, string> = {
|
||||
HEADER_NAME: 'HEADER_NAME',
|
||||
USER_TOKEN: 'USER_TOKEN'
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
type MessagesKey = 'serverError' | 'loginError'
|
||||
|
||||
export const messages: Record<MessagesKey, string> = {
|
||||
serverError: 'Внутренняя ошибка сервиса',
|
||||
loginError: 'Неверный логин или пароль'
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export enum SessionStatusKeysType {
|
||||
allowed = 'ALLOWED',
|
||||
revoked = 'REVOKED',
|
||||
expired = 'EXPIRED'
|
||||
}
|
||||
|
||||
export const sessionStatuses: Record<SessionStatusKeysType, string> = {
|
||||
[SessionStatusKeysType.allowed]: 'Активная',
|
||||
[SessionStatusKeysType.revoked]: 'Отмененная',
|
||||
[SessionStatusKeysType.expired]: 'Истекшая'
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
$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;
|
||||
@@ -0,0 +1,17 @@
|
||||
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'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
||||
|
||||
import { AppDispatch, RootState } from '../stores'
|
||||
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
||||
@@ -0,0 +1,35 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,26 @@
|
||||
import { setupListeners } from '@reduxjs/toolkit/query'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { Provider } from 'react-redux'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
|
||||
import App from './components/App.tsx'
|
||||
|
||||
import { setupStore } from './stores'
|
||||
import 'dayjs/locale/ru'
|
||||
|
||||
import 'react-resizable/css/styles.css'
|
||||
import 'simplebar-react/dist/simplebar.min.css'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
dayjs.locale('ru')
|
||||
const store = setupStore()
|
||||
setupListeners(store.dispatch)
|
||||
const root = createRoot(document.getElementById('root') as HTMLElement)
|
||||
|
||||
root.render(
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</Provider>
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
@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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
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 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'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
|
||||
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
|
||||
@@ -0,0 +1,15 @@
|
||||
@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.
@@ -0,0 +1,113 @@
|
||||
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="Приложения"
|
||||
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)
|
||||
@@ -0,0 +1,26 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
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 ApplicationsContent from '@components/ApplicationsContent'
|
||||
import AppGroupModal from 'src/components/AppGroupModal'
|
||||
|
||||
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 ListItem from '@widgets/ListItem'
|
||||
|
||||
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="Группы приложений"
|
||||
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
|
||||
@@ -0,0 +1,78 @@
|
||||
@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;
|
||||
&::-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;
|
||||
}
|
||||
.ant-tabs-right {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.ant-col-8 .ant-form-item-label {
|
||||
margin-right: $basic-margin *2;
|
||||
}
|
||||
|
||||
}
|
||||
.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: 190px;
|
||||
}
|
||||
.confirm-btn, .danger {
|
||||
margin-right: $basic-margin;
|
||||
}
|
||||
.error-data {
|
||||
color: red;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
import { RollbackOutlined } from '@ant-design/icons'
|
||||
import { Button, Dropdown, MenuProps, message, Radio, RadioChangeEvent, Spin } from 'antd'
|
||||
import { Dispatch, FC, SetStateAction, useEffect, 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, ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
||||
import ConfirmConfigModal from '@components/ConfirmConfigModal/ConfirmConfigModal.tsx'
|
||||
import ErrorConfigModal from '@components/ErrorConfigModal/ErrorConfigModal.tsx'
|
||||
|
||||
export interface ConfigurationEditorPropsType {
|
||||
JsonSchema?: ResponseSchemaType
|
||||
bufConfig?: ConfigType
|
||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||
isCurrentConfigLoading: boolean
|
||||
setDisableBtn?: Dispatch<SetStateAction<boolean>>
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
const onRadioChange = (e: RadioChangeEvent) => {
|
||||
setRadioValue(e.target.value)
|
||||
}
|
||||
|
||||
const handleSaveClick = (upVersion?: number, unsafe?: boolean) => {
|
||||
let newData = {}
|
||||
if (bufConfig) {
|
||||
if (isNew) {
|
||||
newData = {
|
||||
name: state.name,
|
||||
moduleId: moduleId,
|
||||
id: '',
|
||||
version: 0,
|
||||
data: bufConfig.data,
|
||||
unsafe: unsafe
|
||||
} as ConfigType
|
||||
}
|
||||
if (currentConfig) {
|
||||
newData = {
|
||||
...bufConfig,
|
||||
version: upVersion ? upVersion : currentConfig.version,
|
||||
unsafe: unsafe
|
||||
} as ConfigType
|
||||
}
|
||||
}
|
||||
createUpdateConfig(cleanEmptyParamsObject(newData))
|
||||
.unwrap()
|
||||
.then(({ id }) => {
|
||||
isNew && navigate(`/${moduleId}/configEditor/${id}`)
|
||||
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 'form':
|
||||
// return (
|
||||
// <ConfigurationEditorForm
|
||||
// bufConfig={bufConfig}
|
||||
// setBufConfig={setBufConfig}
|
||||
// isCurrentConfigLoading={isCurrentConfigLoading}
|
||||
// />
|
||||
// )
|
||||
case 'json':
|
||||
return (
|
||||
<ConfigurationEditorJson
|
||||
bufConfig={bufConfig}
|
||||
setBufConfig={setBufConfig}
|
||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||
/>
|
||||
)
|
||||
case 'code':
|
||||
return (
|
||||
<ConfigurationEditorCode
|
||||
setDisableBtn={setDisableBtn}
|
||||
bufConfig={bufConfig}
|
||||
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()
|
||||
navigate(`/modules/${moduleId}/configurations`)
|
||||
}}
|
||||
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="json" size="large" onChange={onRadioChange}>
|
||||
<Radio.Button disabled value="form">Форма</Radio.Button>
|
||||
<Radio.Button disabled={disableBtn} value="json">JSON</Radio.Button>
|
||||
<Radio.Button value="code">Редактор кода</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
|
||||
@@ -0,0 +1,19 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
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)
|
||||
@@ -0,0 +1,48 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
import { Spin, Table, Tag, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
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'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
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 keySelector = ({
|
||||
address: { ip, port },
|
||||
establishedAt
|
||||
}: ModuleStatusType) => ip + port + establishedAt
|
||||
|
||||
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={keySelector}
|
||||
pagination={false}
|
||||
dataSource={obj}
|
||||
columns={columns}
|
||||
expandable={{
|
||||
expandedRowRender: (i) => renderEndpoints(i)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(Connections)
|
||||
@@ -0,0 +1,13 @@
|
||||
.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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import './home-page.scss'
|
||||
|
||||
const HomePage = () => {
|
||||
return <div className="home-page">Добро пожаловать!</div>
|
||||
}
|
||||
|
||||
export default HomePage
|
||||
@@ -0,0 +1,122 @@
|
||||
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 =
|
||||
localStorage.getItem('redirectUrl') || routePaths.home
|
||||
navigate(redirectUrl, { replace: true })
|
||||
localStorage.removeItem('redirectUrl')
|
||||
})
|
||||
.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)}
|
||||
>
|
||||
Войти
|
||||
</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
|
||||
@@ -0,0 +1,53 @@
|
||||
@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: "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
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: 1000,
|
||||
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
|
||||
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
|
||||
@@ -0,0 +1,104 @@
|
||||
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[]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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.modules)}>
|
||||
На главную
|
||||
</Button>
|
||||
</NotFoundPage>
|
||||
)
|
||||
}
|
||||
|
||||
export default NotFound
|
||||
@@ -0,0 +1,75 @@
|
||||
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
|
||||
@@ -0,0 +1,34 @@
|
||||
@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
|
||||
}
|
||||
}
|
||||
Loaded 100 of 183 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user