Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f67eee5ee | ||
|
|
7dbbaff972 | ||
|
|
6f6d6fb14a | ||
|
|
d1f72bdd40 | ||
|
|
26de62cdeb | ||
|
|
96ed1658b3 | ||
|
|
856df328fe | ||
|
|
9b51e3379a | ||
|
|
239634454b | ||
|
|
20c8f58a77 | ||
|
|
b165afd655 | ||
|
|
60eddbd9fc | ||
|
|
3e205e5805 | ||
|
|
29f8bcb8e9 | ||
|
|
3462bbcf06 | ||
|
|
49b3e2c32e | ||
|
|
3d37d4acd0 | ||
|
|
028c5b859f | ||
|
|
f528ad46e1 | ||
|
|
369d94afd9 | ||
|
|
641ee55cf6 | ||
|
|
f01971d5c1 | ||
|
|
46e1ed6e3b | ||
|
|
809253ab6e | ||
|
|
4c78fb587d | ||
|
|
9f1caacc5d | ||
|
|
c89f47321a | ||
|
|
38646e56df | ||
|
|
9dfb0ca7a3 | ||
|
|
cbc1f0f6cc | ||
|
|
c55fa2e7d6 | ||
|
|
1cdf65ff08 | ||
|
|
4306ffcf3d | ||
|
|
d006bf7628 | ||
|
|
554f1470c8 | ||
|
|
490e6168ff | ||
|
|
709e14e501 | ||
|
|
fe295beb7f | ||
|
|
39cf7159e4 | ||
|
|
e87ed7cd68 | ||
|
|
e54ce881b7 | ||
|
|
180cdb750e | ||
|
|
e730b5ace3 | ||
|
|
0b6f6cb8fa | ||
|
|
eb8e1683fb | ||
|
|
e7b680aeb1 | ||
|
|
a7ec8b9489 | ||
|
|
23b9e1a1f0 | ||
|
|
dd7aee01ed | ||
|
|
bf773a58f0 | ||
|
|
ac08aef65c | ||
|
|
03fa976526 | ||
|
|
64852bca9f | ||
|
|
fbad913311 | ||
|
|
685a32ee30 | ||
|
|
75f491520b | ||
|
|
a1c96ab2e7 | ||
|
|
d9543c4a24 | ||
|
|
3ddbdbda6d |
No files matched your search
@@ -1,2 +1,3 @@
|
|||||||
PROXY_URL=
|
PROXY_URL=
|
||||||
|
PUBLIC_PATH=
|
||||||
VITE_APP_TOKEN=
|
VITE_APP_TOKEN=
|
||||||
@@ -13,7 +13,12 @@
|
|||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:import/typescript"
|
"plugin:import/typescript"
|
||||||
],
|
],
|
||||||
"ignorePatterns": ["node_modules", "build", "generateVersionFile.cjs"],
|
"ignorePatterns": [
|
||||||
|
"node_modules",
|
||||||
|
"build",
|
||||||
|
"generateVersionFile.cjs",
|
||||||
|
"config.template.js"
|
||||||
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
@@ -32,28 +37,49 @@
|
|||||||
"prettier"
|
"prettier"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"import/no-named-as-default":"off",
|
"import/default": "off",
|
||||||
|
"import/no-named-as-default": "off",
|
||||||
"prettier/prettier": "off",
|
"prettier/prettier": "off",
|
||||||
"quotes": ["error", "single"],
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
"react/jsx-filename-extension": [
|
"react/jsx-filename-extension": [
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
"extensions": [".js", ".jsx", ".tsx"]
|
"extensions": [
|
||||||
|
".js",
|
||||||
|
".jsx",
|
||||||
|
".tsx"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"react/jsx-one-expression-per-line": "off",
|
"react/jsx-one-expression-per-line": "off",
|
||||||
"react/prop-types": 0,
|
"react/prop-types": 0,
|
||||||
"react/react-in-jsx-scope": "off",
|
"react/react-in-jsx-scope": "off",
|
||||||
"semi": ["error", "never"],
|
"semi": [
|
||||||
"@typescript-eslint/no-unused-vars": ["off"],
|
"error",
|
||||||
"@typescript-eslint/no-explicit-any": ["off", null],
|
"never"
|
||||||
"@typescript-eslint/no-non-null-assertion": ["off"],
|
],
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"off"
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-explicit-any": [
|
||||||
|
"off",
|
||||||
|
null
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-non-null-assertion": [
|
||||||
|
"off"
|
||||||
|
],
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
"no-unused-vars": "off"
|
"no-unused-vars": "off"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"import/parsers": {
|
"import/parsers": {
|
||||||
"@typescript-eslint/parser": [".ts", ".tsx"]
|
"@typescript-eslint/parser": [
|
||||||
|
".ts",
|
||||||
|
".tsx"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"react": {
|
"react": {
|
||||||
"version": "detect"
|
"version": "detect"
|
||||||
@@ -63,8 +89,16 @@
|
|||||||
"alwaysTryTypes": true
|
"alwaysTryTypes": true
|
||||||
},
|
},
|
||||||
"node": {
|
"node": {
|
||||||
"extensions": [".js", ".jsx", ".ts", ".tsx"],
|
"extensions": [
|
||||||
"moduleDirectory": ["node_modules", "src/"]
|
".js",
|
||||||
|
".jsx",
|
||||||
|
".ts",
|
||||||
|
".tsx"
|
||||||
|
],
|
||||||
|
"moduleDirectory": [
|
||||||
|
"node_modules",
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
name: Create and publish a Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Get version from tag
|
||||||
|
id: version_reader
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker-container
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
|
||||||
|
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
include:
|
||||||
|
- project: '$CI_PROJECT_PATH'
|
||||||
|
file: '/ci-isp-ui.yml'
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
cfg
|
||||||
|
/config.template.js
|
||||||
+120
@@ -1,3 +1,123 @@
|
|||||||
|
## 0.26.4
|
||||||
|
- Обновлено
|
||||||
|
- библиотека isp-ui-kit (внутренние улучшение библиотеки)
|
||||||
|
- Обновлены импорты в проекте под новую версию библиотеки
|
||||||
|
## 0.26.3
|
||||||
|
- Обновлено
|
||||||
|
- Библиотека isp-admin-ui-kit (Исправлено некорректное отображение подключений в модулях)
|
||||||
|
## 0.26.2
|
||||||
|
- Обновлено
|
||||||
|
- Библиотека isp-admin-ui-kit (Исправлено некорректное перенаправление после авторизации)
|
||||||
|
## 0.26.1
|
||||||
|
- Исправлено
|
||||||
|
- Формирование конфига nginx c public path
|
||||||
|
- Обновлено
|
||||||
|
- Библиотека isp-admin-ui-kit (добавлен public path в вызовы методов)
|
||||||
|
## 0.26.0
|
||||||
|
- Добавлено
|
||||||
|
- Поддержка стороннего public-path
|
||||||
|
- Обновлено
|
||||||
|
- версия библиотеки isp-admin-ui-kit(поддержка стороннего public-path)
|
||||||
|
## 0.25.0
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(Добавлена обработка сетевой ошибки 403, изменена логика получения ролей на экране Профиля)
|
||||||
|
## 0.24.2
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(Исправлено сворачивание полей в редакторе кода при редактировании)
|
||||||
|
## 0.24.1
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(При создании конфига добавлена модалка для ввода нового имени)
|
||||||
|
## 0.24.0
|
||||||
|
- Добавлена возможность копирования невалидного конфига
|
||||||
|
## 0.23.2
|
||||||
|
- Исправлено отображение цвета версии проекта в меню
|
||||||
|
## 0.23.1
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit
|
||||||
|
- Проект оптимизирован для новой версии библиотеки
|
||||||
|
## 0.23.0
|
||||||
|
- Добавлена сортировка элементов по параметрам в Столбцах
|
||||||
|
- Обновлена библиотека isp-ui-kit
|
||||||
|
- Обновлена библиотека isp-admin-ui-kit
|
||||||
|
## 0.22.00
|
||||||
|
- Добавлена возможность удалять "неизвестные методы"
|
||||||
|
- Исправлено "мерцание" дерева доступов
|
||||||
|
## 0.21.13
|
||||||
|
- Исправлено поведение, при котором происходила лишняя прокрутка в Column при первом выборе элемента
|
||||||
|
## 0.21.12
|
||||||
|
- добавлен скрипт для сборки и публикации образа в `GitHub Contaier Registry`
|
||||||
|
## 0.21.11
|
||||||
|
- Добавлено отображение версии приложение в шапку меню
|
||||||
|
## 0.21.10
|
||||||
|
- Исправлено "мерцание" экрана "Переменные" при загрузке страницы
|
||||||
|
- Исправлено неверное поведение инпута "поиск приложения по токену" при его очистке
|
||||||
|
- Запрещена возможность отправки пустого значения в инпуте "поиск приложения по токену"
|
||||||
|
- Обновлена библиотека isp-admin-ui-kit
|
||||||
|
## 0.21.9
|
||||||
|
- Обновлены цвета для темной темы
|
||||||
|
- Исправлены цвета текста для темной темы
|
||||||
|
- Исправлено отображение resize-handle для темной темы
|
||||||
|
## 0.21.8
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(Добавленн поиск приложения по токену и поправлен баг скроллов по всему приоекту)
|
||||||
|
## 0.21.7
|
||||||
|
- Обновлена библиотека компонентов Antd
|
||||||
|
- Исправлено неверное поведение всплывающих подсказок
|
||||||
|
## 0.21.6
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(высота и скрол меню, сортировка и высота в Column)
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit(По вкладке "Доступы приложений" по кнопке сохранить добавлено модальное окно)
|
||||||
|
## 0.21.5
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(Блокировка кнопки сохранить на странице редактирвоания конфига)
|
||||||
|
## 0.21.4
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit(Добавлено редактирвоание ID приложений)
|
||||||
|
## 0.21.3
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit (Для переименования конфига использован новый метод)
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
(Добавлено редактирование ID приложений
|
||||||
|
Добавлено кол-во элементов в Column,
|
||||||
|
Добавлена возможность добавлять иконку в заголовок столбца,
|
||||||
|
Изменен тип label для всех компонентов формы, фикс скроллов)
|
||||||
|
## 0.21.2
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
## 0.21.1
|
||||||
|
- Обновлена версия библиотеки isp-admin-ui-kit
|
||||||
|
## 0.21.0
|
||||||
|
- Добавлены разрешения для страниц проекта
|
||||||
|
## 0.20.0
|
||||||
|
- Добавлена страница работы с переменными
|
||||||
|
## 0.19.1
|
||||||
|
- Обновлена версия ui библиотек
|
||||||
|
## 0.19.0
|
||||||
|
- Замена компонента App на компонент AdminBase из библиотеки
|
||||||
|
- Удален весь код, дублирующий компонент AdminBase
|
||||||
|
## 0.18.9
|
||||||
|
- Исправлены дополнительные параметры подключения в форме
|
||||||
|
## 0.18.8
|
||||||
|
- Добавлено кеширование статики для nginx
|
||||||
|
## 0.18.7
|
||||||
|
- Включена поддержка кэширования зависимостей через Docker
|
||||||
|
- Добавлен файл конфигурации nginx
|
||||||
|
## 0.18.6
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
## 0.18.5
|
||||||
|
- Изолирование стилей в ConfirmConfigModal
|
||||||
|
## 0.18.4
|
||||||
|
- Правка стилей модальных окон
|
||||||
|
## 0.18.3
|
||||||
|
- Изменен репозиторий библиотеки isp-ui-kit
|
||||||
|
- Обновлена версия библиотеки isp-ui-kit
|
||||||
|
## 0.18.2
|
||||||
|
- Добавлено закрытие модального окна после изменения пароля
|
||||||
|
- Добавлен рефеч данных профиля пос после обновления роли
|
||||||
|
- Исправлена верстка модального окна
|
||||||
|
- Добавлено отправка формы на странице логина по нажатии Enter
|
||||||
|
## 0.18.1
|
||||||
|
- В разделе модули в таблице подключений модуля для key строк в таблице добавлено id
|
||||||
|
## 0.18.0
|
||||||
|
- Исправлено редактирование JSON в конфиге
|
||||||
|
## 0.17.3
|
||||||
|
- Обновлены зависимости в package.json
|
||||||
|
## 0.17.1
|
||||||
|
- Обновлена библиотека isp-ui-kit
|
||||||
|
## 0.17.0
|
||||||
|
- Codemirror заменен на MonacoEditor
|
||||||
|
## 0.16.0
|
||||||
|
- Добавлена форма на страницу редактора конфигов
|
||||||
## 0.15.1
|
## 0.15.1
|
||||||
- Изменен цвет компонента Tag в ActiveConfigurationsTable
|
- Изменен цвет компонента Tag в ActiveConfigurationsTable
|
||||||
- Изменена иконка редакторивания конфига на <FormOutlined />
|
- Изменена иконка редакторивания конфига на <FormOutlined />
|
||||||
|
|||||||
+28
-7
@@ -1,13 +1,34 @@
|
|||||||
FROM node:20-alpine as build-deps
|
ARG NODE_VERSION=lts
|
||||||
|
FROM node:${NODE_VERSION}-alpine as base
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY . ./
|
|
||||||
RUN apk add git
|
FROM base as deps
|
||||||
RUN npm install
|
|
||||||
|
RUN --mount=type=bind,source=package.json,target=package.json \
|
||||||
|
--mount=type=bind,source=package-lock.json,target=package-lock.json \
|
||||||
|
--mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci --omit=dev
|
||||||
|
|
||||||
|
FROM deps as build
|
||||||
|
|
||||||
|
RUN --mount=type=bind,source=package.json,target=package.json \
|
||||||
|
--mount=type=bind,source=package-lock.json,target=package-lock.json \
|
||||||
|
--mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
ARG PUBLIC_PATH=/
|
||||||
|
ENV PUBLIC_PATH=$PUBLIC_PATH
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:1.25-alpine-slim
|
FROM nginx:alpine-slim as final
|
||||||
EXPOSE 8001
|
ARG PUBLIC_PATH=/
|
||||||
|
ENV PUBLIC_PATH=$PUBLIC_PATH
|
||||||
|
|
||||||
RUN rm -f /etc/nginx/conf.d/default.conf
|
RUN rm -f /etc/nginx/conf.d/default.conf
|
||||||
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
||||||
COPY --from=build-deps /usr/src/app/build /opt/msp/isp-admin-ui
|
COPY --from=build /usr/src/app/build /opt/msp/isp-admin-ui${PUBLIC_PATH}/
|
||||||
|
|
||||||
|
COPY entrypoint.sh /opt/msp/isp-admin-ui${PUBLIC_PATH}/entrypoint.sh
|
||||||
|
ENTRYPOINT sh -c "/opt/msp/isp-admin-ui${PUBLIC_PATH}/entrypoint.sh"
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder-deps
|
||||||
|
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y nodejs22 npm22
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
RUN npm config set "strict-ssl" false
|
||||||
|
RUN npm config set "registry" https://repo-mirror.mos.ru/repository/npm-public/
|
||||||
|
RUN npm config list
|
||||||
|
COPY . .
|
||||||
|
RUN sed -i 's/registry.npmjs.org/repo-mirror.mos.ru\/repository\/npm-public/g' package-lock.json
|
||||||
|
RUN sed -i 's/github.com/repo-mirror.mos.ru\/repository\/raw-github/g' package-lock.json
|
||||||
|
RUN sed -i 's/github.com/repo-mirror.mos.ru\/repository\/raw-github/g' package.json
|
||||||
|
ENV NODE_OPTIONS="--max_old_space_size=4096"
|
||||||
|
RUN npm ci
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM dockerhub.mos.ru/mosos/arbat:15.5
|
||||||
|
|
||||||
|
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||||
|
RUN echo "Europe/Moscow" > /etc/timezone
|
||||||
|
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y nginx
|
||||||
|
|
||||||
|
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
||||||
|
COPY --from=builder-deps /usr/src/app/build /opt/msp/isp-admin-ui
|
||||||
|
|
||||||
|
COPY entrypoint.sh /opt/msp/isp-admin-ui/entrypoint.sh
|
||||||
|
ENTRYPOINT ["/opt/msp/isp-admin-ui/entrypoint.sh"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -28,3 +28,4 @@ export default {
|
|||||||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
||||||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
||||||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
||||||
|
1
|
||||||
@@ -3,16 +3,56 @@ server {
|
|||||||
server_name localhost;
|
server_name localhost;
|
||||||
root /opt/msp/isp-admin-ui/;
|
root /opt/msp/isp-admin-ui/;
|
||||||
|
|
||||||
|
location __PUBLIC_PATH__api {
|
||||||
|
client_max_body_size 10M;
|
||||||
|
rewrite ^__PUBLIC_PATH__api/(.*)$ /api/$1 break;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri /index.html;
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
add_header Pragma "no-cache"; # Для совместимости с HTTP/1.0
|
||||||
|
expires off;
|
||||||
|
try_files $uri __PUBLIC_PATH__index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api {
|
location /assets/ {
|
||||||
client_max_body_size 10M;
|
gzip on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_types text/plain text/css application/javascript application/json application/xml application/xml+rss text/javascript image/x-icon;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_disable "msie6"; # Отключение Gzip для устаревших версий Internet Explorer
|
||||||
|
|
||||||
proxy_pass http://isp-gate-service:9003;
|
add_header Cache-Control "public, max-age=604800, immutable"; # 1 неделя
|
||||||
proxy_set_header Host $host;
|
}
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
# Кэширование для шрифтов и изображений (1 неделя)
|
||||||
}
|
location ~* \.(?:ico|png|jpg|jpeg|svg|gif|webp|ttf|woff|woff2|otf|eot)$ {
|
||||||
|
gzip on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_types text/plain text/css application/javascript application/json application/xml application/xml+rss text/javascript image/x-icon;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_disable "msie6"; # Отключение Gzip для устаревших версий Internet Explorer
|
||||||
|
|
||||||
|
add_header Cache-Control "public, max-age=604800, immutable"; # 1 неделя
|
||||||
|
}
|
||||||
|
|
||||||
|
# Кэширование JS и CSS (1 неделя)
|
||||||
|
location ~* \.(?:js|css)$ {
|
||||||
|
gzip on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_types text/plain text/css application/javascript application/json application/xml application/xml+rss text/javascript image/x-icon;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_disable "msie6"; # Отключение Gzip для устаревших версий Internet Explorer
|
||||||
|
|
||||||
|
add_header Cache-Control "public, max-age=604800, immutable"; # 1 неделя
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PUBLIC_PATH="${PUBLIC_PATH:-/}"
|
||||||
|
|
||||||
|
PUBLIC_PATH="$(printf '%s' "$PUBLIC_PATH" | sed -E 's|^/*|/|; s|/*$|/|')"
|
||||||
|
|
||||||
|
echo "Using normalized PUBLIC_PATH: '$PUBLIC_PATH'"
|
||||||
|
|
||||||
|
# Генерация конфигурации приложения
|
||||||
|
CONFIG_DIR="/opt/msp/isp-admin-ui${PUBLIC_PATH}"
|
||||||
|
CONFIG_PATH="${CONFIG_DIR}/config.js"
|
||||||
|
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
|
||||||
|
cat <<EOF > "$CONFIG_PATH"
|
||||||
|
window.config = {
|
||||||
|
ENABLE_PASSWORD_LOGIN: ${ENABLE_PASSWORD_LOGIN:-true},
|
||||||
|
APP_TOKEN: '${APP_TOKEN:-"default_token"}',
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Generated config at: $CONFIG_PATH"
|
||||||
|
|
||||||
|
# Подготовка nginx-конфига: заменяем __PUBLIC_PATH__ на реальное значение
|
||||||
|
NGINX_SRC="/etc/nginx/conf.d/80_isp-admin-ui.conf"
|
||||||
|
TMP_FILE="${NGINX_SRC}.tmp"
|
||||||
|
|
||||||
|
echo "Substituting __PUBLIC_PATH__ with: '${PUBLIC_PATH}'"
|
||||||
|
sed "s|__PUBLIC_PATH__|${PUBLIC_PATH}|g" "$NGINX_SRC" > "$TMP_FILE"
|
||||||
|
|
||||||
|
# Проверка результата
|
||||||
|
echo "=== Generated nginx config ==="
|
||||||
|
cat "$TMP_FILE"
|
||||||
|
echo "=== End nginx config ==="
|
||||||
|
|
||||||
|
# Заменяем оригинальный конфиг
|
||||||
|
mv "$TMP_FILE" "$NGINX_SRC"
|
||||||
|
|
||||||
|
echo "Starting nginx..."
|
||||||
|
exec nginx -g "daemon off;"
|
||||||
+23
-14
@@ -1,17 +1,26 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Панель Администратора</title>
|
<title>Панель Администратора</title>
|
||||||
<script type="module" src="/src/index.tsx"></script>
|
<script type="module" src="/src/index.tsx"></script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
window.AppVersion = APP_VERSION
|
window.AppVersion = APP_VERSION
|
||||||
</script>
|
</script>
|
||||||
<script type="module" src="/config.js"></script>
|
<script>
|
||||||
<title>Панель администратора</title>
|
let BASE_URL = '%BASE_URL%'
|
||||||
</head>
|
if (BASE_URL === '/') {
|
||||||
<body>
|
BASE_URL = ''
|
||||||
<div id="root"></div>
|
}
|
||||||
</body>
|
BASE_URL = BASE_URL.replace(/\/$/, '')
|
||||||
|
const configScript = document.createElement('script')
|
||||||
|
configScript.src = BASE_URL + '/config.js'
|
||||||
|
document.head.appendChild(configScript)
|
||||||
|
</script>
|
||||||
|
<title>Панель администратора</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Generated
+6105
-3459
File diff suppressed because it is too large.
Load diff
+12
-18
@@ -1,34 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.15.1",
|
"version": "0.26.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"build": "vite build && node generateVersionFile.cjs",
|
"build": "NODE_OPTIONS=--max-old-space-size=4096 vite build && node generateVersionFile.cjs",
|
||||||
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"fix:prettier": "prettier --write \"src/**/*.{ts,tsx, js}\"",
|
"fix:prettier": "prettier --write \"src/**/*.{ts,tsx, js}\"",
|
||||||
"lint:fix": "eslint --fix .",
|
"lint:fix": "eslint --fix .",
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
"prepare": "husky install"
|
"prepare": "husky || true"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
|
||||||
"@monaco-editor/react": "^4.6.0",
|
"@monaco-editor/react": "^4.6.0",
|
||||||
"@reduxjs/toolkit": "^2.2.3",
|
"@reduxjs/toolkit": "^2.2.3",
|
||||||
"@uiw/react-codemirror": "^4.21.25",
|
"axios": "^1.7.7",
|
||||||
"axios": "^1.6.8",
|
|
||||||
"clipboard": "^2.0.11",
|
|
||||||
"compare-versions": "^6.1.0",
|
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"isp-ui-kit": "github:txix-open/isp-ui-kit",
|
"isp-admin-ui-kit": "1.6.5",
|
||||||
"json-schema-view-js": "^2.0.1",
|
"isp-ui-kit": "1.1.1",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"monaco-editor": "^0.55.1",
|
||||||
"monaco-editor": "^0.52.0",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-codemirror-merge": "^4.21.25",
|
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-hook-form": "^7.51.2",
|
"react-hook-form": "^7.51.2",
|
||||||
"react-redux": "^9.1.0",
|
"react-redux": "^9.1.0",
|
||||||
@@ -39,6 +32,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||||
|
"@types/deep-equal": "^1.0.4",
|
||||||
"@types/lodash.clonedeep": "^4.5.9",
|
"@types/lodash.clonedeep": "^4.5.9",
|
||||||
"@types/node": "^20.12.4",
|
"@types/node": "^20.12.4",
|
||||||
"@types/react": "^18.2.74",
|
"@types/react": "^18.2.74",
|
||||||
@@ -50,7 +44,7 @@
|
|||||||
"@vitejs/plugin-legacy": "^5.3.2",
|
"@vitejs/plugin-legacy": "^5.3.2",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"@vitejs/plugin-react-swc": "^3.6.0",
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
||||||
"antd": "5.16.0",
|
"antd": "5.25.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
@@ -61,10 +55,10 @@
|
|||||||
"eslint-plugin-react-refresh": "^0.4.6",
|
"eslint-plugin-react-refresh": "^0.4.6",
|
||||||
"husky": "^9.0.11",
|
"husky": "^9.0.11",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"sass": "^1.74.1",
|
"sass": "1.74.1",
|
||||||
"terser": "^5.30.3",
|
"terser": "^5.30.3",
|
||||||
"typescript": "^5.4.3",
|
"typescript": "^5.4.3",
|
||||||
"vite": "^5.2.8",
|
"vite": "^5.4.10",
|
||||||
"vite-bundle-visualizer": "^1.2.1",
|
"vite-bundle-visualizer": "^1.2.1",
|
||||||
"vite-plugin-node-polyfills": "^0.21.0",
|
"vite-plugin-node-polyfills": "^0.21.0",
|
||||||
"vite-plugin-style-import": "^2.0.0",
|
"vite-plugin-style-import": "^2.0.0",
|
||||||
@@ -79,7 +73,7 @@
|
|||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-coomit": "eslint --fix .",
|
"pre-commit": "eslint --fix .",
|
||||||
"pre-push": "eslint --fix ."
|
"pre-push": "eslint --fix ."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Whitespace-only changes.
@@ -1,9 +0,0 @@
|
|||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<rect width="24" height="24" fill="url(#pattern0)"/>
|
|
||||||
<defs>
|
|
||||||
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
|
|
||||||
<use xlink:href="#image0_121_5920" transform="scale(0.0025)"/>
|
|
||||||
</pattern>
|
|
||||||
<image id="image0_121_5920" width="400" height="400" xlink:href="data:image/png;base64,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 truncated
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,3 +0,0 @@
|
|||||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M13.2118 12.3535L9.15396 8.29564C9.78364 7.48158 10.1243 6.48627 10.1243 5.43939C10.1243 4.18627 9.6352 3.01127 8.75083 2.12533C7.86645 1.23939 6.68833 0.751892 5.43677 0.751892C4.1852 0.751892 3.00708 1.24095 2.1227 2.12533C1.23677 3.0097 0.749268 4.18627 0.749268 5.43939C0.749268 6.69095 1.23833 7.86908 2.1227 8.75345C3.00708 9.63939 4.18364 10.1269 5.43677 10.1269C6.48364 10.1269 7.47739 9.78627 8.29146 9.15814L12.3493 13.2144C12.3612 13.2263 12.3753 13.2357 12.3908 13.2422C12.4064 13.2486 12.4231 13.2519 12.4399 13.2519C12.4567 13.2519 12.4734 13.2486 12.4889 13.2422C12.5045 13.2357 12.5186 13.2263 12.5305 13.2144L13.2118 12.5347C13.2237 12.5228 13.2331 12.5087 13.2396 12.4931C13.246 12.4776 13.2493 12.4609 13.2493 12.4441C13.2493 12.4272 13.246 12.4106 13.2396 12.395C13.2331 12.3795 13.2237 12.3654 13.2118 12.3535ZM7.91177 7.91439C7.24927 8.57533 6.37114 8.93939 5.43677 8.93939C4.50239 8.93939 3.62427 8.57533 2.96177 7.91439C2.30083 7.25189 1.93677 6.37377 1.93677 5.43939C1.93677 4.50502 2.30083 3.62533 2.96177 2.96439C3.62427 2.30345 4.50239 1.93939 5.43677 1.93939C6.37114 1.93939 7.25083 2.30189 7.91177 2.96439C8.57271 3.62689 8.93677 4.50502 8.93677 5.43939C8.93677 6.37377 8.57271 7.25346 7.91177 7.91439Z" fill="black" fill-opacity="0.85"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 382 KiB |
@@ -1,47 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
|
|
||||||
.active-configurations-table {
|
|
||||||
&__title {
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
&__name-field {
|
|
||||||
input {
|
|
||||||
color: #606060;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
color: var(--ant-color-text);
|
|
||||||
padding: $basic-padding;
|
|
||||||
border-radius: 4px;
|
|
||||||
outline: 1px solid $blue-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: $basic-margin;
|
|
||||||
|
|
||||||
&__actions {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.active-config {
|
|
||||||
tr {
|
|
||||||
background: var(--ant-color-info-bg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { ConfigType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ActiveConfigurationsTablePropsType {
|
|
||||||
isActiveTable?: boolean
|
|
||||||
data: ConfigType[]
|
|
||||||
handleShowConfig: (config: ConfigType) => void
|
|
||||||
handleShowCompareModal: (config: ConfigType) => void
|
|
||||||
currentModule?: ModuleType
|
|
||||||
}
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
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="success">Корректная</Tag>
|
|
||||||
}
|
|
||||||
return <Tag color="error">Некорректная</Tag>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Дата обновления',
|
|
||||||
dataIndex: 'updatedAt',
|
|
||||||
key: 'updatedAt',
|
|
||||||
align: 'center',
|
|
||||||
render: (value: string) => {
|
|
||||||
return dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Действия',
|
|
||||||
dataIndex: 'actions',
|
|
||||||
key: 'actions',
|
|
||||||
align: 'center',
|
|
||||||
render: (_: unknown, record: ConfigType) => (
|
|
||||||
<ActiveTableActionButtons
|
|
||||||
isActive={isActiveTable}
|
|
||||||
handleShowConfig={handleShowConfig}
|
|
||||||
handleShowCompareModal={handleShowCompareModal}
|
|
||||||
handleDeleteConfig={handleDeleteConfig}
|
|
||||||
handleMarkConfigActive={handleMarkConfigActive}
|
|
||||||
record={record}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
]
|
|
||||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
|
||||||
return (
|
|
||||||
<div className="active-configurations-table">
|
|
||||||
<div className="active-configurations-table__buttons">
|
|
||||||
<h2 className="active-configurations-table__title">
|
|
||||||
{isActiveTable ? 'Активная' : 'Остальные'}
|
|
||||||
</h2>
|
|
||||||
{!isActiveTable && <CanEdit>
|
|
||||||
<Button
|
|
||||||
className="configurations__buttons__new-config-brn"
|
|
||||||
onClick={() => navigate(`/${moduleId}/${routePaths.configEditor}/new`, {state: currentModule})}
|
|
||||||
>
|
|
||||||
Создать
|
|
||||||
</Button>
|
|
||||||
</CanEdit>}
|
|
||||||
</div>
|
|
||||||
<Table
|
|
||||||
rowHoverable={false}
|
|
||||||
className={className}
|
|
||||||
rowKey={(record) => record.id}
|
|
||||||
pagination={false}
|
|
||||||
columns={columns}
|
|
||||||
dataSource={data}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ActiveConfigurationsTable
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { ConfigProvider } from 'antd'
|
|
||||||
import ruRu from 'antd/locale/ru_RU'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useLocation } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { darkTheme, lightTheme } from '@constants/theme.ts'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import Routers from '@routes/Routers'
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import './app.scss'
|
|
||||||
|
|
||||||
const App = () => {
|
|
||||||
const [themes, setTheme] = useState(lightTheme)
|
|
||||||
const [changeTheme, setChangeTheme] = useState(
|
|
||||||
localStorage.getItem('theme')
|
|
||||||
? JSON.parse(localStorage.getItem('theme') || '')
|
|
||||||
: true
|
|
||||||
)
|
|
||||||
|
|
||||||
const location = useLocation()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const prevRoute = sessionStorage.getItem('prevRoute')
|
|
||||||
if (
|
|
||||||
location.pathname !== routePaths.error &&
|
|
||||||
location.pathname !== routePaths.login &&
|
|
||||||
location.pathname !== prevRoute
|
|
||||||
) {
|
|
||||||
sessionStorage.setItem('prevRoute', location.pathname)
|
|
||||||
}
|
|
||||||
}, [location])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTheme(() => (changeTheme ? darkTheme : lightTheme))
|
|
||||||
}, [changeTheme])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="app">
|
|
||||||
<Context.Provider value={{ setTheme, setChangeTheme, changeTheme }}>
|
|
||||||
<ConfigProvider theme={themes} locale={ruRu}>
|
|
||||||
<Routers />
|
|
||||||
</ConfigProvider>
|
|
||||||
</Context.Provider>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
@import 'src/constants/style/styleConst';
|
|
||||||
|
|
||||||
.app-access-content {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 760px;
|
|
||||||
|
|
||||||
padding: $basic-padding * 1.8;
|
|
||||||
border: 1px solid $border-color;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
|
|
||||||
&__action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__main {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns:1fr 1fr;
|
|
||||||
|
|
||||||
|
|
||||||
&__tree-search-input {
|
|
||||||
width: 350px;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.unknown-label {
|
|
||||||
color: $error-red
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export interface AppAccessContentPropsType {
|
|
||||||
id: number
|
|
||||||
paramPrefix: string
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
import { SearchOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, Input, message, Spin, TreeProps } from 'antd'
|
|
||||||
import { ChangeEvent, FC, memo, useEffect, useState } from 'react'
|
|
||||||
import { Navigate, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import AccessListTree from '@widgets/AccessListTree'
|
|
||||||
import SelectedAccessMethod from '@widgets/SelectedAccessMethod'
|
|
||||||
|
|
||||||
import { AppAccessContentPropsType } from '@components/AppAccessContent/app-access-content.type.ts'
|
|
||||||
|
|
||||||
import { setSearchValue } from '@utils/columnLayoutUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import accessListApi from '@services/accessListService.ts'
|
|
||||||
import routeApi from '@services/routeService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { AccessListMethodType, EndpointType } from '@type/accessList.type.ts'
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './app-access-content.scss'
|
|
||||||
|
|
||||||
const unknownMethodKey = 'неизвестные методы'
|
|
||||||
|
|
||||||
const AppAccessContent: FC<AppAccessContentPropsType> = ({
|
|
||||||
id,
|
|
||||||
paramPrefix
|
|
||||||
}) => {
|
|
||||||
const [messageApi, contextHolder] = message.useMessage()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
const canWrite = hasPermission(PermissionKeysType.write)
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: methods = [],
|
|
||||||
isLoading: isMethodsLoading,
|
|
||||||
isError: isMethodsError,
|
|
||||||
isSuccess: isMethodsSuccess
|
|
||||||
} = accessListApi.useGetByIdQuery({ id })
|
|
||||||
const [setList] = accessListApi.useSetListMutation()
|
|
||||||
const [setOne] = accessListApi.useSetOneMutation()
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: routes = {
|
|
||||||
originalResponse: [],
|
|
||||||
moduleEndpoints: {},
|
|
||||||
allRouteMap: {}
|
|
||||||
},
|
|
||||||
isLoading: isRouteLoading,
|
|
||||||
isError: isRouteError,
|
|
||||||
isSuccess: isRouteSuccess
|
|
||||||
} = routeApi.useGetAllRoutesQuery()
|
|
||||||
const { moduleEndpoints, allRouteMap } = routes
|
|
||||||
const [defaultAllRoutes, setDefaultAllRoutes] = useState<
|
|
||||||
Record<string, EndpointType[]>
|
|
||||||
>({})
|
|
||||||
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const searchValue = searchParams.get(paramPrefix) || ''
|
|
||||||
|
|
||||||
const isLoading = isMethodsLoading || isRouteLoading
|
|
||||||
const isError = isMethodsError || isRouteError
|
|
||||||
const isSuccess = isMethodsSuccess && isRouteSuccess
|
|
||||||
|
|
||||||
const openSuccessMessage = (body: string) => {
|
|
||||||
messageApi.success(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
const openErrorMessage = (body: string) => {
|
|
||||||
messageApi.error(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
const createAllMethodList = (status: boolean) => {
|
|
||||||
return Object.keys(allRouteMap).map((key) => {
|
|
||||||
return {
|
|
||||||
method: key,
|
|
||||||
value: status
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const onCheck: TreeProps['onCheck'] = (_, info): void | never[] => {
|
|
||||||
const { node } = info
|
|
||||||
if (!node.children) {
|
|
||||||
const sendData = {
|
|
||||||
appId: id,
|
|
||||||
method: node.key as string,
|
|
||||||
value: !node.checked
|
|
||||||
}
|
|
||||||
setOne(sendData)
|
|
||||||
.then(() => {
|
|
||||||
openSuccessMessage('Статус метода успешно изменен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
openErrorMessage('Не удалось изменить статус метода')
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const newCheckedKeys = node.children.map((child) => ({
|
|
||||||
method: child.key as string,
|
|
||||||
value: !node.checked
|
|
||||||
}))
|
|
||||||
setListMethods(newCheckedKeys)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const { value } = e.target
|
|
||||||
setSearchValue(value.trim().toLowerCase(), setSearchParams, paramPrefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setListMethods = (methods: AccessListMethodType[]) => {
|
|
||||||
setList({
|
|
||||||
appId: id,
|
|
||||||
methods: methods
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
openSuccessMessage('Статус методов успешно изменен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
openErrorMessage('Не удалось изменить статус методов')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const setAllMethods = (status: boolean) => {
|
|
||||||
const methods = createAllMethodList(status)
|
|
||||||
setListMethods(methods)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getAllRoutes = () => {
|
|
||||||
const missingRoute: EndpointType[] = []
|
|
||||||
const copyAllRoutes = { ...moduleEndpoints }
|
|
||||||
|
|
||||||
methods.forEach((item) => {
|
|
||||||
if (!allRouteMap[item.method]) {
|
|
||||||
missingRoute.push({ path: item.method } as EndpointType)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (missingRoute.length) {
|
|
||||||
copyAllRoutes[unknownMethodKey] = missingRoute
|
|
||||||
}
|
|
||||||
return copyAllRoutes
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const allRoutes = getAllRoutes()
|
|
||||||
setDefaultAllRoutes(allRoutes)
|
|
||||||
}, [isSuccess])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return <Navigate to={routePaths.error} />
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="app-access-content">
|
|
||||||
{contextHolder}
|
|
||||||
<div className="app-access-content__header">
|
|
||||||
<Input
|
|
||||||
prefix={<SearchOutlined />}
|
|
||||||
allowClear
|
|
||||||
className="app-access-content__main__tree-search-input"
|
|
||||||
value={searchValue}
|
|
||||||
placeholder="Найти метод"
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
<div className="app-access-content__header__action-buttons">
|
|
||||||
<Button
|
|
||||||
disabled={!canWrite}
|
|
||||||
onClick={() => {
|
|
||||||
setAllMethods(false)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Запретить все
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
disabled={!canWrite}
|
|
||||||
onClick={() => {
|
|
||||||
setAllMethods(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Выбрать все
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="app-access-content__main">
|
|
||||||
<AccessListTree
|
|
||||||
searchValue={searchValue}
|
|
||||||
onCheck={onCheck}
|
|
||||||
defaultAllRoutes={defaultAllRoutes}
|
|
||||||
methods={methods}
|
|
||||||
/>
|
|
||||||
<SelectedAccessMethod
|
|
||||||
unknownMethodKey={unknownMethodKey}
|
|
||||||
methods={methods}
|
|
||||||
allRoutes={defaultAllRoutes}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(AppAccessContent)
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
export type AppGroupModalType = Omit<
|
|
||||||
ModalPropsType,
|
|
||||||
'onOk' | 'children'
|
|
||||||
> & {
|
|
||||||
appGroup?: ApplicationsGroupType
|
|
||||||
onOk: (data: ApplicationsGroupType) => void
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { FC, useEffect } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
|
|
||||||
const { FormInput, FormTextArea } = FormComponents
|
|
||||||
|
|
||||||
const AppGroupModal: FC<AppGroupModalType> = ({
|
|
||||||
title,
|
|
||||||
onClose,
|
|
||||||
onOk,
|
|
||||||
open,
|
|
||||||
appGroup,
|
|
||||||
|
|
||||||
}) => {
|
|
||||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
|
||||||
mode: 'onChange',
|
|
||||||
defaultValues: appGroup
|
|
||||||
})
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
reset(appGroup)
|
|
||||||
}, [open])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmit(onOk)}
|
|
||||||
title={title}
|
|
||||||
open={open}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormInput
|
|
||||||
control={control}
|
|
||||||
name="name"
|
|
||||||
label="Наименование"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormTextArea
|
|
||||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
|
||||||
control={control}
|
|
||||||
label="Описание"
|
|
||||||
name="description"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AppGroupModal
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
export type AppModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
|
||||||
app?: ApplicationAppType
|
|
||||||
onOk: (data: ApplicationAppType) => void
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { FC, useEffect } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { AppModalType } from '@components/AppModal/app-group-modal.type.ts'
|
|
||||||
|
|
||||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
|
|
||||||
const { FormInput, FormTextArea } = FormComponents
|
|
||||||
|
|
||||||
const AppModal: FC<AppModalType> = ({ title,onOk, onClose, open, app }) => {
|
|
||||||
const { handleSubmit, control, reset } = useForm<ApplicationAppType>({
|
|
||||||
mode: 'onChange',
|
|
||||||
defaultValues: app
|
|
||||||
})
|
|
||||||
useEffect(() => {
|
|
||||||
reset(app)
|
|
||||||
}, [open])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmit(onOk)}
|
|
||||||
title={title}
|
|
||||||
open={open}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormInput
|
|
||||||
control={control}
|
|
||||||
name="name"
|
|
||||||
label="Наименование"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormTextArea
|
|
||||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
|
||||||
control={control}
|
|
||||||
label="Описание"
|
|
||||||
name="description"
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AppModal
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.applications-content {
|
|
||||||
height: 100%;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns:min-content 1fr;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.column-content {
|
|
||||||
margin-left: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__add-btn {
|
|
||||||
display: flex;
|
|
||||||
max-width: 240px;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-bottom: $basic-margin * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__update-btn {
|
|
||||||
margin-right: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__addToken-btn {
|
|
||||||
display: flex;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link-btn {
|
|
||||||
color: $blue-color;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $text-color-blue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.column {
|
|
||||||
border-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
import { FileProtectOutlined } from '@ant-design/icons'
|
|
||||||
import { List, message, Spin, Tooltip } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
|
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import AppModal from '@components/AppModal'
|
|
||||||
import TokenContent from '@components/TokenContent'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApplicationAppType,
|
|
||||||
ApplicationsServiceType,
|
|
||||||
NewApplicationAppType,
|
|
||||||
UpdateApplicationAppType
|
|
||||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import applicationsApi from '@services/applicationsService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import './applications-content.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const { EmptyData, Column } = Layout
|
|
||||||
|
|
||||||
interface ApplicationsContentPropTypes {
|
|
||||||
selectedItemId: number
|
|
||||||
currentApplicationsApp: number
|
|
||||||
setCurrentApplicationsApp: Dispatch<SetStateAction<number>>
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
|
||||||
selectedItemId,
|
|
||||||
setCurrentApplicationsApp
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
data: applications = [],
|
|
||||||
isLoading: isLoadingApplicationsContent = []
|
|
||||||
} = applicationsApi.useGetApplicationsByServiceIdQuery({
|
|
||||||
id: selectedItemId
|
|
||||||
})
|
|
||||||
|
|
||||||
const [createApplicationService] =
|
|
||||||
applicationsApi.useCreateApplicationServiceMutation()
|
|
||||||
const [updateApplication] =
|
|
||||||
applicationsApi.useUpdateApplicationsServiceMutation()
|
|
||||||
const [removeApplicationsService] =
|
|
||||||
applicationsApi.useRemoveApplicationsServiceMutation()
|
|
||||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
|
||||||
addModal: false,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams('')
|
|
||||||
const searchAppValue = searchParams.get('appSearch') || ''
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { appId = '' } = useParams()
|
|
||||||
|
|
||||||
const currentApp = useMemo(() => {
|
|
||||||
const element = applications.find(
|
|
||||||
(application) => application.app.id.toString() === appId
|
|
||||||
)
|
|
||||||
return element ? element.app : undefined
|
|
||||||
}, [applications, appId])
|
|
||||||
|
|
||||||
const updateApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const addApplicationModal = () => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const renderTokenContent = () => {
|
|
||||||
if (!appId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
return <TokenContent key={appId} id={Number(appId)} />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUpdateApplicationApp = (data: ApplicationAppType) => {
|
|
||||||
if (currentApp) {
|
|
||||||
const updateApplications: UpdateApplicationAppType = {
|
|
||||||
id: currentApp.id,
|
|
||||||
name: data.name,
|
|
||||||
description: data.description
|
|
||||||
? data.description
|
|
||||||
: currentApp.description,
|
|
||||||
serviceId: selectedItemId,
|
|
||||||
type: 'SYSTEM'
|
|
||||||
}
|
|
||||||
updateApplication({ ...currentApp, ...updateApplications })
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
message.success('Элемент сохранен')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка обновления элемента'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCreateApplicationApp = (data: ApplicationAppType) => {
|
|
||||||
const newApplicationApp: NewApplicationAppType = {
|
|
||||||
name: data.name,
|
|
||||||
description: data.description,
|
|
||||||
serviceId: selectedItemId,
|
|
||||||
type: 'SYSTEM'
|
|
||||||
}
|
|
||||||
|
|
||||||
createApplicationService(newApplicationApp)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент сохранен')
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка добавления элемента'))
|
|
||||||
}
|
|
||||||
const handleRemoveApplicationApp = (id: number) =>
|
|
||||||
removeApplicationsService([id])
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
message.success('Элемент удален')
|
|
||||||
navigate(`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`)
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Ошибка удаления элемента'))
|
|
||||||
|
|
||||||
const renderColumnItems = (item: ColumnItem<any>) => {
|
|
||||||
return (
|
|
||||||
<List.Item>
|
|
||||||
<Tooltip mouseEnterDelay={1.3} title={item.name}>
|
|
||||||
<List.Item.Meta title={item.name} description={<span>id: {item.id}</span>}/>
|
|
||||||
<div
|
|
||||||
className="link-btn"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
navigate(`/appAccess/${item.id}`)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Tooltip title="Доступы приложений">
|
|
||||||
<FileProtectOutlined />
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
</List.Item>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedItemId) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
if (selectedItemId)
|
|
||||||
if (isLoadingApplicationsContent) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="applications-content">
|
|
||||||
<Column
|
|
||||||
title="Приложения"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
onUpdateItem={updateApplicationModal}
|
|
||||||
showUpdateBtn={true}
|
|
||||||
onAddItem={addApplicationModal}
|
|
||||||
onRemoveItem={() => handleRemoveApplicationApp(Number(appId))}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
applications?.map((el) => {
|
|
||||||
return el.app
|
|
||||||
}) as unknown as ColumnItem<ApplicationsServiceType>[],
|
|
||||||
searchAppValue
|
|
||||||
)}
|
|
||||||
renderItems={renderColumnItems}
|
|
||||||
searchValue={searchAppValue}
|
|
||||||
selectedItemId={appId}
|
|
||||||
setSelectedItemId={(itemId: string) => {
|
|
||||||
setCurrentApplicationsApp(Number(itemId))
|
|
||||||
setSelectedItemId(
|
|
||||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`,
|
|
||||||
itemId.toString(),
|
|
||||||
searchAppValue,
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
onChangeSearchValue={(value: string) => {
|
|
||||||
setSearchValue(
|
|
||||||
value.trim().toLowerCase(),
|
|
||||||
setSearchParams,
|
|
||||||
'appSearch'
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{renderTokenContent()}
|
|
||||||
<AppModal
|
|
||||||
app={currentApp}
|
|
||||||
onOk={handleUpdateApplicationApp}
|
|
||||||
title="Редактировать приложение"
|
|
||||||
open={showApplicationsModal.updateModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<AppModal
|
|
||||||
onOk={handleCreateApplicationApp}
|
|
||||||
title="Добавить приложение"
|
|
||||||
open={showApplicationsModal.addModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ApplicationsContent
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { PropsWithChildren } from 'react'
|
|
||||||
|
|
||||||
import { useRole } from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
const CanEdit = ({ children }: PropsWithChildren) => {
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
if (hasPermission(PermissionKeysType.write)) {
|
|
||||||
return <>{children}</>
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CanEdit
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
export type ChangePasswordModalType = {
|
|
||||||
oldPassword: string
|
|
||||||
newPassword: string
|
|
||||||
confirmPassword: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ChangePasswordModalProps = {
|
|
||||||
open: boolean
|
|
||||||
onClose: () => void
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.compare-version-modal {
|
|
||||||
.modal__wrap {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
justify-content: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__content {
|
|
||||||
overflow: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
margin-top: $basic-margin;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
.cm-merge-theme {
|
|
||||||
overflow-y: scroll;
|
|
||||||
height: calc(90vh - 150px);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow-y: auto;
|
|
||||||
height: calc(90vh - 50px);
|
|
||||||
|
|
||||||
&__row {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
export interface CompareVersionModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
config: Record<string, any>
|
|
||||||
currentConfigId: string
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
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)
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
|
|
||||||
export interface ConfigSchemaModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
schema?: JSONSchema
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.config-schema-modal {
|
|
||||||
.modal__wrap {
|
|
||||||
min-width: 880px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-schema-view {
|
|
||||||
padding: $basic-padding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { FC, memo } from 'react'
|
|
||||||
|
|
||||||
import JsonSchemaViewer from '@widgets/JSONViewer'
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts'
|
|
||||||
|
|
||||||
import './config-schema-modal.scss'
|
|
||||||
|
|
||||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
schema = {}
|
|
||||||
}) => {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="config-schema-modal">
|
|
||||||
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
|
||||||
<JsonSchemaViewer schema={schema} />
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ConfigSchemaModal)
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
import { FC, useContext } from 'react'
|
|
||||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage'
|
|
||||||
import Editor, { loader } from '@monaco-editor/react'
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import * as monaco from 'monaco-editor'
|
|
||||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
||||||
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
||||||
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
|
||||||
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
|
||||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
||||||
|
|
||||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({setDisableBtn= () => {}, bufConfig, setBufConfig }) => {
|
|
||||||
const { changeTheme } = useContext(Context)
|
|
||||||
|
|
||||||
self.MonacoEnvironment = {
|
|
||||||
getWorker(_, label) {
|
|
||||||
if (label === 'json') {
|
|
||||||
return new jsonWorker();
|
|
||||||
}
|
|
||||||
if (label === 'css' || label === 'scss' || label === 'less') {
|
|
||||||
return new cssWorker();
|
|
||||||
}
|
|
||||||
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
|
||||||
return new htmlWorker();
|
|
||||||
}
|
|
||||||
if (label === 'typescript' || label === 'javascript') {
|
|
||||||
return new tsWorker();
|
|
||||||
}
|
|
||||||
return new editorWorker();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
loader.config({ monaco });
|
|
||||||
|
|
||||||
loader.init().then();
|
|
||||||
|
|
||||||
const handleChange = (data: string | undefined) => {
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
try {
|
|
||||||
const newData = {
|
|
||||||
...bufConfig,
|
|
||||||
data: {...JSON.parse(data) }
|
|
||||||
} as ConfigType
|
|
||||||
setDisableBtn(false)
|
|
||||||
setBufConfig(newData)
|
|
||||||
} catch (error) {
|
|
||||||
setDisableBtn(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Editor
|
|
||||||
width="auto"
|
|
||||||
height="100vh"
|
|
||||||
language="json"
|
|
||||||
theme={changeTheme ? 'vs-dark' : 'vs-white'}
|
|
||||||
value={editorValue}
|
|
||||||
onChange={handleChange}
|
|
||||||
options={{
|
|
||||||
minimap: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
fontSize: 16,
|
|
||||||
}}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ConfigurationEditorCode
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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={({updated_src}: any) => handleEdit(updated_src)}
|
|
||||||
onDelete={({updated_src}: any) => handleEdit(updated_src)}
|
|
||||||
displayDataTypes={false}
|
|
||||||
displayObjectSize={false}
|
|
||||||
name={null}
|
|
||||||
enableClipboard={true}
|
|
||||||
iconStyle="square"
|
|
||||||
onEdit={({updated_src}: any) => handleEdit(updated_src)}
|
|
||||||
src={bufConfig.data}
|
|
||||||
sortKeys={true}
|
|
||||||
collapsed={1}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ConfigurationEditorJson
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
.configuration-preview-modal {
|
|
||||||
.react-json-view {
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
|
||||||
|
|
||||||
export interface ConfigurationPreviewModalPropsType
|
|
||||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
|
||||||
config: Record<string, any>
|
|
||||||
versionCompare?: boolean
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { ReactJsonView } from 'isp-ui-kit'
|
|
||||||
import { FC, memo, useContext } from 'react'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import { ConfigurationPreviewModalPropsType } from '@components/ConfigurationPreviewModal/configuration-preview-modal.type.ts'
|
|
||||||
|
|
||||||
import './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)
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
const DefaultUser = () => {
|
|
||||||
return (
|
|
||||||
<span role="img" className="anticon ant-menu-item-icon">
|
|
||||||
<svg
|
|
||||||
data-icon="appstore"
|
|
||||||
width="1.5em"
|
|
||||||
height="1.5em"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
||||||
>
|
|
||||||
<rect width="24" height="24" fill="url(#pattern0)" />
|
|
||||||
<defs>
|
|
||||||
<pattern
|
|
||||||
id="pattern0"
|
|
||||||
patternContentUnits="objectBoundingBox"
|
|
||||||
width="1"
|
|
||||||
height="1"
|
|
||||||
>
|
|
||||||
<use xlinkHref="#image0_121_5920" transform="scale(0.0025)" />
|
|
||||||
</pattern>
|
|
||||||
<image
|
|
||||||
id="image0_121_5920"
|
|
||||||
width="400"
|
|
||||||
height="400"
|
|
||||||
xlinkHref="data:image/png;base64,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 truncated
|
|
||||||
/>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DefaultUser
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
import {
|
|
||||||
AppstoreAddOutlined,
|
|
||||||
FileProtectOutlined,
|
|
||||||
ProductOutlined,
|
|
||||||
ProfileOutlined
|
|
||||||
} from '@ant-design/icons'
|
|
||||||
import type { MenuProps } from 'antd'
|
|
||||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
|
||||||
import { useContext, useEffect, useState } from 'react'
|
|
||||||
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
|
|
||||||
import Header from '@widgets/Header'
|
|
||||||
|
|
||||||
import DefaultUser from '@components/Icons/DefaultUser.tsx'
|
|
||||||
import {
|
|
||||||
MenuItemKeysType,
|
|
||||||
MenuItemType,
|
|
||||||
menuKeys
|
|
||||||
} from '@components/Layout/layout.type.ts'
|
|
||||||
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { fetchProfile, fetchUI } from '@stores/redusers/ActionCreators.ts'
|
|
||||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './layout.scss'
|
|
||||||
|
|
||||||
const { Content, Sider } = Layout
|
|
||||||
|
|
||||||
const LayoutComponent = () => {
|
|
||||||
const [collapsed, setCollapsed] = useState<boolean>(
|
|
||||||
LocalStorage.get('menu') === null ? true : LocalStorage.get('menu')
|
|
||||||
)
|
|
||||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
|
||||||
const [loading, setLoading] = useState(true)
|
|
||||||
const dispatch = useAppDispatch()
|
|
||||||
const {
|
|
||||||
status,
|
|
||||||
profile: { firstName }
|
|
||||||
} = useAppSelector((state) => state.profileReducer)
|
|
||||||
const location = useLocation()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
const { theme } = useContext(ConfigProvider.ConfigContext)
|
|
||||||
|
|
||||||
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
|
|
||||||
|
|
||||||
const hideItem = (permission: PermissionKeysType | PermissionKeysType[]) => {
|
|
||||||
if (Array.isArray(permission)) {
|
|
||||||
const result = permission.reduce((acc, currentValue) => {
|
|
||||||
const hasPermissionFunc = hasPermission(currentValue)
|
|
||||||
return hasPermissionFunc || acc
|
|
||||||
}, false)
|
|
||||||
return result ? '' : 'hide-item'
|
|
||||||
}
|
|
||||||
return hasPermission(permission) ? '' : 'hide-item'
|
|
||||||
}
|
|
||||||
const menuItems: MenuItemType[] = [
|
|
||||||
{
|
|
||||||
label: firstName || '',
|
|
||||||
key: 'profile',
|
|
||||||
className: 'user-item',
|
|
||||||
icon: <DefaultUser />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Приложения',
|
|
||||||
key: 'applications_group',
|
|
||||||
className: hideItem([PermissionKeysType.read]),
|
|
||||||
icon: <AppstoreAddOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Доступы приложений',
|
|
||||||
key: 'appAccess',
|
|
||||||
className: hideItem([PermissionKeysType.read]),
|
|
||||||
icon: <FileProtectOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Модули',
|
|
||||||
key: 'modules',
|
|
||||||
className: hideItem(PermissionKeysType.read),
|
|
||||||
icon: <ProductOutlined />
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Пользователи и роли',
|
|
||||||
key: 'sessionManagement',
|
|
||||||
className: hideItem([
|
|
||||||
PermissionKeysType.user_view,
|
|
||||||
PermissionKeysType.session_view,
|
|
||||||
PermissionKeysType.role_view,
|
|
||||||
]),
|
|
||||||
icon: <ProfileOutlined />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: 'Пользователи',
|
|
||||||
key: 'users',
|
|
||||||
className: hideItem(PermissionKeysType.user_view),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Пользовательские сессии',
|
|
||||||
key: 'sessions',
|
|
||||||
className: hideItem(PermissionKeysType.session_view),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Просмотр журналов ИБ',
|
|
||||||
key: 'securityLog',
|
|
||||||
className: hideItem(PermissionKeysType.security_log_view),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Роли',
|
|
||||||
key: 'roles',
|
|
||||||
className: hideItem(PermissionKeysType.role_view),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
ConfigProvider.config({
|
|
||||||
holderRender: (children) => (
|
|
||||||
<ConfigProvider prefixCls="static" theme={theme}>
|
|
||||||
{children}
|
|
||||||
</ConfigProvider>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}, [theme])
|
|
||||||
useEffect(() => {
|
|
||||||
if (userToken && status === StateProfileStatus.notInit) {
|
|
||||||
dispatch(fetchProfile())
|
|
||||||
dispatch(fetchUI())
|
|
||||||
}
|
|
||||||
}, [userToken, status])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
status === StateProfileStatus.resolved ||
|
|
||||||
status === StateProfileStatus.rejected
|
|
||||||
) {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}, [status])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const menuKey = location.pathname.split('/')[1] as MenuItemKeysType
|
|
||||||
const selectedKey = selectedMenuKeys[0] || ''
|
|
||||||
const menuItem = menuKeys[menuKey]
|
|
||||||
|
|
||||||
if (menuItem && menuKey !== selectedKey) {
|
|
||||||
setSelectedMenuKeys([menuItem.key])
|
|
||||||
if (selectedKey) {
|
|
||||||
setOpenKeys(menuItem.parent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [location.pathname])
|
|
||||||
|
|
||||||
const handlerOnClickMenu: MenuProps['onClick'] = ({ key }): void => {
|
|
||||||
switch (key) {
|
|
||||||
case MenuItemKeysType.profile: {
|
|
||||||
navigate(routePaths.profile)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case MenuItemKeysType.users:
|
|
||||||
navigate(routePaths.users)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.sessions:
|
|
||||||
navigate(routePaths.sessions)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.securityLog:
|
|
||||||
navigate(routePaths.securityLog)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.appAccess:
|
|
||||||
navigate(routePaths.appAccess)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.roles:
|
|
||||||
navigate(routePaths.roles)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.modules:
|
|
||||||
navigate(routePaths.modules)
|
|
||||||
break
|
|
||||||
case MenuItemKeysType.applicationsGroup:
|
|
||||||
navigate(routePaths.applicationsGroup)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loading || status === StateProfileStatus.pending) {
|
|
||||||
return <Spin size="large" fullscreen />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status === StateProfileStatus.rejected) {
|
|
||||||
return <Navigate to={routePaths.error} replace />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section>
|
|
||||||
<Layout className="layout" data-cy="homePage">
|
|
||||||
<Sider
|
|
||||||
width="250px"
|
|
||||||
data-cy="aside"
|
|
||||||
theme="light"
|
|
||||||
collapsible
|
|
||||||
collapsed={collapsed}
|
|
||||||
onCollapse={(value) => {
|
|
||||||
LocalStorage.set('menu', value)
|
|
||||||
setCollapsed(value)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Header collapsed={collapsed} />
|
|
||||||
<Menu
|
|
||||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
|
||||||
openKeys={openKeys}
|
|
||||||
selectedKeys={selectedMenuKeys}
|
|
||||||
onClick={handlerOnClickMenu}
|
|
||||||
theme="light"
|
|
||||||
mode="inline"
|
|
||||||
items={menuItems}
|
|
||||||
/>
|
|
||||||
</Sider>
|
|
||||||
<Layout className="site-layout">
|
|
||||||
<Content className="site-layout__content">
|
|
||||||
<Outlet />
|
|
||||||
</Content>
|
|
||||||
</Layout>
|
|
||||||
</Layout>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LayoutComponent
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
@import 'src/constants/style/styleConst';
|
|
||||||
|
|
||||||
.layout {
|
|
||||||
min-height: 100vh !important;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.hide-item {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-spin {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu {
|
|
||||||
border-inline-end: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-title-content {
|
|
||||||
padding-left: 10px
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-item {
|
|
||||||
padding-left: 21px !important;
|
|
||||||
& .ant-menu-submenu-arrow {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
border-bottom: 1px solid var(--ant-color-border);
|
|
||||||
border-radius: 0 !important;
|
|
||||||
|
|
||||||
& .ant-menu-title-content {
|
|
||||||
margin: 0 !important;
|
|
||||||
padding-left: 17px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-inline-collapsed {
|
|
||||||
& .user-item {
|
|
||||||
padding-left: 24px !important;
|
|
||||||
padding-top: 5px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-menu-submenu {
|
|
||||||
.hide-item {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import { MenuProps } from 'antd'
|
|
||||||
|
|
||||||
export enum MenuItemKeysType {
|
|
||||||
users = 'users',
|
|
||||||
sessions = 'sessions',
|
|
||||||
securityLog = 'securityLog',
|
|
||||||
appAccess = 'appAccess',
|
|
||||||
roles = 'roles',
|
|
||||||
logout = 'logout',
|
|
||||||
profile = 'profile',
|
|
||||||
modules = 'modules',
|
|
||||||
applicationsGroup = 'applications_group'
|
|
||||||
}
|
|
||||||
export enum MenuItemLabelsType {
|
|
||||||
users = 'Пользователи',
|
|
||||||
sessions = 'Пользовательские сессии',
|
|
||||||
securityLog = 'Просмотр журналов ИБ',
|
|
||||||
appAccess = 'Доступы приложений',
|
|
||||||
roles = 'Роли',
|
|
||||||
profile = 'Профиль',
|
|
||||||
modules = 'Модули',
|
|
||||||
logout = 'Выход',
|
|
||||||
applications_group = 'Группы приложений'
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MenuItem {
|
|
||||||
key: MenuItemKeysType
|
|
||||||
parent: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
|
|
||||||
[MenuItemKeysType.users]: {
|
|
||||||
key: MenuItemKeysType.users,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.sessions]: {
|
|
||||||
key: MenuItemKeysType.sessions,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.securityLog]: {
|
|
||||||
key: MenuItemKeysType.securityLog,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.appAccess]: {
|
|
||||||
key: MenuItemKeysType.appAccess,
|
|
||||||
parent: ['appAccess']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.roles]: {
|
|
||||||
key: MenuItemKeysType.roles,
|
|
||||||
parent: ['users']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.logout]: {
|
|
||||||
key: MenuItemKeysType.logout,
|
|
||||||
parent: ['']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.profile]: {
|
|
||||||
key: MenuItemKeysType.profile,
|
|
||||||
parent: ['']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.modules]: {
|
|
||||||
key: MenuItemKeysType.modules,
|
|
||||||
parent: ['modules']
|
|
||||||
},
|
|
||||||
[MenuItemKeysType.applicationsGroup]: {
|
|
||||||
key: MenuItemKeysType.applicationsGroup,
|
|
||||||
parent: ['applicationsGroup']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MenuItemType = Required<MenuProps>['items'][number]
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import { Tabs } from 'antd'
|
|
||||||
import { memo } from 'react'
|
|
||||||
import { useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ModuleTabContent from '@widgets/ModuleTabContent'
|
|
||||||
|
|
||||||
import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts'
|
|
||||||
|
|
||||||
|
|
||||||
const secondColumnItems = [
|
|
||||||
{
|
|
||||||
key: 'configurations',
|
|
||||||
name: 'Конфигурации'
|
|
||||||
},
|
|
||||||
{ key: 'connections', name: 'Подключения' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const ModuleTabs = ({
|
|
||||||
activeTab,
|
|
||||||
setActiveTab,
|
|
||||||
currentModule
|
|
||||||
}: ModuleTabsPropsType) => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
return (
|
|
||||||
<Tabs
|
|
||||||
activeKey={activeTab}
|
|
||||||
onChange={(activeKey) => {
|
|
||||||
setActiveTab(activeKey)
|
|
||||||
const path = `${selectedItemId}/${activeKey}`
|
|
||||||
navigate(path)
|
|
||||||
}}
|
|
||||||
className="modules-page__tabs"
|
|
||||||
items={secondColumnItems.map((item) => {
|
|
||||||
return {
|
|
||||||
disabled: selectedItemId === '',
|
|
||||||
label: item.name,
|
|
||||||
key: item.key,
|
|
||||||
children: (
|
|
||||||
<div className="modules-page__content">
|
|
||||||
<ModuleTabContent
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
currentModule={currentModule}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ModuleTabs)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
export interface ModuleTabsPropsType {
|
|
||||||
activeTab: string
|
|
||||||
setActiveTab: (key: string) => void
|
|
||||||
currentModule: ModuleType | undefined
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import { Descriptions, Spin } from 'antd'
|
|
||||||
|
|
||||||
import { RoleListProps } from '@components/RoleList/role-list.type.ts'
|
|
||||||
|
|
||||||
import roleApi from '@services/roleService.ts'
|
|
||||||
|
|
||||||
import './role-list.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const RoleList = ({ userRoles }: RoleListProps) => {
|
|
||||||
const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery()
|
|
||||||
const roleIds = new Set(userRoles)
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Descriptions layout="vertical" className="role-list">
|
|
||||||
<Descriptions.Item label="Список ролей">
|
|
||||||
{isLoading ? (
|
|
||||||
<Spin className="spin" />
|
|
||||||
) : (
|
|
||||||
<ul>
|
|
||||||
{roles.map((roleData) => {
|
|
||||||
if (roleIds.has(roleData.id) && roleData.name) {
|
|
||||||
return <li key={roleData.id}>{roleData.name}</li>
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RoleList
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.role-list {
|
|
||||||
.ant-descriptions-item-label {
|
|
||||||
font-size: $text-size-header2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spin {
|
|
||||||
position: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul, li {
|
|
||||||
list-style-position: inside
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
font-size: $text-size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export type RoleListProps = {
|
|
||||||
userRoles: number[]
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
import { Divider, message, Table } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import { FormComponents } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { Controller, useForm } from 'react-hook-form'
|
|
||||||
import { useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import SaveButton from '@ui/SaveButton'
|
|
||||||
|
|
||||||
import AgreementModal from '@widgets/AgreementModal'
|
|
||||||
|
|
||||||
import { RolesContentPropsType } from '@components/RolesContent/roles-content.type.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './roles-content.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const newRole: Partial<RoleType> = {
|
|
||||||
externalGroup: '',
|
|
||||||
name: '',
|
|
||||||
permissions: []
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType = [
|
|
||||||
{
|
|
||||||
title: 'Действие',
|
|
||||||
dataIndex: 'name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Ключ в системе',
|
|
||||||
dataIndex: 'key'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
const { FormInput } = FormComponents
|
|
||||||
const RolesContent = ({
|
|
||||||
role,
|
|
||||||
permissions,
|
|
||||||
saveRole,
|
|
||||||
title = 'Редактировать',
|
|
||||||
immutable = false
|
|
||||||
}: RolesContentPropsType) => {
|
|
||||||
const {
|
|
||||||
control,
|
|
||||||
formState: { isDirty },
|
|
||||||
setError,
|
|
||||||
getValues,
|
|
||||||
reset
|
|
||||||
} = useForm<RoleType>({
|
|
||||||
defaultValues: role,
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
const { id: selectedItemId } = useParams()
|
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState<boolean>(false)
|
|
||||||
const isUpdateRole = hasPermission(PermissionKeysType.role_update)
|
|
||||||
const isCreateRole = hasPermission(PermissionKeysType.role_add)
|
|
||||||
|
|
||||||
const isSaveBtnAvailable =
|
|
||||||
selectedItemId === 'new' ? isCreateRole : isUpdateRole
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
reset(newRole)
|
|
||||||
} else {
|
|
||||||
reset(role)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
const handleSubmitForm = (changeMessage: string) => {
|
|
||||||
if (!changeMessage) {
|
|
||||||
message.error('Поле не может быть пустым')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const formValue = getValues()
|
|
||||||
formValue.changeMessage = changeMessage
|
|
||||||
saveRole(formValue, setError)
|
|
||||||
setOpenModal(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderFormTable = () => (
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
name="permissions"
|
|
||||||
render={({ field: { value, onChange } }) => (
|
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
dataSource={permissions}
|
|
||||||
pagination={{ pageSize: 10 }}
|
|
||||||
scroll={{
|
|
||||||
y: 'calc(100vh - 270px)'
|
|
||||||
}}
|
|
||||||
rowSelection={{
|
|
||||||
selectedRowKeys: value,
|
|
||||||
type: 'checkbox',
|
|
||||||
onChange: (selectedRowKeys) => {
|
|
||||||
onChange(selectedRowKeys)
|
|
||||||
},
|
|
||||||
getCheckboxProps: () => ({
|
|
||||||
disabled: immutable
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{openModal && (
|
|
||||||
<AgreementModal
|
|
||||||
open
|
|
||||||
destroyOnClose
|
|
||||||
onCancel={() => setOpenModal(false)}
|
|
||||||
okText="Сохранить"
|
|
||||||
title="Для подтверждения изменений укажите причину"
|
|
||||||
description="Основание для измений"
|
|
||||||
onConfirm={handleSubmitForm}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<form className="roles-content">
|
|
||||||
<div className="roles-content__header">
|
|
||||||
<h2
|
|
||||||
data-cy="roles-content__header__title"
|
|
||||||
className="roles-content__header__title"
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</h2>
|
|
||||||
<SaveButton
|
|
||||||
disabled={!isDirty || !isSaveBtnAvailable}
|
|
||||||
type="primary"
|
|
||||||
data-cy="roles-content__header__save-button"
|
|
||||||
onClick={() => setOpenModal(true)}
|
|
||||||
className="roles-content__header__save-button"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Divider />
|
|
||||||
<div className="roles-content__wrap-input">
|
|
||||||
<FormInput
|
|
||||||
data-cy="roles-content__input__name"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
label="Наименование роли"
|
|
||||||
name="name"
|
|
||||||
control={control}
|
|
||||||
/>
|
|
||||||
<FormInput
|
|
||||||
data-cy="roles-content__input__external-group"
|
|
||||||
label="Группы ЕСК"
|
|
||||||
name="externalGroup"
|
|
||||||
control={control}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{renderFormTable()}
|
|
||||||
</form>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RolesContent
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.roles-content {
|
|
||||||
padding: $basic-padding*2 $basic-padding*3 0;
|
|
||||||
min-width: 400px;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__wrap-input {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-pagination {
|
|
||||||
margin: 8px 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-divider-horizontal {
|
|
||||||
margin: 14px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { UseFormSetError } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
export interface RolesContentPropsType {
|
|
||||||
role?: Partial<RoleType>
|
|
||||||
title?: string
|
|
||||||
immutable?: boolean
|
|
||||||
permissions: PermissionType[]
|
|
||||||
saveRole: (
|
|
||||||
formValue: RoleType | NewRoleType,
|
|
||||||
setError: UseFormSetError<RoleType | NewRoleType>
|
|
||||||
) => void
|
|
||||||
}
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import ClipboardJS from 'clipboard'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import 'dayjs/locale/ru'
|
|
||||||
import duration from 'dayjs/plugin/duration'
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
||||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
|
|
||||||
import Modal from '@widgets/Modal'
|
|
||||||
|
|
||||||
import CanEdit from '@components/CanEdit'
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApplicationTokenType,
|
|
||||||
NewApplicationTokenType
|
|
||||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
|
||||||
|
|
||||||
import tokensApi from '@services/tokensService.ts'
|
|
||||||
|
|
||||||
import './tokens.scss'
|
|
||||||
|
|
||||||
const { FormSelect } = FormComponents
|
|
||||||
const { EmptyData } = Layout
|
|
||||||
|
|
||||||
interface TokenPropTypes {
|
|
||||||
id: number
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-named-as-default-member
|
|
||||||
dayjs.locale('ru')
|
|
||||||
dayjs.extend(duration)
|
|
||||||
dayjs.extend(relativeTime)
|
|
||||||
|
|
||||||
const TokenContent = ({ id }: TokenPropTypes) => {
|
|
||||||
const [showApplicationsModal, setShowApplicationsModal] = useState(false)
|
|
||||||
const {
|
|
||||||
handleSubmit: handleSubmitTokens,
|
|
||||||
control: controlTokens,
|
|
||||||
reset
|
|
||||||
} = useForm<ApplicationTokenType>({
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data, isLoading } = tokensApi.useGetTokensByAppIdQuery({ id })
|
|
||||||
const [createToken] = tokensApi.useCreateTokenMutation()
|
|
||||||
const [revokeToken] = tokensApi.useRevokeTokensMutation()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const clipboard = new ClipboardJS('.copy-btn')
|
|
||||||
clipboard.on('success', () => {
|
|
||||||
message.success('Токен скопирован в буфер обмена')
|
|
||||||
})
|
|
||||||
clipboard.on('error', () => {
|
|
||||||
message.error('Ошибка копирования')
|
|
||||||
})
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clipboard.destroy()
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleCreateToken = (data: any) => {
|
|
||||||
if (id) {
|
|
||||||
const newToken: NewApplicationTokenType = {
|
|
||||||
expireTimeMs: data.expireTime,
|
|
||||||
appId: Number(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
createToken(newToken)
|
|
||||||
.then(() => {
|
|
||||||
setShowApplicationsModal(false)
|
|
||||||
reset()
|
|
||||||
message.success('Элемент добавлен')
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
message.error('Ошибка добавления элемента')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shortenString(longString: string) {
|
|
||||||
if (longString.length <= 6) {
|
|
||||||
return <span>{longString}</span>
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<span>
|
|
||||||
{longString.slice(0, 3)}...{longString.slice(-3)}
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRevokeToken = (elem: ApplicationTokenType) => {
|
|
||||||
const currentRemoveToken = {
|
|
||||||
appId: id,
|
|
||||||
tokens: [elem.token]
|
|
||||||
}
|
|
||||||
|
|
||||||
revokeToken(currentRemoveToken)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => message.success('Элемент удален'))
|
|
||||||
.catch(() => message.error('Ошибка удаления элемента'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const columns: ColumnsType<ApplicationTokenType> = [
|
|
||||||
{
|
|
||||||
title: 'Токен',
|
|
||||||
dataIndex: 'token',
|
|
||||||
key: 'token',
|
|
||||||
render: (value) => <div>{shortenString(value)}</div>
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Дата/Время выпуска',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
key: 'createdAt',
|
|
||||||
render: (value) => {
|
|
||||||
const formatTime = dayjs(value).format(dateFormats.fullFormat)
|
|
||||||
return <div>{formatTime}</div>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Истекает',
|
|
||||||
dataIndex: 'expireTime',
|
|
||||||
key: 'expireTime',
|
|
||||||
render: (value, record) => {
|
|
||||||
if (value === -1) {
|
|
||||||
return <span>Никогда</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
const dateNow = dayjs()
|
|
||||||
const expireTime = dayjs(record.createdAt).add(value)
|
|
||||||
if (expireTime.isBefore(dateNow)) {
|
|
||||||
return <span>Просрочен</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatTime = expireTime.format(dateFormats.fullFormat)
|
|
||||||
return <span>{formatTime}</span>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Действия',
|
|
||||||
dataIndex: 'token',
|
|
||||||
key: 'actions',
|
|
||||||
render: (value, record) => {
|
|
||||||
return (
|
|
||||||
<Button.Group>
|
|
||||||
<Tooltip title="Скопировать">
|
|
||||||
<Button
|
|
||||||
className="copy-btn"
|
|
||||||
icon={<CopyOutlined />}
|
|
||||||
data-clipboard-text={value}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Удалить">
|
|
||||||
<Popconfirm
|
|
||||||
title="Закончить эту сессию?"
|
|
||||||
onConfirm={() => handleRevokeToken(record)}
|
|
||||||
>
|
|
||||||
<Button icon={<DeleteOutlined />} />
|
|
||||||
</Popconfirm>
|
|
||||||
</Tooltip>
|
|
||||||
</Button.Group>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const tokensOptions = useMemo(
|
|
||||||
() => [
|
|
||||||
{
|
|
||||||
value: -1,
|
|
||||||
label: 'Бессрочно'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 3600000,
|
|
||||||
label: 'Один час'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 86400000,
|
|
||||||
label: 'Один день'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 2592000000,
|
|
||||||
label: '30 дней'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 31536000000,
|
|
||||||
label: 'Один год'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
if (!id) {
|
|
||||||
return <EmptyData />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleShowAddModalToken = () => {
|
|
||||||
setShowApplicationsModal(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="token-content">
|
|
||||||
<div className="token-content__wrap">
|
|
||||||
<header className="token-content__header">
|
|
||||||
<h3>Токены</h3>
|
|
||||||
<CanEdit>
|
|
||||||
<Button
|
|
||||||
className="applications-content__add-btn"
|
|
||||||
type="primary"
|
|
||||||
onClick={handleShowAddModalToken}
|
|
||||||
>
|
|
||||||
Добавить токен
|
|
||||||
</Button>
|
|
||||||
</CanEdit>
|
|
||||||
</header>
|
|
||||||
<div className="token-content__table">
|
|
||||||
<Table
|
|
||||||
className="appliactions-tokent__table"
|
|
||||||
rowKey={(record) => record.createdAt}
|
|
||||||
pagination={false}
|
|
||||||
columns={columns}
|
|
||||||
dataSource={data}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Modal
|
|
||||||
onOk={handleSubmitTokens(handleCreateToken)}
|
|
||||||
title="Добавить"
|
|
||||||
open={showApplicationsModal}
|
|
||||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
|
||||||
onClose={() => setShowApplicationsModal(false)}
|
|
||||||
>
|
|
||||||
<form>
|
|
||||||
<FormSelect
|
|
||||||
options={tokensOptions}
|
|
||||||
name="expireTime"
|
|
||||||
control={controlTokens}
|
|
||||||
label="Время действия"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TokenContent
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.token-content {
|
|
||||||
overflow-x: scroll;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow-x: scroll;
|
|
||||||
height: calc(100vh - 100px);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__wrap {
|
|
||||||
padding: $basic-padding*1.25 $basic-padding*3;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 19px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
font-family: PT Sans, sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
*, html {
|
|
||||||
margin:0;
|
|
||||||
padding:0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app{
|
|
||||||
overflow: hidden;
|
|
||||||
height: 100vh;
|
|
||||||
min-height: 0;
|
|
||||||
min-width: 500px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-btn:focus-visible{
|
|
||||||
outline: none !important;
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
type PathKeys =
|
|
||||||
| 'baseUrl'
|
|
||||||
| 'baseSystemUrl'
|
|
||||||
| 'baseConfigUrl'
|
|
||||||
| 'getAllRoles'
|
|
||||||
| 'createRole'
|
|
||||||
| 'updateRole'
|
|
||||||
| 'deleteRole'
|
|
||||||
| 'login'
|
|
||||||
| 'logout'
|
|
||||||
| 'getProfile'
|
|
||||||
| 'getUsers'
|
|
||||||
| 'createUser'
|
|
||||||
| 'updateUser'
|
|
||||||
| 'blockUser'
|
|
||||||
| 'deleteUser'
|
|
||||||
| 'getRoles'
|
|
||||||
| 'getAllPermissions'
|
|
||||||
| 'baseUserUrl'
|
|
||||||
| 'baseAdminUrl'
|
|
||||||
| 'getAllSession'
|
|
||||||
| 'revokeSession'
|
|
||||||
| 'getAllLogs'
|
|
||||||
| 'getLogEvents'
|
|
||||||
| 'setLogEvents'
|
|
||||||
| 'getSystemTree'
|
|
||||||
| 'getById'
|
|
||||||
| 'setList'
|
|
||||||
| 'setOne'
|
|
||||||
| 'getAllRoutes'
|
|
||||||
| 'getModules'
|
|
||||||
| 'deleteModule'
|
|
||||||
| 'createUpdateService'
|
|
||||||
| 'deleteService'
|
|
||||||
| 'getAllService'
|
|
||||||
| 'getServiceById'
|
|
||||||
| 'getServicesByDomainId'
|
|
||||||
| 'createUpdateApplication'
|
|
||||||
| 'deleteApplication'
|
|
||||||
| 'getApplicationById'
|
|
||||||
| 'getAllApplications'
|
|
||||||
| 'getApplicationsByServiceId'
|
|
||||||
| 'createToken'
|
|
||||||
| 'getTokensByAppId'
|
|
||||||
| 'revokeTokens'
|
|
||||||
| 'revokeTokensForApp'
|
|
||||||
| 'getConfigsByModuleId'
|
|
||||||
| 'getConfigById'
|
|
||||||
| 'getAllVersions'
|
|
||||||
| 'createUpdateConfig'
|
|
||||||
| 'deleteVersion'
|
|
||||||
| 'deleteConfig'
|
|
||||||
| 'markConfigAsActive'
|
|
||||||
| 'getUI'
|
|
||||||
| 'getByModuleId'
|
|
||||||
| 'changePassword'
|
|
||||||
|
|
||||||
export const apiPaths: Record<PathKeys, string> = {
|
|
||||||
baseUrl: '/api/kkd-configuration-service',
|
|
||||||
baseAdminUrl: '/api/admin',
|
|
||||||
baseUserUrl: '/api/admin/user',
|
|
||||||
baseSystemUrl: '/api/system',
|
|
||||||
baseConfigUrl: '/api/config',
|
|
||||||
// ======= ROLES ======
|
|
||||||
getAllRoles: '/role/all',
|
|
||||||
createRole: '/role/create',
|
|
||||||
updateRole: '/role/update',
|
|
||||||
deleteRole: '/role/delete',
|
|
||||||
// ======= AUTH ======
|
|
||||||
login: '/api/admin/auth/login',
|
|
||||||
logout: '/api/admin/auth/logout',
|
|
||||||
// ======= PROFILE ======
|
|
||||||
getProfile: '/api/admin/user/get_profile',
|
|
||||||
getUI: '/api/admin/user/get_design',
|
|
||||||
changePassword: '/api/admin/user/change_password',
|
|
||||||
// ======= USERS ======
|
|
||||||
getUsers: '/get_users',
|
|
||||||
createUser: '/create_user',
|
|
||||||
updateUser: '/update_user',
|
|
||||||
blockUser: '/block_user',
|
|
||||||
deleteUser: '/delete_user',
|
|
||||||
getRoles: '/get_roles',
|
|
||||||
getAllPermissions: '/get_permissions',
|
|
||||||
// ======= SESSIONS ======
|
|
||||||
getAllSession: '/session/all',
|
|
||||||
revokeSession: '/session/revoke',
|
|
||||||
// ======= LOGS ======
|
|
||||||
getAllLogs: '/log/all',
|
|
||||||
getLogEvents: '/log/events',
|
|
||||||
setLogEvents: '/log/set_events',
|
|
||||||
// ======= APPLICATIONS ======
|
|
||||||
getSystemTree: '/application/get_system_tree',
|
|
||||||
getAllApplications: '/application/get_applications',
|
|
||||||
createUpdateApplication: '/application/create_update_application',
|
|
||||||
getApplicationsByServiceId: '/application/get_applications_by_service_id',
|
|
||||||
deleteApplication: '/application/delete_applications',
|
|
||||||
getApplicationById: '/application/get_application_by_id',
|
|
||||||
// ======= ACCESS_LIST ======
|
|
||||||
getById: '/access_list/get_by_id',
|
|
||||||
setList: '/access_list/set_list',
|
|
||||||
setOne: '/access_list/set_one',
|
|
||||||
getAllRoutes: '/routing/get_routes',
|
|
||||||
// ======= MODULES ======
|
|
||||||
getModules: '/module/get_modules_info',
|
|
||||||
deleteModule: '/module/delete_module',
|
|
||||||
getByModuleId: '/schema/get_by_module_id',
|
|
||||||
// ======= SERVICE ======
|
|
||||||
getServiceById: '/service/get_service_by_id',
|
|
||||||
getAllService: '/service/get_service',
|
|
||||||
deleteService: '/service/delete_service',
|
|
||||||
createUpdateService: '/service/create_update_service',
|
|
||||||
getServicesByDomainId: '/service/get_services_by_domain_id',
|
|
||||||
// ======= TOKENS ======
|
|
||||||
createToken: '/token/create_token',
|
|
||||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
|
||||||
revokeTokens: '/token/revoke_tokens',
|
|
||||||
revokeTokensForApp: '/token/revoke_tokens_for_app',
|
|
||||||
// ======= CONFIGS ======
|
|
||||||
getConfigsByModuleId: '/config/get_configs_by_module_id',
|
|
||||||
getConfigById: '/config/get_config_by_id',
|
|
||||||
getAllVersions: '/config/get_all_version',
|
|
||||||
createUpdateConfig: '/config/create_update_config',
|
|
||||||
deleteVersion: '/config/delete_version',
|
|
||||||
deleteConfig: '/config/delete_config',
|
|
||||||
markConfigAsActive: '/config/mark_config_as_active'
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type FormattersKey = 'fullFormat'
|
|
||||||
|
|
||||||
|
|
||||||
export const dateFormats:Record<FormattersKey,string> = {
|
|
||||||
fullFormat: 'DD.MM.YYYY HH:mm:ss'
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
type ValidationRulesKeys = 'required'
|
|
||||||
|
|
||||||
export const ValidationRules: Record<ValidationRulesKeys, any> = {
|
|
||||||
required: { value: true, message: 'Поле не может быть пустым' }
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type LocalStorageKeys = 'HEADER_NAME' | 'USER_TOKEN'
|
|
||||||
|
|
||||||
export const localStorageKeys: Record<LocalStorageKeys, string> = {
|
|
||||||
HEADER_NAME: 'HEADER_NAME',
|
|
||||||
USER_TOKEN: 'USER_TOKEN'
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type MessagesKey = 'serverError' | 'loginError'
|
|
||||||
|
|
||||||
export const messages: Record<MessagesKey, string> = {
|
|
||||||
serverError: 'Внутренняя ошибка сервиса',
|
|
||||||
loginError: 'Неверный логин или пароль'
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
export enum SessionStatusKeysType {
|
|
||||||
allowed = 'ALLOWED',
|
|
||||||
revoked = 'REVOKED',
|
|
||||||
expired = 'EXPIRED'
|
|
||||||
}
|
|
||||||
|
|
||||||
export const sessionStatuses: Record<SessionStatusKeysType, string> = {
|
|
||||||
[SessionStatusKeysType.allowed]: 'Активная',
|
|
||||||
[SessionStatusKeysType.revoked]: 'Отмененная',
|
|
||||||
[SessionStatusKeysType.expired]: 'Истекшая'
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
$basic-margin: 8px;
|
|
||||||
$basic-padding: 8px;
|
|
||||||
|
|
||||||
$text-size: 1rem;
|
|
||||||
$text-size-header1: 1.7rem;
|
|
||||||
$text-size-header2: 1.25rem;
|
|
||||||
|
|
||||||
$text-color-gray: var(--ant-layout-header-color);
|
|
||||||
$background-color: var(--ant-layout-light-sider-bg);
|
|
||||||
$grey: #606060;
|
|
||||||
$border-color: var(--ant-color-border);
|
|
||||||
$error-red: #cf1322;
|
|
||||||
|
|
||||||
$blue-color: #40A9FF;
|
|
||||||
$blue-light: #E6F7FF;
|
|
||||||
$text-color-blue: #1890FF;
|
|
||||||
|
|
||||||
$blue-color-2: #bae0ff;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { theme } from 'antd'
|
|
||||||
|
|
||||||
export const darkTheme = {
|
|
||||||
algorithm: theme.darkAlgorithm,
|
|
||||||
cssVar: true,
|
|
||||||
token: {
|
|
||||||
colorBgLayout: '#000000'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const lightTheme = {
|
|
||||||
algorithm: theme.defaultAlgorithm,
|
|
||||||
cssVar: true,
|
|
||||||
token: {
|
|
||||||
colorBgLayout: '#FFFFFF'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
|
||||||
|
|
||||||
import { AppDispatch, RootState } from '../stores'
|
|
||||||
|
|
||||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
|
||||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import { useAuth } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
|
|
||||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
|
|
||||||
const useLogout = () => {
|
|
||||||
const { logout, isLoading } = useAuth()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME)
|
|
||||||
|
|
||||||
const logoutUser = () =>
|
|
||||||
logout(apiPaths.logout, {
|
|
||||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
|
||||||
'APP_TOKEN',
|
|
||||||
import.meta.env.VITE_APP_TOKEN
|
|
||||||
),
|
|
||||||
[headerName]: LocalStorage.get(localStorageKeys.USER_TOKEN)
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
LocalStorage.remove(localStorageKeys.USER_TOKEN)
|
|
||||||
LocalStorage.remove(localStorageKeys.HEADER_NAME)
|
|
||||||
navigate(routePaths.login, { replace: true })
|
|
||||||
})
|
|
||||||
.catch(() => {})
|
|
||||||
return { isLoading, logoutUser }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default useLogout
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { useMemo } from 'react'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import { useAppSelector } from './redux.ts'
|
|
||||||
|
|
||||||
export const useRole = () => {
|
|
||||||
const { profile } = useAppSelector((state: any) => state.profileReducer)
|
|
||||||
const role: string = useMemo(() => profile && profile.role, [profile])
|
|
||||||
|
|
||||||
const hasPermission = (permission: PermissionKeysType) => {
|
|
||||||
const userPermission = profile.permissions || []
|
|
||||||
return userPermission.includes(permission)
|
|
||||||
}
|
|
||||||
|
|
||||||
return { role, hasPermission }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default useRole
|
|
||||||
+34
-10
@@ -1,26 +1,50 @@
|
|||||||
|
import { loader } from '@monaco-editor/react'
|
||||||
import { setupListeners } from '@reduxjs/toolkit/query'
|
import { setupListeners } from '@reduxjs/toolkit/query'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import 'dayjs/locale/ru'
|
||||||
|
import { AdminBase, baseSetupStore } from 'isp-admin-ui-kit'
|
||||||
|
import * as monaco from 'monaco-editor'
|
||||||
|
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
|
||||||
|
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
|
||||||
|
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
|
||||||
|
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
|
||||||
|
|
||||||
import App from './components/App.tsx'
|
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
||||||
|
|
||||||
import { setupStore } from './stores'
|
|
||||||
import 'dayjs/locale/ru'
|
|
||||||
|
|
||||||
import 'react-resizable/css/styles.css'
|
import 'react-resizable/css/styles.css'
|
||||||
import 'simplebar-react/dist/simplebar.min.css'
|
import 'simplebar-react/dist/simplebar.min.css'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
|
self.MonacoEnvironment = {
|
||||||
|
getWorker(_, label) {
|
||||||
|
if (label === 'json') {
|
||||||
|
return new jsonWorker()
|
||||||
|
}
|
||||||
|
if (label === 'css' || label === 'scss' || label === 'less') {
|
||||||
|
return new cssWorker()
|
||||||
|
}
|
||||||
|
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
||||||
|
return new htmlWorker()
|
||||||
|
}
|
||||||
|
if (label === 'typescript' || label === 'javascript') {
|
||||||
|
return new tsWorker()
|
||||||
|
}
|
||||||
|
return new editorWorker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loader.config({ monaco })
|
||||||
|
|
||||||
|
loader.init().then()
|
||||||
|
|
||||||
dayjs.locale('ru')
|
dayjs.locale('ru')
|
||||||
const store = setupStore()
|
const store = baseSetupStore()
|
||||||
setupListeners(store.dispatch)
|
setupListeners(store.dispatch)
|
||||||
const root = createRoot(document.getElementById('root') as HTMLElement)
|
const root = createRoot(document.getElementById('root') as HTMLElement)
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<BrowserRouter>
|
<AdminBase />
|
||||||
<App />
|
|
||||||
</BrowserRouter>
|
|
||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.all-version-page {
|
|
||||||
padding: $basic-padding*2 0;
|
|
||||||
|
|
||||||
&__back-btn {
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
|
||||||
overflow: auto;
|
|
||||||
height: calc(100vh - 150px);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions-field {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,221 +0,0 @@
|
|||||||
import {
|
|
||||||
DeleteOutlined,
|
|
||||||
EyeOutlined,
|
|
||||||
ReloadOutlined,
|
|
||||||
SwapOutlined
|
|
||||||
} from '@ant-design/icons'
|
|
||||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
|
||||||
import { ColumnsType } from 'antd/es/table'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { Navigate, useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import 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
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.app-access-page {
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
.ant-tree {
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content-wrap {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,114 +0,0 @@
|
|||||||
import { Spin } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { memo, useEffect } from 'react'
|
|
||||||
import {
|
|
||||||
createSearchParams,
|
|
||||||
Navigate,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import ListItem from '@widgets/ListItem'
|
|
||||||
|
|
||||||
import AppAccessContent from '@components/AppAccessContent'
|
|
||||||
|
|
||||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import appApi from '@services/appService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { SystemTreeAppType } from '@type/app.type.ts'
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './app-access-page.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const { Column, EmptyData } = Layout
|
|
||||||
|
|
||||||
const firstColumnSearchParam = 'search'
|
|
||||||
const findMethodParam = 'method'
|
|
||||||
|
|
||||||
const AppAccessPage = () => {
|
|
||||||
const {
|
|
||||||
data = { originalResponse: [], appList: [] },
|
|
||||||
isLoading,
|
|
||||||
isError
|
|
||||||
} = appApi.useGetSystemTreeQuery()
|
|
||||||
|
|
||||||
const { appList } = data
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { hasPermission } = useRole()
|
|
||||||
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const searchValue = searchParams.get(firstColumnSearchParam) || ''
|
|
||||||
const canRead = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!canRead) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [canRead])
|
|
||||||
|
|
||||||
const handleOnChangeSearchValue = (value: string): void => {
|
|
||||||
setSearchValue(value, setSearchParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSelectedItemId = (id: string): void => {
|
|
||||||
setSearchValue('', setSearchParams, findMethodParam)
|
|
||||||
setSelectedItemId(
|
|
||||||
routePaths.appAccess,
|
|
||||||
id,
|
|
||||||
createSearchParams(searchParams).toString(),
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin className="spin" />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError) {
|
|
||||||
return <Navigate to={routePaths.error} />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="app-access-page">
|
|
||||||
<Column
|
|
||||||
title="Приложения"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
showUpdateBtn={false}
|
|
||||||
showAddBtn={false}
|
|
||||||
showRemoveBtn={false}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
appList as ColumnItem<SystemTreeAppType>,
|
|
||||||
searchValue
|
|
||||||
)}
|
|
||||||
renderItems={(item) => <ListItem item={item} />}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={onSelectedItemId}
|
|
||||||
onChangeSearchValue={handleOnChangeSearchValue}
|
|
||||||
/>
|
|
||||||
<div className="app-access-page__content-wrap">
|
|
||||||
{selectedItemId ? (
|
|
||||||
<AppAccessContent
|
|
||||||
paramPrefix={findMethodParam}
|
|
||||||
key={`content-${selectedItemId}`}
|
|
||||||
id={Number(selectedItemId)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<EmptyData />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(AppAccessPage)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.applications-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
&__list {
|
|
||||||
.ant-list-item {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: self-start;
|
|
||||||
|
|
||||||
.applications-page__list__desc {
|
|
||||||
width: auto !important;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.column-content {
|
|
||||||
max-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__wrap{
|
|
||||||
min-width: 380px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
export interface ApplicationsGroupType {
|
|
||||||
createdAt: string
|
|
||||||
description: string
|
|
||||||
domainId: number
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
updatedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NewApplicationsGroupType = Omit<
|
|
||||||
ApplicationsGroupType,
|
|
||||||
'id' | 'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type UpdateApplicationsGroupType = Omit<
|
|
||||||
ApplicationsGroupType,
|
|
||||||
'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
|
|
||||||
export interface ApplicationsServiceType {
|
|
||||||
app: ApplicationAppType
|
|
||||||
tokens: ApplicationTokenType[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type NewApplicationTokenType = {
|
|
||||||
appId: number
|
|
||||||
expireTimeMs: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationAppType {
|
|
||||||
createdAt: string
|
|
||||||
description: string
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
serviceId: number
|
|
||||||
type: string
|
|
||||||
updatedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UpdateApplicationAppType = Omit<
|
|
||||||
ApplicationAppType,
|
|
||||||
'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type NewApplicationAppType = Omit<
|
|
||||||
ApplicationAppType,
|
|
||||||
'id' | 'createdAt' | 'updatedAt'
|
|
||||||
>
|
|
||||||
export type RevokeTokenType = {
|
|
||||||
appId: number
|
|
||||||
tokens: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationTokenType {
|
|
||||||
appId: number
|
|
||||||
createdAt: string
|
|
||||||
expireTime: number
|
|
||||||
token: string
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
import { message, Spin } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import 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="Группы приложений"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
onUpdateItem={updateApplicationModal}
|
|
||||||
showUpdateBtn={true}
|
|
||||||
onAddItem={addApplicationModal}
|
|
||||||
onRemoveItem={handleRemoveApplicationsGtoup}
|
|
||||||
items={filterFirstColumnItems(
|
|
||||||
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
|
|
||||||
searchValue
|
|
||||||
)}
|
|
||||||
renderItems={(item) => <ListItem item={item} />}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={(itemId) => {
|
|
||||||
setCurrentApplicationsApp(0)
|
|
||||||
setSelectedItemId(
|
|
||||||
`${routePaths.applicationsGroup}`,
|
|
||||||
itemId,
|
|
||||||
searchValue,
|
|
||||||
navigate
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
onChangeSearchValue={(value) => setSearchValue(value, setSearchParams)}
|
|
||||||
/>
|
|
||||||
{renderMainContent()}
|
|
||||||
<AppGroupModal
|
|
||||||
onOk={handleAddApplicationGroup}
|
|
||||||
title="Добавить группу приложений"
|
|
||||||
open={showApplicationsModal.addModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
addModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<AppGroupModal
|
|
||||||
appGroup={currentAppGroup}
|
|
||||||
title="Редактировать группу приложений"
|
|
||||||
onOk={handleUpdateApplicationsGroup}
|
|
||||||
open={showApplicationsModal.updateModal}
|
|
||||||
onClose={() =>
|
|
||||||
setShowApplicationsModal({
|
|
||||||
...showApplicationsModal,
|
|
||||||
updateModal: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ApplicationsPage
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.configuration-editor-page {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
-ms-overflow-style: none; /* IE и Edge */
|
|
||||||
scrollbar-width: none;
|
|
||||||
border-left: 1px solid $border-color;
|
|
||||||
height: 100vh;
|
|
||||||
overflow: scroll;
|
|
||||||
padding-bottom: 80px;
|
|
||||||
&::-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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
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 })
|
|
||||||
}
|
|
||||||
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
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.configurations {
|
|
||||||
height: calc(100vh - 80px);
|
|
||||||
width: 100%;
|
|
||||||
overflow-y: auto;
|
|
||||||
min-width: 700px;
|
|
||||||
|
|
||||||
&__buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: $basic-margin*2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.active-configurations-table:last-child {
|
|
||||||
margin-top: $basic-margin*3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
import { Button, Spin } from 'antd'
|
|
||||||
import { memo, useEffect, useMemo, useState } from 'react'
|
|
||||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
|
||||||
|
|
||||||
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
|
||||||
import CompareVersionModal from '@components/CompareVersionModal'
|
|
||||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
|
||||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
|
||||||
|
|
||||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import configServiceApi from '@services/configService.ts'
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './configurations.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const Configurations = () => {
|
|
||||||
const {
|
|
||||||
data: modulesList = [],
|
|
||||||
isLoading: isModulesLoading,
|
|
||||||
isError: isModulesError
|
|
||||||
} = modulesServiceApi.useGetModulesQuery('configurations')
|
|
||||||
const { id: selectedItemId = '', configId = '' } = useParams()
|
|
||||||
const {
|
|
||||||
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
|
||||||
isLoading: isConfigsLoading,
|
|
||||||
isError: isConfigsError
|
|
||||||
} = configServiceApi.useGetConfigsByModuleIdQuery(selectedItemId)
|
|
||||||
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
||||||
const [isShowModalOpen, setisShowModalOpen] = useState(false)
|
|
||||||
const [isCompareModalOpen, setIsCompareModalOpen] = useState(false)
|
|
||||||
|
|
||||||
const [currentConfig, setCurrentConfig] = useState<ConfigType>(
|
|
||||||
{} as ConfigType
|
|
||||||
)
|
|
||||||
const { activeConfigs, inactiveConfigs } = data
|
|
||||||
const currentModule = useMemo(
|
|
||||||
() => modulesList.find((module) => module.id === selectedItemId),
|
|
||||||
[selectedItemId, modulesList]
|
|
||||||
)
|
|
||||||
const isLoading = isModulesLoading || isConfigsLoading
|
|
||||||
const isError = isModulesError || isConfigsError
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.home)
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configId) {
|
|
||||||
return <Outlet />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="configurations">
|
|
||||||
<ConfigurationPreviewModal
|
|
||||||
config={currentConfig}
|
|
||||||
open={isShowModalOpen}
|
|
||||||
onClose={() => setisShowModalOpen(false)}
|
|
||||||
/>
|
|
||||||
<ConfigSchemaModal
|
|
||||||
schema={currentModule?.configSchema || {}}
|
|
||||||
open={isModalOpen}
|
|
||||||
onClose={() => setIsModalOpen(false)}
|
|
||||||
/>
|
|
||||||
{isCompareModalOpen && (
|
|
||||||
<CompareVersionModal
|
|
||||||
currentConfigId={currentConfig.id}
|
|
||||||
config={currentConfig}
|
|
||||||
open={isCompareModalOpen}
|
|
||||||
onClose={() => setIsCompareModalOpen(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="configurations__buttons">
|
|
||||||
<Button
|
|
||||||
disabled={!currentModule?.configSchema}
|
|
||||||
className="configurations____buttons__show-schema-btn"
|
|
||||||
onClick={() => setIsModalOpen(true)}
|
|
||||||
>
|
|
||||||
Текущая схема
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ActiveConfigurationsTable
|
|
||||||
currentModule={currentModule}
|
|
||||||
isActiveTable
|
|
||||||
data={isError ? [] : activeConfigs}
|
|
||||||
handleShowConfig={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setisShowModalOpen(true)
|
|
||||||
}}
|
|
||||||
handleShowCompareModal={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setIsCompareModalOpen(true)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<ActiveConfigurationsTable
|
|
||||||
currentModule={currentModule}
|
|
||||||
data={isError ? [] : inactiveConfigs}
|
|
||||||
handleShowConfig={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setisShowModalOpen(true)
|
|
||||||
}}
|
|
||||||
handleShowCompareModal={(config) => {
|
|
||||||
setCurrentConfig(config)
|
|
||||||
setIsCompareModalOpen(true)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(Configurations)
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.connection-page {
|
|
||||||
&__content {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__wrap-table {
|
|
||||||
overflow-x: scroll;
|
|
||||||
height: calc(100vh - 70px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__endpoint-list {
|
|
||||||
&__item {
|
|
||||||
height: 25px;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__inner-marker {
|
|
||||||
font-size: 11px;
|
|
||||||
border: 1px solid var(--ant-color-border);
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 0 4px;
|
|
||||||
margin: 4px
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__no-data {
|
|
||||||
user-select: none;
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
font-size: 1.5em;
|
|
||||||
overflow: hidden;
|
|
||||||
font-family: PT Sans, sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
padding: 8px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
|
||||||
&__inner-tag{
|
|
||||||
margin-left: $basic-margin !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
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)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Button } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
const { ErrorPage } = Layout
|
|
||||||
|
|
||||||
const ErrorWrapperPage = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ErrorPage>
|
|
||||||
<Button type="primary" onClick={() => navigate(routePaths.modules)}>
|
|
||||||
На главную
|
|
||||||
</Button>
|
|
||||||
</ErrorPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ErrorWrapperPage
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
.home-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
background-image: url("/src/assets/images/home-background.png");
|
|
||||||
font-size: calc(1.5vw + 1.5vh);
|
|
||||||
font-family: 'Roboto',sans-serif;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 56px;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import './home-page.scss'
|
|
||||||
|
|
||||||
const HomePage = () => {
|
|
||||||
return <div className="home-page">Добро пожаловать!</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HomePage
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
import { LockOutlined, UserOutlined } from '@ant-design/icons'
|
|
||||||
import { Button, Divider, Layout } from 'antd'
|
|
||||||
import { AxiosError } from 'axios'
|
|
||||||
import { FormComponents, useAuth } from 'isp-ui-kit'
|
|
||||||
import { useForm } from 'react-hook-form'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
|
||||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
|
||||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
|
||||||
import { messages } from '@constants/messages.ts'
|
|
||||||
|
|
||||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
|
||||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { MSPError } from '@type/index.ts'
|
|
||||||
import { LoginRequest } from '@type/login.type.ts'
|
|
||||||
|
|
||||||
import './login-page.scss'
|
|
||||||
|
|
||||||
const passwordLoginEnabled = getConfigProperty('ENABLE_PASSWORD_LOGIN', true)
|
|
||||||
|
|
||||||
const LoginPage = () => {
|
|
||||||
const { login, isLoading } = useAuth()
|
|
||||||
const { handleSubmit, control, setError } = useForm<LoginRequest>({
|
|
||||||
mode: 'onChange'
|
|
||||||
})
|
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
const setFormError = (statusText: string, message: string): void => {
|
|
||||||
setError('email', {})
|
|
||||||
setError('password', {
|
|
||||||
message,
|
|
||||||
type: statusText
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleError = (err: AxiosError<MSPError>): void => {
|
|
||||||
const { response, status } = err
|
|
||||||
if (response && status === 401) {
|
|
||||||
setFormError(response.statusText, messages.loginError)
|
|
||||||
} else {
|
|
||||||
setFormError('serverError', messages.serverError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmitForm = (data: LoginRequest): void => {
|
|
||||||
login(apiPaths.login, data, {
|
|
||||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
|
||||||
'APP_TOKEN',
|
|
||||||
import.meta.env.VITE_APP_TOKEN
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
LocalStorage.set(localStorageKeys.HEADER_NAME, response.headerName)
|
|
||||||
LocalStorage.set(localStorageKeys.USER_TOKEN, response.token)
|
|
||||||
const redirectUrl =
|
|
||||||
sessionStorage.getItem('prevRoute') || routePaths.home
|
|
||||||
navigate(redirectUrl, { replace: true })
|
|
||||||
})
|
|
||||||
.catch((err: AxiosError<MSPError>) => handleError(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderInternalAuthForm = () => {
|
|
||||||
if (!passwordLoginEnabled) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<FormComponents.FormInput
|
|
||||||
data-cy="email-input"
|
|
||||||
control={control}
|
|
||||||
name="email"
|
|
||||||
className="login-page__content__email-field"
|
|
||||||
prefix={<UserOutlined className="color" />}
|
|
||||||
placeholder="Логин"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<FormComponents.FormInput
|
|
||||||
data-cy="password-input"
|
|
||||||
control={control}
|
|
||||||
name="password"
|
|
||||||
className="login-page__content__password-field"
|
|
||||||
prefix={<LockOutlined className="color" />}
|
|
||||||
type="password"
|
|
||||||
placeholder="Пароль"
|
|
||||||
rules={{ required: ValidationRules.required }}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
data-cy="submit-btn"
|
|
||||||
disabled={isLoading}
|
|
||||||
loading={isLoading}
|
|
||||||
type="primary"
|
|
||||||
className="login-page__content__submit-btn"
|
|
||||||
onClick={handleSubmit(handleSubmitForm)}
|
|
||||||
>
|
|
||||||
Войти
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Layout>
|
|
||||||
<section className="login-page">
|
|
||||||
<form className="login-page__content">
|
|
||||||
<h1 data-cy="login-title" className="login-page__content__title">
|
|
||||||
Вход в систему
|
|
||||||
</h1>
|
|
||||||
<Divider />
|
|
||||||
{renderInternalAuthForm()}
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
</Layout>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LoginPage
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
@import "src/constants/style/styleConst";
|
|
||||||
|
|
||||||
.login-page {
|
|
||||||
height: 100vh;
|
|
||||||
background: $background-color;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.ant-input {
|
|
||||||
width: 300px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-divider-horizontal {
|
|
||||||
margin-top: $basic-margin !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-form-item-explain-error {
|
|
||||||
margin-bottom: $basic-margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color {
|
|
||||||
color: $text-color-gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
max-width: 360px;
|
|
||||||
margin: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
&__title {
|
|
||||||
text-align: center;
|
|
||||||
font-family: 'Roboto', sans-serif;
|
|
||||||
font-size: $text-size;
|
|
||||||
line-height: 20px;
|
|
||||||
color: $text-color-gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__submit-sudir-btn {
|
|
||||||
background: #0000000f;
|
|
||||||
margin-top: 4 * $basic-margin;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.09) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.requiredInput::after {
|
|
||||||
content: "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
|
||||||
import { Badge, List, message, Spin, Tag, Tooltip } from 'antd'
|
|
||||||
import { compareVersions } from 'compare-versions'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import {
|
|
||||||
createSearchParams,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useParams,
|
|
||||||
useSearchParams
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import ModuleTabs from '@components/ModuleTabs'
|
|
||||||
|
|
||||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
|
||||||
|
|
||||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
|
||||||
|
|
||||||
import useRole from '@hooks/useRole.tsx'
|
|
||||||
|
|
||||||
import modulesServiceApi from '@services/modulesService.ts'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
||||||
|
|
||||||
import './modules-page.scss'
|
|
||||||
|
|
||||||
|
|
||||||
const { Column } = Layout
|
|
||||||
|
|
||||||
const ModulesPage = () => {
|
|
||||||
const [activeTab, setActiveTab] = useState('configurations')
|
|
||||||
const { id: selectedItemId = '' } = useParams()
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const { role, hasPermission } = useRole()
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
|
||||||
const { data: ModulesList = [], isLoading: isModulesLoading } =
|
|
||||||
modulesServiceApi.useGetModulesQuery('modules', {
|
|
||||||
pollingInterval: 5000,
|
|
||||||
skipPollingIfUnfocused: true
|
|
||||||
})
|
|
||||||
const [removeModule] = modulesServiceApi.useRemoveModuleMutation()
|
|
||||||
const location = useLocation()
|
|
||||||
|
|
||||||
const searchValue = searchParams.get('search') || ''
|
|
||||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
|
||||||
const isRemoveModule = hasPermission(PermissionKeysType.write)
|
|
||||||
const isLoading = isModulesLoading
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isPageAvailable) {
|
|
||||||
navigate(routePaths.profile)
|
|
||||||
message.error('Страница не найдена')
|
|
||||||
}
|
|
||||||
}, [isPageAvailable])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!role) {
|
|
||||||
navigate(routePaths.error)
|
|
||||||
}
|
|
||||||
}, [role])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const url = location.pathname.substring(
|
|
||||||
location.pathname.lastIndexOf('/') + 1
|
|
||||||
)
|
|
||||||
switch (url) {
|
|
||||||
case 'configurations':
|
|
||||||
return setActiveTab('configurations')
|
|
||||||
case 'connections':
|
|
||||||
return setActiveTab('connections')
|
|
||||||
}
|
|
||||||
}, [location])
|
|
||||||
|
|
||||||
const setSelectedItemId = (id: string): void => {
|
|
||||||
if (id) {
|
|
||||||
navigate(
|
|
||||||
{
|
|
||||||
pathname: `${routePaths.modules}/${id}/${activeTab}`,
|
|
||||||
search: createSearchParams(searchParams).toString()
|
|
||||||
},
|
|
||||||
{ replace: true }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOnChangeSearchValue = (value: string): void => {
|
|
||||||
setSearchParams((prev) => {
|
|
||||||
if (!value) {
|
|
||||||
prev.delete('search')
|
|
||||||
} else {
|
|
||||||
prev.set('search', value)
|
|
||||||
}
|
|
||||||
return prev
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRemoveModule = (id: string) => {
|
|
||||||
removeModule(id)
|
|
||||||
.unwrap()
|
|
||||||
.then(() => {
|
|
||||||
navigate(routePaths.modules)
|
|
||||||
message.success('Модуль успешно удален').then()
|
|
||||||
setSelectedItemId('')
|
|
||||||
})
|
|
||||||
.catch(() => message.error('Не удалось удалить модуль'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const versionCompare = (versions: string[]) => {
|
|
||||||
const sorted = (versions || ['']).sort(compareVersions)
|
|
||||||
const firstVersion = sorted[0]
|
|
||||||
for (let i = 1; i < sorted.length; i++) {
|
|
||||||
if (compareVersions(firstVersion, sorted[i]) !== 0) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const getLastVersion = (versions: string[]) => {
|
|
||||||
const sorted = (versions || ['']).sort(compareVersions)
|
|
||||||
return sorted[sorted.length - 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <Spin />
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentModule = ModulesList.find(
|
|
||||||
(item: ModuleType) => item.id.toString() === selectedItemId
|
|
||||||
)
|
|
||||||
|
|
||||||
const renderItems = (item: ModuleType) => {
|
|
||||||
const isSame = versionCompare(item?.status?.map((i) => i.version))
|
|
||||||
const textTooltip = isSame
|
|
||||||
? 'Активны экземпляры одинаковых версий'
|
|
||||||
: 'Активны экземпляры разных версий'
|
|
||||||
const lastVersion = getLastVersion(item.status?.map((i) => i.version))
|
|
||||||
|
|
||||||
const renderVersion = () => {
|
|
||||||
if (!isSame && lastVersion) {
|
|
||||||
return (
|
|
||||||
<Tag icon={<ExclamationCircleOutlined />} color="warning">
|
|
||||||
{lastVersion}
|
|
||||||
</Tag>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (isSame && lastVersion) {
|
|
||||||
return <Tag color="default">{lastVersion}</Tag>
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<List.Item>
|
|
||||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
|
||||||
<List.Item.Meta
|
|
||||||
title={
|
|
||||||
<div className="module-item__name">
|
|
||||||
<span>{item.name}</span>
|
|
||||||
<Tooltip
|
|
||||||
overlayInnerStyle={{ width: '300px' }}
|
|
||||||
title={textTooltip}
|
|
||||||
>
|
|
||||||
{renderVersion()}
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
description={
|
|
||||||
<div className="module-item__content">
|
|
||||||
<span className="module-item__content__description">
|
|
||||||
активные экземпляры:
|
|
||||||
</span>
|
|
||||||
<Badge
|
|
||||||
size="small"
|
|
||||||
showZero
|
|
||||||
count={(item.status && item.status.length) || 0}
|
|
||||||
color={!item.status || !item.status.length ? '' : 'cyan'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</List.Item>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="modules-page">
|
|
||||||
<Column
|
|
||||||
title="Модули"
|
|
||||||
searchPlaceholder="Введите имя или id"
|
|
||||||
items={filterFirstColumnItems(ModulesList, searchValue)}
|
|
||||||
showAddBtn={false}
|
|
||||||
showUpdateBtn={false}
|
|
||||||
showRemoveBtn={isRemoveModule}
|
|
||||||
onRemoveItem={handleRemoveModule}
|
|
||||||
onChangeSearchValue={handleOnChangeSearchValue}
|
|
||||||
renderItems={renderItems}
|
|
||||||
searchValue={searchValue}
|
|
||||||
selectedItemId={selectedItemId}
|
|
||||||
setSelectedItemId={setSelectedItemId}
|
|
||||||
/>
|
|
||||||
<ModuleTabs
|
|
||||||
currentModule={currentModule}
|
|
||||||
activeTab={activeTab}
|
|
||||||
setActiveTab={setActiveTab}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ModulesPage
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
export interface RequiredModuleType {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
required: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AddressType {
|
|
||||||
ip: string
|
|
||||||
port: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EndpointType {
|
|
||||||
extra: Record<string, unknown>
|
|
||||||
inner: boolean
|
|
||||||
path: string
|
|
||||||
userAuthRequired: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleStatusType {
|
|
||||||
establishedAt: string
|
|
||||||
libVersion: string
|
|
||||||
version: string
|
|
||||||
address: AddressType
|
|
||||||
endpoints: EndpointType[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConfigType {
|
|
||||||
active: boolean
|
|
||||||
commonConfigs: string[]
|
|
||||||
createdAt: string
|
|
||||||
data: Record<string, unknown>
|
|
||||||
description: string
|
|
||||||
id: string
|
|
||||||
moduleId: string
|
|
||||||
name: string
|
|
||||||
updatedAt: string
|
|
||||||
valid: boolean
|
|
||||||
version: number
|
|
||||||
unsafe?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JSONSchema {
|
|
||||||
$ref?: string
|
|
||||||
$schema?: string
|
|
||||||
additionalItems?: boolean | JSONSchema
|
|
||||||
additionalProperties?: boolean | JSONSchema
|
|
||||||
allOf?: JSONSchema[]
|
|
||||||
anyOf?: JSONSchema[]
|
|
||||||
default?: any
|
|
||||||
definitions?: Record<string, JSONSchema>
|
|
||||||
dependencies?: Record<string, string | string[] | JSONSchema>
|
|
||||||
description?: string
|
|
||||||
enum?: any[]
|
|
||||||
exclusiveMaximum?: boolean
|
|
||||||
exclusiveMinimum?: boolean
|
|
||||||
format?: string
|
|
||||||
items?: JSONSchema | JSONSchema[]
|
|
||||||
maxItems?: number
|
|
||||||
maxLength?: number
|
|
||||||
maxProperties?: number
|
|
||||||
maximum?: number
|
|
||||||
media?: JSONSchema
|
|
||||||
minItems?: number
|
|
||||||
minLength?: number
|
|
||||||
minProperties?: number
|
|
||||||
minimum?: number
|
|
||||||
multipleOf?: number
|
|
||||||
not?: JSONSchema
|
|
||||||
oneOf?: JSONSchema[]
|
|
||||||
pattern?: string
|
|
||||||
patternProperties?: Record<string, JSONSchema>
|
|
||||||
properties?: Record<string, JSONSchema>
|
|
||||||
required?: string[]
|
|
||||||
title?: string
|
|
||||||
type?: string | string[]
|
|
||||||
uniqueItems?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleType {
|
|
||||||
active: boolean
|
|
||||||
configs: ConfigType[]
|
|
||||||
createdAt: string
|
|
||||||
id: string
|
|
||||||
lastConnectedAt: string
|
|
||||||
lastDisconnectedAt: string
|
|
||||||
name: string
|
|
||||||
requiredModules: RequiredModuleType[]
|
|
||||||
status: ModuleStatusType[]
|
|
||||||
configSchema: JSONSchema
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResponseSchemaType {
|
|
||||||
createdAt: string,
|
|
||||||
id: string,
|
|
||||||
moduleId: string,
|
|
||||||
schema: JSONSchema,
|
|
||||||
updatedAt: string,
|
|
||||||
version: string
|
|
||||||
}
|
|
||||||
export interface ConfigResponse {
|
|
||||||
originalResponse: ConfigType[]
|
|
||||||
activeConfigs: ConfigType[]
|
|
||||||
inactiveConfigs:ConfigType[]
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
@import "../../constants/style/styleConst";
|
|
||||||
|
|
||||||
.modules-page {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
&__tabs {
|
|
||||||
padding: 0 $basic-padding*2;
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-tag {
|
|
||||||
height: 22px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.module-item {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
display: flex;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
&__description {
|
|
||||||
color: $grey;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__content {
|
|
||||||
overflow-x: scroll;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.column .column__items__item span {
|
|
||||||
width: fit-content !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Button } from 'antd'
|
|
||||||
import { Layout } from 'isp-ui-kit'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
|
||||||
|
|
||||||
|
|
||||||
const { NotFoundPage } = Layout
|
|
||||||
|
|
||||||
const NotFound = () => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
return (
|
|
||||||
<NotFoundPage>
|
|
||||||
<Button type="primary" onClick={() => navigate(routePaths.home)}>
|
|
||||||
На главную
|
|
||||||
</Button>
|
|
||||||
</NotFoundPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NotFound
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
import { Button, Descriptions, Popconfirm } from 'antd'
|
|
||||||
import { useContext, useEffect, useState } from 'react'
|
|
||||||
|
|
||||||
import PermissionList from '@widgets/PermissionList'
|
|
||||||
|
|
||||||
import ChangePasswordModal from '@components/ChangePasswordModal'
|
|
||||||
import RoleList from '@components/RoleList'
|
|
||||||
|
|
||||||
import { useAppSelector } from '@hooks/redux.ts'
|
|
||||||
import useLogout from '@hooks/useLogout.tsx'
|
|
||||||
|
|
||||||
import { Context } from '@stores/index.tsx'
|
|
||||||
|
|
||||||
import './profile-page.scss'
|
|
||||||
|
|
||||||
const ProfilePage = () => {
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false)
|
|
||||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
|
||||||
const { logoutUser, isLoading } = useLogout()
|
|
||||||
const { changeTheme, setChangeTheme } = useContext(Context)
|
|
||||||
|
|
||||||
const onChangeTheme = () => {
|
|
||||||
setChangeTheme((prev: any) => !prev)
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
localStorage.setItem('theme', JSON.stringify(changeTheme))
|
|
||||||
}, [changeTheme])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="profile-page">
|
|
||||||
<ChangePasswordModal
|
|
||||||
onClose={() => setIsModalOpen(false)}
|
|
||||||
open={isModalOpen}
|
|
||||||
/>
|
|
||||||
<header className="profile-page__header">
|
|
||||||
<h1 className="profile-page__title">{`${profile.lastName} ${profile.firstName}`}</h1>
|
|
||||||
<Button onClick={onChangeTheme}>Сменить тему</Button>
|
|
||||||
</header>
|
|
||||||
<div className="profile-page__user-info">
|
|
||||||
<div className="profile-page__user-info__email-wrapper">
|
|
||||||
<Descriptions>
|
|
||||||
<Descriptions.Item label="Email">{profile.email}</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<RoleList userRoles={profile.roles} />
|
|
||||||
<PermissionList permissions={profile.permissions} />
|
|
||||||
<div className="profile-page__actions">
|
|
||||||
<Popconfirm
|
|
||||||
okText="Выйти"
|
|
||||||
cancelText="Отмена"
|
|
||||||
title="Вы действительно хотите выйти из профиля?"
|
|
||||||
onConfirm={logoutUser}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
loading={isLoading}
|
|
||||||
disabled={isLoading}
|
|
||||||
className="profile-page__actions__exit-btn"
|
|
||||||
>
|
|
||||||
Выход
|
|
||||||
</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
<Button
|
|
||||||
className="profile-page__actions__change-pass-btn"
|
|
||||||
onClick={() => setIsModalOpen(true)}
|
|
||||||
>
|
|
||||||
Сменить пароль
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProfilePage
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
@import '../../constants/style/styleConst';
|
|
||||||
|
|
||||||
.profile-page {
|
|
||||||
height: 100vh;
|
|
||||||
overflow: auto;
|
|
||||||
border: 1px solid var(--ant-color-border);
|
|
||||||
padding: $basic-padding * 2;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: start;
|
|
||||||
|
|
||||||
&__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__title {
|
|
||||||
font-size: $text-size-header1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__user-info {
|
|
||||||
margin-top: $basic-padding;
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: $text-size !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions {
|
|
||||||
display: flex;
|
|
||||||
gap: $basic-margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 181 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user