Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e54ce881b7 | ||
|
|
180cdb750e | ||
|
|
e730b5ace3 | ||
|
|
0b6f6cb8fa | ||
|
|
eb8e1683fb | ||
|
|
e7b680aeb1 |
No files matched your search
@@ -0,0 +1,23 @@
|
||||
docker-build:
|
||||
image: docker:latest
|
||||
stage: build
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
- export VERSION=`sh version.sh`
|
||||
- echo $VERSION
|
||||
- echo $CI_DOCKER_FILE
|
||||
- echo $CI_REGISTRY
|
||||
script:
|
||||
- set
|
||||
- mkdir -p migrations
|
||||
- docker build -f "$CI_DOCKER_FILE" --force-rm --build-arg="version=$VERSION" --build-arg="app_name=$CI_PROJECT_NAME" --pull -t "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" .
|
||||
- |
|
||||
docker tag "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
||||
- docker logout $CI_REGISTRY
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
## 0.19.0
|
||||
- Замена компонента App на компонент AdminBase из библиотеки
|
||||
- Удален весь код, дублирующий компонент AdminBase
|
||||
## 0.18.9
|
||||
- Исправлены дополнительные параметры подключения в форме
|
||||
## 0.18.8
|
||||
- Добавлено кеширование статики для nginx
|
||||
## 0.18.7
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder-deps
|
||||
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y nodejs14 yarn
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
RUN yarn config set "strict-ssl" false
|
||||
RUN yarn config set "registry" https://repo-mirror.mos.ru/repository/yarn-central/
|
||||
RUN yarn config list
|
||||
RUN yarn --ignore-engines install
|
||||
COPY . ./
|
||||
RUN sed -i 's/github.com/repo-mirror.mos.ru\/repository\/raw-github/g' package.json
|
||||
RUN sed -i 's/registry.yarnpkg.com/repo-mirror.mos.ru\/repository\/yarn-central/g' yarn.lock
|
||||
RUN yarn --ignore-engines 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=build-deps /usr/src/app/build /opt/msp/isp-admin-ui
|
||||
Generated
+131
-192
@@ -1,27 +1,19 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"version": "0.18.8",
|
||||
"version": "0.19.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "isp-admin-ui",
|
||||
"version": "0.18.8",
|
||||
"version": "0.19.0",
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@rjsf/antd": "^5.21.2",
|
||||
"@rjsf/core": "^5.21.2",
|
||||
"@rjsf/validator-ajv8": "^5.21.2",
|
||||
"axios": "^1.7.7",
|
||||
"clipboard": "^2.0.11",
|
||||
"compare-versions": "^6.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"deep-equal": "^2.2.3",
|
||||
"isp-ui-kit": "^0.10.1",
|
||||
"json-schema-view-js": "^2.0.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"isp-admin-ui-kit": "^0.3.1",
|
||||
"isp-ui-kit": "^0.12.3",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -3410,7 +3402,6 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
@@ -4034,14 +4025,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
|
||||
"integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA=="
|
||||
},
|
||||
"node_modules/@types/lodash-es": {
|
||||
"version": "4.17.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz",
|
||||
"integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
|
||||
"dependencies": {
|
||||
"@types/lodash": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/lodash.clonedeep": {
|
||||
"version": "4.5.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz",
|
||||
@@ -4726,12 +4709,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/asap": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
|
||||
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/asn1.js": {
|
||||
"version": "4.10.1",
|
||||
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
|
||||
@@ -5672,15 +5649,6 @@
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.8",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz",
|
||||
"integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.12"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@@ -6943,36 +6911,6 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fbemitter": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fbemitter/-/fbemitter-3.0.0.tgz",
|
||||
"integrity": "sha512-KWKaceCwKQU0+HPoop6gn4eOHk50bBv/VxjJtGMfwmJt3D29JpN4H4eisCtIPA+a8GVBam+ldMMpMjJUvpDyHw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbjs": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fbjs": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-3.0.5.tgz",
|
||||
"integrity": "sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.5",
|
||||
"fbjs-css-vars": "^1.0.0",
|
||||
"loose-envify": "^1.0.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"promise": "^7.1.1",
|
||||
"setimmediate": "^1.0.5",
|
||||
"ua-parser-js": "^1.0.35"
|
||||
}
|
||||
},
|
||||
"node_modules/fbjs-css-vars": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz",
|
||||
"integrity": "sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
@@ -7033,19 +6971,6 @@
|
||||
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/flux": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/flux/-/flux-4.0.4.tgz",
|
||||
"integrity": "sha512-NCj3XlayA2UsapRpM7va6wU1+9rE5FIL7qoMcmxWHRzbp0yujihMBm9BBHZ1MDIk5h5o2Bl6eGiCe8rYELAmYw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"fbemitter": "^3.0.0",
|
||||
"fbjs": "^3.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^15.0.2 || ^16.0.0 || ^17.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.6",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||
@@ -8051,38 +7976,73 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/isp-ui-kit": {
|
||||
"version": "0.10.1",
|
||||
"resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.10.1.tgz",
|
||||
"integrity": "sha512-WcDUtS9Gw0mRvLWjytuVT9EY7wZjTSOXKfP2krv4MgeG5Q9eTS36RJ9d2slqS86m5H4PHohMmAJNuomw+sf8Rw==",
|
||||
"license": "MIT",
|
||||
"node_modules/isp-admin-ui-kit": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/isp-admin-ui-kit/-/isp-admin-ui-kit-0.3.1.tgz",
|
||||
"integrity": "sha512-Hm855/ivVV6KGgrNb2pqrKrA7FnG7bkf2vuOwNIBjZ9+qa5pzQMucQmQUZzV6OcuVM0TMvgr1AIwzaiXzebvnw==",
|
||||
"dependencies": {
|
||||
"flux": "^4.0.4",
|
||||
"react-base16-styling": "^0.10.0",
|
||||
"react-lifecycles-compat": "^3.0.4",
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"@rjsf/antd": "^5.21.2",
|
||||
"@rjsf/core": "^5.21.2",
|
||||
"@rjsf/validator-ajv8": "^5.21.2",
|
||||
"clipboard": "^2.0.11",
|
||||
"compare-versions": "^6.1.0",
|
||||
"deep-equal": "^2.2.3",
|
||||
"json-schema-view-js": "^2.0.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"react-resizable": "^3.0.5",
|
||||
"react-textarea-autosize": "^6.1.0",
|
||||
"simplebar": "^6.2.5",
|
||||
"simplebar-react": "^3.2.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.32.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"antd": "^5.12.2",
|
||||
"axios": "^1.7.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-ui-kit": "^0.12.3",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.49.1"
|
||||
"react": ">=18.2.0",
|
||||
"react-dom": ">=18.2.0",
|
||||
"react-hook-form": "^7.54.0",
|
||||
"react-router-dom": "^6.22.3"
|
||||
}
|
||||
},
|
||||
"node_modules/isp-ui-kit/node_modules/react-textarea-autosize": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-6.1.0.tgz",
|
||||
"integrity": "sha512-F6bI1dgib6fSvG8so1HuArPUv+iVEfPliuLWusLF+gAKz0FbB4jLrWUrTAeq1afnPT2c9toEZYUdz/y1uKMy4A==",
|
||||
"license": "MIT",
|
||||
"node_modules/isp-admin-ui-kit/node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.32.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.32.1.tgz",
|
||||
"integrity": "sha512-WQFLZ9c42ECqEjwg/GHHsouij3pzLXkFdz0UxHa/0OM12LzvX7DzedlY0SIEly2v18YZLRhCRoHZDxbBSWoGYg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/isp-ui-kit": {
|
||||
"version": "0.12.3",
|
||||
"resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.12.3.tgz",
|
||||
"integrity": "sha512-7WK90Y43VvDNzEen6Ycd4vOEzoKjwVfqUJroPbBfTcv6cd5Z2TBTKqt8s4IGXMKXiX2CFxKGxHVhCIVzalSifQ==",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.6.0"
|
||||
"react-base16-styling": "~0.10.0",
|
||||
"react-lifecycles-compat": "~3.0.4",
|
||||
"react-resizable": "^3.0.5",
|
||||
"react-textarea-autosize": "~8.5.7",
|
||||
"simplebar-react": "^3.3.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.9.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=0.14.0 <17.0.0"
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"antd": ">=5.12",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18",
|
||||
"react-hook-form": "^7.54.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iterator.prototype": {
|
||||
@@ -8542,26 +8502,6 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
"version": "2.0.14",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
|
||||
@@ -9105,15 +9045,6 @@
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
||||
},
|
||||
"node_modules/promise": {
|
||||
"version": "7.3.1",
|
||||
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
|
||||
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asap": "~2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
@@ -9855,18 +9786,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-hook-form": {
|
||||
"version": "7.51.2",
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.51.2.tgz",
|
||||
"integrity": "sha512-y++lwaWjtzDt/XNnyGDQy6goHskFualmDlf+jzEZvjvz6KWDf7EboL7pUvRCzPTJd0EOPpdekYaQLEvvG6m6HA==",
|
||||
"version": "7.54.2",
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.54.2.tgz",
|
||||
"integrity": "sha512-eHpAUgUjWbZocoQYUHposymRb4ZP6d0uwUnooL2uOybA9/3tPUvoAKqEWK1WaSiTxxOfTpffNZP7QwlnM3/gEg==",
|
||||
"engines": {
|
||||
"node": ">=12.22.0"
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/react-hook-form"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17 || ^18"
|
||||
"react": "^16.8.0 || ^17 || ^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
@@ -9957,6 +9888,22 @@
|
||||
"react-dom": ">=16.8"
|
||||
}
|
||||
},
|
||||
"node_modules/react-textarea-autosize": {
|
||||
"version": "8.5.7",
|
||||
"resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.5.7.tgz",
|
||||
"integrity": "sha512-2MqJ3p0Jh69yt9ktFIaZmORHXw4c4bxSIhCeWiFwmJ9EYKgLmuNII3e9c9b2UO+ijl4StnpZdqpxNIhTdHvqtQ==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"use-composed-ref": "^1.3.0",
|
||||
"use-latest": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||
@@ -10479,7 +10426,8 @@
|
||||
"node_modules/setimmediate": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA=="
|
||||
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/sha.js": {
|
||||
"version": "2.4.11",
|
||||
@@ -10562,22 +10510,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/simplebar-core": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/simplebar-core/-/simplebar-core-1.2.4.tgz",
|
||||
"integrity": "sha512-P+Sqshef4fq3++gQ82TgNYcgl3qZFSCP5jS2/8NMmw18oagXOijMzs1G+vm6RUY3oMvpwH3wGoqh9u6SyDjHfQ==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/simplebar-core/-/simplebar-core-1.3.0.tgz",
|
||||
"integrity": "sha512-LpWl3w0caz0bl322E68qsrRPpIn+rWBGAaEJ0lUJA7Xpr2sw92AkIhg6VWj988IefLXYh50ILatfAnbNoCFrlA==",
|
||||
"dependencies": {
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"can-use-dom": "^0.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21"
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
},
|
||||
"node_modules/simplebar-react": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/simplebar-react/-/simplebar-react-3.2.4.tgz",
|
||||
"integrity": "sha512-ogLN79e7JUm82wJChD7NSUB+4EHCFvDkjXpiu8hT1Alk7DnCekUWds61NXcsP9jC97KOgF5To/AVjYFbX0olgg==",
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/simplebar-react/-/simplebar-react-3.3.0.tgz",
|
||||
"integrity": "sha512-sxzy+xRuU41He4tT4QLGYutchtOuye/xxVeq7xhyOiwMiHNK1ZpvbOTyy+7P0i7gfpXLGTJ8Bep8+4Mhdgtz/g==",
|
||||
"dependencies": {
|
||||
"simplebar-core": "^1.2.4"
|
||||
"simplebar-core": "^1.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8.0"
|
||||
@@ -10970,12 +10915,6 @@
|
||||
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
|
||||
"integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ=="
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ts-api-utils": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz",
|
||||
@@ -11154,32 +11093,6 @@
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/ua-parser-js": {
|
||||
"version": "1.0.39",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.39.tgz",
|
||||
"integrity": "sha512-k24RCVWlEcjkdOxYmVJgeD/0a1TiSpqLg+ZalVGV9lsnr4yqu0w7tX/x2xX6G4zpkgQnRf89lxuZ1wsbjXM8lw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/ua-parser-js"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/faisalman"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/faisalman"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"ua-parser-js": "script/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/unbox-primitive": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
|
||||
@@ -11323,6 +11236,48 @@
|
||||
"integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/use-composed-ref": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/use-composed-ref/-/use-composed-ref-1.4.0.tgz",
|
||||
"integrity": "sha512-djviaxuOOh7wkj0paeO1Q/4wMZ8Zrnag5H6yBvzN7AKKe8beOaED9SF5/ByLqsku8NP4zQqsvM2u3ew/tJK8/w==",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/use-isomorphic-layout-effect": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.2.0.tgz",
|
||||
"integrity": "sha512-q6ayo8DWoPZT0VdG4u3D3uxcgONP3Mevx2i2b0434cwWBoL+aelL1DzkXI6w3PhTZzUeR2kaVlZn70iCiseP6w==",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/use-latest": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/use-latest/-/use-latest-1.3.0.tgz",
|
||||
"integrity": "sha512-mhg3xdm9NaM8q+gLT8KryJPnRFOz1/5XPBhmDEVZK1webPzDjrPk7f/mbpeLqTgB9msytYWANxgALOCJKnLvcQ==",
|
||||
"dependencies": {
|
||||
"use-isomorphic-layout-effect": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
|
||||
@@ -11583,22 +11538,6 @@
|
||||
"integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
+10
-18
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"private": true,
|
||||
"version": "0.18.8",
|
||||
"version": "0.19.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
@@ -14,27 +14,19 @@
|
||||
"prepare": "husky || true"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-ui-kit": "^0.12.3",
|
||||
"axios": "^1.7.7",
|
||||
"react-router-dom": "^6.22.3",
|
||||
"react-hook-form": "^7.51.2",
|
||||
"react-dom": "^18.2.0",
|
||||
"react": "^18.2.0",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@rjsf/antd": "^5.21.2",
|
||||
"@rjsf/core": "^5.21.2",
|
||||
"@rjsf/validator-ajv8": "^5.21.2",
|
||||
"axios": "^1.7.7",
|
||||
"clipboard": "^2.0.11",
|
||||
"compare-versions": "^6.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"deep-equal": "^2.2.3",
|
||||
"isp-ui-kit": "^0.10.1",
|
||||
"json-schema-view-js": "^2.0.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.51.2",
|
||||
"isp-admin-ui-kit": "^0.3.1",
|
||||
"react-redux": "^9.1.0",
|
||||
"react-resizable": "^3.0.5",
|
||||
"react-router-dom": "^6.22.3",
|
||||
"simplebar": "^6.2.5",
|
||||
"simplebar-react": "^3.2.4"
|
||||
},
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<rect width="24" height="24" fill="url(#pattern0)"/>
|
||||
<defs>
|
||||
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
|
||||
<use xlink:href="#image0_121_5920" transform="scale(0.0025)"/>
|
||||
</pattern>
|
||||
<image id="image0_121_5920" width="400" height="400" xlink:href="data:image/png;base64,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 truncated
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,3 +0,0 @@
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.2118 12.3535L9.15396 8.29564C9.78364 7.48158 10.1243 6.48627 10.1243 5.43939C10.1243 4.18627 9.6352 3.01127 8.75083 2.12533C7.86645 1.23939 6.68833 0.751892 5.43677 0.751892C4.1852 0.751892 3.00708 1.24095 2.1227 2.12533C1.23677 3.0097 0.749268 4.18627 0.749268 5.43939C0.749268 6.69095 1.23833 7.86908 2.1227 8.75345C3.00708 9.63939 4.18364 10.1269 5.43677 10.1269C6.48364 10.1269 7.47739 9.78627 8.29146 9.15814L12.3493 13.2144C12.3612 13.2263 12.3753 13.2357 12.3908 13.2422C12.4064 13.2486 12.4231 13.2519 12.4399 13.2519C12.4567 13.2519 12.4734 13.2486 12.4889 13.2422C12.5045 13.2357 12.5186 13.2263 12.5305 13.2144L13.2118 12.5347C13.2237 12.5228 13.2331 12.5087 13.2396 12.4931C13.246 12.4776 13.2493 12.4609 13.2493 12.4441C13.2493 12.4272 13.246 12.4106 13.2396 12.395C13.2331 12.3795 13.2237 12.3654 13.2118 12.3535ZM7.91177 7.91439C7.24927 8.57533 6.37114 8.93939 5.43677 8.93939C4.50239 8.93939 3.62427 8.57533 2.96177 7.91439C2.30083 7.25189 1.93677 6.37377 1.93677 5.43939C1.93677 4.50502 2.30083 3.62533 2.96177 2.96439C3.62427 2.30345 4.50239 1.93939 5.43677 1.93939C6.37114 1.93939 7.25083 2.30189 7.91177 2.96439C8.57271 3.62689 8.93677 4.50502 8.93677 5.43939C8.93677 6.37377 8.57271 7.25346 7.91177 7.91439Z" fill="black" fill-opacity="0.85"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 382 KiB |
@@ -1,47 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
|
||||
.active-configurations-table {
|
||||
&__title {
|
||||
margin-bottom: $basic-margin*2;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
&__table {
|
||||
&__name-field {
|
||||
input {
|
||||
color: #606060;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
|
||||
&:focus-visible {
|
||||
color: var(--ant-color-text);
|
||||
padding: $basic-padding;
|
||||
border-radius: 4px;
|
||||
outline: 1px solid $blue-color;
|
||||
}
|
||||
}
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: $basic-margin;
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
gap: $basic-margin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.active-config {
|
||||
tr {
|
||||
background: var(--ant-color-info-bg);
|
||||
}
|
||||
}
|
||||
|
||||
&__buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { ConfigType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ActiveConfigurationsTablePropsType {
|
||||
isActiveTable?: boolean
|
||||
data: ConfigType[]
|
||||
handleShowConfig: (config: ConfigType) => void
|
||||
handleShowCompareModal: (config: ConfigType) => void
|
||||
currentModule?: ModuleType
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Table, Tag, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { FC, useEffect, useRef, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons'
|
||||
|
||||
import { ActiveConfigurationsTablePropsType } from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import configApi from '@services/configService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './active-configurations-table.scss'
|
||||
|
||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> = ({
|
||||
isActiveTable = false,
|
||||
handleShowConfig,
|
||||
handleShowCompareModal,
|
||||
data,
|
||||
currentModule = {}
|
||||
}) => {
|
||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
||||
const inputRefs = useRef<Record<string, HTMLInputElement | null>>({})
|
||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
||||
const navigate = useNavigate()
|
||||
const { id: moduleId } = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRefs.current[editKeyConfig]) {
|
||||
inputRefs.current[editKeyConfig]?.focus()
|
||||
}
|
||||
}, [editKeyConfig])
|
||||
const handleEditStart = (record: ConfigType) => {
|
||||
setEditKeyConfig(record.id)
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleCancelEdit = (record: ConfigType) => {
|
||||
setEditKeyConfig('')
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleSaveEdit = (record: ConfigType) => {
|
||||
const sendData = { ...record, name: tempEditValues[record.id] }
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно сохранен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось сохранить элемент')
|
||||
})
|
||||
}
|
||||
const handleDeleteConfig = (record: ConfigType) => {
|
||||
deleteConfig(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const handleMarkConfigActive = (record: ConfigType) => {
|
||||
markConfigAsActive(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно обновлен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось обновить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const renderNameField = (value: string, record: ConfigType) => {
|
||||
const canEdit = editKeyConfig === record.id
|
||||
const inputValue = canEdit ? tempEditValues[record.id] : value
|
||||
|
||||
return (
|
||||
<div className="active-configurations-table__table__name-field">
|
||||
<input
|
||||
ref={(inputRef) => (inputRefs.current[record.id] = inputRef)}
|
||||
onChange={(event) => {
|
||||
const { value } = event.target
|
||||
setTempEditValues({ ...tempEditValues, [record.id]: value })
|
||||
}}
|
||||
disabled={!canEdit}
|
||||
value={inputValue}
|
||||
/>
|
||||
{canEdit ? (
|
||||
<div className="active-configurations-table__table__name-field__actions">
|
||||
<Tooltip title="Сохранить">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => handleSaveEdit(record)}
|
||||
icon={<CheckOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Отменить">
|
||||
<Button
|
||||
onClick={() => handleCancelEdit(record)}
|
||||
icon={<CloseOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать название">
|
||||
<Button
|
||||
onClick={() => handleEditStart(record)}
|
||||
icon={<EditOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ConfigType> = [
|
||||
{
|
||||
title: 'Наименование',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: renderNameField,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Версия',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Статус',
|
||||
dataIndex: 'valid',
|
||||
key: 'version',
|
||||
align: 'center',
|
||||
render: (value: boolean) => {
|
||||
if (value) {
|
||||
return <Tag color="success">Корректная</Tag>
|
||||
}
|
||||
return <Tag color="error">Некорректная</Tag>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Дата обновления',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
key: 'actions',
|
||||
align: 'center',
|
||||
render: (_: unknown, record: ConfigType) => (
|
||||
<ActiveTableActionButtons
|
||||
isActive={isActiveTable}
|
||||
handleShowConfig={handleShowConfig}
|
||||
handleShowCompareModal={handleShowCompareModal}
|
||||
handleDeleteConfig={handleDeleteConfig}
|
||||
handleMarkConfigActive={handleMarkConfigActive}
|
||||
record={record}
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
||||
return (
|
||||
<div className="active-configurations-table">
|
||||
<div className="active-configurations-table__buttons">
|
||||
<h2 className="active-configurations-table__title">
|
||||
{isActiveTable ? 'Активная' : 'Остальные'}
|
||||
</h2>
|
||||
{!isActiveTable && (
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="configurations__buttons__new-config-brn"
|
||||
onClick={() =>
|
||||
navigate(`/${moduleId}/${routePaths.configEditor}/new`, {
|
||||
state: currentModule
|
||||
})
|
||||
}
|
||||
>
|
||||
Создать
|
||||
</Button>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
rowHoverable={false}
|
||||
className={className}
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActiveConfigurationsTable
|
||||
@@ -1,51 +0,0 @@
|
||||
import { ConfigProvider } from 'antd'
|
||||
import ruRu from 'antd/locale/ru_RU'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
import { darkTheme, lightTheme } from '@constants/theme.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import Routers from '@routes/Routers'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './app.scss'
|
||||
|
||||
const App = () => {
|
||||
const [themes, setTheme] = useState(lightTheme)
|
||||
const [changeTheme, setChangeTheme] = useState(
|
||||
localStorage.getItem('theme')
|
||||
? JSON.parse(localStorage.getItem('theme') || '')
|
||||
: true
|
||||
)
|
||||
|
||||
const location = useLocation()
|
||||
|
||||
useEffect(() => {
|
||||
const prevRoute = sessionStorage.getItem('prevRoute')
|
||||
if (
|
||||
location.pathname !== routePaths.error &&
|
||||
location.pathname !== routePaths.login &&
|
||||
location.pathname !== prevRoute
|
||||
) {
|
||||
sessionStorage.setItem('prevRoute', location.pathname)
|
||||
}
|
||||
}, [location])
|
||||
|
||||
useEffect(() => {
|
||||
setTheme(() => (changeTheme ? darkTheme : lightTheme))
|
||||
}, [changeTheme])
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<Context.Provider value={{ setTheme, setChangeTheme, changeTheme }}>
|
||||
<ConfigProvider theme={themes} locale={ruRu}>
|
||||
<Routers />
|
||||
</ConfigProvider>
|
||||
</Context.Provider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -1,36 +0,0 @@
|
||||
@import 'src/constants/style/styleConst';
|
||||
|
||||
.app-access-content {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
min-width: 760px;
|
||||
|
||||
padding: $basic-padding * 1.8;
|
||||
border: 1px solid $border-color;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: $basic-margin * 2;
|
||||
|
||||
&__action-buttons {
|
||||
display: flex;
|
||||
gap: $basic-margin * 2;
|
||||
}
|
||||
}
|
||||
|
||||
&__main {
|
||||
display: grid;
|
||||
grid-template-columns:1fr 1fr;
|
||||
|
||||
|
||||
&__tree-search-input {
|
||||
width: 350px;
|
||||
margin-bottom: $basic-margin * 2;
|
||||
}
|
||||
}
|
||||
|
||||
.unknown-label {
|
||||
color: $error-red
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface AppAccessContentPropsType {
|
||||
id: number
|
||||
paramPrefix: string
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
import { SearchOutlined } from '@ant-design/icons'
|
||||
import { Button, Input, message, Spin, TreeProps } from 'antd'
|
||||
import { ChangeEvent, FC, memo, useEffect, useState } from 'react'
|
||||
import { Navigate, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import AccessListTree from '@widgets/AccessListTree'
|
||||
import SelectedAccessMethod from '@widgets/SelectedAccessMethod'
|
||||
|
||||
import { AppAccessContentPropsType } from '@components/AppAccessContent/app-access-content.type.ts'
|
||||
|
||||
import { setSearchValue } from '@utils/columnLayoutUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import accessListApi from '@services/accessListService.ts'
|
||||
import routeApi from '@services/routeService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { AccessListMethodType, EndpointType } from '@type/accessList.type.ts'
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './app-access-content.scss'
|
||||
|
||||
const unknownMethodKey = 'неизвестные методы'
|
||||
|
||||
const AppAccessContent: FC<AppAccessContentPropsType> = ({
|
||||
id,
|
||||
paramPrefix
|
||||
}) => {
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
const canWrite = hasPermission(PermissionKeysType.write)
|
||||
|
||||
const {
|
||||
data: methods = [],
|
||||
isLoading: isMethodsLoading,
|
||||
isError: isMethodsError,
|
||||
isSuccess: isMethodsSuccess
|
||||
} = accessListApi.useGetByIdQuery({ id })
|
||||
const [setList] = accessListApi.useSetListMutation()
|
||||
const [setOne] = accessListApi.useSetOneMutation()
|
||||
|
||||
const {
|
||||
data: routes = {
|
||||
originalResponse: [],
|
||||
moduleEndpoints: {},
|
||||
allRouteMap: {}
|
||||
},
|
||||
isLoading: isRouteLoading,
|
||||
isError: isRouteError,
|
||||
isSuccess: isRouteSuccess
|
||||
} = routeApi.useGetAllRoutesQuery()
|
||||
const { moduleEndpoints, allRouteMap } = routes
|
||||
const [defaultAllRoutes, setDefaultAllRoutes] = useState<
|
||||
Record<string, EndpointType[]>
|
||||
>({})
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const searchValue = searchParams.get(paramPrefix) || ''
|
||||
|
||||
const isLoading = isMethodsLoading || isRouteLoading
|
||||
const isError = isMethodsError || isRouteError
|
||||
const isSuccess = isMethodsSuccess && isRouteSuccess
|
||||
|
||||
const openSuccessMessage = (body: string) => {
|
||||
messageApi.success(body)
|
||||
}
|
||||
|
||||
const openErrorMessage = (body: string) => {
|
||||
messageApi.error(body)
|
||||
}
|
||||
|
||||
const createAllMethodList = (status: boolean) => {
|
||||
return Object.keys(allRouteMap).map((key) => {
|
||||
return {
|
||||
method: key,
|
||||
value: status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onCheck: TreeProps['onCheck'] = (_, info): void | never[] => {
|
||||
const { node } = info
|
||||
if (!node.children) {
|
||||
const sendData = {
|
||||
appId: id,
|
||||
method: node.key as string,
|
||||
value: !node.checked
|
||||
}
|
||||
setOne(sendData)
|
||||
.then(() => {
|
||||
openSuccessMessage('Статус метода успешно изменен')
|
||||
})
|
||||
.catch(() => {
|
||||
openErrorMessage('Не удалось изменить статус метода')
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const newCheckedKeys = node.children.map((child) => ({
|
||||
method: child.key as string,
|
||||
value: !node.checked
|
||||
}))
|
||||
setListMethods(newCheckedKeys)
|
||||
}
|
||||
|
||||
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const { value } = e.target
|
||||
setSearchValue(value.trim().toLowerCase(), setSearchParams, paramPrefix)
|
||||
}
|
||||
|
||||
const setListMethods = (methods: AccessListMethodType[]) => {
|
||||
setList({
|
||||
appId: id,
|
||||
methods: methods
|
||||
})
|
||||
.then(() => {
|
||||
openSuccessMessage('Статус методов успешно изменен')
|
||||
})
|
||||
.catch(() => {
|
||||
openErrorMessage('Не удалось изменить статус методов')
|
||||
})
|
||||
}
|
||||
|
||||
const setAllMethods = (status: boolean) => {
|
||||
const methods = createAllMethodList(status)
|
||||
setListMethods(methods)
|
||||
}
|
||||
|
||||
const getAllRoutes = () => {
|
||||
const missingRoute: EndpointType[] = []
|
||||
const copyAllRoutes = { ...moduleEndpoints }
|
||||
|
||||
methods.forEach((item) => {
|
||||
if (!allRouteMap[item.method]) {
|
||||
missingRoute.push({ path: item.method } as EndpointType)
|
||||
}
|
||||
})
|
||||
|
||||
if (missingRoute.length) {
|
||||
copyAllRoutes[unknownMethodKey] = missingRoute
|
||||
}
|
||||
return copyAllRoutes
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const allRoutes = getAllRoutes()
|
||||
setDefaultAllRoutes(allRoutes)
|
||||
}, [isSuccess])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return <Navigate to={routePaths.error} />
|
||||
}
|
||||
return (
|
||||
<div className="app-access-content">
|
||||
{contextHolder}
|
||||
<div className="app-access-content__header">
|
||||
<Input
|
||||
prefix={<SearchOutlined />}
|
||||
allowClear
|
||||
className="app-access-content__main__tree-search-input"
|
||||
value={searchValue}
|
||||
placeholder="Найти метод"
|
||||
onChange={onChange}
|
||||
/>
|
||||
<div className="app-access-content__header__action-buttons">
|
||||
<Button
|
||||
disabled={!canWrite}
|
||||
onClick={() => {
|
||||
setAllMethods(false)
|
||||
}}
|
||||
>
|
||||
Запретить все
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!canWrite}
|
||||
onClick={() => {
|
||||
setAllMethods(true)
|
||||
}}
|
||||
>
|
||||
Выбрать все
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-access-content__main">
|
||||
<AccessListTree
|
||||
searchValue={searchValue}
|
||||
onCheck={onCheck}
|
||||
defaultAllRoutes={defaultAllRoutes}
|
||||
methods={methods}
|
||||
/>
|
||||
<SelectedAccessMethod
|
||||
unknownMethodKey={unknownMethodKey}
|
||||
methods={methods}
|
||||
allRoutes={defaultAllRoutes}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(AppAccessContent)
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
export type AppGroupModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
||||
appGroup?: ApplicationsGroupType
|
||||
onOk: (data: ApplicationsGroupType) => void
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.type.ts'
|
||||
|
||||
import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
const { FormInput, FormTextArea } = FormComponents
|
||||
|
||||
const AppGroupModal: FC<AppGroupModalType> = ({
|
||||
title,
|
||||
onClose,
|
||||
onOk,
|
||||
open,
|
||||
appGroup
|
||||
}) => {
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
||||
mode: 'onChange',
|
||||
defaultValues: appGroup
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
reset(appGroup)
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onOk={handleSubmit(onOk)}
|
||||
title={title}
|
||||
open={open}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={onClose}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormTextArea
|
||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
control={control}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppGroupModal
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
export type AppModalType = Omit<ModalPropsType, 'onOk' | 'children'> & {
|
||||
app?: ApplicationAppType
|
||||
onOk: (data: ApplicationAppType) => void
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { AppModalType } from '@components/AppModal/app-group-modal.type.ts'
|
||||
|
||||
import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
const { FormInput, FormTextArea } = FormComponents
|
||||
|
||||
const AppModal: FC<AppModalType> = ({ title, onOk, onClose, open, app }) => {
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationAppType>({
|
||||
mode: 'onChange',
|
||||
defaultValues: app
|
||||
})
|
||||
useEffect(() => {
|
||||
reset(app)
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onOk={handleSubmit(onOk)}
|
||||
title={title}
|
||||
open={open}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={onClose}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormTextArea
|
||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
control={control}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppModal
|
||||
@@ -1,39 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-content {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-columns:min-content 1fr;
|
||||
width: 100%;
|
||||
|
||||
.column-content {
|
||||
margin-left: $basic-margin;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
display: flex;
|
||||
max-width: 240px;
|
||||
margin-left: auto;
|
||||
margin-bottom: $basic-margin * 2;
|
||||
}
|
||||
|
||||
&__update-btn {
|
||||
margin-right: $basic-margin;
|
||||
}
|
||||
|
||||
&__addToken-btn {
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.link-btn {
|
||||
color: $blue-color;
|
||||
|
||||
&:hover {
|
||||
color: $text-color-blue;
|
||||
}
|
||||
}
|
||||
.column {
|
||||
border-left: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
import { FileProtectOutlined } from '@ant-design/icons'
|
||||
import { List, message, Spin, Tooltip } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import AppModal from '@components/AppModal'
|
||||
import TokenContent from '@components/TokenContent'
|
||||
|
||||
import {
|
||||
ApplicationAppType,
|
||||
ApplicationsServiceType,
|
||||
NewApplicationAppType,
|
||||
UpdateApplicationAppType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import './applications-content.scss'
|
||||
|
||||
const { EmptyData, Column } = Layout
|
||||
|
||||
interface ApplicationsContentPropTypes {
|
||||
selectedItemId: number
|
||||
currentApplicationsApp: number
|
||||
setCurrentApplicationsApp: Dispatch<SetStateAction<number>>
|
||||
}
|
||||
|
||||
const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
selectedItemId,
|
||||
setCurrentApplicationsApp
|
||||
}) => {
|
||||
const {
|
||||
data: applications = [],
|
||||
isLoading: isLoadingApplicationsContent = []
|
||||
} = applicationsApi.useGetApplicationsByServiceIdQuery({
|
||||
id: selectedItemId
|
||||
})
|
||||
|
||||
const [createApplicationService] =
|
||||
applicationsApi.useCreateApplicationServiceMutation()
|
||||
const [updateApplication] =
|
||||
applicationsApi.useUpdateApplicationsServiceMutation()
|
||||
const [removeApplicationsService] =
|
||||
applicationsApi.useRemoveApplicationsServiceMutation()
|
||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
||||
addModal: false,
|
||||
updateModal: false
|
||||
})
|
||||
const [searchParams, setSearchParams] = useSearchParams('')
|
||||
const searchAppValue = searchParams.get('appSearch') || ''
|
||||
const navigate = useNavigate()
|
||||
const { appId = '' } = useParams()
|
||||
|
||||
const currentApp = useMemo(() => {
|
||||
const element = applications.find(
|
||||
(application) => application.app.id.toString() === appId
|
||||
)
|
||||
return element ? element.app : undefined
|
||||
}, [applications, appId])
|
||||
|
||||
const updateApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: true
|
||||
})
|
||||
}
|
||||
const addApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: true
|
||||
})
|
||||
}
|
||||
const renderTokenContent = () => {
|
||||
if (!appId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
return <TokenContent key={appId} id={Number(appId)} />
|
||||
}
|
||||
|
||||
const handleUpdateApplicationApp = (data: ApplicationAppType) => {
|
||||
if (currentApp) {
|
||||
const updateApplications: UpdateApplicationAppType = {
|
||||
id: currentApp.id,
|
||||
name: data.name,
|
||||
description: data.description
|
||||
? data.description
|
||||
: currentApp.description,
|
||||
serviceId: selectedItemId,
|
||||
type: 'SYSTEM'
|
||||
}
|
||||
updateApplication({ ...currentApp, ...updateApplications })
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
message.success('Элемент сохранен')
|
||||
})
|
||||
.catch(() => message.error('Ошибка обновления элемента'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateApplicationApp = (data: ApplicationAppType) => {
|
||||
const newApplicationApp: NewApplicationAppType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
serviceId: selectedItemId,
|
||||
type: 'SYSTEM'
|
||||
}
|
||||
|
||||
createApplicationService(newApplicationApp)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент сохранен')
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
})
|
||||
.catch(() => message.error('Ошибка добавления элемента'))
|
||||
}
|
||||
const handleRemoveApplicationApp = (id: number) =>
|
||||
removeApplicationsService([id])
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент удален')
|
||||
navigate(
|
||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`
|
||||
)
|
||||
})
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
|
||||
const renderColumnItems = (item: ColumnItem<any>) => {
|
||||
return (
|
||||
<List.Item>
|
||||
<Tooltip mouseEnterDelay={1.3} title={item.name}>
|
||||
<List.Item.Meta
|
||||
title={item.name}
|
||||
description={<span>id: {item.id}</span>}
|
||||
/>
|
||||
<div
|
||||
className="link-btn"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
navigate(`/appAccess/${item.id}`)
|
||||
}}
|
||||
>
|
||||
<Tooltip title="Доступы приложений">
|
||||
<FileProtectOutlined />
|
||||
</Tooltip>
|
||||
</div>
|
||||
</Tooltip>
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
if (selectedItemId)
|
||||
if (isLoadingApplicationsContent) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="applications-content">
|
||||
<Column
|
||||
title="Приложения"
|
||||
searchPlaceholder="Введите имя или id"
|
||||
onUpdateItem={updateApplicationModal}
|
||||
showUpdateBtn={true}
|
||||
onAddItem={addApplicationModal}
|
||||
onRemoveItem={() => handleRemoveApplicationApp(Number(appId))}
|
||||
items={filterFirstColumnItems(
|
||||
applications?.map((el) => {
|
||||
return el.app
|
||||
}) as unknown as ColumnItem<ApplicationsServiceType>[],
|
||||
searchAppValue
|
||||
)}
|
||||
renderItems={renderColumnItems}
|
||||
searchValue={searchAppValue}
|
||||
selectedItemId={appId}
|
||||
setSelectedItemId={(itemId: string) => {
|
||||
setCurrentApplicationsApp(Number(itemId))
|
||||
setSelectedItemId(
|
||||
`${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`,
|
||||
itemId.toString(),
|
||||
searchAppValue,
|
||||
navigate
|
||||
)
|
||||
}}
|
||||
onChangeSearchValue={(value: string) => {
|
||||
setSearchValue(
|
||||
value.trim().toLowerCase(),
|
||||
setSearchParams,
|
||||
'appSearch'
|
||||
)
|
||||
}}
|
||||
/>
|
||||
{renderTokenContent()}
|
||||
<AppModal
|
||||
app={currentApp}
|
||||
onOk={handleUpdateApplicationApp}
|
||||
title="Редактировать приложение"
|
||||
open={showApplicationsModal.updateModal}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
/>
|
||||
<AppModal
|
||||
onOk={handleCreateApplicationApp}
|
||||
title="Добавить приложение"
|
||||
open={showApplicationsModal.addModal}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationsContent
|
||||
@@ -1,16 +0,0 @@
|
||||
import { PropsWithChildren } from 'react'
|
||||
|
||||
import { useRole } from '@hooks/useRole.tsx'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
const CanEdit = ({ children }: PropsWithChildren) => {
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
if (hasPermission(PermissionKeysType.write)) {
|
||||
return <>{children}</>
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export default CanEdit
|
||||
@@ -1,10 +0,0 @@
|
||||
export type ChangePasswordModalType = {
|
||||
oldPassword: string
|
||||
newPassword: string
|
||||
confirmPassword: string
|
||||
}
|
||||
|
||||
export type ChangePasswordModalProps = {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
import { message } from 'antd'
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import {
|
||||
ChangePasswordModalProps,
|
||||
ChangePasswordModalType
|
||||
} from '@components/ChangePasswordModal/change-password-modal.type.ts'
|
||||
|
||||
import { ChangeProfilePassword } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
const { FormInputPassword } = FormComponents
|
||||
const ChangePasswordModal: FC<ChangePasswordModalProps> = ({
|
||||
open,
|
||||
onClose
|
||||
}) => {
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setError,
|
||||
clearErrors,
|
||||
watch,
|
||||
reset,
|
||||
trigger
|
||||
} = useForm<ChangePasswordModalType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { logoutUser } = useLogout()
|
||||
|
||||
const onSubmit = async (formValue: ChangePasswordModalType) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await apiService.post<ChangeProfilePassword>(apiPaths.changePassword, {
|
||||
oldPassword: formValue.oldPassword,
|
||||
newPassword: formValue.newPassword
|
||||
})
|
||||
await logoutUser()
|
||||
message.success('Пароль успешно изменен')
|
||||
clearErrors('oldPassword')
|
||||
onClose()
|
||||
} catch (error: any) {
|
||||
if (error.response.data.errorCode === 1001) {
|
||||
setError('oldPassword', {
|
||||
message: 'Не верный текущий пароль'
|
||||
})
|
||||
}
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCloseModal = () => {
|
||||
onClose()
|
||||
reset()
|
||||
}
|
||||
|
||||
const confirmPassword = watch('confirmPassword')
|
||||
const newPassword = watch('newPassword')
|
||||
|
||||
useEffect(() => {
|
||||
trigger('newPassword')
|
||||
trigger('confirmPassword')
|
||||
}, [newPassword, confirmPassword])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="Сменить пароль"
|
||||
open={open}
|
||||
onClose={handleCloseModal}
|
||||
onOk={handleSubmit(onSubmit)}
|
||||
footer={{ onOkText: 'Изменить пароль', onCanselText: 'Отмена' }}
|
||||
loading={loading}
|
||||
>
|
||||
<form key="change-pass-modal">
|
||||
<FormInputPassword
|
||||
rules={{
|
||||
required: { value: true, message: 'Поле не может быть пустым' }
|
||||
}}
|
||||
label="Текущий пароль"
|
||||
control={control}
|
||||
name="oldPassword"
|
||||
/>
|
||||
<FormInputPassword
|
||||
rules={{
|
||||
required: { value: true, message: 'Поле не может быть пустым' },
|
||||
validate: (value) => {
|
||||
return value === confirmPassword || 'Пароли не совпадают'
|
||||
}
|
||||
}}
|
||||
label="Новый пароль"
|
||||
control={control}
|
||||
name="newPassword"
|
||||
/>
|
||||
|
||||
<FormInputPassword
|
||||
rules={{
|
||||
required: { value: true, message: 'Поле не может быть пустым' },
|
||||
validate: (value) => {
|
||||
if (value !== newPassword) return 'Пароли не совпадают'
|
||||
if (!value) return 'Поле не может быть пустым'
|
||||
return true
|
||||
}
|
||||
}}
|
||||
label="Подтвердите пароль"
|
||||
control={control}
|
||||
name="confirmPassword"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default ChangePasswordModal
|
||||
@@ -1,37 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.compare-version-modal {
|
||||
.modal__wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
justify-content: initial;
|
||||
}
|
||||
|
||||
.modal__content {
|
||||
overflow: initial;
|
||||
}
|
||||
|
||||
&__header {
|
||||
margin-top: $basic-margin;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: $basic-margin;
|
||||
|
||||
}
|
||||
|
||||
&__content {
|
||||
.monaco-diff-editor {
|
||||
overflow-y: scroll;
|
||||
height: calc(90vh - 150px) !important;
|
||||
}
|
||||
|
||||
&__table {
|
||||
overflow-y: auto;
|
||||
height: calc(90vh - 50px);
|
||||
|
||||
&__row {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface CompareVersionModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
currentConfigId: string
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
import { DiffEditor } from '@monaco-editor/react'
|
||||
import { Button, Spin, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { FC, memo, useContext, useState } from 'react'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { CompareVersionModalPropsType } from '@components/CompareVersionModal/compare-version-modal.type'
|
||||
|
||||
import { sortObject } from '@utils/objectUtils.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import { VersionType } from '@type/version.type'
|
||||
|
||||
import './compare-version-modal.scss'
|
||||
|
||||
const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
config,
|
||||
currentConfigId
|
||||
}) => {
|
||||
const [selectedItem, setSelectedItem] = useState<VersionType>()
|
||||
const { data: versions = [], isLoading: isVersionLoading } =
|
||||
configServiceApi.useGetAllVersionQuery(currentConfigId)
|
||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||
userServiceApi.useGetAllUsersQuery()
|
||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
||||
const { changeTheme } = useContext(Context)
|
||||
const isLoading = isVersionLoading || isUsersLoading
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const columns: ColumnsType<VersionType> = [
|
||||
{
|
||||
key: 'configVersion',
|
||||
title: 'Версия',
|
||||
dataIndex: 'configVersion'
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'user',
|
||||
title: 'Автор',
|
||||
dataIndex: 'adminId',
|
||||
render: (value: number) => {
|
||||
const user = allUsers.find((user) => user.id === value)
|
||||
if (user) {
|
||||
return `${user.lastName} ${user.firstName}`
|
||||
}
|
||||
return `${profile.lastName} ${profile.firstName}`
|
||||
}
|
||||
}
|
||||
]
|
||||
return (
|
||||
<div className="compare-version-modal">
|
||||
<Modal
|
||||
title="Выберите версию для сравнения"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
{selectedItem ? (
|
||||
<div className="compare-version-modal__content">
|
||||
<Button onClick={() => setSelectedItem(undefined)}>Назад</Button>
|
||||
<div className="compare-version-modal__header">
|
||||
<span> Версия: {selectedItem.configVersion}</span>
|
||||
<span>
|
||||
{config?.version
|
||||
? `Текущая версия : ${config?.version}`
|
||||
: `Версия: ${config?.configVersion}`}
|
||||
</span>
|
||||
</div>
|
||||
<DiffEditor
|
||||
original={JSON.stringify(sortObject(selectedItem.data), null, 2)}
|
||||
modified={JSON.stringify(sortObject(config?.data), null, 2)}
|
||||
theme={changeTheme ? 'vs-dark' : 'vs-white'}
|
||||
options={{
|
||||
readOnly: true,
|
||||
domReadOnly: true,
|
||||
renderOverviewRuler: false,
|
||||
autoClosingOvertype: 'auto'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="compare-version-modal__content__table">
|
||||
<Table
|
||||
size="small"
|
||||
columns={columns}
|
||||
pagination={{ pageSize: 30 }}
|
||||
dataSource={versions}
|
||||
rowKey={(record) => record.id}
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: () => setSelectedItem(record)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(CompareVersionModal)
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ConfigSchemaModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
schema?: JSONSchema
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.config-schema-modal {
|
||||
.modal__wrap {
|
||||
min-width: 880px;
|
||||
}
|
||||
|
||||
.json-schema-view {
|
||||
padding: $basic-padding
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { FC, memo } from 'react'
|
||||
|
||||
import JsonSchemaViewer from '@widgets/JSONViewer'
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts'
|
||||
|
||||
import './config-schema-modal.scss'
|
||||
|
||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
schema = {}
|
||||
}) => {
|
||||
return (
|
||||
<div className="config-schema-modal">
|
||||
<Modal title="Текущая схема" open={open} onClose={onClose}>
|
||||
<JsonSchemaViewer schema={schema} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ConfigSchemaModal)
|
||||
@@ -1,53 +0,0 @@
|
||||
import Editor from '@monaco-editor/react'
|
||||
import { FC, useContext } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
const ConfigurationEditorCode: FC<ConfigurationEditorPropsType> = ({
|
||||
setDisableBtn = () => {},
|
||||
bufConfig,
|
||||
setBufConfig
|
||||
}) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
|
||||
const handleChange = (data: string | undefined) => {
|
||||
if (data) {
|
||||
try {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: { ...JSON.parse(data) }
|
||||
} as ConfigType
|
||||
setDisableBtn(false)
|
||||
setBufConfig(newData)
|
||||
} catch (error) {
|
||||
setDisableBtn(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const editorValue = JSON.stringify(bufConfig?.data, null, '\t')
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Editor
|
||||
width="auto"
|
||||
height="100vh"
|
||||
language="json"
|
||||
theme={changeTheme ? 'vs-dark' : 'vs-white'}
|
||||
value={editorValue}
|
||||
onChange={handleChange}
|
||||
options={{
|
||||
minimap: {
|
||||
enabled: false
|
||||
},
|
||||
fontSize: 16
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorCode
|
||||
@@ -1,332 +0,0 @@
|
||||
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'
|
||||
import { Theme as AntDTheme } from '@rjsf/antd'
|
||||
import { withTheme } from '@rjsf/core'
|
||||
import { UiSchema } from '@rjsf/utils'
|
||||
import validator from '@rjsf/validator-ajv8'
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Tabs,
|
||||
Tooltip,
|
||||
Form as FormAntd,
|
||||
Collapse,
|
||||
Typography,
|
||||
Space
|
||||
} from 'antd'
|
||||
import equal from 'deep-equal'
|
||||
import { createRef, FC, memo, useEffect, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
ArrayFieldTemplatePropsType,
|
||||
ConfigurationEditorPropsType,
|
||||
DescriptionPropsType,
|
||||
ErrorsObjType,
|
||||
FieldTemplatePropsType,
|
||||
ObjectFieldTemplatePropertyType,
|
||||
ObjectFieldTemplatePropsType,
|
||||
SortPropType
|
||||
} from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
import { ResponseSchemaType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { cleanEmptyParamsObject } from '@utils/objectUtils.ts'
|
||||
|
||||
const { Text: AntdText } = Typography
|
||||
|
||||
const ConfigurationEditorForm: FC<ConfigurationEditorPropsType> = ({
|
||||
bufConfig = {},
|
||||
jsonSchema = {},
|
||||
submitRef
|
||||
}) => {
|
||||
const Form = withTheme(AntDTheme)
|
||||
const sortProps = (a: SortPropType, b: SortPropType) =>
|
||||
a.name.localeCompare(b.name)
|
||||
|
||||
const [formState, setFormState] = useState(bufConfig.data)
|
||||
const { id } = useParams()
|
||||
const formRef = createRef<any>()
|
||||
|
||||
useEffect(() => {
|
||||
if (!equal(formState, bufConfig.data)) {
|
||||
setFormState(bufConfig.data)
|
||||
}
|
||||
}, [bufConfig.data])
|
||||
|
||||
const uiSchema: UiSchema = {
|
||||
'ui:submitButtonOptions': {
|
||||
norender: true
|
||||
}
|
||||
}
|
||||
|
||||
const onSubmit = (data: any) => {
|
||||
if (!submitRef) return
|
||||
if (
|
||||
!formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
||||
) {
|
||||
submitRef.current = data
|
||||
} else {
|
||||
submitRef.current = data.formData
|
||||
}
|
||||
}
|
||||
|
||||
const forceSubmit = () => {
|
||||
if (formRef.current) {
|
||||
const formData = formRef.current.state.formData
|
||||
|
||||
onSubmit(cleanEmptyParamsObject(formData))
|
||||
}
|
||||
}
|
||||
|
||||
const onFormChange = () => {
|
||||
if (!formRef.current) return
|
||||
if (
|
||||
formRef.current.validateFormWithFormData(formRef.current.state.formData)
|
||||
) {
|
||||
formRef?.current?.submit()
|
||||
} else {
|
||||
forceSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
const Description: FC<DescriptionPropsType> = ({ description }) =>
|
||||
description ? (
|
||||
<span>
|
||||
|
||||
<Tooltip title={description}></Tooltip>
|
||||
</span>
|
||||
) : null
|
||||
|
||||
const getDepth = (id: string) => {
|
||||
if (!id) {
|
||||
return 0
|
||||
}
|
||||
return id.split('_').length
|
||||
}
|
||||
|
||||
const getName = (id: string) => {
|
||||
if (!id) {
|
||||
return ''
|
||||
}
|
||||
const arr = id.split('_')
|
||||
return `#${arr[arr.length - 1] || ''}`
|
||||
}
|
||||
|
||||
const FieldTemplate: FC<FieldTemplatePropsType> = (props) => {
|
||||
const {
|
||||
id,
|
||||
classNames,
|
||||
label,
|
||||
rawHelp,
|
||||
required,
|
||||
rawDescription,
|
||||
rawErrors,
|
||||
children,
|
||||
displayLabel,
|
||||
schema
|
||||
} = props
|
||||
|
||||
const isObject = schema.type === 'object'
|
||||
const depth = getDepth(id)
|
||||
const name = label || getName(id)
|
||||
|
||||
// Проверяем на наличие ошибок и формируем их вывод
|
||||
const errorMessages = rawErrors ? rawErrors.join('\n') : null
|
||||
|
||||
// Объекты и массивы - Обработка по глубине
|
||||
if (isObject && depth !== 1) {
|
||||
const title = (
|
||||
<div className={required ? 'ant-form-item-required' : ''}>
|
||||
{depth !== 2 && <AntdText strong>{name}</AntdText>}
|
||||
{errorMessages && (
|
||||
<AntdText type="danger">{` (${errorMessages})`}</AntdText>
|
||||
)}
|
||||
{depth !== 2 && <Description description={rawDescription} />}
|
||||
</div>
|
||||
)
|
||||
|
||||
if (depth === 2 || schema.dynamic) {
|
||||
return (
|
||||
<div style={{ width: '100%' }}>
|
||||
{!schema.dynamic && title}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapse className="collapse" defaultActiveKey={depth > 1 ? '' : id}>
|
||||
<Collapse.Panel
|
||||
key={id}
|
||||
className="configEditor_collapseObject"
|
||||
header={title}
|
||||
>
|
||||
{children}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
)
|
||||
}
|
||||
|
||||
// Для остальных типов возвращаем форму с элементами
|
||||
return (
|
||||
<FormAntd.Item
|
||||
className={classNames}
|
||||
validateStatus={errorMessages ? 'error' : undefined}
|
||||
help={errorMessages || undefined}
|
||||
extra={rawHelp}
|
||||
required={required}
|
||||
label={
|
||||
displayLabel && !schema.dynamic ? (
|
||||
<>
|
||||
{name}
|
||||
<Description description={rawDescription} />
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</FormAntd.Item>
|
||||
)
|
||||
}
|
||||
|
||||
const ArrayFieldTemplate: FC<ArrayFieldTemplatePropsType> = ({
|
||||
items,
|
||||
onAddClick,
|
||||
canAdd,
|
||||
title,
|
||||
idSchema,
|
||||
schema: { description }
|
||||
}) => {
|
||||
return (
|
||||
<Collapse defaultActiveKey={idSchema.$id}>
|
||||
<Collapse.Panel
|
||||
key={idSchema.$id}
|
||||
className="collapseArray"
|
||||
header={
|
||||
<Space
|
||||
direction="horizontal"
|
||||
style={{ justifyContent: 'space-between', width: '100%' }}
|
||||
>
|
||||
<Space direction="horizontal">
|
||||
<AntdText>{title}</AntdText>
|
||||
<Badge count={items ? items.length : 0} showZero />
|
||||
<Description description={description} />
|
||||
</Space>
|
||||
{canAdd && (
|
||||
<Button
|
||||
type="link"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAddClick(e as unknown as MouseEvent)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{items &&
|
||||
items.map((element) => (
|
||||
<div key={element.index} className="collapseArray_item">
|
||||
<div className="collapseArray_item_content">
|
||||
{element.children}
|
||||
</div>
|
||||
<Button
|
||||
type="link"
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={element.onDropIndexClick(element.index)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
)
|
||||
}
|
||||
|
||||
const ObjectFieldTemplate: FC<ObjectFieldTemplatePropsType> = (props) => {
|
||||
const {
|
||||
properties,
|
||||
idSchema,
|
||||
schema: { properties: schemaProperties },
|
||||
activeTabKey,
|
||||
handleTabsChange
|
||||
} = props
|
||||
|
||||
properties.sort(sortProps)
|
||||
if (idSchema.$id === 'root') {
|
||||
const propsComplex: ObjectFieldTemplatePropertyType[] = []
|
||||
const propsSimple: ObjectFieldTemplatePropertyType[] = []
|
||||
|
||||
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)}</>
|
||||
}
|
||||
|
||||
const transformErrors = (errors: ErrorsObjType[]): ErrorsObjType[] => {
|
||||
if (errors.length > 0) {
|
||||
errors.forEach((error) => {
|
||||
error.message = 'Поле является обязательным'
|
||||
})
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="configuration-editor-page__form">
|
||||
<Form
|
||||
formContext={{
|
||||
labelCol: { span: 8 },
|
||||
wrapperCol: { span: 30 },
|
||||
layout: 'vertical'
|
||||
}}
|
||||
uiSchema={uiSchema}
|
||||
templates={{
|
||||
ObjectFieldTemplate: ObjectFieldTemplate as any,
|
||||
FieldTemplate: FieldTemplate as any,
|
||||
ArrayFieldTemplate: ArrayFieldTemplate as any
|
||||
}}
|
||||
ref={formRef}
|
||||
transformErrors={transformErrors as any}
|
||||
schema={jsonSchema?.schema as ResponseSchemaType}
|
||||
onSubmit={onSubmit}
|
||||
validator={validator}
|
||||
formData={id === 'new' ? {} : formState}
|
||||
onChange={onFormChange}
|
||||
showErrorList={false}
|
||||
></Form>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ConfigurationEditorForm)
|
||||
@@ -1,45 +0,0 @@
|
||||
import { Spin } from 'antd'
|
||||
import { ReactJsonView } from 'isp-ui-kit'
|
||||
import { FC, useContext } from 'react'
|
||||
|
||||
import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
const ConfigurationEditorJson: FC<ConfigurationEditorPropsType> = ({
|
||||
bufConfig,
|
||||
setBufConfig,
|
||||
isCurrentConfigLoading
|
||||
}) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
if (isCurrentConfigLoading) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
const handleEdit = (updated_src: any) => {
|
||||
const newData = {
|
||||
...bufConfig,
|
||||
data: { ...updated_src }
|
||||
}
|
||||
setBufConfig(newData)
|
||||
}
|
||||
|
||||
return (
|
||||
<ReactJsonView
|
||||
theme={changeTheme ? 'twilight' : ''}
|
||||
onAdd={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
onDelete={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
displayDataTypes={false}
|
||||
displayObjectSize={false}
|
||||
name={null}
|
||||
enableClipboard={true}
|
||||
iconStyle="square"
|
||||
onEdit={({ updated_src }: any) => handleEdit(updated_src)}
|
||||
src={bufConfig?.data}
|
||||
sortKeys={true}
|
||||
collapsed={1}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorJson
|
||||
@@ -1,5 +0,0 @@
|
||||
.configuration-preview-modal {
|
||||
.react-json-view {
|
||||
width: 100vw;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface ConfigurationPreviewModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
versionCompare?: boolean
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import { ReactJsonView } from 'isp-ui-kit'
|
||||
import { FC, memo, useContext } from 'react'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigurationPreviewModalPropsType } from '@components/ConfigurationPreviewModal/configuration-preview-modal.type.ts'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import './configuration-preview-modal.scss'
|
||||
|
||||
const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
||||
versionCompare = false,
|
||||
config,
|
||||
open,
|
||||
onClose
|
||||
}) => {
|
||||
const { changeTheme } = useContext(Context)
|
||||
const data = JSON.parse(JSON.stringify(config.data || {}))
|
||||
const configName = versionCompare
|
||||
? `Версия: ${config.configVersion}`
|
||||
: config.name
|
||||
return (
|
||||
<div className="configuration-preview-modal">
|
||||
<Modal title={configName || ''} open={open} onClose={onClose}>
|
||||
<ReactJsonView
|
||||
theme={changeTheme ? 'twilight' : ''}
|
||||
src={data}
|
||||
name={false}
|
||||
sortKeys={true}
|
||||
displayDataTypes={false}
|
||||
editKeys={false}
|
||||
/>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ConfigurationPreviewModal)
|
||||
@@ -1,62 +0,0 @@
|
||||
import { Button } from 'antd'
|
||||
import { Dispatch, FC, SetStateAction } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
|
||||
import './confirm-config-modal.scss'
|
||||
|
||||
interface ConfirmModalProps extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
handleSaveClick: (upVersion?: number, unsafe?: boolean) => void
|
||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||
currentConfig: ConfigType | undefined
|
||||
}
|
||||
|
||||
const ConfirmConfigModal: FC<ConfirmModalProps> = ({
|
||||
currentConfig,
|
||||
setBufConfig,
|
||||
handleSaveClick,
|
||||
onClose = () => null,
|
||||
open
|
||||
}) => {
|
||||
const { id = '' } = useParams()
|
||||
const isNew = id === 'new' ? '' : id
|
||||
|
||||
const { data } = configServiceApi.useGetConfigByIdQuery(isNew)
|
||||
|
||||
const onConfirmHandler = () => {
|
||||
setBufConfig(currentConfig)
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="confirm-config-modal">
|
||||
<Modal
|
||||
title="Версия конфигурации была кем-то изменена"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<Button
|
||||
className="confirm-btn danger"
|
||||
type="primary"
|
||||
danger
|
||||
onClick={() => {
|
||||
handleSaveClick(data && data.version)
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
Сохранить принудительно
|
||||
</Button>
|
||||
<Button className="confirm-btn" type="primary" onClick={onConfirmHandler}>
|
||||
Принять изменения
|
||||
</Button>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default ConfirmConfigModal
|
||||
@@ -1,6 +0,0 @@
|
||||
.confirm-config-modal {
|
||||
.modal__content {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Table } from 'antd'
|
||||
import { FC } from 'react'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
interface ErrorConfigModalProps
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
details?: { [key: string]: string }
|
||||
}
|
||||
|
||||
const ErrorConfigModal: FC<ErrorConfigModalProps> = ({
|
||||
details = {},
|
||||
onClose,
|
||||
open
|
||||
}) => {
|
||||
const columns = [
|
||||
{
|
||||
dataIndex: 'key',
|
||||
key: 'key',
|
||||
render: (text: string) => <span style={{ color: 'red' }}>{text}</span>
|
||||
},
|
||||
{
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}
|
||||
]
|
||||
|
||||
const data = Object.keys(details).map((key) => ({
|
||||
key,
|
||||
value: details[key]
|
||||
}))
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="Несоотвествия схемы конфигурации"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
>
|
||||
<div>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
showHeader={false}
|
||||
pagination={false}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default ErrorConfigModal
|
||||
@@ -1,35 +0,0 @@
|
||||
const DefaultUser = () => {
|
||||
return (
|
||||
<span role="img" className="anticon ant-menu-item-icon">
|
||||
<svg
|
||||
data-icon="appstore"
|
||||
width="1.5em"
|
||||
height="1.5em"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||
>
|
||||
<rect width="24" height="24" fill="url(#pattern0)" />
|
||||
<defs>
|
||||
<pattern
|
||||
id="pattern0"
|
||||
patternContentUnits="objectBoundingBox"
|
||||
width="1"
|
||||
height="1"
|
||||
>
|
||||
<use xlinkHref="#image0_121_5920" transform="scale(0.0025)" />
|
||||
</pattern>
|
||||
<image
|
||||
id="image0_121_5920"
|
||||
width="400"
|
||||
height="400"
|
||||
xlinkHref="data:image/png;base64,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 truncated
|
||||
/>
|
||||
</defs>
|
||||
</svg>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export default DefaultUser
|
||||
@@ -1,241 +0,0 @@
|
||||
import {
|
||||
AppstoreAddOutlined,
|
||||
FileProtectOutlined,
|
||||
ProductOutlined,
|
||||
ProfileOutlined
|
||||
} from '@ant-design/icons'
|
||||
import type { MenuProps } from 'antd'
|
||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
|
||||
import Header from '@widgets/Header'
|
||||
|
||||
import DefaultUser from '@components/Icons/DefaultUser.tsx'
|
||||
import {
|
||||
MenuItemKeysType,
|
||||
MenuItemType,
|
||||
menuKeys
|
||||
} from '@components/Layout/layout.type.ts'
|
||||
|
||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
||||
|
||||
import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import { fetchProfile, fetchUI } from '@stores/redusers/ActionCreators.ts'
|
||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './layout.scss'
|
||||
|
||||
const { Content, Sider } = Layout
|
||||
|
||||
const LayoutComponent = () => {
|
||||
const [collapsed, setCollapsed] = useState<boolean>(
|
||||
LocalStorage.get('menu') === null ? true : LocalStorage.get('menu')
|
||||
)
|
||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
|
||||
[]
|
||||
)
|
||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const dispatch = useAppDispatch()
|
||||
const {
|
||||
status,
|
||||
profile: { firstName }
|
||||
} = useAppSelector((state) => state.profileReducer)
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const { hasPermission } = useRole()
|
||||
const { theme } = useContext(ConfigProvider.ConfigContext)
|
||||
|
||||
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
|
||||
|
||||
const hideItem = (permission: PermissionKeysType | PermissionKeysType[]) => {
|
||||
if (Array.isArray(permission)) {
|
||||
const result = permission.reduce((acc, currentValue) => {
|
||||
const hasPermissionFunc = hasPermission(currentValue)
|
||||
return hasPermissionFunc || acc
|
||||
}, false)
|
||||
return result ? '' : 'hide-item'
|
||||
}
|
||||
return hasPermission(permission) ? '' : 'hide-item'
|
||||
}
|
||||
const menuItems: MenuItemType[] = [
|
||||
{
|
||||
label: firstName || '',
|
||||
key: 'profile',
|
||||
className: 'user-item',
|
||||
icon: <DefaultUser />
|
||||
},
|
||||
{
|
||||
label: 'Приложения',
|
||||
key: 'applications_group',
|
||||
className: hideItem([PermissionKeysType.read]),
|
||||
icon: <AppstoreAddOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Доступы приложений',
|
||||
key: 'appAccess',
|
||||
className: hideItem([PermissionKeysType.read]),
|
||||
icon: <FileProtectOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Модули',
|
||||
key: 'modules',
|
||||
className: hideItem(PermissionKeysType.read),
|
||||
icon: <ProductOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Пользователи и роли',
|
||||
key: 'sessionManagement',
|
||||
className: hideItem([
|
||||
PermissionKeysType.user_view,
|
||||
PermissionKeysType.session_view,
|
||||
PermissionKeysType.role_view
|
||||
]),
|
||||
icon: <ProfileOutlined />,
|
||||
children: [
|
||||
{
|
||||
label: 'Пользователи',
|
||||
key: 'users',
|
||||
className: hideItem(PermissionKeysType.user_view)
|
||||
},
|
||||
{
|
||||
label: 'Пользовательские сессии',
|
||||
key: 'sessions',
|
||||
className: hideItem(PermissionKeysType.session_view)
|
||||
},
|
||||
{
|
||||
label: 'Просмотр журналов ИБ',
|
||||
key: 'securityLog',
|
||||
className: hideItem(PermissionKeysType.security_log_view)
|
||||
},
|
||||
{
|
||||
label: 'Роли',
|
||||
key: 'roles',
|
||||
className: hideItem(PermissionKeysType.role_view)
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
ConfigProvider.config({
|
||||
holderRender: (children) => (
|
||||
<ConfigProvider prefixCls="static" theme={theme}>
|
||||
{children}
|
||||
</ConfigProvider>
|
||||
)
|
||||
})
|
||||
}, [theme])
|
||||
useEffect(() => {
|
||||
if (userToken && status === StateProfileStatus.notInit) {
|
||||
dispatch(fetchProfile())
|
||||
dispatch(fetchUI())
|
||||
}
|
||||
}, [userToken, status])
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
status === StateProfileStatus.resolved ||
|
||||
status === StateProfileStatus.rejected
|
||||
) {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [status])
|
||||
|
||||
useEffect(() => {
|
||||
const menuKey = location.pathname.split('/')[1] as MenuItemKeysType
|
||||
const selectedKey = selectedMenuKeys[0] || ''
|
||||
const menuItem = menuKeys[menuKey]
|
||||
|
||||
if (menuItem && menuKey !== selectedKey) {
|
||||
setSelectedMenuKeys([menuItem.key])
|
||||
if (selectedKey) {
|
||||
setOpenKeys(menuItem.parent)
|
||||
}
|
||||
}
|
||||
}, [location.pathname])
|
||||
|
||||
const handlerOnClickMenu: MenuProps['onClick'] = ({ key }): void => {
|
||||
switch (key) {
|
||||
case MenuItemKeysType.profile: {
|
||||
navigate(routePaths.profile)
|
||||
break
|
||||
}
|
||||
case MenuItemKeysType.users:
|
||||
navigate(routePaths.users)
|
||||
break
|
||||
case MenuItemKeysType.sessions:
|
||||
navigate(routePaths.sessions)
|
||||
break
|
||||
case MenuItemKeysType.securityLog:
|
||||
navigate(routePaths.securityLog)
|
||||
break
|
||||
case MenuItemKeysType.appAccess:
|
||||
navigate(routePaths.appAccess)
|
||||
break
|
||||
case MenuItemKeysType.roles:
|
||||
navigate(routePaths.roles)
|
||||
break
|
||||
case MenuItemKeysType.modules:
|
||||
navigate(routePaths.modules)
|
||||
break
|
||||
case MenuItemKeysType.applicationsGroup:
|
||||
navigate(routePaths.applicationsGroup)
|
||||
break
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if (loading || status === StateProfileStatus.pending) {
|
||||
return <Spin size="large" fullscreen />
|
||||
}
|
||||
|
||||
if (status === StateProfileStatus.rejected) {
|
||||
return <Navigate to={routePaths.error} replace />
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
<Sider
|
||||
width="250px"
|
||||
data-cy="aside"
|
||||
theme="light"
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={(value) => {
|
||||
LocalStorage.set('menu', value)
|
||||
setCollapsed(value)
|
||||
}}
|
||||
>
|
||||
<Header collapsed={collapsed} />
|
||||
<Menu
|
||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
||||
openKeys={openKeys}
|
||||
selectedKeys={selectedMenuKeys}
|
||||
onClick={handlerOnClickMenu}
|
||||
theme="light"
|
||||
mode="inline"
|
||||
items={menuItems}
|
||||
/>
|
||||
</Sider>
|
||||
<Layout className="site-layout">
|
||||
<Content className="site-layout__content">
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
</Layout>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default LayoutComponent
|
||||
@@ -1,52 +0,0 @@
|
||||
@import 'src/constants/style/styleConst';
|
||||
|
||||
.layout {
|
||||
min-height: 100vh !important;
|
||||
position: relative;
|
||||
|
||||
.hide-item {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.ant-spin {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
.ant-menu {
|
||||
border-inline-end: none !important;
|
||||
}
|
||||
|
||||
.ant-menu-title-content {
|
||||
padding-left: 10px
|
||||
}
|
||||
}
|
||||
|
||||
.user-item {
|
||||
padding-left: 21px !important;
|
||||
& .ant-menu-submenu-arrow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--ant-color-border);
|
||||
border-radius: 0 !important;
|
||||
|
||||
& .ant-menu-title-content {
|
||||
margin: 0 !important;
|
||||
padding-left: 17px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu-inline-collapsed {
|
||||
& .user-item {
|
||||
padding-left: 24px !important;
|
||||
padding-top: 5px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu-submenu {
|
||||
.hide-item {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import { MenuProps } from 'antd'
|
||||
|
||||
export enum MenuItemKeysType {
|
||||
users = 'users',
|
||||
sessions = 'sessions',
|
||||
securityLog = 'securityLog',
|
||||
appAccess = 'appAccess',
|
||||
roles = 'roles',
|
||||
logout = 'logout',
|
||||
profile = 'profile',
|
||||
modules = 'modules',
|
||||
applicationsGroup = 'applications_group'
|
||||
}
|
||||
export enum MenuItemLabelsType {
|
||||
users = 'Пользователи',
|
||||
sessions = 'Пользовательские сессии',
|
||||
securityLog = 'Просмотр журналов ИБ',
|
||||
appAccess = 'Доступы приложений',
|
||||
roles = 'Роли',
|
||||
profile = 'Профиль',
|
||||
modules = 'Модули',
|
||||
logout = 'Выход',
|
||||
applications_group = 'Группы приложений'
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
key: MenuItemKeysType
|
||||
parent: string[]
|
||||
}
|
||||
|
||||
export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
|
||||
[MenuItemKeysType.users]: {
|
||||
key: MenuItemKeysType.users,
|
||||
parent: ['users']
|
||||
},
|
||||
[MenuItemKeysType.sessions]: {
|
||||
key: MenuItemKeysType.sessions,
|
||||
parent: ['users']
|
||||
},
|
||||
[MenuItemKeysType.securityLog]: {
|
||||
key: MenuItemKeysType.securityLog,
|
||||
parent: ['users']
|
||||
},
|
||||
[MenuItemKeysType.appAccess]: {
|
||||
key: MenuItemKeysType.appAccess,
|
||||
parent: ['appAccess']
|
||||
},
|
||||
[MenuItemKeysType.roles]: {
|
||||
key: MenuItemKeysType.roles,
|
||||
parent: ['users']
|
||||
},
|
||||
[MenuItemKeysType.logout]: {
|
||||
key: MenuItemKeysType.logout,
|
||||
parent: ['']
|
||||
},
|
||||
[MenuItemKeysType.profile]: {
|
||||
key: MenuItemKeysType.profile,
|
||||
parent: ['']
|
||||
},
|
||||
[MenuItemKeysType.modules]: {
|
||||
key: MenuItemKeysType.modules,
|
||||
parent: ['modules']
|
||||
},
|
||||
[MenuItemKeysType.applicationsGroup]: {
|
||||
key: MenuItemKeysType.applicationsGroup,
|
||||
parent: ['applicationsGroup']
|
||||
}
|
||||
}
|
||||
|
||||
export type MenuItemType = Required<MenuProps>['items'][number]
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Tabs } from 'antd'
|
||||
import { memo } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import ModuleTabContent from '@widgets/ModuleTabContent'
|
||||
|
||||
import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts'
|
||||
|
||||
const secondColumnItems = [
|
||||
{
|
||||
key: 'configurations',
|
||||
name: 'Конфигурации'
|
||||
},
|
||||
{ key: 'connections', name: 'Подключения' }
|
||||
]
|
||||
|
||||
const ModuleTabs = ({
|
||||
activeTab,
|
||||
setActiveTab,
|
||||
currentModule
|
||||
}: ModuleTabsPropsType) => {
|
||||
const navigate = useNavigate()
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
return (
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={(activeKey) => {
|
||||
setActiveTab(activeKey)
|
||||
const path = `${selectedItemId}/${activeKey}`
|
||||
navigate(path)
|
||||
}}
|
||||
className="modules-page__tabs"
|
||||
items={secondColumnItems.map((item) => {
|
||||
return {
|
||||
disabled: selectedItemId === '',
|
||||
label: item.name,
|
||||
key: item.key,
|
||||
children: (
|
||||
<div className="modules-page__content">
|
||||
<ModuleTabContent
|
||||
selectedItemId={selectedItemId}
|
||||
currentModule={currentModule}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(ModuleTabs)
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ModuleTabsPropsType {
|
||||
activeTab: string
|
||||
setActiveTab: (key: string) => void
|
||||
currentModule: ModuleType | undefined
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Descriptions, Spin } from 'antd'
|
||||
|
||||
import { RoleListProps } from '@components/RoleList/role-list.type.ts'
|
||||
|
||||
import roleApi from '@services/roleService.ts'
|
||||
|
||||
import './role-list.scss'
|
||||
|
||||
const RoleList = ({ userRoles }: RoleListProps) => {
|
||||
const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery()
|
||||
const roleIds = new Set(userRoles)
|
||||
|
||||
if (isError) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Descriptions layout="vertical" className="role-list">
|
||||
<Descriptions.Item label="Список ролей">
|
||||
{isLoading ? (
|
||||
<Spin className="spin" />
|
||||
) : (
|
||||
<ul>
|
||||
{roles.map((roleData) => {
|
||||
if (roleIds.has(roleData.id) && roleData.name) {
|
||||
return <li key={roleData.id}>{roleData.name}</li>
|
||||
}
|
||||
return null
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)
|
||||
}
|
||||
|
||||
export default RoleList
|
||||
@@ -1,19 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.role-list {
|
||||
.ant-descriptions-item-label {
|
||||
font-size: $text-size-header2;
|
||||
}
|
||||
|
||||
.spin {
|
||||
position: initial;
|
||||
}
|
||||
|
||||
ul, li {
|
||||
list-style-position: inside
|
||||
}
|
||||
|
||||
li {
|
||||
font-size: $text-size
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export type RoleListProps = {
|
||||
userRoles: number[]
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
import { Divider, message, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Controller, useForm } from 'react-hook-form'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import SaveButton from '@ui/SaveButton'
|
||||
|
||||
import AgreementModal from '@widgets/AgreementModal'
|
||||
|
||||
import { RolesContentPropsType } from '@components/RolesContent/roles-content.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
||||
|
||||
import './roles-content.scss'
|
||||
|
||||
const newRole: Partial<RoleType> = {
|
||||
externalGroup: '',
|
||||
name: '',
|
||||
permissions: []
|
||||
}
|
||||
|
||||
const columns: ColumnsType = [
|
||||
{
|
||||
title: 'Действие',
|
||||
dataIndex: 'name'
|
||||
},
|
||||
{
|
||||
title: 'Ключ в системе',
|
||||
dataIndex: 'key'
|
||||
}
|
||||
]
|
||||
const { FormInput } = FormComponents
|
||||
const RolesContent = ({
|
||||
role,
|
||||
permissions,
|
||||
saveRole,
|
||||
title = 'Редактировать',
|
||||
immutable = false
|
||||
}: RolesContentPropsType) => {
|
||||
const {
|
||||
control,
|
||||
formState: { isDirty },
|
||||
setError,
|
||||
getValues,
|
||||
reset
|
||||
} = useForm<RoleType>({
|
||||
defaultValues: role,
|
||||
mode: 'onChange'
|
||||
})
|
||||
const { hasPermission } = useRole()
|
||||
const { id: selectedItemId } = useParams()
|
||||
|
||||
const [openModal, setOpenModal] = useState<boolean>(false)
|
||||
const isUpdateRole = hasPermission(PermissionKeysType.role_update)
|
||||
const isCreateRole = hasPermission(PermissionKeysType.role_add)
|
||||
|
||||
const isSaveBtnAvailable =
|
||||
selectedItemId === 'new' ? isCreateRole : isUpdateRole
|
||||
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
reset(newRole)
|
||||
} else {
|
||||
reset(role)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
const handleSubmitForm = (changeMessage: string) => {
|
||||
if (!changeMessage) {
|
||||
message.error('Поле не может быть пустым')
|
||||
return
|
||||
}
|
||||
const formValue = getValues()
|
||||
formValue.changeMessage = changeMessage
|
||||
saveRole(formValue, setError)
|
||||
setOpenModal(false)
|
||||
}
|
||||
|
||||
const renderFormTable = () => (
|
||||
<Controller
|
||||
control={control}
|
||||
name="permissions"
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={permissions}
|
||||
pagination={{ pageSize: 10 }}
|
||||
scroll={{
|
||||
y: 'calc(100vh - 270px)'
|
||||
}}
|
||||
rowSelection={{
|
||||
selectedRowKeys: value,
|
||||
type: 'checkbox',
|
||||
onChange: (selectedRowKeys) => {
|
||||
onChange(selectedRowKeys)
|
||||
},
|
||||
getCheckboxProps: () => ({
|
||||
disabled: immutable
|
||||
})
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{openModal && (
|
||||
<AgreementModal
|
||||
open
|
||||
destroyOnClose
|
||||
onCancel={() => setOpenModal(false)}
|
||||
okText="Сохранить"
|
||||
title="Для подтверждения изменений укажите причину"
|
||||
description="Основание для измений"
|
||||
onConfirm={handleSubmitForm}
|
||||
/>
|
||||
)}
|
||||
<form className="roles-content">
|
||||
<div className="roles-content__header">
|
||||
<h2
|
||||
data-cy="roles-content__header__title"
|
||||
className="roles-content__header__title"
|
||||
>
|
||||
{title}
|
||||
</h2>
|
||||
<SaveButton
|
||||
disabled={!isDirty || !isSaveBtnAvailable}
|
||||
type="primary"
|
||||
data-cy="roles-content__header__save-button"
|
||||
onClick={() => setOpenModal(true)}
|
||||
className="roles-content__header__save-button"
|
||||
/>
|
||||
</div>
|
||||
<Divider />
|
||||
<div className="roles-content__wrap-input">
|
||||
<FormInput
|
||||
data-cy="roles-content__input__name"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
label="Наименование роли"
|
||||
name="name"
|
||||
control={control}
|
||||
/>
|
||||
<FormInput
|
||||
data-cy="roles-content__input__external-group"
|
||||
label="Группы ЕСК"
|
||||
name="externalGroup"
|
||||
control={control}
|
||||
/>
|
||||
</div>
|
||||
{renderFormTable()}
|
||||
</form>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default RolesContent
|
||||
@@ -1,30 +0,0 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.roles-content {
|
||||
padding: $basic-padding*2 $basic-padding*3 0;
|
||||
min-width: 400px;
|
||||
height: 100%;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&__wrap-input {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.ant-pagination {
|
||||
margin: 8px 0 !important;
|
||||
}
|
||||
|
||||
.ant-divider-horizontal {
|
||||
margin: 14px 0;
|
||||
}
|
||||
|
||||
.ant-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { UseFormSetError } from 'react-hook-form'
|
||||
|
||||
import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts'
|
||||
|
||||
export interface RolesContentPropsType {
|
||||
role?: Partial<RoleType>
|
||||
title?: string
|
||||
immutable?: boolean
|
||||
permissions: PermissionType[]
|
||||
saveRole: (
|
||||
formValue: RoleType | NewRoleType,
|
||||
setError: UseFormSetError<RoleType | NewRoleType>
|
||||
) => void
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import ClipboardJS from 'clipboard'
|
||||
import dayjs from 'dayjs'
|
||||
import 'dayjs/locale/ru'
|
||||
import duration from 'dayjs/plugin/duration'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
import {
|
||||
ApplicationTokenType,
|
||||
NewApplicationTokenType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import tokensApi from '@services/tokensService.ts'
|
||||
|
||||
import './tokens.scss'
|
||||
|
||||
const { FormSelect } = FormComponents
|
||||
const { EmptyData } = Layout
|
||||
|
||||
interface TokenPropTypes {
|
||||
id: number
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-named-as-default-member
|
||||
dayjs.locale('ru')
|
||||
dayjs.extend(duration)
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const TokenContent = ({ id }: TokenPropTypes) => {
|
||||
const [showApplicationsModal, setShowApplicationsModal] = useState(false)
|
||||
const {
|
||||
handleSubmit: handleSubmitTokens,
|
||||
control: controlTokens,
|
||||
reset
|
||||
} = useForm<ApplicationTokenType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
const { data, isLoading } = tokensApi.useGetTokensByAppIdQuery({ id })
|
||||
const [createToken] = tokensApi.useCreateTokenMutation()
|
||||
const [revokeToken] = tokensApi.useRevokeTokensMutation()
|
||||
|
||||
useEffect(() => {
|
||||
const clipboard = new ClipboardJS('.copy-btn')
|
||||
clipboard.on('success', () => {
|
||||
message.success('Токен скопирован в буфер обмена')
|
||||
})
|
||||
clipboard.on('error', () => {
|
||||
message.error('Ошибка копирования')
|
||||
})
|
||||
|
||||
return () => {
|
||||
clipboard.destroy()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleCreateToken = (data: any) => {
|
||||
if (id) {
|
||||
const newToken: NewApplicationTokenType = {
|
||||
expireTimeMs: data.expireTime,
|
||||
appId: Number(id)
|
||||
}
|
||||
|
||||
createToken(newToken)
|
||||
.then(() => {
|
||||
setShowApplicationsModal(false)
|
||||
reset()
|
||||
message.success('Элемент добавлен')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Ошибка добавления элемента')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function shortenString(longString: string) {
|
||||
if (longString.length <= 6) {
|
||||
return <span>{longString}</span>
|
||||
} else {
|
||||
return (
|
||||
<span>
|
||||
{longString.slice(0, 3)}...{longString.slice(-3)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const handleRevokeToken = (elem: ApplicationTokenType) => {
|
||||
const currentRemoveToken = {
|
||||
appId: id,
|
||||
tokens: [elem.token]
|
||||
}
|
||||
|
||||
revokeToken(currentRemoveToken)
|
||||
.unwrap()
|
||||
.then(() => message.success('Элемент удален'))
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ApplicationTokenType> = [
|
||||
{
|
||||
title: 'Токен',
|
||||
dataIndex: 'token',
|
||||
key: 'token',
|
||||
render: (value) => <div>{shortenString(value)}</div>
|
||||
},
|
||||
{
|
||||
title: 'Дата/Время выпуска',
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (value) => {
|
||||
const formatTime = dayjs(value).format(dateFormats.fullFormat)
|
||||
return <div>{formatTime}</div>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Истекает',
|
||||
dataIndex: 'expireTime',
|
||||
key: 'expireTime',
|
||||
render: (value, record) => {
|
||||
if (value === -1) {
|
||||
return <span>Никогда</span>
|
||||
}
|
||||
|
||||
const dateNow = dayjs()
|
||||
const expireTime = dayjs(record.createdAt).add(value)
|
||||
if (expireTime.isBefore(dateNow)) {
|
||||
return <span>Просрочен</span>
|
||||
}
|
||||
|
||||
const formatTime = expireTime.format(dateFormats.fullFormat)
|
||||
return <span>{formatTime}</span>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действия',
|
||||
dataIndex: 'token',
|
||||
key: 'actions',
|
||||
render: (value, record) => {
|
||||
return (
|
||||
<Button.Group>
|
||||
<Tooltip title="Скопировать">
|
||||
<Button
|
||||
className="copy-btn"
|
||||
icon={<CopyOutlined />}
|
||||
data-clipboard-text={value}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Удалить">
|
||||
<Popconfirm
|
||||
title="Закончить эту сессию?"
|
||||
onConfirm={() => handleRevokeToken(record)}
|
||||
>
|
||||
<Button icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</Button.Group>
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const tokensOptions = useMemo(
|
||||
() => [
|
||||
{
|
||||
value: -1,
|
||||
label: 'Бессрочно'
|
||||
},
|
||||
{
|
||||
value: 3600000,
|
||||
label: 'Один час'
|
||||
},
|
||||
{
|
||||
value: 86400000,
|
||||
label: 'Один день'
|
||||
},
|
||||
{
|
||||
value: 2592000000,
|
||||
label: '30 дней'
|
||||
},
|
||||
{
|
||||
value: 31536000000,
|
||||
label: 'Один год'
|
||||
}
|
||||
],
|
||||
[]
|
||||
)
|
||||
if (!id) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
const handleShowAddModalToken = () => {
|
||||
setShowApplicationsModal(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="token-content">
|
||||
<div className="token-content__wrap">
|
||||
<header className="token-content__header">
|
||||
<h3>Токены</h3>
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="applications-content__add-btn"
|
||||
type="primary"
|
||||
onClick={handleShowAddModalToken}
|
||||
>
|
||||
Добавить токен
|
||||
</Button>
|
||||
</CanEdit>
|
||||
</header>
|
||||
<div className="token-content__table">
|
||||
<Table
|
||||
className="appliactions-tokent__table"
|
||||
rowKey={(record) => record.createdAt}
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
/>
|
||||
</div>
|
||||
<Modal
|
||||
onOk={handleSubmitTokens(handleCreateToken)}
|
||||
title="Добавить"
|
||||
open={showApplicationsModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() => setShowApplicationsModal(false)}
|
||||
>
|
||||
<form>
|
||||
<FormSelect
|
||||
options={tokensOptions}
|
||||
name="expireTime"
|
||||
control={controlTokens}
|
||||
label="Время действия"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default TokenContent
|
||||
@@ -1,35 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.token-content {
|
||||
overflow-x: scroll;
|
||||
width: 100%;
|
||||
|
||||
&__table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 100px);
|
||||
}
|
||||
|
||||
&__wrap {
|
||||
padding: $basic-padding*1.25 $basic-padding*3;
|
||||
}
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 19px;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-family: PT Sans, sans-serif;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
*, html {
|
||||
margin:0;
|
||||
padding:0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.app{
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
min-height: 0;
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
.ant-btn:focus-visible{
|
||||
outline: none !important;
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
type PathKeys =
|
||||
| 'baseUrl'
|
||||
| 'baseSystemUrl'
|
||||
| 'baseConfigUrl'
|
||||
| 'getAllRoles'
|
||||
| 'createRole'
|
||||
| 'updateRole'
|
||||
| 'deleteRole'
|
||||
| 'login'
|
||||
| 'logout'
|
||||
| 'getProfile'
|
||||
| 'getUsers'
|
||||
| 'createUser'
|
||||
| 'updateUser'
|
||||
| 'blockUser'
|
||||
| 'deleteUser'
|
||||
| 'getRoles'
|
||||
| 'getAllPermissions'
|
||||
| 'baseUserUrl'
|
||||
| 'baseAdminUrl'
|
||||
| 'getAllSession'
|
||||
| 'revokeSession'
|
||||
| 'getAllLogs'
|
||||
| 'getLogEvents'
|
||||
| 'setLogEvents'
|
||||
| 'getSystemTree'
|
||||
| 'getById'
|
||||
| 'setList'
|
||||
| 'setOne'
|
||||
| 'getAllRoutes'
|
||||
| 'getModules'
|
||||
| 'deleteModule'
|
||||
| 'createUpdateService'
|
||||
| 'deleteService'
|
||||
| 'getAllService'
|
||||
| 'getServiceById'
|
||||
| 'getServicesByDomainId'
|
||||
| 'createUpdateApplication'
|
||||
| 'deleteApplication'
|
||||
| 'getApplicationById'
|
||||
| 'getAllApplications'
|
||||
| 'getApplicationsByServiceId'
|
||||
| 'createToken'
|
||||
| 'getTokensByAppId'
|
||||
| 'revokeTokens'
|
||||
| 'revokeTokensForApp'
|
||||
| 'getConfigsByModuleId'
|
||||
| 'getConfigById'
|
||||
| 'getAllVersions'
|
||||
| 'createUpdateConfig'
|
||||
| 'deleteVersion'
|
||||
| 'deleteConfig'
|
||||
| 'markConfigAsActive'
|
||||
| 'getUI'
|
||||
| 'getByModuleId'
|
||||
| 'changePassword'
|
||||
|
||||
export const apiPaths: Record<PathKeys, string> = {
|
||||
baseUrl: '/api/kkd-configuration-service',
|
||||
baseAdminUrl: '/api/admin',
|
||||
baseUserUrl: '/api/admin/user',
|
||||
baseSystemUrl: '/api/system',
|
||||
baseConfigUrl: '/api/config',
|
||||
// ======= ROLES ======
|
||||
getAllRoles: '/role/all',
|
||||
createRole: '/role/create',
|
||||
updateRole: '/role/update',
|
||||
deleteRole: '/role/delete',
|
||||
// ======= AUTH ======
|
||||
login: '/api/admin/auth/login',
|
||||
logout: '/api/admin/auth/logout',
|
||||
// ======= PROFILE ======
|
||||
getProfile: '/api/admin/user/get_profile',
|
||||
getUI: '/api/admin/user/get_design',
|
||||
changePassword: '/api/admin/user/change_password',
|
||||
// ======= USERS ======
|
||||
getUsers: '/get_users',
|
||||
createUser: '/create_user',
|
||||
updateUser: '/update_user',
|
||||
blockUser: '/block_user',
|
||||
deleteUser: '/delete_user',
|
||||
getRoles: '/get_roles',
|
||||
getAllPermissions: '/get_permissions',
|
||||
// ======= SESSIONS ======
|
||||
getAllSession: '/session/all',
|
||||
revokeSession: '/session/revoke',
|
||||
// ======= LOGS ======
|
||||
getAllLogs: '/log/all',
|
||||
getLogEvents: '/log/events',
|
||||
setLogEvents: '/log/set_events',
|
||||
// ======= APPLICATIONS ======
|
||||
getSystemTree: '/application/get_system_tree',
|
||||
getAllApplications: '/application/get_applications',
|
||||
createUpdateApplication: '/application/create_update_application',
|
||||
getApplicationsByServiceId: '/application/get_applications_by_service_id',
|
||||
deleteApplication: '/application/delete_applications',
|
||||
getApplicationById: '/application/get_application_by_id',
|
||||
// ======= ACCESS_LIST ======
|
||||
getById: '/access_list/get_by_id',
|
||||
setList: '/access_list/set_list',
|
||||
setOne: '/access_list/set_one',
|
||||
getAllRoutes: '/routing/get_routes',
|
||||
// ======= MODULES ======
|
||||
getModules: '/module/get_modules_info',
|
||||
deleteModule: '/module/delete_module',
|
||||
getByModuleId: '/schema/get_by_module_id',
|
||||
// ======= SERVICE ======
|
||||
getServiceById: '/service/get_service_by_id',
|
||||
getAllService: '/service/get_service',
|
||||
deleteService: '/service/delete_service',
|
||||
createUpdateService: '/service/create_update_service',
|
||||
getServicesByDomainId: '/service/get_services_by_domain_id',
|
||||
// ======= TOKENS ======
|
||||
createToken: '/token/create_token',
|
||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
||||
revokeTokens: '/token/revoke_tokens',
|
||||
revokeTokensForApp: '/token/revoke_tokens_for_app',
|
||||
// ======= CONFIGS ======
|
||||
getConfigsByModuleId: '/config/get_configs_by_module_id',
|
||||
getConfigById: '/config/get_config_by_id',
|
||||
getAllVersions: '/config/get_all_version',
|
||||
createUpdateConfig: '/config/create_update_config',
|
||||
deleteVersion: '/config/delete_version',
|
||||
deleteConfig: '/config/delete_config',
|
||||
markConfigAsActive: '/config/mark_config_as_active'
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
type FormattersKey = 'fullFormat'
|
||||
|
||||
export const dateFormats: Record<FormattersKey, string> = {
|
||||
fullFormat: 'DD.MM.YYYY HH:mm:ss'
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
type ValidationRulesKeys = 'required'
|
||||
|
||||
export const ValidationRules: Record<ValidationRulesKeys, any> = {
|
||||
required: { value: true, message: 'Поле не может быть пустым' }
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
type LocalStorageKeys = 'HEADER_NAME' | 'USER_TOKEN'
|
||||
|
||||
export const localStorageKeys: Record<LocalStorageKeys, string> = {
|
||||
HEADER_NAME: 'HEADER_NAME',
|
||||
USER_TOKEN: 'USER_TOKEN'
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
type MessagesKey = 'serverError' | 'loginError'
|
||||
|
||||
export const messages: Record<MessagesKey, string> = {
|
||||
serverError: 'Внутренняя ошибка сервиса',
|
||||
loginError: 'Неверный логин или пароль'
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
export enum SessionStatusKeysType {
|
||||
allowed = 'ALLOWED',
|
||||
revoked = 'REVOKED',
|
||||
expired = 'EXPIRED'
|
||||
}
|
||||
|
||||
export const sessionStatuses: Record<SessionStatusKeysType, string> = {
|
||||
[SessionStatusKeysType.allowed]: 'Активная',
|
||||
[SessionStatusKeysType.revoked]: 'Отмененная',
|
||||
[SessionStatusKeysType.expired]: 'Истекшая'
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
$basic-margin: 8px;
|
||||
$basic-padding: 8px;
|
||||
|
||||
$text-size: 1rem;
|
||||
$text-size-header1: 1.7rem;
|
||||
$text-size-header2: 1.25rem;
|
||||
|
||||
$text-color-gray: var(--ant-layout-header-color);
|
||||
$background-color: var(--ant-layout-light-sider-bg);
|
||||
$grey: #606060;
|
||||
$border-color: var(--ant-color-border);
|
||||
$error-red: #cf1322;
|
||||
|
||||
$blue-color: #40A9FF;
|
||||
$blue-light: #E6F7FF;
|
||||
$text-color-blue: #1890FF;
|
||||
|
||||
$blue-color-2: #bae0ff;
|
||||
@@ -1,17 +0,0 @@
|
||||
import { theme } from 'antd'
|
||||
|
||||
export const darkTheme = {
|
||||
algorithm: theme.darkAlgorithm,
|
||||
cssVar: true,
|
||||
token: {
|
||||
colorBgLayout: '#000000'
|
||||
}
|
||||
}
|
||||
|
||||
export const lightTheme = {
|
||||
algorithm: theme.defaultAlgorithm,
|
||||
cssVar: true,
|
||||
token: {
|
||||
colorBgLayout: '#FFFFFF'
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
||||
|
||||
import { AppDispatch, RootState } from '../stores'
|
||||
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
||||
@@ -1,34 +0,0 @@
|
||||
import { useAuth } from 'isp-ui-kit'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
|
||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
const useLogout = () => {
|
||||
const { logout, isLoading } = useAuth()
|
||||
const navigate = useNavigate()
|
||||
const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME)
|
||||
|
||||
const logoutUser = () =>
|
||||
logout(apiPaths.logout, {
|
||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
||||
'APP_TOKEN',
|
||||
import.meta.env.VITE_APP_TOKEN
|
||||
),
|
||||
[headerName]: LocalStorage.get(localStorageKeys.USER_TOKEN)
|
||||
})
|
||||
.then(() => {
|
||||
LocalStorage.remove(localStorageKeys.USER_TOKEN)
|
||||
LocalStorage.remove(localStorageKeys.HEADER_NAME)
|
||||
navigate(routePaths.login, { replace: true })
|
||||
})
|
||||
.catch(() => {})
|
||||
return { isLoading, logoutUser }
|
||||
}
|
||||
|
||||
export default useLogout
|
||||
@@ -1,19 +0,0 @@
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import { useAppSelector } from './redux.ts'
|
||||
|
||||
export const useRole = () => {
|
||||
const { profile } = useAppSelector((state: any) => state.profileReducer)
|
||||
const role: string = useMemo(() => profile && profile.role, [profile])
|
||||
|
||||
const hasPermission = (permission: PermissionKeysType) => {
|
||||
const userPermission = profile.permissions || []
|
||||
return userPermission.includes(permission)
|
||||
}
|
||||
|
||||
return { role, hasPermission }
|
||||
}
|
||||
|
||||
export default useRole
|
||||
+3
-5
@@ -10,12 +10,10 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { Provider } from 'react-redux'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
import { AdminBase, baseSetupStore } from 'isp-admin-ui-kit'
|
||||
|
||||
import App from './components/App.tsx'
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
||||
|
||||
import { setupStore } from './stores'
|
||||
|
||||
import 'react-resizable/css/styles.css'
|
||||
import 'simplebar-react/dist/simplebar.min.css'
|
||||
|
||||
@@ -42,14 +40,14 @@ loader.config({ monaco })
|
||||
loader.init().then()
|
||||
|
||||
dayjs.locale('ru')
|
||||
const store = setupStore()
|
||||
const store = baseSetupStore()
|
||||
setupListeners(store.dispatch)
|
||||
const root = createRoot(document.getElementById('root') as HTMLElement)
|
||||
|
||||
root.render(
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
<AdminBase />
|
||||
</BrowserRouter>
|
||||
</Provider>
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.all-version-page {
|
||||
padding: $basic-padding*2 0;
|
||||
|
||||
&__back-btn {
|
||||
margin-bottom: $basic-margin*2;
|
||||
}
|
||||
|
||||
&__table {
|
||||
overflow: auto;
|
||||
height: calc(100vh - 150px);
|
||||
}
|
||||
|
||||
&__actions-field {
|
||||
display: flex;
|
||||
gap: $basic-margin
|
||||
}
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
import {
|
||||
DeleteOutlined,
|
||||
EyeOutlined,
|
||||
ReloadOutlined,
|
||||
SwapOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Navigate, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import CompareVersionModal from '@components/CompareVersionModal'
|
||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { VersionType } from '@type/version.type.ts'
|
||||
|
||||
import './all-versions-page.scss'
|
||||
|
||||
const AllVersionsPage = () => {
|
||||
const [showCompareModal, setShowCompareModal] = useState<boolean>(false)
|
||||
const [showPreviewModal, setShowPreviewModal] = useState<boolean>(false)
|
||||
|
||||
const [currentClickVersion, setCurrentClickVersion] = useState<VersionType>(
|
||||
{} as VersionType
|
||||
)
|
||||
const navigate = useNavigate()
|
||||
const { id = '', configId = '' } = useParams()
|
||||
const {
|
||||
data: versions = [],
|
||||
isLoading: isVersionLoading,
|
||||
isError: isVersionError
|
||||
} = configServiceApi.useGetAllVersionQuery(configId)
|
||||
const {
|
||||
data: currentConfig,
|
||||
isLoading: isCurrentConfigLoading,
|
||||
isError: isCurrentConfigError
|
||||
} = configServiceApi.useGetConfigByIdQuery(configId)
|
||||
const [deleteVersion] = configServiceApi.useDeleteVersionMutation()
|
||||
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
||||
|
||||
const {
|
||||
data: allUsers = [],
|
||||
isLoading: isUsersLoading,
|
||||
isError: isUsersError
|
||||
} = userServiceApi.useGetAllUsersQuery()
|
||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
||||
|
||||
const { role, hasPermission } = useRole()
|
||||
|
||||
const isLoading = isVersionLoading || isCurrentConfigLoading || isUsersLoading
|
||||
const isError = isVersionError || isCurrentConfigError || isUsersError
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
if (isError) {
|
||||
return <Navigate to={routePaths.error} />
|
||||
}
|
||||
|
||||
const handeRemoveVersion = (versionId: string) => {
|
||||
deleteVersion(versionId)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
const handleRevertVersion = (newData: Record<string, unknown>) => {
|
||||
const sendData = { ...currentConfig, data: newData } as ConfigType
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Версия успешно восстановлена')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось восстановить версию')
|
||||
})
|
||||
}
|
||||
const renderActionsField = (_: unknown, record: VersionType) => {
|
||||
return (
|
||||
<div className="all-version-page__actions-field">
|
||||
<Button.Group className="button_group">
|
||||
<CanEdit>
|
||||
<Tooltip title="Установить выбранную версию">
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите установить выбранную версию ?"
|
||||
onConfirm={() => handleRevertVersion(record.data)}
|
||||
>
|
||||
<Button icon={<ReloadOutlined />} />
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
<Tooltip title="Просмотр версии">
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCurrentClickVersion(record)
|
||||
setShowPreviewModal(true)
|
||||
}}
|
||||
icon={<EyeOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Сравнение версий">
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCurrentClickVersion(record)
|
||||
setShowCompareModal(true)
|
||||
}}
|
||||
icon={<SwapOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<CanEdit>
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите удалить выбранную версию ?"
|
||||
onConfirm={() => handeRemoveVersion(record.id)}
|
||||
>
|
||||
<Button danger icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
</CanEdit>
|
||||
</Button.Group>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const columns: ColumnsType<VersionType> = [
|
||||
{
|
||||
key: 'configVersion',
|
||||
title: 'Версия',
|
||||
dataIndex: 'configVersion'
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'user',
|
||||
title: 'Автор',
|
||||
dataIndex: 'adminId',
|
||||
render: (value: number) => {
|
||||
const user = allUsers.find((user) => user.id === value)
|
||||
if (user) {
|
||||
return `${user.lastName} ${user.firstName}`
|
||||
}
|
||||
return `${profile.lastName} ${profile.firstName}`
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
render: renderActionsField
|
||||
}
|
||||
]
|
||||
return (
|
||||
<section className="all-version-page">
|
||||
{showPreviewModal && (
|
||||
<ConfigurationPreviewModal
|
||||
versionCompare={true}
|
||||
config={currentClickVersion}
|
||||
open={showPreviewModal}
|
||||
onClose={() => setShowPreviewModal(false)}
|
||||
/>
|
||||
)}
|
||||
{showCompareModal && (
|
||||
<CompareVersionModal
|
||||
currentConfigId={currentConfig?.id || ''}
|
||||
config={currentClickVersion}
|
||||
open={showCompareModal}
|
||||
onClose={() => setShowCompareModal(false)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
className="all-version-page__back-btn"
|
||||
onClick={() => navigate(`${routePaths.modules}/${id}/configurations`)}
|
||||
>
|
||||
Назад
|
||||
</Button>
|
||||
<div className="all-version-page__table">
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={versions}
|
||||
pagination={{ pageSize: 30 }}
|
||||
rowKey={(record) => record.id}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default AllVersionsPage
|
||||
@@ -1,15 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.app-access-page {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
|
||||
.ant-tree {
|
||||
background: none;
|
||||
}
|
||||
|
||||
&__content-wrap {
|
||||
width: 100%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,113 +0,0 @@
|
||||
import { Spin } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { memo, useEffect } from 'react'
|
||||
import {
|
||||
createSearchParams,
|
||||
Navigate,
|
||||
useNavigate,
|
||||
useParams,
|
||||
useSearchParams
|
||||
} from 'react-router-dom'
|
||||
|
||||
import ListItem from '@widgets/ListItem'
|
||||
|
||||
import AppAccessContent from '@components/AppAccessContent'
|
||||
|
||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import appApi from '@services/appService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { SystemTreeAppType } from '@type/app.type.ts'
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './app-access-page.scss'
|
||||
|
||||
const { Column, EmptyData } = Layout
|
||||
|
||||
const firstColumnSearchParam = 'search'
|
||||
const findMethodParam = 'method'
|
||||
|
||||
const AppAccessPage = () => {
|
||||
const {
|
||||
data = { originalResponse: [], appList: [] },
|
||||
isLoading,
|
||||
isError
|
||||
} = appApi.useGetSystemTreeQuery()
|
||||
|
||||
const { appList } = data
|
||||
const navigate = useNavigate()
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const searchValue = searchParams.get(firstColumnSearchParam) || ''
|
||||
const canRead = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!canRead) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [canRead])
|
||||
|
||||
const handleOnChangeSearchValue = (value: string): void => {
|
||||
setSearchValue(value, setSearchParams)
|
||||
}
|
||||
|
||||
const onSelectedItemId = (id: string): void => {
|
||||
setSearchValue('', setSearchParams, findMethodParam)
|
||||
setSelectedItemId(
|
||||
routePaths.appAccess,
|
||||
id,
|
||||
createSearchParams(searchParams).toString(),
|
||||
navigate
|
||||
)
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return <Navigate to={routePaths.error} />
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="app-access-page">
|
||||
<Column
|
||||
title="Приложения"
|
||||
searchPlaceholder="Введите имя или id"
|
||||
showUpdateBtn={false}
|
||||
showAddBtn={false}
|
||||
showRemoveBtn={false}
|
||||
items={filterFirstColumnItems(
|
||||
appList as ColumnItem<SystemTreeAppType>,
|
||||
searchValue
|
||||
)}
|
||||
renderItems={(item) => <ListItem item={item} />}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={onSelectedItemId}
|
||||
onChangeSearchValue={handleOnChangeSearchValue}
|
||||
/>
|
||||
<div className="app-access-page__content-wrap">
|
||||
{selectedItemId ? (
|
||||
<AppAccessContent
|
||||
paramPrefix={findMethodParam}
|
||||
key={`content-${selectedItemId}`}
|
||||
id={Number(selectedItemId)}
|
||||
/>
|
||||
) : (
|
||||
<EmptyData />
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(AppAccessPage)
|
||||
@@ -1,26 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-page {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
|
||||
&__list {
|
||||
.ant-list-item {
|
||||
flex-direction: column;
|
||||
align-items: self-start;
|
||||
|
||||
.applications-page__list__desc {
|
||||
width: auto !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.column-content {
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
.modal__wrap{
|
||||
min-width: 380px;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
export interface ApplicationsGroupType {
|
||||
createdAt: string
|
||||
description: string
|
||||
domainId: number
|
||||
id: number
|
||||
name: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type NewApplicationsGroupType = Omit<
|
||||
ApplicationsGroupType,
|
||||
'id' | 'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type UpdateApplicationsGroupType = Omit<
|
||||
ApplicationsGroupType,
|
||||
'createdAt' | 'updatedAt'
|
||||
>
|
||||
|
||||
export interface ApplicationsServiceType {
|
||||
app: ApplicationAppType
|
||||
tokens: ApplicationTokenType[]
|
||||
}
|
||||
|
||||
export type NewApplicationTokenType = {
|
||||
appId: number
|
||||
expireTimeMs: number
|
||||
}
|
||||
|
||||
export interface ApplicationAppType {
|
||||
createdAt: string
|
||||
description: string
|
||||
id: number
|
||||
name: string
|
||||
serviceId: number
|
||||
type: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type UpdateApplicationAppType = Omit<
|
||||
ApplicationAppType,
|
||||
'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type NewApplicationAppType = Omit<
|
||||
ApplicationAppType,
|
||||
'id' | 'createdAt' | 'updatedAt'
|
||||
>
|
||||
export type RevokeTokenType = {
|
||||
appId: number
|
||||
tokens: string[]
|
||||
}
|
||||
|
||||
export interface ApplicationTokenType {
|
||||
appId: number
|
||||
createdAt: string
|
||||
expireTime: number
|
||||
token: string
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
import { message, Spin } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import ListItem from '@widgets/ListItem'
|
||||
|
||||
import ApplicationsContent from '@components/ApplicationsContent'
|
||||
|
||||
import {
|
||||
ApplicationsGroupType,
|
||||
NewApplicationsGroupType,
|
||||
UpdateApplicationsGroupType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts'
|
||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import AppGroupModal from 'src/components/AppGroupModal'
|
||||
|
||||
import './applications-page.scss'
|
||||
|
||||
const { Column, EmptyData } = Layout
|
||||
|
||||
const ApplicationsPage = () => {
|
||||
const navigate = useNavigate()
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const [searchParams, setSearchParams] = useSearchParams('')
|
||||
const { hasPermission } = useRole()
|
||||
const [currentApplicationsApp, setCurrentApplicationsApp] = useState(0)
|
||||
|
||||
const {
|
||||
data: applicationsGroup = [],
|
||||
isError: isErrorApplicationsGroup,
|
||||
isLoading: isLoadingApplicationsGroup
|
||||
} = applicationsGroupApi.useGetApplicationsGroupByDomainIdQuery({ id: 1 })
|
||||
|
||||
const [createApplicationsGroup] =
|
||||
applicationsGroupApi.useCreateApplicationsGroupMutation()
|
||||
const [updateApplicationsGroup] =
|
||||
applicationsGroupApi.useUpdateApplicationsGroupMutation()
|
||||
|
||||
const [deleteApplicationsGroup] =
|
||||
applicationsGroupApi.useRemoveApplicationsGroupMutation()
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
// const hasRevokePermission = hasPermission(PermissionKeysType.write)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
||||
addModal: false,
|
||||
updateModal: false
|
||||
})
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
|
||||
const currentAppGroup = useMemo(
|
||||
() =>
|
||||
applicationsGroup.find((group) => group.id.toString() === selectedItemId),
|
||||
[applicationsGroup, selectedItemId]
|
||||
)
|
||||
|
||||
if (isErrorApplicationsGroup) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
if (isLoadingApplicationsGroup) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
const addApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: true
|
||||
})
|
||||
}
|
||||
|
||||
const updateApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: true
|
||||
})
|
||||
}
|
||||
|
||||
const handleAddApplicationGroup = (data: ApplicationsGroupType) => {
|
||||
const newService: NewApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
domainId: 1
|
||||
}
|
||||
createApplicationsGroup(newService)
|
||||
.unwrap()
|
||||
.then((res) => {
|
||||
setSelectedItemId(
|
||||
`${routePaths.applicationsGroup}`,
|
||||
res.id.toString(),
|
||||
searchValue,
|
||||
navigate
|
||||
)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
message.success('Группа приложений успешно создана')
|
||||
})
|
||||
.catch(() => message.error('Не удалось создать группу приложений'))
|
||||
}
|
||||
|
||||
const handleUpdateApplicationsGroup = (data: ApplicationsGroupType) => {
|
||||
const updateService: UpdateApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
domainId: 1,
|
||||
id: Number(selectedItemId)
|
||||
}
|
||||
|
||||
updateApplicationsGroup(updateService)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
message.success('Группа приложений успешно отредактирована')
|
||||
})
|
||||
.catch(() =>
|
||||
message.error('Не удалось отредактировать группу приложений')
|
||||
)
|
||||
}
|
||||
|
||||
const handleRemoveApplicationsGtoup = () => {
|
||||
deleteApplicationsGroup([Number(selectedItemId)])
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент удален')
|
||||
navigate(routePaths.applicationsGroup)
|
||||
})
|
||||
.catch(() => message.error('Ошибка удаления элемента'))
|
||||
}
|
||||
|
||||
const renderMainContent = () => {
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
return (
|
||||
<ApplicationsContent
|
||||
selectedItemId={Number(selectedItemId)}
|
||||
currentApplicationsApp={currentApplicationsApp}
|
||||
setCurrentApplicationsApp={setCurrentApplicationsApp}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="applications-page">
|
||||
<Column
|
||||
title="Группы приложений"
|
||||
searchPlaceholder="Введите имя или id"
|
||||
onUpdateItem={updateApplicationModal}
|
||||
showUpdateBtn={true}
|
||||
onAddItem={addApplicationModal}
|
||||
onRemoveItem={handleRemoveApplicationsGtoup}
|
||||
items={filterFirstColumnItems(
|
||||
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
|
||||
searchValue
|
||||
)}
|
||||
renderItems={(item) => <ListItem item={item} />}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={(itemId) => {
|
||||
setCurrentApplicationsApp(0)
|
||||
setSelectedItemId(
|
||||
`${routePaths.applicationsGroup}`,
|
||||
itemId,
|
||||
searchValue,
|
||||
navigate
|
||||
)
|
||||
}}
|
||||
onChangeSearchValue={(value) => setSearchValue(value, setSearchParams)}
|
||||
/>
|
||||
{renderMainContent()}
|
||||
<AppGroupModal
|
||||
onOk={handleAddApplicationGroup}
|
||||
title="Добавить группу приложений"
|
||||
open={showApplicationsModal.addModal}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
/>
|
||||
<AppGroupModal
|
||||
appGroup={currentAppGroup}
|
||||
title="Редактировать группу приложений"
|
||||
onOk={handleUpdateApplicationsGroup}
|
||||
open={showApplicationsModal.updateModal}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
/>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationsPage
|
||||
@@ -1,96 +0,0 @@
|
||||
import {
|
||||
ComponentType,
|
||||
Dispatch,
|
||||
MutableRefObject,
|
||||
ReactNode,
|
||||
SetStateAction
|
||||
} from 'react'
|
||||
|
||||
import {
|
||||
ConfigType,
|
||||
ResponseSchemaType
|
||||
} from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ConfigurationEditorPropsType {
|
||||
jsonSchema?: ResponseSchemaType
|
||||
bufConfig: ConfigType
|
||||
setBufConfig: Dispatch<SetStateAction<ConfigType | undefined>>
|
||||
isCurrentConfigLoading: boolean
|
||||
setDisableBtn?: Dispatch<SetStateAction<boolean>>
|
||||
submitRef?: MutableRefObject<null>
|
||||
}
|
||||
|
||||
export interface DescriptionPropsType {
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface Schema {
|
||||
type: string
|
||||
dynamic?: boolean
|
||||
}
|
||||
|
||||
export interface FieldTemplatePropsType {
|
||||
id: string
|
||||
classNames?: string
|
||||
label?: string
|
||||
rawHelp?: string
|
||||
required?: boolean
|
||||
rawDescription?: string
|
||||
rawErrors?: string[]
|
||||
children: ReactNode
|
||||
displayLabel?: boolean
|
||||
schema: Schema
|
||||
}
|
||||
|
||||
export interface ArrayFieldTemplatePropsType {
|
||||
items: {
|
||||
index: number
|
||||
children: ReactNode
|
||||
onDropIndexClick: (index: number) => () => void
|
||||
}[]
|
||||
onAddClick: (event: MouseEvent) => void
|
||||
canAdd: boolean
|
||||
title: string
|
||||
titleField?: ComponentType<any>
|
||||
idSchema: { $id: string }
|
||||
schema: { description?: string }
|
||||
}
|
||||
|
||||
export interface ObjectFieldTemplatePropertyType {
|
||||
name: string
|
||||
content: ReactNode
|
||||
}
|
||||
|
||||
export interface SchemaPropertiesType {
|
||||
[key: string]: {
|
||||
type?: string
|
||||
title?: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface ObjectFieldTemplatePropsType {
|
||||
properties: ObjectFieldTemplatePropertyType[]
|
||||
idSchema: {
|
||||
$id: string
|
||||
}
|
||||
schema: {
|
||||
properties: SchemaPropertiesType
|
||||
}
|
||||
activeTabKey: string
|
||||
handleTabsChange: (key: string) => void
|
||||
}
|
||||
|
||||
export interface ErrorsObjType {
|
||||
message: string
|
||||
name: string
|
||||
params: {
|
||||
missingProperty?: string
|
||||
}
|
||||
property: string
|
||||
schemaPath: string
|
||||
stack: string
|
||||
}
|
||||
|
||||
export interface SortPropType {
|
||||
name: string
|
||||
}
|
||||
@@ -1,144 +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-form-item-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.collapseArray_item_content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-collapse-item {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.ant-collapse-header {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.collapseArray_item {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
|
||||
.anticon-delete {
|
||||
margin-left: auto;
|
||||
padding-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-col-sm-16 {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.ant-col .ant-form-item-control {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.ant-form-item-control-input-content {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
.flex-space-between {
|
||||
display: flex;
|
||||
flex-direction: row !important;
|
||||
justify-content: space-between;
|
||||
|
||||
&__plus {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
.collapseArray_item {
|
||||
align-items: center;
|
||||
.ant-btn-link {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-btn-group {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.ant-row .ant-row-end {
|
||||
width: 60px;
|
||||
margin: 0 0 $basic-margin auto !important;
|
||||
}
|
||||
|
||||
&__form {
|
||||
padding: $basic-padding;
|
||||
}
|
||||
|
||||
.modal__wrap {
|
||||
min-height: 110px;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
width: auto;
|
||||
min-width: 190px;
|
||||
}
|
||||
|
||||
.error-data {
|
||||
color: red;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
import { RollbackOutlined } from '@ant-design/icons'
|
||||
import { Button, Dropdown, MenuProps, message, Radio, RadioChangeEvent, Spin } from 'antd'
|
||||
import { FC, useEffect, useRef, useState} from 'react'
|
||||
import { useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import ConfigurationEditorCode from '@components/ConfigurationEditorCode'
|
||||
import ConfigurationEditorJson from '@components/ConfigurationEditorJson'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import './configuration-editor-page.scss'
|
||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
||||
import { cleanEmptyParamsObject, sortObject } from '@utils/objectUtils.ts'
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import ConfirmConfigModal from '@components/ConfirmConfigModal/ConfirmConfigModal.tsx'
|
||||
import ErrorConfigModal from '@components/ErrorConfigModal/ErrorConfigModal.tsx'
|
||||
import ConfigurationEditorForm from '@components/ConfigurationEditorForm'
|
||||
|
||||
|
||||
|
||||
const ConfigurationEditorPage: FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const { moduleId = '' } = useParams()
|
||||
const { id = '' } = useParams()
|
||||
const isNew = id === 'new'
|
||||
const { data: jsonSchema, isLoading: isLoadingJsonSchema } =
|
||||
modulesServiceApi.useGetByModuleIdQuery(moduleId)
|
||||
const {
|
||||
data: currentConfig,
|
||||
isLoading: isCurrentConfigLoading,
|
||||
} = configServiceApi.useGetConfigByIdQuery(id)
|
||||
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
||||
const { state } = useLocation()
|
||||
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
||||
const [showSchemeModal, setShowSchemeModal] = useState(false)
|
||||
const [radioValue, setRadioValue] = useState('json')
|
||||
const [bufConfig, setBufConfig] = useState<ConfigType>()
|
||||
const [detailsErrors, setDetailsError] = useState({ details: {}, isOpenDetailsErrorModal: false })
|
||||
const [disableBtn, setDisableBtn] = useState(false)
|
||||
const submitRef = useRef<any>(null)
|
||||
|
||||
const formRadio = 'form'
|
||||
const codeRadio = 'code'
|
||||
const jsonRadio = 'json'
|
||||
|
||||
useEffect(() => {
|
||||
setBufConfig(isNew ? {} : sortObject(currentConfig))
|
||||
}, [isCurrentConfigLoading])
|
||||
|
||||
const itemsSaveBtn = [
|
||||
{
|
||||
key: 'save',
|
||||
label: 'Сохранить'
|
||||
},
|
||||
{
|
||||
key: 'unsafe',
|
||||
label: 'Сохранить небезопасно'
|
||||
}
|
||||
]
|
||||
|
||||
const onSaveBtn: MenuProps['onClick'] = (e, upVersion = undefined) => {
|
||||
const isUnsafe = e.key === 'unsafe'
|
||||
handleSaveClick(upVersion, isUnsafe, false)
|
||||
|
||||
}
|
||||
|
||||
const onRadioChange = (e: RadioChangeEvent) => {
|
||||
if (!bufConfig) return
|
||||
if (submitRef.current && radioValue === formRadio) {
|
||||
setBufConfig({ ...bufConfig, data: { ...submitRef.current } })
|
||||
}
|
||||
setRadioValue(e.target.value)
|
||||
}
|
||||
|
||||
const handleSaveClick = (upVersion?: number, unsafe?: boolean, isGoBack?: boolean) => {
|
||||
let newData = {}
|
||||
const sentData =
|
||||
radioValue === formRadio
|
||||
? { ...bufConfig, data: { ...submitRef.current } }
|
||||
: { ...bufConfig }
|
||||
if (bufConfig) {
|
||||
if (isNew) {
|
||||
newData = {
|
||||
name: state.name,
|
||||
moduleId: moduleId,
|
||||
id: '',
|
||||
version: 0,
|
||||
data: sentData.data,
|
||||
unsafe: unsafe
|
||||
} as ConfigType
|
||||
}
|
||||
if (currentConfig) {
|
||||
newData = {
|
||||
...sentData,
|
||||
version: upVersion ? upVersion : currentConfig.version,
|
||||
unsafe: unsafe
|
||||
} as ConfigType
|
||||
}
|
||||
}
|
||||
createUpdateConfig(cleanEmptyParamsObject(newData))
|
||||
.unwrap()
|
||||
.then(({ id }) => {
|
||||
isNew && navigate(`/${moduleId}/configEditor/${id}`)
|
||||
isGoBack && navigate(`/modules/${moduleId}/configurations`)
|
||||
message.success('Конфигурация успешно сохранена')
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.data.errorCode === 2004) {
|
||||
setShowConfirmModal(true)
|
||||
}
|
||||
if (e.data.errorCode === 2003) {
|
||||
setDetailsError({ details: e.data.details, isOpenDetailsErrorModal: true })
|
||||
}
|
||||
if (e.data.errorCode === 400) {
|
||||
message.error('Невалидный JSON объект')
|
||||
}
|
||||
message.error('Ошибка обновления элемента')
|
||||
})
|
||||
}
|
||||
if (isLoadingJsonSchema || isCurrentConfigLoading) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
|
||||
const renderContent = () => {
|
||||
|
||||
switch (radioValue) {
|
||||
case formRadio:
|
||||
return (
|
||||
<ConfigurationEditorForm
|
||||
submitRef={submitRef}
|
||||
bufConfig={bufConfig as ConfigType}
|
||||
setBufConfig={setBufConfig}
|
||||
jsonSchema={jsonSchema}
|
||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||
setDisableBtn={setDisableBtn}
|
||||
/>
|
||||
)
|
||||
case jsonRadio:
|
||||
return (
|
||||
<ConfigurationEditorJson
|
||||
bufConfig={bufConfig as ConfigType}
|
||||
setBufConfig={setBufConfig}
|
||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||
/>
|
||||
)
|
||||
case codeRadio:
|
||||
return (
|
||||
<ConfigurationEditorCode
|
||||
setDisableBtn={setDisableBtn}
|
||||
bufConfig={bufConfig as ConfigType}
|
||||
setBufConfig={setBufConfig}
|
||||
isCurrentConfigLoading={isCurrentConfigLoading}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<main className="configuration-editor-page">
|
||||
<section className="configuration-editor-page__header">
|
||||
<Button onClick={() => navigate(-1)}>
|
||||
<RollbackOutlined />
|
||||
Назад
|
||||
</Button>
|
||||
<h1>{bufConfig?.name}</h1>
|
||||
<div className="configuration-editor-page__controll">
|
||||
<Button
|
||||
disabled={!jsonSchema}
|
||||
className="configurations____buttons__show-schema-btn"
|
||||
onClick={() => setShowSchemeModal(true)}
|
||||
>
|
||||
Текущая схема конфигурации
|
||||
</Button>
|
||||
<Dropdown.Button
|
||||
onClick={() => handleSaveClick(undefined, undefined, true)}
|
||||
disabled={disableBtn}
|
||||
type="primary"
|
||||
className="configuration-editor-page__save-btn"
|
||||
menu={{ items: itemsSaveBtn, onClick: onSaveBtn }}
|
||||
>
|
||||
Сохранить и выйти
|
||||
</Dropdown.Button>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<div className="configuration-editor-page__content">
|
||||
<Radio.Group defaultValue={jsonRadio} disabled={disableBtn} size="large" onChange={onRadioChange}>
|
||||
<Radio.Button value={formRadio}>Форма</Radio.Button>
|
||||
<Radio.Button disabled={disableBtn} value={jsonRadio}>
|
||||
JSON
|
||||
</Radio.Button>
|
||||
<Radio.Button value={codeRadio}>Редактор кода</Radio.Button>
|
||||
</Radio.Group>
|
||||
|
||||
{renderContent()}
|
||||
</div>
|
||||
|
||||
|
||||
<ConfigSchemaModal
|
||||
schema={jsonSchema?.schema}
|
||||
open={showSchemeModal}
|
||||
onClose={() => setShowSchemeModal(false)}
|
||||
/>
|
||||
|
||||
<ConfirmConfigModal
|
||||
currentConfig={currentConfig}
|
||||
setBufConfig={setBufConfig}
|
||||
open={showConfirmModal}
|
||||
handleSaveClick={handleSaveClick}
|
||||
onClose={() => setShowConfirmModal(false)} />
|
||||
|
||||
<ErrorConfigModal details={detailsErrors.details} open={detailsErrors.isOpenDetailsErrorModal}
|
||||
onClose={() => setDetailsError({details: {}, isOpenDetailsErrorModal: false })} />
|
||||
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationEditorPage
|
||||
@@ -1,19 +0,0 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.configurations {
|
||||
height: calc(100vh - 80px);
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
min-width: 700px;
|
||||
|
||||
&__buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: $basic-margin*2;
|
||||
|
||||
}
|
||||
|
||||
.active-configurations-table:last-child {
|
||||
margin-top: $basic-margin*3;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
import { Button, Spin } from 'antd'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
||||
import CompareVersionModal from '@components/CompareVersionModal'
|
||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './configurations.scss'
|
||||
|
||||
const Configurations = () => {
|
||||
const {
|
||||
data: modulesList = [],
|
||||
isLoading: isModulesLoading,
|
||||
isError: isModulesError
|
||||
} = modulesServiceApi.useGetModulesQuery('configurations')
|
||||
const { id: selectedItemId = '', configId = '' } = useParams()
|
||||
const {
|
||||
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
||||
isLoading: isConfigsLoading,
|
||||
isError: isConfigsError
|
||||
} = configServiceApi.useGetConfigsByModuleIdQuery(selectedItemId)
|
||||
|
||||
const { role, hasPermission } = useRole()
|
||||
const navigate = useNavigate()
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
const [isShowModalOpen, setisShowModalOpen] = useState(false)
|
||||
const [isCompareModalOpen, setIsCompareModalOpen] = useState(false)
|
||||
|
||||
const [currentConfig, setCurrentConfig] = useState<ConfigType>(
|
||||
{} as ConfigType
|
||||
)
|
||||
const { activeConfigs, inactiveConfigs } = data
|
||||
const currentModule = useMemo(
|
||||
() => modulesList.find((module) => module.id === selectedItemId),
|
||||
[selectedItemId, modulesList]
|
||||
)
|
||||
const isLoading = isModulesLoading || isConfigsLoading
|
||||
const isError = isModulesError || isConfigsError
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
if (configId) {
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="configurations">
|
||||
<ConfigurationPreviewModal
|
||||
config={currentConfig}
|
||||
open={isShowModalOpen}
|
||||
onClose={() => setisShowModalOpen(false)}
|
||||
/>
|
||||
<ConfigSchemaModal
|
||||
schema={currentModule?.configSchema || {}}
|
||||
open={isModalOpen}
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
/>
|
||||
{isCompareModalOpen && (
|
||||
<CompareVersionModal
|
||||
currentConfigId={currentConfig.id}
|
||||
config={currentConfig}
|
||||
open={isCompareModalOpen}
|
||||
onClose={() => setIsCompareModalOpen(false)}
|
||||
/>
|
||||
)}
|
||||
<div className="configurations__buttons">
|
||||
<Button
|
||||
disabled={!currentModule?.configSchema}
|
||||
className="configurations____buttons__show-schema-btn"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
Текущая схема
|
||||
</Button>
|
||||
</div>
|
||||
<ActiveConfigurationsTable
|
||||
currentModule={currentModule}
|
||||
isActiveTable
|
||||
data={isError ? [] : activeConfigs}
|
||||
handleShowConfig={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setisShowModalOpen(true)
|
||||
}}
|
||||
handleShowCompareModal={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setIsCompareModalOpen(true)
|
||||
}}
|
||||
/>
|
||||
<ActiveConfigurationsTable
|
||||
currentModule={currentModule}
|
||||
data={isError ? [] : inactiveConfigs}
|
||||
handleShowConfig={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setisShowModalOpen(true)
|
||||
}}
|
||||
handleShowCompareModal={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setIsCompareModalOpen(true)
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(Configurations)
|
||||
@@ -1,48 +0,0 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.connection-page {
|
||||
&__content {
|
||||
width: 100%;
|
||||
|
||||
&__wrap-table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 70px);
|
||||
}
|
||||
}
|
||||
|
||||
&__endpoint-list {
|
||||
&__item {
|
||||
height: 25px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
&__inner-marker {
|
||||
font-size: 11px;
|
||||
border: 1px solid var(--ant-color-border);
|
||||
border-radius: 12px;
|
||||
padding: 0 4px;
|
||||
margin: 4px
|
||||
}
|
||||
}
|
||||
|
||||
&__no-data {
|
||||
user-select: none;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 1.5em;
|
||||
overflow: hidden;
|
||||
font-family: PT Sans, sans-serif;
|
||||
font-weight: 500;
|
||||
padding: 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
&__inner-tag{
|
||||
margin-left: $basic-margin !important;
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
import { Spin, Table, Tag, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import {
|
||||
AddressType,
|
||||
EndpointType,
|
||||
ModuleStatusType,
|
||||
ModuleType
|
||||
} from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './connections.scss'
|
||||
|
||||
const Connections = () => {
|
||||
const { data: ConnectionsList = [], isLoading: isModulesLoading } =
|
||||
modulesServiceApi.useGetModulesQuery('modules')
|
||||
const { role, hasPermission } = useRole()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams()
|
||||
const [obj, setObj] = useState<ModuleStatusType[] | []>([])
|
||||
|
||||
const isLoading = isModulesLoading
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
const filterId = ConnectionsList.find((item: ModuleType) => item.id === id)
|
||||
if (filterId && filterId.status) {
|
||||
setObj(filterId.status)
|
||||
}
|
||||
}, [ConnectionsList, id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const formatFullDate = (obj: string) =>
|
||||
dayjs(obj).format(dateFormats.fullFormat)
|
||||
|
||||
const renderEndpoints = ({ endpoints }: ModuleStatusType) => {
|
||||
if (endpoints && endpoints.length) {
|
||||
return (
|
||||
<ul className="connection-page__endpoint-list">
|
||||
{endpoints.map(({ path, inner }) => (
|
||||
<li className="connection-page__endpoint-list__item" key={path}>
|
||||
{path}
|
||||
{inner && (
|
||||
<Tag
|
||||
className="connection-page__inner-tag"
|
||||
color="processing"
|
||||
bordered={false}
|
||||
>
|
||||
Внутренний
|
||||
</Tag>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="connection-page__no-data">Нет реализованных методов</div>
|
||||
)
|
||||
}
|
||||
|
||||
const columns: ColumnsType = [
|
||||
{
|
||||
title: '#',
|
||||
dataIndex: '',
|
||||
key: 'num',
|
||||
render: (
|
||||
_val: ModuleStatusType,
|
||||
_record: ModuleStatusType,
|
||||
index: number
|
||||
) => index + 1
|
||||
},
|
||||
{
|
||||
title: 'Версия',
|
||||
dataIndex: 'version',
|
||||
key: 'version'
|
||||
},
|
||||
{
|
||||
title: 'Версия библиотеки',
|
||||
dataIndex: 'libVersion',
|
||||
key: 'libVersion'
|
||||
},
|
||||
{
|
||||
title: 'Адрес',
|
||||
dataIndex: 'address',
|
||||
key: 'address',
|
||||
render: (value: AddressType) => `${value.ip}:${value.port}`
|
||||
},
|
||||
{
|
||||
title: 'Соединение установлено',
|
||||
dataIndex: 'establishedAt',
|
||||
key: 'establishedAt',
|
||||
render: (val: string) => {
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
return (
|
||||
<Tooltip title={formatFullDate(val)}>{dayjs(val).fromNow()}</Tooltip>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Реализованные методы',
|
||||
dataIndex: 'endpoints',
|
||||
key: 'endpoints',
|
||||
render: (value: EndpointType[]) => (value && value.length) || '0'
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<section className="connection-page">
|
||||
<div className="connection-page__content">
|
||||
<div className="connection-page__content__wrap-table">
|
||||
<Table
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
dataSource={obj}
|
||||
columns={columns}
|
||||
expandable={{
|
||||
expandedRowRender: (i) => renderEndpoints(i)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(Connections)
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Button } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
const { ErrorPage } = Layout
|
||||
|
||||
const ErrorWrapperPage = () => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
return (
|
||||
<ErrorPage>
|
||||
<Button type="primary" onClick={() => navigate(routePaths.modules)}>
|
||||
На главную
|
||||
</Button>
|
||||
</ErrorPage>
|
||||
)
|
||||
}
|
||||
|
||||
export default ErrorWrapperPage
|
||||
@@ -1,13 +0,0 @@
|
||||
.home-page {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
background-image: url("/src/assets/images/home-background.png");
|
||||
font-size: calc(1.5vw + 1.5vh);
|
||||
font-family: 'Roboto',sans-serif;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 56px;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import './home-page.scss'
|
||||
|
||||
const HomePage = () => {
|
||||
return <div className="home-page">Добро пожаловать!</div>
|
||||
}
|
||||
|
||||
export default HomePage
|
||||
@@ -1,122 +0,0 @@
|
||||
import { LockOutlined, UserOutlined } from '@ant-design/icons'
|
||||
import { Button, Divider, Layout } from 'antd'
|
||||
import { AxiosError } from 'axios'
|
||||
import { FormComponents, useAuth } from 'isp-ui-kit'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
import { messages } from '@constants/messages.ts'
|
||||
|
||||
import { getConfigProperty } from '@utils/configUtils.ts'
|
||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { MSPError } from '@type/index.ts'
|
||||
import { LoginRequest } from '@type/login.type.ts'
|
||||
|
||||
import './login-page.scss'
|
||||
|
||||
const passwordLoginEnabled = getConfigProperty('ENABLE_PASSWORD_LOGIN', true)
|
||||
|
||||
const LoginPage = () => {
|
||||
const { login, isLoading } = useAuth()
|
||||
const { handleSubmit, control, setError } = useForm<LoginRequest>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
const navigate = useNavigate()
|
||||
|
||||
const setFormError = (statusText: string, message: string): void => {
|
||||
setError('email', {})
|
||||
setError('password', {
|
||||
message,
|
||||
type: statusText
|
||||
})
|
||||
}
|
||||
|
||||
const handleError = (err: AxiosError<MSPError>): void => {
|
||||
const { response, status } = err
|
||||
if (response && status === 401) {
|
||||
setFormError(response.statusText, messages.loginError)
|
||||
} else {
|
||||
setFormError('serverError', messages.serverError)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmitForm = (data: LoginRequest): void => {
|
||||
login(apiPaths.login, data, {
|
||||
'X-APPLICATION-TOKEN': getConfigProperty(
|
||||
'APP_TOKEN',
|
||||
import.meta.env.VITE_APP_TOKEN
|
||||
)
|
||||
})
|
||||
.then((response) => {
|
||||
LocalStorage.set(localStorageKeys.HEADER_NAME, response.headerName)
|
||||
LocalStorage.set(localStorageKeys.USER_TOKEN, response.token)
|
||||
const redirectUrl =
|
||||
sessionStorage.getItem('prevRoute') || routePaths.home
|
||||
navigate(redirectUrl, { replace: true })
|
||||
})
|
||||
.catch((err: AxiosError<MSPError>) => handleError(err))
|
||||
}
|
||||
|
||||
const renderInternalAuthForm = () => {
|
||||
if (!passwordLoginEnabled) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<FormComponents.FormInput
|
||||
data-cy="email-input"
|
||||
control={control}
|
||||
name="email"
|
||||
className="login-page__content__email-field"
|
||||
prefix={<UserOutlined className="color" />}
|
||||
placeholder="Логин"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormComponents.FormInput
|
||||
data-cy="password-input"
|
||||
control={control}
|
||||
name="password"
|
||||
className="login-page__content__password-field"
|
||||
prefix={<LockOutlined className="color" />}
|
||||
type="password"
|
||||
placeholder="Пароль"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<Button
|
||||
data-cy="submit-btn"
|
||||
disabled={isLoading}
|
||||
loading={isLoading}
|
||||
type="primary"
|
||||
className="login-page__content__submit-btn"
|
||||
onClick={handleSubmit(handleSubmitForm)}
|
||||
htmlType="submit"
|
||||
>
|
||||
Войти
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<section className="login-page">
|
||||
<form className="login-page__content">
|
||||
<h1 data-cy="login-title" className="login-page__content__title">
|
||||
Вход в систему
|
||||
</h1>
|
||||
<Divider />
|
||||
{renderInternalAuthForm()}
|
||||
</form>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export default LoginPage
|
||||
@@ -1,53 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.login-page {
|
||||
height: 100vh;
|
||||
background: $background-color;
|
||||
|
||||
display: flex;
|
||||
|
||||
.ant-input {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ant-divider-horizontal {
|
||||
margin-top: $basic-margin !important;
|
||||
}
|
||||
|
||||
.ant-form-item-explain-error {
|
||||
margin-bottom: $basic-margin;
|
||||
}
|
||||
|
||||
.color {
|
||||
color: $text-color-gray;
|
||||
}
|
||||
|
||||
&__content {
|
||||
max-width: 360px;
|
||||
margin: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&__title {
|
||||
text-align: center;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: $text-size;
|
||||
line-height: 20px;
|
||||
color: $text-color-gray;
|
||||
}
|
||||
|
||||
&__submit-sudir-btn {
|
||||
background: #0000000f;
|
||||
margin-top: 4 * $basic-margin;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.09) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.requiredInput::after {
|
||||
content: "";
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
||||
import { Badge, List, message, Spin, Tag, Tooltip } from 'antd'
|
||||
import { compareVersions } from 'compare-versions'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
createSearchParams,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
useParams,
|
||||
useSearchParams
|
||||
} from 'react-router-dom'
|
||||
|
||||
import ModuleTabs from '@components/ModuleTabs'
|
||||
|
||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './modules-page.scss'
|
||||
|
||||
const { Column } = Layout
|
||||
|
||||
const ModulesPage = () => {
|
||||
const [activeTab, setActiveTab] = useState('configurations')
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const { role, hasPermission } = useRole()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const { data: ModulesList = [], isLoading: isModulesLoading } =
|
||||
modulesServiceApi.useGetModulesQuery('modules', {
|
||||
pollingInterval: 5000,
|
||||
skipPollingIfUnfocused: true
|
||||
})
|
||||
const [removeModule] = modulesServiceApi.useRemoveModuleMutation()
|
||||
const location = useLocation()
|
||||
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
const isRemoveModule = hasPermission(PermissionKeysType.write)
|
||||
const isLoading = isModulesLoading
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.profile)
|
||||
message.error('Страница не найдена')
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
useEffect(() => {
|
||||
const url = location.pathname.substring(
|
||||
location.pathname.lastIndexOf('/') + 1
|
||||
)
|
||||
switch (url) {
|
||||
case 'configurations':
|
||||
return setActiveTab('configurations')
|
||||
case 'connections':
|
||||
return setActiveTab('connections')
|
||||
}
|
||||
}, [location])
|
||||
|
||||
const setSelectedItemId = (id: string): void => {
|
||||
if (id) {
|
||||
navigate(
|
||||
{
|
||||
pathname: `${routePaths.modules}/${id}/${activeTab}`,
|
||||
search: createSearchParams(searchParams).toString()
|
||||
},
|
||||
{ replace: true }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const handleOnChangeSearchValue = (value: string): void => {
|
||||
setSearchParams((prev) => {
|
||||
if (!value) {
|
||||
prev.delete('search')
|
||||
} else {
|
||||
prev.set('search', value)
|
||||
}
|
||||
return prev
|
||||
})
|
||||
}
|
||||
|
||||
const handleRemoveModule = (id: string) => {
|
||||
removeModule(id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
navigate(routePaths.modules)
|
||||
message.success('Модуль успешно удален').then()
|
||||
setSelectedItemId('')
|
||||
})
|
||||
.catch(() => message.error('Не удалось удалить модуль'))
|
||||
}
|
||||
|
||||
const versionCompare = (versions: string[]) => {
|
||||
const sorted = (versions || ['']).sort(compareVersions)
|
||||
const firstVersion = sorted[0]
|
||||
for (let i = 1; i < sorted.length; i++) {
|
||||
if (compareVersions(firstVersion, sorted[i]) !== 0) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const getLastVersion = (versions: string[]) => {
|
||||
const sorted = (versions || ['']).sort(compareVersions)
|
||||
return sorted[sorted.length - 1]
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const currentModule = ModulesList.find(
|
||||
(item: ModuleType) => item.id.toString() === selectedItemId
|
||||
)
|
||||
|
||||
const renderItems = (item: ModuleType) => {
|
||||
const isSame = versionCompare(item?.status?.map((i) => i.version))
|
||||
const textTooltip = isSame
|
||||
? 'Активны экземпляры одинаковых версий'
|
||||
: 'Активны экземпляры разных версий'
|
||||
const lastVersion = getLastVersion(item.status?.map((i) => i.version))
|
||||
|
||||
const renderVersion = () => {
|
||||
if (!isSame && lastVersion) {
|
||||
return (
|
||||
<Tag icon={<ExclamationCircleOutlined />} color="warning">
|
||||
{lastVersion}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
if (isSame && lastVersion) {
|
||||
return <Tag color="default">{lastVersion}</Tag>
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
return (
|
||||
<List.Item>
|
||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
||||
<List.Item.Meta
|
||||
title={
|
||||
<div className="module-item__name">
|
||||
<span>{item.name}</span>
|
||||
<Tooltip
|
||||
overlayInnerStyle={{ width: '300px' }}
|
||||
title={textTooltip}
|
||||
>
|
||||
{renderVersion()}
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
description={
|
||||
<div className="module-item__content">
|
||||
<span className="module-item__content__description">
|
||||
активные экземпляры:
|
||||
</span>
|
||||
<Badge
|
||||
size="small"
|
||||
showZero
|
||||
count={(item.status && item.status.length) || 0}
|
||||
color={!item.status || !item.status.length ? '' : 'cyan'}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="modules-page">
|
||||
<Column
|
||||
title="Модули"
|
||||
searchPlaceholder="Введите имя или id"
|
||||
items={filterFirstColumnItems(ModulesList, searchValue)}
|
||||
showAddBtn={false}
|
||||
showUpdateBtn={false}
|
||||
showRemoveBtn={isRemoveModule}
|
||||
onRemoveItem={handleRemoveModule}
|
||||
onChangeSearchValue={handleOnChangeSearchValue}
|
||||
renderItems={renderItems}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={setSelectedItemId}
|
||||
/>
|
||||
<ModuleTabs
|
||||
currentModule={currentModule}
|
||||
activeTab={activeTab}
|
||||
setActiveTab={setActiveTab}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModulesPage
|
||||
@@ -1,104 +0,0 @@
|
||||
export interface RequiredModuleType {
|
||||
id: string
|
||||
name: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
export interface AddressType {
|
||||
ip: string
|
||||
port: string
|
||||
}
|
||||
|
||||
export interface EndpointType {
|
||||
extra: Record<string, unknown>
|
||||
inner: boolean
|
||||
path: string
|
||||
userAuthRequired: boolean
|
||||
}
|
||||
|
||||
export interface ModuleStatusType {
|
||||
establishedAt: string
|
||||
libVersion: string
|
||||
version: string
|
||||
address: AddressType
|
||||
endpoints: EndpointType[]
|
||||
}
|
||||
|
||||
export interface ConfigType {
|
||||
active: boolean
|
||||
commonConfigs: string[]
|
||||
createdAt: string
|
||||
data: Record<string, unknown>
|
||||
description: string
|
||||
id: string
|
||||
moduleId: string
|
||||
name: string
|
||||
updatedAt: string
|
||||
valid: boolean
|
||||
version: number
|
||||
unsafe?: boolean
|
||||
}
|
||||
|
||||
export interface JSONSchema {
|
||||
$ref?: string
|
||||
$schema?: string
|
||||
additionalItems?: boolean | JSONSchema
|
||||
additionalProperties?: boolean | JSONSchema
|
||||
allOf?: JSONSchema[]
|
||||
anyOf?: JSONSchema[]
|
||||
default?: any
|
||||
definitions?: Record<string, JSONSchema>
|
||||
dependencies?: Record<string, string | string[] | JSONSchema>
|
||||
description?: string
|
||||
enum?: any[]
|
||||
exclusiveMaximum?: boolean
|
||||
exclusiveMinimum?: boolean
|
||||
format?: string
|
||||
items?: JSONSchema | JSONSchema[]
|
||||
maxItems?: number
|
||||
maxLength?: number
|
||||
maxProperties?: number
|
||||
maximum?: number
|
||||
media?: JSONSchema
|
||||
minItems?: number
|
||||
minLength?: number
|
||||
minProperties?: number
|
||||
minimum?: number
|
||||
multipleOf?: number
|
||||
not?: JSONSchema
|
||||
oneOf?: JSONSchema[]
|
||||
pattern?: string
|
||||
patternProperties?: Record<string, JSONSchema>
|
||||
properties?: Record<string, JSONSchema>
|
||||
required?: string[]
|
||||
title?: string
|
||||
type?: string | string[]
|
||||
uniqueItems?: boolean
|
||||
}
|
||||
|
||||
export interface ModuleType {
|
||||
active: boolean
|
||||
configs: ConfigType[]
|
||||
createdAt: string
|
||||
id: string
|
||||
lastConnectedAt: string
|
||||
lastDisconnectedAt: string
|
||||
name: string
|
||||
requiredModules: RequiredModuleType[]
|
||||
status: ModuleStatusType[]
|
||||
configSchema: JSONSchema
|
||||
}
|
||||
|
||||
export interface ResponseSchemaType {
|
||||
createdAt: string
|
||||
id: string
|
||||
moduleId: string
|
||||
schema: JSONSchema
|
||||
updatedAt: string
|
||||
version: string
|
||||
}
|
||||
export interface ConfigResponse {
|
||||
originalResponse: ConfigType[]
|
||||
activeConfigs: ConfigType[]
|
||||
inactiveConfigs: ConfigType[]
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.modules-page {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
&__tabs {
|
||||
padding: 0 $basic-padding*2;
|
||||
width: 100%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.ant-tag {
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.module-item {
|
||||
width: 100%;
|
||||
|
||||
&__name {
|
||||
display: flex;
|
||||
padding-bottom: 5px;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
&__description {
|
||||
color: $grey;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
overflow-x: scroll;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.column .column__items__item span {
|
||||
width: fit-content !important;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { Button } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
const { NotFoundPage } = Layout
|
||||
|
||||
const NotFound = () => {
|
||||
const navigate = useNavigate()
|
||||
return (
|
||||
<NotFoundPage>
|
||||
<Button type="primary" onClick={() => navigate(routePaths.home)}>
|
||||
На главную
|
||||
</Button>
|
||||
</NotFoundPage>
|
||||
)
|
||||
}
|
||||
|
||||
export default NotFound
|
||||
@@ -1,75 +0,0 @@
|
||||
import { Button, Descriptions, Popconfirm } from 'antd'
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
|
||||
import PermissionList from '@widgets/PermissionList'
|
||||
|
||||
import ChangePasswordModal from '@components/ChangePasswordModal'
|
||||
import RoleList from '@components/RoleList'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
|
||||
import { Context } from '@stores/index.tsx'
|
||||
|
||||
import './profile-page.scss'
|
||||
|
||||
const ProfilePage = () => {
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false)
|
||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
||||
const { logoutUser, isLoading } = useLogout()
|
||||
const { changeTheme, setChangeTheme } = useContext(Context)
|
||||
|
||||
const onChangeTheme = () => {
|
||||
setChangeTheme((prev: any) => !prev)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('theme', JSON.stringify(changeTheme))
|
||||
}, [changeTheme])
|
||||
|
||||
return (
|
||||
<section className="profile-page">
|
||||
<ChangePasswordModal
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
open={isModalOpen}
|
||||
/>
|
||||
<header className="profile-page__header">
|
||||
<h1 className="profile-page__title">{`${profile.lastName} ${profile.firstName}`}</h1>
|
||||
<Button onClick={onChangeTheme}>Сменить тему</Button>
|
||||
</header>
|
||||
<div className="profile-page__user-info">
|
||||
<div className="profile-page__user-info__email-wrapper">
|
||||
<Descriptions>
|
||||
<Descriptions.Item label="Email">{profile.email}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</div>
|
||||
</div>
|
||||
<RoleList userRoles={profile.roles} />
|
||||
<PermissionList permissions={profile.permissions} />
|
||||
<div className="profile-page__actions">
|
||||
<Popconfirm
|
||||
okText="Выйти"
|
||||
cancelText="Отмена"
|
||||
title="Вы действительно хотите выйти из профиля?"
|
||||
onConfirm={logoutUser}
|
||||
>
|
||||
<Button
|
||||
loading={isLoading}
|
||||
disabled={isLoading}
|
||||
className="profile-page__actions__exit-btn"
|
||||
>
|
||||
Выход
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
className="profile-page__actions__change-pass-btn"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
Сменить пароль
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProfilePage
|
||||
@@ -1,34 +0,0 @@
|
||||
@import '../../constants/style/styleConst';
|
||||
|
||||
.profile-page {
|
||||
height: 100vh;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--ant-color-border);
|
||||
padding: $basic-padding * 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: start;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: $text-size-header1;
|
||||
}
|
||||
|
||||
&__user-info {
|
||||
margin-top: $basic-padding;
|
||||
|
||||
span {
|
||||
font-size: $text-size !important;
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
gap: $basic-margin
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
||||
|
||||
export type ProfileDataType = {
|
||||
email: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
role: string
|
||||
roles: number[]
|
||||
permissions: string[]
|
||||
idleTimeoutMs: number
|
||||
}
|
||||
|
||||
export type ProfileType = {
|
||||
profile: ProfileDataType
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
|
||||
export type ChangeProfilePassword = {
|
||||
oldPassword: string
|
||||
newPassword: string
|
||||
}
|
||||
|
||||
export type UIDataType = {
|
||||
name: string
|
||||
primaryColor: string
|
||||
}
|
||||
|
||||
export type UIType = {
|
||||
ui: UIDataType
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
import { List, message, Spin, Tooltip } from 'antd'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { useEffect } from 'react'
|
||||
import { UseFormSetError } from 'react-hook-form'
|
||||
import {
|
||||
createSearchParams,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
useParams,
|
||||
useSearchParams
|
||||
} from 'react-router-dom'
|
||||
|
||||
import RolesContent from '@components/RolesContent'
|
||||
|
||||
import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { NewRoleType, PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
||||
|
||||
import './roles-page.scss'
|
||||
import { useAppDispatch } from '@hooks/redux.ts'
|
||||
import { fetchProfile } from '@stores/redusers/ActionCreators.ts'
|
||||
|
||||
const { Column, EmptyData, NoData } = Layout
|
||||
|
||||
const RolesPage = () => {
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const fromApp = location.state?.fromApp || false
|
||||
const { role, hasPermission } = useRole()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const dispatch = useAppDispatch()
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
const { data: permissionList = [], isLoading: isPermissionLoading } =
|
||||
userServiceApi.useGetAllPermissionsQuery()
|
||||
const { data = [], isLoading: isRolesLoading } = roleApi.useGetAllRolesQuery()
|
||||
const [createRole] = roleApi.useCreateRoleMutation()
|
||||
const [updateRole] = roleApi.useUpdateRoleMutation()
|
||||
const [removeRole] = roleApi.useRemoveRoleMutation()
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.role_view)
|
||||
const isAddRolePermissions = hasPermission(PermissionKeysType.role_add)
|
||||
const isRemoveRolePermissions = hasPermission(PermissionKeysType.role_delete)
|
||||
const isLoading = isPermissionLoading || isRolesLoading
|
||||
|
||||
const isNew = selectedItemId === 'new'
|
||||
|
||||
useEffect(() => {
|
||||
if (!fromApp) {
|
||||
navigate(routePaths.roles)
|
||||
}
|
||||
}, [fromApp])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
const setSelectedItemId = (id: string): void => {
|
||||
navigate(
|
||||
{
|
||||
pathname: `${routePaths.roles}/${id}`,
|
||||
search: createSearchParams(searchParams).toString()
|
||||
},
|
||||
{ replace: true, state: { fromApp: true } }
|
||||
)
|
||||
}
|
||||
|
||||
const handleOnChangeSearchValue = (value: string): void => {
|
||||
setSearchParams((prev) => {
|
||||
if (!value) {
|
||||
prev.delete('search')
|
||||
} else {
|
||||
prev.set('search', value)
|
||||
}
|
||||
return prev
|
||||
})
|
||||
}
|
||||
|
||||
const handeOnAddItem = () => setSelectedItemId('new')
|
||||
|
||||
const handleUpdateRole = (
|
||||
formValue: RoleType | NewRoleType,
|
||||
setError: UseFormSetError<RoleType>
|
||||
) => {
|
||||
updateRole(formValue as RoleType)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
dispatch(fetchProfile())
|
||||
message.success('Элемент успешно добавлен').then()
|
||||
})
|
||||
.catch((error) => {
|
||||
const { status } = error
|
||||
if (status === 409) {
|
||||
setError('name', {
|
||||
message: 'Роль с таким названием уже существует'
|
||||
})
|
||||
}
|
||||
message.error('Не удалось сохранить роль')
|
||||
})
|
||||
}
|
||||
|
||||
const handleCreateRole = (
|
||||
formValue: NewRoleType,
|
||||
setError: UseFormSetError<NewRoleType>
|
||||
) => {
|
||||
createRole(formValue)
|
||||
.unwrap()
|
||||
.then((res) => {
|
||||
message.success('Элемент успешно добавлен').then()
|
||||
setSelectedItemId(res.id.toString())
|
||||
})
|
||||
.catch((error) => {
|
||||
const { status } = error
|
||||
if (status === 409) {
|
||||
setError('name', {
|
||||
message: 'Роль с таким названием уже существует'
|
||||
})
|
||||
}
|
||||
message.error('Не удалось добавить роль').then()
|
||||
})
|
||||
}
|
||||
|
||||
const handleRemoveRole = (id: string) => {
|
||||
const idAsNumber = parseInt(id, 10)
|
||||
removeRole(idAsNumber)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален').then()
|
||||
setSelectedItemId('')
|
||||
})
|
||||
.catch(() => message.error('Не удалось удалить роль'))
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const currentRole = data
|
||||
? data.find((item) => item.id.toString() === selectedItemId)
|
||||
: null
|
||||
const renderItems = (item: RoleType) => (
|
||||
<List.Item data-cy="role-item">
|
||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
||||
<List.Item.Meta
|
||||
title={item.name}
|
||||
description={<span>id: {item.id}</span>}
|
||||
/>
|
||||
</Tooltip>
|
||||
</List.Item>
|
||||
)
|
||||
|
||||
const renderMainContent = () => {
|
||||
if (isNew) {
|
||||
return (
|
||||
<RolesContent
|
||||
saveRole={handleCreateRole}
|
||||
permissions={permissionList}
|
||||
title="Добавить"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
if (!currentRole) {
|
||||
return <NoData />
|
||||
}
|
||||
|
||||
return (
|
||||
<RolesContent
|
||||
immutable={currentRole.immutable}
|
||||
saveRole={handleUpdateRole}
|
||||
permissions={permissionList}
|
||||
role={currentRole}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="roles-page">
|
||||
<Column
|
||||
title="Роли пользователей"
|
||||
searchPlaceholder="Введите имя или id"
|
||||
showUpdateBtn={false}
|
||||
items={filterFirstColumnItems(data, searchValue)}
|
||||
showAddBtn={isAddRolePermissions}
|
||||
showRemoveBtn={isRemoveRolePermissions}
|
||||
onAddItem={handeOnAddItem}
|
||||
onRemoveItem={handleRemoveRole}
|
||||
onChangeSearchValue={handleOnChangeSearchValue}
|
||||
renderItems={renderItems}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={setSelectedItemId}
|
||||
/>
|
||||
<div className="roles-page__content">{renderMainContent()}</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default RolesPage
|
||||
@@ -1,17 +0,0 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.roles-page {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
|
||||
.role-item {
|
||||
&__id {
|
||||
color: $grey;
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
overflow-x: scroll;
|
||||
width: 100%
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
import { Pagination, Spin, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
|
||||
import { getUserFullName } from '@utils/userUtils/getFullNameUtil'
|
||||
|
||||
import useRole from '@hooks/useRole'
|
||||
|
||||
import securityLogServiceApi from '@services/securityLogService'
|
||||
import userServiceApi from '@services/userService'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { LogType } from '@type/log.type'
|
||||
import { PermissionKeysType } from '@type/roles.type'
|
||||
|
||||
import './security-log-page.scss'
|
||||
|
||||
const limit = 10
|
||||
|
||||
const SecurityLogPage = () => {
|
||||
const [getAllLogs, { data, isLoading: isLoadingLogs }] =
|
||||
securityLogServiceApi.useGetAllLogsMutation()
|
||||
|
||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||
userServiceApi.useGetAllUsersQuery()
|
||||
const { role, hasPermission } = useRole()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [currentPage, setCurrentPage] = useState(1)
|
||||
|
||||
const isLoading = isUsersLoading || isLoadingLogs
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.security_log_view)
|
||||
|
||||
useEffect(() => {
|
||||
getAllLogs({ limit, offset: 0 })
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
const handleChangePagination = (page: number) => {
|
||||
setCurrentPage(page)
|
||||
getAllLogs({ limit, offset: (page - 1) * limit })
|
||||
}
|
||||
|
||||
if (isLoading || !data) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const columns: ColumnsType<LogType> = [
|
||||
{
|
||||
title: 'Пользователь',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
render: (value) => {
|
||||
const user = allUsers.find((el) => el.id === value)
|
||||
if (user) {
|
||||
return getUserFullName(user)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Время события',
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (value) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действие',
|
||||
dataIndex: 'message',
|
||||
key: 'message',
|
||||
render: (value: string) =>
|
||||
value.split('\n').map((line) => <p key={line}>{line}</p>)
|
||||
}
|
||||
]
|
||||
|
||||
const { totalCount, items } = data
|
||||
|
||||
return (
|
||||
<section className="security-log-page">
|
||||
<header className="security-log-page__header">
|
||||
<span
|
||||
data-cy="security-log-page__header__title"
|
||||
className="security-log-page__header__title"
|
||||
>
|
||||
Просмотр журналов ИБ
|
||||
</span>
|
||||
</header>
|
||||
<section className="security-log-page__content">
|
||||
<div className="security-log-page__content__wrap-table">
|
||||
<Table
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
dataSource={items}
|
||||
columns={columns}
|
||||
/>
|
||||
</div>
|
||||
<div className="security-log-page__content__pagination">
|
||||
<Pagination
|
||||
showSizeChanger={false}
|
||||
current={currentPage}
|
||||
total={totalCount}
|
||||
pageSize={limit}
|
||||
onChange={handleChangePagination}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default SecurityLogPage
|
||||
@@ -1,35 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.security-log-page {
|
||||
height: 100%;
|
||||
border: 1px solid $border-color;
|
||||
|
||||
&__header {
|
||||
border-bottom: 1px solid $border-color;
|
||||
padding: 0 3 * $basic-padding;
|
||||
|
||||
&__title {
|
||||
padding: 3 * $basic-padding 0;
|
||||
display: inline-block;
|
||||
font-weight: 500;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
padding: 2 * $basic-padding 3 * $basic-padding;
|
||||
|
||||
&__wrap-table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 160px);
|
||||
}
|
||||
|
||||
&__pagination {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
import { LogoutOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
Button,
|
||||
Popconfirm,
|
||||
Spin,
|
||||
Table,
|
||||
message,
|
||||
Pagination,
|
||||
Tooltip
|
||||
} from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { SessionStatusKeysType, sessionStatuses } from '@constants/statuses'
|
||||
|
||||
import { getUserFullName } from '@utils/userUtils/getFullNameUtil'
|
||||
|
||||
import useRole from '@hooks/useRole'
|
||||
|
||||
import sessionServiceApi from '@services/sessionService'
|
||||
import userServiceApi from '@services/userService'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { SessionType } from '@type/session.type'
|
||||
|
||||
import './sessions-page.scss'
|
||||
|
||||
const limit = 10
|
||||
|
||||
const SessionsPage = () => {
|
||||
const [offset, setOffset] = useState<number>(0)
|
||||
const { data, isLoading: isLoadingSession } =
|
||||
sessionServiceApi.useGetAllSessionsQuery({ limit, offset })
|
||||
const [revokeSession] = sessionServiceApi.useRevokeSessionMutation()
|
||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||
userServiceApi.useGetAllUsersQuery()
|
||||
const { role, hasPermission } = useRole()
|
||||
const navigate = useNavigate()
|
||||
const [currentPage, setCurrentPage] = useState(1)
|
||||
|
||||
const isLoading = isUsersLoading || isLoadingSession
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.session_view)
|
||||
const hasRevokePermission = hasPermission(PermissionKeysType.session_revoke)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
const handleChangePagination = (page: number) => {
|
||||
setCurrentPage(page)
|
||||
const currentOffset = (page - 1) * limit
|
||||
setOffset(currentOffset)
|
||||
}
|
||||
|
||||
const handleRevokeSessions = (id: number) => {
|
||||
revokeSession(id)
|
||||
.unwrap()
|
||||
.then(() => message.success('Сессия успешно завершена'))
|
||||
.catch(() => message.error('Не удалось завершить сессию'))
|
||||
}
|
||||
|
||||
if (isLoading || !data) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const columns: ColumnsType<SessionType> = [
|
||||
{
|
||||
title: 'Пользователь',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
render: (value) => {
|
||||
const user = allUsers.find((el) => el.id === value)
|
||||
return user && getUserFullName(user)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Идентификатор',
|
||||
dataIndex: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
{
|
||||
title: 'Дата начала сессии',
|
||||
dataIndex: 'createdAt',
|
||||
key: 'createdAt',
|
||||
render: (value) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Дата окончания сессии',
|
||||
dataIndex: 'expiredAt',
|
||||
key: 'expiredAt',
|
||||
render: (value) => {
|
||||
return dayjs(value).format(dateFormats.fullFormat)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Статус',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
render: (value: SessionStatusKeysType) => sessionStatuses[value]
|
||||
},
|
||||
{
|
||||
dataIndex: 'actions',
|
||||
key: 'actions',
|
||||
render: (_, record) => {
|
||||
if (record.status !== SessionStatusKeysType.allowed) {
|
||||
return null
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{hasRevokePermission && (
|
||||
<Popconfirm
|
||||
title="Закончить эту сессию?"
|
||||
onConfirm={() => handleRevokeSessions(record.id)}
|
||||
>
|
||||
<Tooltip key="LogoutOutlined" title="Закончить сессию">
|
||||
<Button
|
||||
data-cy="sessions-page__content__table__logout-btn"
|
||||
icon={<LogoutOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const { totalCount, items } = data
|
||||
return (
|
||||
<section className="sessions-page">
|
||||
<header className="sessions-page__header">
|
||||
<span
|
||||
data-cy="sessions-page__header__title"
|
||||
className="sessions-page__header__title"
|
||||
>
|
||||
Пользовательские сессии
|
||||
</span>
|
||||
</header>
|
||||
<section className="sessions-page__content">
|
||||
<div className="sessions-page__content__wrap-table">
|
||||
<Table
|
||||
className="sessions-page__content__table"
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
dataSource={items}
|
||||
columns={columns}
|
||||
/>
|
||||
</div>
|
||||
<div className="sessions-page__content__pagination">
|
||||
<Pagination
|
||||
showSizeChanger={false}
|
||||
current={currentPage}
|
||||
total={totalCount}
|
||||
pageSize={limit}
|
||||
onChange={handleChangePagination}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default SessionsPage
|
||||
@@ -1,41 +0,0 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.sessions-page {
|
||||
height: 100%;
|
||||
border: 1px solid $border-color;
|
||||
|
||||
&__header {
|
||||
border-bottom: 1px solid $border-color;
|
||||
padding: 0 3 * $basic-padding;
|
||||
|
||||
&__title {
|
||||
padding: 3 * $basic-padding 0;
|
||||
display: inline-block;
|
||||
font-weight: 500;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
padding: 2 * $basic-padding 3 * $basic-padding;
|
||||
|
||||
&__wrap-table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 160px);
|
||||
}
|
||||
|
||||
&__table {
|
||||
&__logout-btn {
|
||||
color: $blue-color;
|
||||
background: $blue-light;
|
||||
}
|
||||
}
|
||||
|
||||
&__pagination {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Spin } from 'antd'
|
||||
import dayjs from 'dayjs'
|
||||
import { FormComponents } from 'isp-ui-kit'
|
||||
import { useEffect } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { dateFormats } from '@constants/date.ts'
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import { findExclusiveRole } from '@utils/roleUtils.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
||||
import { UserType } from '@type/user.type.ts'
|
||||
|
||||
import { LabelItem } from 'isp-ui-kit/dist/FormComponents/formTypes'
|
||||
|
||||
import './user-editor.scss'
|
||||
|
||||
const UserEditor = () => {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const state = location.state as UserType
|
||||
const isNew = location.pathname.includes('new')
|
||||
const fromApp = location.state?.fromApp || false
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
const hasCreateUserPermission = hasPermission(PermissionKeysType.write)
|
||||
const hasUpdateUserPermission = hasPermission(PermissionKeysType.write)
|
||||
|
||||
const [createUser] = userServiceApi.useCreateUserMutation()
|
||||
const { data: roles = [], isLoading } = roleApi.useGetAllRolesQuery()
|
||||
|
||||
const [updateUser] = userServiceApi.useUpdateUserMutation()
|
||||
|
||||
const isSaveBtnAvailable = isNew
|
||||
? hasCreateUserPermission
|
||||
: hasUpdateUserPermission
|
||||
|
||||
const {
|
||||
control,
|
||||
formState: { isDirty },
|
||||
getValues,
|
||||
setValue,
|
||||
watch,
|
||||
setError
|
||||
} = useForm<UserType>({
|
||||
defaultValues: isNew
|
||||
? {
|
||||
description: '',
|
||||
email: '',
|
||||
firstName: '',
|
||||
password: '',
|
||||
roles: []
|
||||
}
|
||||
: state,
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (isNew && !fromApp) {
|
||||
navigate(routePaths.users)
|
||||
}
|
||||
}, [fromApp])
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = watch((value, { name, type }) => {
|
||||
if (name === 'roles' && type === 'change') {
|
||||
const exclusiveRole = findExclusiveRole(roles, value.roles as number[])
|
||||
if (exclusiveRole) {
|
||||
if (value.roles && value.roles.length > 1) {
|
||||
message.error(
|
||||
<>
|
||||
Роль: <strong>{exclusiveRole.name}</strong> несовместима с
|
||||
другими ролями
|
||||
</>
|
||||
)
|
||||
}
|
||||
setValue('roles', [exclusiveRole.id])
|
||||
}
|
||||
}
|
||||
})
|
||||
return () => subscription.unsubscribe()
|
||||
}, [watch])
|
||||
|
||||
const sendForm = () => {
|
||||
if (isNew) {
|
||||
const newUser = {
|
||||
email: getValues().email,
|
||||
password: getValues().password,
|
||||
description: getValues().description,
|
||||
firstName: getValues().firstName,
|
||||
lastName: getValues().lastName,
|
||||
roles: getValues().roles
|
||||
}
|
||||
createUser(newUser)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Пользователь успешно создан')
|
||||
navigate(routePaths.users)
|
||||
})
|
||||
.catch((error) => {
|
||||
const { status } = error
|
||||
if (status === 409) {
|
||||
setError('email', {
|
||||
message: 'Пользователь с таким Email уже существует'
|
||||
})
|
||||
}
|
||||
message.error('Произошла ошибка создания пользователя')
|
||||
})
|
||||
} else {
|
||||
const formData = getValues()
|
||||
delete formData.lastSessionCreatedAt
|
||||
updateUser(formData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Пользователь успешно изменен')
|
||||
navigate(routePaths.users)
|
||||
})
|
||||
.catch((error) => {
|
||||
const { status } = error
|
||||
if (status === 409) {
|
||||
setError('email', {
|
||||
message: 'Пользователь с таким Email уже существует'
|
||||
})
|
||||
}
|
||||
message.error('Произошла ошибка обновления пользователя')
|
||||
})
|
||||
}
|
||||
}
|
||||
const createSelectOptions = (role: RoleType[]) => {
|
||||
const options: LabelItem[] = role.map((r) => ({
|
||||
value: r.id,
|
||||
label: r.name
|
||||
}))
|
||||
return options
|
||||
}
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
return (
|
||||
<section className="user-editor">
|
||||
<header className="user-editor__header">
|
||||
<div className="user-editor__header__nav">
|
||||
<Button
|
||||
data-cy="user-editor__header__nav__backBtn"
|
||||
className="user-editor__header__nav__backBtn"
|
||||
type="text"
|
||||
onClick={() => navigate(routePaths.users)}
|
||||
icon={<ArrowLeftOutlined />}
|
||||
/>
|
||||
|
||||
<h2 className="user-editor__header__name">
|
||||
{isNew ? 'Новый пользователь' : `${state.firstName}`}
|
||||
</h2>
|
||||
<Button
|
||||
disabled={!isDirty || !isSaveBtnAvailable}
|
||||
data-cy="user-editor__header__btn"
|
||||
className="user-editor__header__btn"
|
||||
onClick={() => sendForm()}
|
||||
type="primary"
|
||||
icon={<SaveOutlined />}
|
||||
>
|
||||
Сохранить
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{isNew ? (
|
||||
''
|
||||
) : (
|
||||
<span data-cy="user-editor__status" className="user-editor__status">
|
||||
{state.lastSessionCreatedAt && (
|
||||
<>
|
||||
Последняя сессия
|
||||
{dayjs(state.lastSessionCreatedAt).format(
|
||||
dateFormats.fullFormat
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<form className="user-editor__content">
|
||||
<div className="user-editor__content__wrap">
|
||||
<div className="user-editor__content__name">
|
||||
<FormComponents.FormInput
|
||||
label="Имя"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
control={control}
|
||||
name="firstName"
|
||||
/>
|
||||
</div>
|
||||
<div className="user-editor__content__name">
|
||||
<FormComponents.FormInput
|
||||
label="Фамилия"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
control={control}
|
||||
name="lastName"
|
||||
/>
|
||||
</div>
|
||||
<div className="user-editor__content__email">
|
||||
<FormComponents.FormInput
|
||||
label="Email"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
control={control}
|
||||
name="email"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isNew && (
|
||||
<div className="user-editor__content__password">
|
||||
<FormComponents.FormInputPassword
|
||||
label="Пароль"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
control={control}
|
||||
name="password"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="user-editor__content__description">
|
||||
<FormComponents.FormTextArea
|
||||
autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
label="Описание"
|
||||
control={control}
|
||||
name="description"
|
||||
/>
|
||||
</div>
|
||||
<div className="user-editor__content__roles">
|
||||
<FormComponents.FormSelect
|
||||
mode="multiple"
|
||||
label="Роли"
|
||||
optionFilterProp="label"
|
||||
disabled={!hasPermission(PermissionKeysType.write)}
|
||||
control={control}
|
||||
name="roles"
|
||||
options={createSelectOptions(roles)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
export default UserEditor
|
||||
Loaded 100 of 172 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user