MSP-3106 refactor applications page

This commit is contained in:
mikheykinnv committed 2024-05-07 15:51:35 +03:00
1 parent aa6853211b
commit 67ee8aec3a
16 files changed
+1066 -525

No files matched your search

+269 -7
View File
@@ -1,20 +1,22 @@
{ {
"name": "isp-admin-ui", "name": "isp-admin-ui",
"version": "0.8.1", "version": "0.10.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "isp-admin-ui", "name": "isp-admin-ui",
"version": "0.8.1", "version": "0.10.1",
"dependencies": { "dependencies": {
"@reduxjs/toolkit": "^2.2.3", "@reduxjs/toolkit": "^2.2.3",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"axios": "^1.6.8", "axios": "^1.6.8",
"clipboard": "^2.0.11",
"compare-versions": "^6.1.0",
"isp-ui-kit": "github:txix-open/isp-ui-kit", "isp-ui-kit": "github:txix-open/isp-ui-kit",
"moment": "^2.30.1", "moment": "^2.30.1",
"compare-versions": "^6.1.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hook-form": "^7.51.2", "react-hook-form": "^7.51.2",
"react-redux": "^9.1.0", "react-redux": "^9.1.0",
@@ -27,6 +29,7 @@
"@trivago/prettier-plugin-sort-imports": "^4.3.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.12.4", "@types/node": "^20.12.4",
"@types/react": "^18.2.74", "@types/react": "^18.2.74",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.2.24", "@types/react-dom": "^18.2.24",
"@types/react-resizable": "^3.0.7", "@types/react-resizable": "^3.0.7",
"@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/eslint-plugin": "^7.5.0",
@@ -3913,6 +3916,15 @@
"csstype": "^3.0.2" "csstype": "^3.0.2"
} }
}, },
"node_modules/@types/react-copy-to-clipboard": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/@types/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.7.tgz",
"integrity": "sha512-Gft19D+as4M+9Whq1oglhmK49vqPhcLzk8WfvfLvaYMIPYanyfLy0+CwFucMJfdKoSFyySPmkkWn8/E6voQXjQ==",
"dev": true,
"dependencies": {
"@types/react": "*"
}
},
"node_modules/@types/react-dom": { "node_modules/@types/react-dom": {
"version": "18.2.24", "version": "18.2.24",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.24.tgz", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.24.tgz",
@@ -4578,6 +4590,11 @@
"url": "https://github.com/sponsors/ljharb" "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=="
},
"node_modules/async-validator": { "node_modules/async-validator": {
"version": "4.2.5", "version": "4.2.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz", "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
@@ -4917,6 +4934,16 @@
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
"integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==" "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow=="
}, },
"node_modules/clipboard": {
"version": "2.0.11",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz",
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
"dependencies": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
"tiny-emitter": "^2.0.0"
}
},
"node_modules/clsx": { "node_modules/clsx": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
@@ -4939,6 +4966,18 @@
"@codemirror/view": "^6.0.0" "@codemirror/view": "^6.0.0"
} }
}, },
"node_modules/color": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz",
"integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
"dependencies": {
"color-convert": "^2.0.1",
"color-string": "^1.9.0"
},
"engines": {
"node": ">=12.5.0"
}
},
"node_modules/color-convert": { "node_modules/color-convert": {
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@@ -4951,8 +4990,32 @@
"node_modules/color-name": { "node_modules/color-name": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
"dev": true },
"node_modules/color-string": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
"integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
"dependencies": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
}
},
"node_modules/color/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
}, },
"node_modules/combined-stream": { "node_modules/combined-stream": {
"version": "1.0.8", "version": "1.0.8",
@@ -5073,6 +5136,14 @@
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==" "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
}, },
"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==",
"dependencies": {
"node-fetch": "^2.6.12"
}
},
"node_modules/cross-spawn": { "node_modules/cross-spawn": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -5213,6 +5284,11 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/delegate": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
},
"node_modules/dir-glob": { "node_modules/dir-glob": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -6144,6 +6220,33 @@
"reusify": "^1.0.4" "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==",
"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==",
"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=="
},
"node_modules/file-entry-cache": { "node_modules/file-entry-cache": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@@ -6204,6 +6307,18 @@
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"dev": true "dev": true
}, },
"node_modules/flux": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/flux/-/flux-4.0.4.tgz",
"integrity": "sha512-NCj3XlayA2UsapRpM7va6wU1+9rE5FIL7qoMcmxWHRzbp0yujihMBm9BBHZ1MDIk5h5o2Bl6eGiCe8rYELAmYw==",
"dependencies": {
"fbemitter": "^3.0.0",
"fbjs": "^3.0.1"
},
"peerDependencies": {
"react": "^15.0.2 || ^16.0.0 || ^17.0.0"
}
},
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.15.6", "version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
@@ -6476,6 +6591,14 @@
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true "dev": true
}, },
"node_modules/good-listener": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
"dependencies": {
"delegate": "^3.1.2"
}
},
"node_modules/gopd": { "node_modules/gopd": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
@@ -7062,20 +7185,35 @@
"dev": true "dev": true
}, },
"node_modules/isp-ui-kit": { "node_modules/isp-ui-kit": {
"version": "0.3.4", "version": "0.5.2",
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#ee517a533f9e4934d08bf6d70cdfda31198cba4c", "resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#b49acfe2e535398a8716407e75865e4b2e9dd84a",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@codemirror/lang-javascript": "^6.2.1", "@codemirror/lang-javascript": "^6.2.1",
"@codemirror/lang-json": "^6.0.1", "@codemirror/lang-json": "^6.0.1",
"@uiw/react-codemirror": "^4.21.21", "@uiw/react-codemirror": "^4.21.21",
"antd": "^5.12.2", "antd": "^5.12.2",
"flux": "^4.0.4",
"react": "^18.2.0", "react": "^18.2.0",
"react-base16-styling": "^0.10.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hook-form": "^7.49.1", "react-hook-form": "^7.49.1",
"react-lifecycles-compat": "^3.0.4",
"react-textarea-autosize": "^6.1.0",
"simplebar-react": "^3.2.4" "simplebar-react": "^3.2.4"
} }
}, },
"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==",
"dependencies": {
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": ">=0.14.0 <17.0.0"
}
},
"node_modules/iterator.prototype": { "node_modules/iterator.prototype": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz", "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz",
@@ -7426,6 +7564,25 @@
"tslib": "^2.0.3" "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==",
"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": { "node_modules/node-releases": {
"version": "2.0.14", "version": "2.0.14",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
@@ -7820,6 +7977,14 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/promise": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
"dependencies": {
"asap": "~2.0.3"
}
},
"node_modules/prop-types": { "node_modules/prop-types": {
"version": "15.8.1", "version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
@@ -8460,6 +8625,29 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/react-base16-styling": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.10.0.tgz",
"integrity": "sha512-H1k2eFB6M45OaiRru3PBXkuCcn2qNmx+gzLb4a9IPMR7tMH8oBRXU5jGbPDYG1Hz+82d88ED0vjR8BmqU3pQdg==",
"dependencies": {
"@types/lodash": "^4.17.0",
"color": "^4.2.3",
"csstype": "^3.1.3",
"lodash-es": "^4.17.21"
}
},
"node_modules/react-copy-to-clipboard": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz",
"integrity": "sha512-k61RsNgAayIJNoy9yDsYzDe/yAZAzEbEgcz3DZMhF686LEyukcE1hzurxe85JandPUG+yTfGVFzuEw3xt8WP/A==",
"dependencies": {
"copy-to-clipboard": "^3.3.1",
"prop-types": "^15.8.1"
},
"peerDependencies": {
"react": "^15.3.0 || 16 || 17 || 18"
}
},
"node_modules/react-dom": { "node_modules/react-dom": {
"version": "18.2.0", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
@@ -8505,6 +8693,11 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
}, },
"node_modules/react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"node_modules/react-redux": { "node_modules/react-redux": {
"version": "9.1.0", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz",
@@ -8911,6 +9104,11 @@
"compute-scroll-into-view": "^3.0.2" "compute-scroll-into-view": "^3.0.2"
} }
}, },
"node_modules/select": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA=="
},
"node_modules/semver": { "node_modules/semver": {
"version": "7.6.0", "version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
@@ -8987,6 +9185,11 @@
"node": ">= 0.4" "node": ">= 0.4"
} }
}, },
"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=="
},
"node_modules/shebang-command": { "node_modules/shebang-command": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@@ -9026,6 +9229,19 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
"integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
"dependencies": {
"is-arrayish": "^0.3.1"
}
},
"node_modules/simple-swizzle/node_modules/is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
},
"node_modules/simplebar": { "node_modules/simplebar": {
"version": "6.2.5", "version": "6.2.5",
"resolved": "https://registry.npmjs.org/simplebar/-/simplebar-6.2.5.tgz", "resolved": "https://registry.npmjs.org/simplebar/-/simplebar-6.2.5.tgz",
@@ -9336,6 +9552,11 @@
"node": ">=12.22" "node": ">=12.22"
} }
}, },
"node_modules/tiny-emitter": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
},
"node_modules/to-fast-properties": { "node_modules/to-fast-properties": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
@@ -9362,6 +9583,11 @@
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
"integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" "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=="
},
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz",
@@ -9534,6 +9760,28 @@
"node": ">=14.17" "node": ">=14.17"
} }
}, },
"node_modules/ua-parser-js": {
"version": "1.0.37",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz",
"integrity": "sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==",
"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"
}
],
"engines": {
"node": "*"
}
},
"node_modules/unbox-primitive": { "node_modules/unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@@ -9811,6 +10059,20 @@
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
}, },
"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=="
},
"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==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+4 -1
View File
@@ -17,10 +17,12 @@
"@reduxjs/toolkit": "^2.2.3", "@reduxjs/toolkit": "^2.2.3",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"axios": "^1.6.8", "axios": "^1.6.8",
"clipboard": "^2.0.11",
"compare-versions": "^6.1.0", "compare-versions": "^6.1.0",
"moment": "^2.30.1",
"isp-ui-kit": "github:txix-open/isp-ui-kit", "isp-ui-kit": "github:txix-open/isp-ui-kit",
"moment": "^2.30.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hook-form": "^7.51.2", "react-hook-form": "^7.51.2",
"react-redux": "^9.1.0", "react-redux": "^9.1.0",
@@ -33,6 +35,7 @@
"@trivago/prettier-plugin-sort-imports": "^4.3.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.12.4", "@types/node": "^20.12.4",
"@types/react": "^18.2.74", "@types/react": "^18.2.74",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.2.24", "@types/react-dom": "^18.2.24",
"@types/react-resizable": "^3.0.7", "@types/react-resizable": "^3.0.7",
"@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/eslint-plugin": "^7.5.0",
@@ -1,9 +1,11 @@
@import "src/constants/style/styleConst"; @import "src/constants/style/styleConst";
.applications-content { .applications-content {
padding: $basic-padding *2 $basic-padding;
display: flex; display: flex;
flex-direction: column; height: 100vh;
.column-content {
margin-left: $basic-margin;
}
&__add-btn { &__add-btn {
max-width: 240px; max-width: 240px;
margin-left: auto; margin-left: auto;
@@ -16,4 +18,10 @@
display: flex; display: flex;
margin: 0 auto; margin: 0 auto;
} }
.link-btn {
color: $blue-color;
&:hover {
color: $text-color-blue;
}
}
} }
+177 -271
View File
@@ -1,59 +1,66 @@
import { import { LinkOutlined } from '@ant-design/icons'
EditOutlined, import { List, message, Spin, Tooltip } from 'antd'
DeleteOutlined,
PlusSquareOutlined
} from '@ant-design/icons'
import {Button, message, Spin, Table} from 'antd'
import { ColumnsType } from 'antd/es/table'
import { FormComponents, Layout } from 'isp-ui-kit' import { FormComponents, Layout } from 'isp-ui-kit'
import { FC, useState } from 'react' import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
import { Dispatch, FC, SetStateAction, useState } from 'react'
import { useForm } from 'react-hook-form' import { useForm } from 'react-hook-form'
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
import { ValidationRules } from '@constants/form/validationRules.ts' import { ValidationRules } from '@constants/form/validationRules.ts'
import Modal from '@widgets/Modal' import Modal from '@widgets/Modal'
import CanEdit from '@components/CanEdit' import TokenContent from '@components/TokenContent'
import { import {
ApplicationAppType, ApplicationAppType,
ApplicationsServiceType, ApplicationsServiceType,
ApplicationTokenType,
NewApplicationAppType, NewApplicationAppType,
NewApplicationTokenType,
UpdateApplicationAppType UpdateApplicationAppType
} from '@pages/ApplicationsPage/applications.type.ts' } 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 applicationsApi from '@services/applicationsService.ts'
import tokensApi from '@services/tokensService.ts'
import { routePaths } from '@routes/routePaths.ts'
import './applications-content.scss' import './applications-content.scss'
const { FormInput, FormSelect } = FormComponents const { FormInput } = FormComponents
const { EmptyData } = Layout const { EmptyData, Column, ContentColumn } = Layout
interface ApplicationsContentPropTypes { interface ApplicationsContentPropTypes {
id: number selectedItemId: number
currentApplicationsApp: number
setCurrentApplicationsApp: Dispatch<SetStateAction<number>>
} }
const ApplicationsContent: FC<ApplicationsContentPropTypes> = (id) => { const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
selectedItemId,
currentApplicationsApp,
setCurrentApplicationsApp
}) => {
const { data: applications, isLoading: isLoadingApplicationsContent = [] } = const { data: applications, isLoading: isLoadingApplicationsContent = [] } =
applicationsApi.useGetApplicationsByServiceIdQuery(id) applicationsApi.useGetApplicationsByServiceIdQuery({
id: selectedItemId
})
const [createApplicationService] = const [createApplicationService] =
applicationsApi.useCreateApplicationServiceMutation() applicationsApi.useCreateApplicationServiceMutation()
const [updateApplication] = const [updateApplication] =
applicationsApi.useUpdateApplicationsServiceMutation() applicationsApi.useUpdateApplicationsServiceMutation()
const [removeApplicationsService] = const [removeApplicationsService] =
applicationsApi.useRemoveApplicationsServiceMutation() applicationsApi.useRemoveApplicationsServiceMutation()
const [createToken] = tokensApi.useCreateTokenMutation()
const [showApplicationsModal, setShowApplicationsModal] = useState({ const [showApplicationsModal, setShowApplicationsModal] = useState({
addModal: false, addModal: false,
updateModal: false, updateModal: false
addToken: false
}) })
const [currentApplicationsApp, setCurrentApplicationsApp] = const [searchParams, setSearchParams] = useSearchParams('')
useState<ApplicationAppType>() const searchAppValue = searchParams.get('appSearch') || ''
const navigate = useNavigate()
const { appId } = useParams()
const { const {
handleSubmit, handleSubmit,
@@ -62,55 +69,53 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = (id) => {
} = useForm<ApplicationAppType>({ } = useForm<ApplicationAppType>({
mode: 'onChange' mode: 'onChange'
}) })
const updateApplicationModal = () => {
const { handleSubmit: handleSubmitTokens, control: controlTokens } =
useForm<ApplicationTokenType>({
mode: 'onChange'
})
const handleShowUpdateModalApplicationApp = (data: ApplicationAppType) => {
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
updateModal: true updateModal: true
}) })
setCurrentApplicationsApp(data)
} }
const handleShowCreateModalApplicationApp = () => { const addApplicationModal = () => {
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
addModal: true addModal: true
}) })
} }
const handleShowAddModalToken = (data: ApplicationAppType) => { const renderTokenContent = () => {
setShowApplicationsModal({ if (!currentApplicationsApp) {
...showApplicationsModal, return <EmptyData />
addToken: true }
})
setCurrentApplicationsApp(data) return (
<TokenContent key={currentApplicationsApp} id={currentApplicationsApp} />
)
} }
const handleUpdateApplicationApp = (data: UpdateApplicationAppType) => { const handleUpdateApplicationApp = (data: UpdateApplicationAppType) => {
if (currentApplicationsApp) { const currentElement = applications?.filter(
(el) => el.app.id === Number(appId)
)[0].app
if (currentElement) {
const updateApplications: UpdateApplicationAppType = { const updateApplications: UpdateApplicationAppType = {
id: currentApplicationsApp.id, id: currentElement.id,
name: data.name, name: data.name,
description: data.description description: data.description
? data.description ? data.description
: currentApplicationsApp.description, : currentElement.description,
serviceId: id.id, serviceId: selectedItemId,
type: 'SYSTEM' type: 'SYSTEM'
} }
updateApplication({ ...currentApplicationsApp, ...updateApplications }) updateApplication({ ...currentElement, ...updateApplications })
.unwrap() .unwrap()
.then(() => { .then(() => {
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
updateModal: false updateModal: false
})
reset()
message.info('Элемент сохранен')
}) })
.catch(() => message.error('Ошибка обновления элемента')) reset()
message.info('Элемент сохранен')
})
.catch(() => message.error('Ошибка обновления элемента'))
} }
} }
@@ -118,14 +123,14 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = (id) => {
const newApplicationApp: NewApplicationAppType = { const newApplicationApp: NewApplicationAppType = {
name: data.name, name: data.name,
description: data.description, description: data.description,
serviceId: id.id, serviceId: selectedItemId,
type: 'SYSTEM' type: 'SYSTEM'
} }
createApplicationService(newApplicationApp) createApplicationService(newApplicationApp)
.unwrap() .unwrap()
.then(message.info('Элемент сохранен')) .then(message.info('Элемент сохранен'))
.catch((e) => message.error(e)) .catch((e) => message.error(e))
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
addModal: false addModal: false
@@ -133,227 +138,128 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = (id) => {
reset() reset()
} }
const handleRemoveApplicationApp = (id: number) => const handleRemoveApplicationApp = (id: number) =>
removeApplicationsService([id]) removeApplicationsService([id])
.then(() => { .unwrap()
message.info('Элемент удален') .then(() => message.success('Элемент удален'))
}) .catch(() => message.info('Ошибка удаления элемента'))
.catch(message.error('Ошибка добавления элемента'))
const handleCreateToken = (data: NewApplicationTokenType) => { const renderColumnItems = (item: ColumnItem<any>) => {
if (currentApplicationsApp) { return (
const newToken: NewApplicationTokenType = { <List.Item>
expireTimeMs: data.expireTimeMs, <Tooltip mouseEnterDelay={1} title={item.name}>
appId: currentApplicationsApp.id <List.Item.Meta title={item.name} />
} <div
className="link-btn"
createToken(newToken) onClick={(e) => {
.then(() => { e.stopPropagation()
setShowApplicationsModal({ navigate(`/appAccess/${item.id}`)
...showApplicationsModal, }}
addToken: false >
}) <LinkOutlined />
reset() </div>
message.info('Элемент добавлен') </Tooltip>
}) </List.Item>
.catch(() => { )
message.error('Ошибка добавления элемента')
})
}
} }
const columns: ColumnsType<ApplicationsServiceType> = [ if (!selectedItemId) {
{
title: 'id',
dataIndex: ['app', 'id'],
key: 'id'
},
{
title: 'Наименование',
dataIndex: ['app', 'name'],
key: 'name'
},
{
title: 'Описание',
dataIndex: ['app', 'description'],
key: 'description'
},
{
title: 'Type',
dataIndex: ['app', 'type'],
key: 'Type'
},
{
title: 'Количество токенов',
dataIndex: 'tokens',
key: 'tokensAmount',
render: (value) => {
return value.length
}
},
{
title: 'Действия',
dataIndex: 'app',
key: 'actions',
render: (record) => {
return (
<CanEdit>
<Button
danger
className="applications-content__update-btn"
onClick={() => {
handleShowUpdateModalApplicationApp(record)
}}
icon={<EditOutlined />}
/>
<Button
onClick={() => handleRemoveApplicationApp(record.id)}
icon={<DeleteOutlined />}
/>
</CanEdit>
)
}
}
]
const tokensOptions = [
{
value: -1,
label: 'Бессрочно'
},
{
value: 3600000,
label: 'Один час'
},
{
value: 86400000,
label: 'Один день'
},
{
value: 2592000000,
label: '30 дней'
},
{
value: 31536000000,
label: 'Один год'
}
]
if (!id) {
return <EmptyData /> return <EmptyData />
} }
if (selectedItemId)
if (isLoadingApplicationsContent) { if (isLoadingApplicationsContent) {
return <Spin className="spin" /> return <Spin className="spin" />
} }
return ( return (
<section className="applications-content"> <section className="applications-content">
<CanEdit> <Column
<Button title="Приложения"
className="applications-content__add-btn" onUpdateItem={updateApplicationModal}
type="primary" showUpdateBtn={!!appId}
onClick={handleShowCreateModalApplicationApp} onAddItem={addApplicationModal}
> onRemoveItem={() => handleRemoveApplicationApp(Number(appId))}
Добавить items={filterFirstColumnItems(
</Button> applications?.map((el) => {
</CanEdit> return el.app
<Table }) as unknown as ColumnItem<ApplicationsServiceType>[],
expandable={{ searchAppValue
expandedRowRender: (record) => ( )}
<CanEdit> renderItems={renderColumnItems}
<Button searchValue={searchAppValue}
className="applications-content__addToken-btn" selectedItemId={currentApplicationsApp.toString()}
onClick={() => handleShowAddModalToken(record.app)} setSelectedItemId={(itemId: string) => {
> setCurrentApplicationsApp(Number(itemId))
<PlusSquareOutlined /> Добавить токен setSelectedItemId(
</Button> `${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`,
</CanEdit> itemId.toString(),
) searchAppValue,
}} navigate
className="appliactions-content__table" )
rowKey={(record) => record.app.id} }}
pagination={false} onChangeSearchValue={(value: string) => {
dataSource={applications} setSearchValue(
columns={columns} value.trim().toLowerCase(),
/> setSearchParams,
'appSearch'
)
}}
/>
<ContentColumn>{renderTokenContent()}</ContentColumn>
<Modal <Modal
onOk={handleSubmit(handleUpdateApplicationApp)} onOk={handleSubmit(handleUpdateApplicationApp)}
title="Редактировать" title="Редактировать"
open={showApplicationsModal.updateModal} open={showApplicationsModal.updateModal}
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }} footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
onClose={() => onClose={() =>
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
updateModal: false updateModal: false
}) })
} }
> >
<form> <form>
<FormInput <FormInput
control={controlApplicationApp} control={controlApplicationApp}
name="name" name="name"
label="Наименование" label="Наименование"
rules={{ required: ValidationRules.required }} rules={{ required: ValidationRules.required }}
/> />
<FormInput <FormInput
control={controlApplicationApp} control={controlApplicationApp}
label="Описание" label="Описание"
name="description" name="description"
/> />
</form> </form>
</Modal> </Modal>
<Modal <Modal
onOk={handleSubmit(handleCreateApplicationApp)} onOk={handleSubmit(handleCreateApplicationApp)}
title="Добавить" title="Добавить"
open={showApplicationsModal.addModal} open={showApplicationsModal.addModal}
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }} footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
onClose={() => onClose={() =>
setShowApplicationsModal({ setShowApplicationsModal({
...showApplicationsModal, ...showApplicationsModal,
addModal: false addModal: false
}) })
} }
> >
<form> <form>
<FormInput <FormInput
control={controlApplicationApp} control={controlApplicationApp}
name="name" name="name"
label="Наименование" label="Наименование"
rules={{ required: ValidationRules.required }} rules={{ required: ValidationRules.required }}
/> />
<FormInput <FormInput
control={controlApplicationApp} control={controlApplicationApp}
label="Описание" label="Описание"
name="description" name="description"
/> />
</form> </form>
</Modal> </Modal>
</section>
<Modal
onOk={handleSubmitTokens(handleCreateToken)}
title="Добавить"
open={showApplicationsModal.addToken}
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
onClose={() =>
setShowApplicationsModal({
...showApplicationsModal,
addToken: false
})
}
>
<form>
<FormSelect
options={tokensOptions}
name="expireTimeMs"
control={controlTokens}
label="Время действия"
rules={{ required: ValidationRules.required }}
/>
</form>
</Modal>
</section>
) )
} }
+41 -41
View File
@@ -40,7 +40,7 @@ const { Content, Sider } = Layout
const LayoutComponent = () => { const LayoutComponent = () => {
const [collapsed, setCollapsed] = useState<boolean>(false) const [collapsed, setCollapsed] = useState<boolean>(false)
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>( const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
[] []
) )
const [title, setTitle] = useState('') const [title, setTitle] = useState('')
const [openKeys, setOpenKeys] = useState<string[]>([]) const [openKeys, setOpenKeys] = useState<string[]>([])
@@ -88,7 +88,7 @@ const LayoutComponent = () => {
}, },
{ {
label: 'Группа приложений', label: 'Группа приложений',
key: 'applications', key: 'applications_group',
className: hideItem([PermissionKeysType.read]), className: hideItem([PermissionKeysType.read]),
icon: <AppstoreAddOutlined /> icon: <AppstoreAddOutlined />
}, },
@@ -137,9 +137,9 @@ const LayoutComponent = () => {
useEffect(() => { useEffect(() => {
ConfigProvider.config({ ConfigProvider.config({
holderRender: (children) => ( holderRender: (children) => (
<ConfigProvider prefixCls="static" theme={theme}> <ConfigProvider prefixCls="static" theme={theme}>
{children} {children}
</ConfigProvider> </ConfigProvider>
) )
}) })
}, [theme]) }, [theme])
@@ -191,8 +191,8 @@ const LayoutComponent = () => {
case MenuItemKeysType.modules: case MenuItemKeysType.modules:
navigate(routePaths.modules) navigate(routePaths.modules)
break break
case MenuItemKeysType.applications: case MenuItemKeysType.applicationsGroup:
navigate(routePaths.applications) navigate(routePaths.applicationsGroup)
break break
default: default:
} }
@@ -203,40 +203,40 @@ const LayoutComponent = () => {
} }
return ( return (
<section> <section>
<Header title={title} /> <Header title={title} />
<Layout className="layout" data-cy="homePage"> <Layout className="layout" data-cy="homePage">
{status === StateProfileStatus.pending ? ( {status === StateProfileStatus.pending ? (
<Spin size="large" /> <Spin size="large" />
) : ( ) : (
<> <>
<Sider <Sider
width="250px" width="250px"
data-cy="aside" data-cy="aside"
theme="light" theme="light"
collapsible collapsible
collapsed={collapsed} collapsed={collapsed}
onCollapse={(value) => setCollapsed(value)} onCollapse={(value) => setCollapsed(value)}
> >
<Menu <Menu
onOpenChange={(keys) => setOpenKeys(keys)} onOpenChange={(keys) => setOpenKeys(keys)}
openKeys={openKeys} openKeys={openKeys}
selectedKeys={selectedMenuKeys} selectedKeys={selectedMenuKeys}
onClick={handlerOnClickMenu} onClick={handlerOnClickMenu}
theme="light" theme="light"
mode="inline" mode="inline"
items={menuItems} items={menuItems}
/> />
</Sider> </Sider>
<Layout className="site-layout"> <Layout className="site-layout">
<Content className="site-layout__content"> <Content className="site-layout__content">
<Outlet /> <Outlet />
</Content> </Content>
</Layout> </Layout>
</> </>
)} )}
</Layout> </Layout>
</section> </section>
) )
} }
+5 -4
View File
@@ -9,7 +9,7 @@ export enum MenuItemKeysType {
logout = 'logout', logout = 'logout',
profile = 'profile', profile = 'profile',
modules = 'modules', modules = 'modules',
applications = 'applications' applicationsGroup = 'applications_group'
} }
export enum MenuItemLabelsType { export enum MenuItemLabelsType {
users = 'Пользователи', users = 'Пользователи',
@@ -19,14 +19,15 @@ export enum MenuItemLabelsType {
roles = 'Роли', roles = 'Роли',
profile = 'Профиль', profile = 'Профиль',
modules = 'Модули', modules = 'Модули',
applications = 'Группа приложений',
logout = 'Выход', logout = 'Выход',
applications_group = 'Группа приложений'
} }
interface MenuItem { interface MenuItem {
key: MenuItemKeysType key: MenuItemKeysType
parent: string[] parent: string[]
} }
export const menuKeys: Record<MenuItemKeysType, MenuItem> = { export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
[MenuItemKeysType.users]: { [MenuItemKeysType.users]: {
key: MenuItemKeysType.users, key: MenuItemKeysType.users,
@@ -60,8 +61,8 @@ export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
key: MenuItemKeysType.modules, key: MenuItemKeysType.modules,
parent: [] parent: []
}, },
[MenuItemKeysType.applications]: { [MenuItemKeysType.applicationsGroup]: {
key: MenuItemKeysType.applications, key: MenuItemKeysType.applicationsGroup,
parent: [''] parent: ['']
} }
} }
+261
View File
@@ -0,0 +1,261 @@
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons'
import { Button, message, Popconfirm, Spin, Table } 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 { Layout, FormComponents } from 'isp-ui-kit'
import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
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'
import CanEdit from '@components/CanEdit'
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.info('Элемент добавлен')
})
.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.info('Ошибка удаления элемента'))
}
const columns: ColumnsType<ApplicationTokenType> = [
{
title: 'Токен',
dataIndex: 'token',
key: 'token',
render: (record) => <div>{shortenString(record)}</div>
},
{
title: 'Дата/Время выпуска',
dataIndex: 'createdAt',
key: 'createdAt',
render: (record) => {
const FULL_DATE_FORMAT = 'DD-MM-YYYY/HH:mm'
const formatTime = dayjs(record.createdAt).format(FULL_DATE_FORMAT)
return <div>{formatTime}</div>
}
},
{
title: 'Срок действия',
dataIndex: 'expireTime',
key: 'expireTime',
render: (value) => {
const time = dayjs.duration(value).humanize()
if (value > 0) {
return <div>{time}</div>
}
return <div>Отсутствует</div>
}
},
{
title: 'Истекает',
dataIndex: 'expireTime',
key: 'expireTime',
render: (value, record) => {
const FULL_DATE_FORMAT = 'DD-MM-YYYY, HH:mm'
const formatTime = dayjs(record.createdAt)
.add(record.expireTime)
.format(FULL_DATE_FORMAT)
return value > 0 ? <span>{formatTime}</span> : <span> Никогда </span>
}
},
{
title: 'Скопировать',
dataIndex: 'token',
key: 'copyToken',
align: 'center',
render: (record) => {
return (
<Button className="copy-btn" data-clipboard-text={record}>
<CopyOutlined />
</Button>
)
}
},
{
title: 'Отозвать',
dataIndex: 'appId',
key: 'recall',
align: 'center',
render: (_, record) => {
return (
<Popconfirm
title="Закончить эту сессию?"
onConfirm={() => handleRevokeToken(record)}
>
<Button danger>
<DeleteOutlined />
</Button>
</Popconfirm>
)
}
}
]
const tokensOptions = [
{
value: -1,
label: 'Бессрочно'
},
{
value: 3600000,
label: 'Один час'
},
{
value: 86400000,
label: 'Один день'
},
{
value: 2592000000,
label: '30 дней'
},
{
value: 31536000000,
label: 'Один год'
}
]
if (!id) {
return <EmptyData />
}
if (isLoading) {
return <Spin className="spin" />
}
const handleShowAddModalToken = () => {
setShowApplicationsModal(true)
}
return (
<section className="token-content">
<CanEdit>
<Button
className="applications-content__add-btn"
type="primary"
onClick={handleShowAddModalToken}
>
Добавить токен
</Button>
</CanEdit>
<Table
className="appliactions-tokent__table"
rowKey={(record) => record.createdAt}
pagination={false}
columns={columns}
dataSource={data}
/>
<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>
</section>
)
}
export default TokenContent
+7
View File
@@ -0,0 +1,7 @@
@import "src/constants/style/styleConst";
.token-content {
padding: $basic-padding *2 $basic-padding;
.copy-btn {
cursor: pointer;
}
}
@@ -1,7 +1,10 @@
@import "src/constants/style/styleConst"; @import "src/constants/style/styleConst";
.applications-page { .applications-page {
height: 100%; height: 100vh;
.column-content {
max-height: 100vh;
}
.three-columns { .three-columns {
display: flex; display: flex;
background: #fff; background: #fff;
+44 -26
View File
@@ -1,39 +1,57 @@
export interface ApplicationsGroupType { export interface ApplicationsGroupType {
createdAt: string, createdAt: string
description: string, description: string
domainId: number, domainId: number
id: number, id: number
name: string, name: string
updatedAt: string updatedAt: string
} }
export type NewApplicationsGroupType = Omit<ApplicationsGroupType, 'id' | 'createdAt' | 'updatedAt'> export type NewApplicationsGroupType = Omit<
export type UpdateApplicationsGroupType = Omit<ApplicationsGroupType, 'createdAt' | 'updatedAt'> ApplicationsGroupType,
'id' | 'createdAt' | 'updatedAt'
>
export type UpdateApplicationsGroupType = Omit<
ApplicationsGroupType,
'createdAt' | 'updatedAt'
>
export interface ApplicationsServiceType { export interface ApplicationsServiceType {
app:ApplicationAppType app: ApplicationAppType
tokens: ApplicationTokenType[] tokens: ApplicationTokenType[]
} }
export type NewApplicationTokenType = Omit<ApplicationTokenType, 'createdAt' | 'token'> export type NewApplicationTokenType = {
export interface ApplicationAppType { appId: number
createdAt: string, expireTimeMs: number
description: string,
id: number,
name: string,
serviceId: number,
type: string,
updatedAt: string
} }
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 UpdateApplicationAppType = Omit<
export type NewApplicationAppType = Omit<ApplicationAppType, 'id' | 'createdAt' | 'updatedAt'> ApplicationAppType,
'createdAt' | 'updatedAt'
>
export type NewApplicationAppType = Omit<
ApplicationAppType,
'id' | 'createdAt' | 'updatedAt'
>
export type RevokeTokenType = {
appId: number
tokens: string[]
}
export interface ApplicationTokenType { export interface ApplicationTokenType {
appId: number, appId: number
createdAt: string, createdAt: string
expireTimeMs: number, expireTime: number
token: string token: string
} }
+22 -4
View File
@@ -39,6 +39,7 @@ const ApplicationsPage = () => {
const { id: selectedItemId = '' } = useParams() const { id: selectedItemId = '' } = useParams()
const [searchParams, setSearchParams] = useSearchParams('') const [searchParams, setSearchParams] = useSearchParams('')
const { hasPermission } = useRole() const { hasPermission } = useRole()
const [currentApplicationsApp, setCurrentApplicationsApp] = useState(0)
const { const {
data: applicationsGroup = [], data: applicationsGroup = [],
@@ -55,6 +56,7 @@ const ApplicationsPage = () => {
applicationsGroupApi.useRemoveApplicationsGroupMutation() applicationsGroupApi.useRemoveApplicationsGroupMutation()
const isPageAvailable = hasPermission(PermissionKeysType.read) const isPageAvailable = hasPermission(PermissionKeysType.read)
// const hasRevokePermission = hasPermission(PermissionKeysType.write)
useEffect(() => { useEffect(() => {
if (!isPageAvailable) { if (!isPageAvailable) {
@@ -128,21 +130,36 @@ const ApplicationsPage = () => {
message.info('Сервис успешно отредактирован') message.info('Сервис успешно отредактирован')
} }
const handleRemoveApplicationsGtoup = () => {
deleteApplicationsGroup([Number(selectedItemId)])
.unwrap()
.then(() => message.success('Элемент удален'))
.catch(() => message.info('Ошибка удаления элемента'))
}
const renderMainContent = () => { const renderMainContent = () => {
if (!selectedItemId) { if (!selectedItemId) {
return <EmptyData /> return <EmptyData />
} }
return <ApplicationsContent id={Number(selectedItemId)} />
return (
<ApplicationsContent
selectedItemId={Number(selectedItemId)}
currentApplicationsApp={currentApplicationsApp}
setCurrentApplicationsApp={setCurrentApplicationsApp}
/>
)
} }
return ( return (
<main className="applications-page "> <main className="applications-page">
<div className="applications-page__wrap three-columns"> <div className="applications-page__wrap three-columns">
<Column <Column
title="Группа приложений"
onUpdateItem={updateApplicationModal} onUpdateItem={updateApplicationModal}
showUpdateBtn={!!selectedItemId} showUpdateBtn={!!selectedItemId}
onAddItem={addApplicationModal} onAddItem={addApplicationModal}
onRemoveItem={() => deleteApplicationsGroup([Number(selectedItemId)])} onRemoveItem={handleRemoveApplicationsGtoup}
items={filterFirstColumnItems( items={filterFirstColumnItems(
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[], applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
searchValue searchValue
@@ -151,8 +168,9 @@ const ApplicationsPage = () => {
searchValue={searchValue} searchValue={searchValue}
selectedItemId={selectedItemId} selectedItemId={selectedItemId}
setSelectedItemId={(itemId) => { setSelectedItemId={(itemId) => {
setCurrentApplicationsApp(0)
setSelectedItemId( setSelectedItemId(
`${routePaths.applications}`, `${routePaths.applicationsGroup}`,
itemId, itemId,
searchValue, searchValue,
navigate navigate
+161 -142
View File
@@ -23,156 +23,175 @@ const Connections = lazy(() => import('@components/Connections'))
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage')) const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
const Routers = () => { const Routers = () => {
return ( return (
<Routes> <Routes>
<Route element={<PrivateRoute />}> <Route element={<PrivateRoute />}>
<Route path={routePaths.home} element={<Layout />}> <Route path={routePaths.home} element={<Layout />}>
<Route <Route
index index
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<HomePage /> <HomePage />
</Suspense> </Suspense>
} }
/> />
<Route <Route
path={`${routePaths.profile}`} path={`${routePaths.profile}`}
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<ProfilePage /> <ProfilePage />
</Suspense> </Suspense>
} }
/> />
<Route <Route
path={routePaths.users} path={routePaths.users}
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<UsersPage /> <UsersPage />
</Suspense> </Suspense>
} }
/> />
<Route <Route
path={`${routePaths.users}/:id`} path={`${routePaths.users}/:id`}
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<UserEditor /> <UserEditor />
</Suspense> </Suspense>
} }
/> />
<Route <Route
path={routePaths.roles} path={routePaths.roles}
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<RolesPage /> <RolesPage />
</Suspense> </Suspense>
} }
> >
<Route
path=":id"
element={
<Suspense fallback={<Spin />}>
<RolesPage />
</Suspense>
}
/>
</Route>
<Route
path={routePaths.applicationsGroup}
element={
<Suspense fallback={<Spin />}>
<ApplicationsPage />
</Suspense>
}
>
<Route
path=":id"
element={
<Suspense fallback={<Spin />}>
<ApplicationsPage />
</Suspense>
}
>
<Route
path={routePaths.application}
element={
<Suspense fallback={<Spin />}>
<ApplicationsPage />
</Suspense>
}
>
<Route
path=":appId"
element={
<Suspense fallback={<Spin />}>
<ApplicationsPage />
</Suspense>
}
/>
</Route>
</Route>
</Route>
<Route
path={routePaths.sessions}
element={
<Suspense fallback={<Spin />}>
<SessionsPage />
</Suspense>
}
/>
<Route
path={routePaths.securityLog}
element={
<Suspense fallback={<Spin />}>
<SecurityLogPage />
</Suspense>
}
/>
<Route
path={`${routePaths.appAccess}`}
element={
<Suspense fallback={<Spin />}>
<AppAccessPage />
</Suspense>
}
>
<Route
path=":id"
element={
<Suspense fallback={<Spin />}>
<AppAccessPage />
</Suspense>
}
/>
</Route>
<Route
path={routePaths.modules}
element={
<Suspense fallback={<Spin />}>
<ModulesPage />
</Suspense>
}
>
<Route path=":id">
<Route
path="configurations"
element={
<Suspense fallback={<Spin />}>
<div>Configurations</div>
</Suspense>
}
/>
<Route
path="connections"
element={
<Suspense fallback={<Spin />}>
<Connections />
</Suspense>
}
/>
</Route>
</Route>
</Route>
</Route>
<Route <Route
path=":id" path={routePaths.error}
element={
<Suspense fallback={<Spin />}>
<RolesPage />
</Suspense>
}
/>
</Route>
<Route
path={routePaths.applications}
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<ApplicationsPage /> <ErrorPage />
</Suspense> </Suspense>
} }
>
<Route
path=":id"
element={
<Suspense fallback={<Spin />}>
<ApplicationsPage />
</Suspense>
}
/>
</Route>
<Route
path={routePaths.sessions}
element={
<Suspense fallback={<Spin />}>
<SessionsPage />
</Suspense>
}
/>
<Route
path={routePaths.securityLog}
element={
<Suspense fallback={<Spin />}>
<SecurityLogPage />
</Suspense>
}
/>
<Route
path={`${routePaths.appAccess}`}
element={
<Suspense fallback={<Spin />}>
<AppAccessPage />
</Suspense>
}
>
<Route
path=":id"
element={
<Suspense fallback={<Spin />}>
<AppAccessPage />
</Suspense>
}
/> />
</Route> <Route
<Route path={routePaths.login}
path={routePaths.modules}
element={
<Suspense fallback={<Spin />}>
<ModulesPage />
</Suspense>
}
>
<Route path=":id">
<Route
path="configurations"
element={ element={
<Suspense fallback={<Spin />}> <Suspense fallback={<Spin />}>
<div>Configurations</div> <LoginPage />
</Suspense> </Suspense>
} }
/> />
<Route </Routes>
path="connections" )
element={
<Suspense fallback={<Spin />}>
<Connections />
</Suspense>
}
/>
</Route>
</Route>
</Route>
</Route>
<Route
path={routePaths.error}
element={
<Suspense fallback={<Spin />}>
<ErrorPage />
</Suspense>
}
/>
<Route
path={routePaths.login}
element={
<Suspense fallback={<Spin />}>
<LoginPage />
</Suspense>
}
/>
</Routes>
)
} }
export default Routers export default Routers
+6 -2
View File
@@ -9,8 +9,10 @@ type RoutePaths =
| 'securityLog' | 'securityLog'
| 'roles' | 'roles'
| 'appAccess' | 'appAccess'
| 'applicationsGroup'
| 'configuration'
| 'modules' | 'modules'
| 'applications' | 'application'
export const routePaths: Record<RoutePaths, string> = { export const routePaths: Record<RoutePaths, string> = {
home: '/', home: '/',
@@ -23,6 +25,8 @@ export const routePaths: Record<RoutePaths, string> = {
securityLog: '/securityLog', securityLog: '/securityLog',
roles: '/roles', roles: '/roles',
appAccess: '/appAccess', appAccess: '/appAccess',
applicationsGroup: '/applications_group',
configuration: '/configuration',
modules: '/modules', modules: '/modules',
applications: '/applications' application: 'application'
} }
+29 -18
View File
@@ -1,9 +1,11 @@
import { createApi } from '@reduxjs/toolkit/query/react' import { createApi } from '@reduxjs/toolkit/query/react'
import { apiPaths } from '@constants/api/apiPaths.ts' import { apiPaths } from '@constants/api/apiPaths.ts'
import { import {
ApplicationAppType, ApplicationAppType,
ApplicationsServiceType, NewApplicationAppType, ApplicationsServiceType,
NewApplicationAppType,
UpdateApplicationAppType UpdateApplicationAppType
} from '@pages/ApplicationsPage/applications.type.ts' } from '@pages/ApplicationsPage/applications.type.ts'
@@ -15,52 +17,61 @@ const applicationsApi = createApi({
tagTypes: ['Applications'], tagTypes: ['Applications'],
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
endpoints: (builder) => ({ endpoints: (builder) => ({
getAllApplicationsService: builder.query< getAllApplicationsService: builder.query<
ApplicationsServiceType[], ApplicationsServiceType[],
{ id: string } { id: string }
>({ >({
query: () => ({ url: apiPaths.getAllApplications }), query: () => ({ url: apiPaths.getAllApplications }),
providesTags: () => ['Applications'] providesTags: () => ['Applications']
}), }),
createApplicationService: builder.mutation< createApplicationService: builder.mutation<
ApplicationAppType, ApplicationAppType,
NewApplicationAppType NewApplicationAppType
>({ >({
query: ( NewApplicationsService) => ({ query: (NewApplicationsService) => ({
url: apiPaths.createUpdateApplication, url: apiPaths.createUpdateApplication,
data: NewApplicationsService data: NewApplicationsService
}), }),
invalidatesTags: ['Applications'] invalidatesTags: ['Applications']
}), }),
getApplicationsServiceById: builder.query<ApplicationsServiceType, { id : number}>({ getApplicationsServiceById: builder.query<
ApplicationsServiceType,
{ id: number }
>({
query: (id) => ({ query: (id) => ({
url: apiPaths.getApplicationById, url: apiPaths.getApplicationById,
data: id data: id
}), }),
providesTags: () => ['Applications']
}), }),
getApplicationsByServiceId: builder.query<ApplicationsServiceType[], { id : number}>({ getApplicationsByServiceId: builder.query<
ApplicationsServiceType[],
{ id: number }
>({
query: (id) => ({ query: (id) => ({
url: apiPaths.getApplicationsByServiceId, url: apiPaths.getApplicationsByServiceId,
data: id data: id
}), }),
providesTags: () => ['Applications']
}), }),
updateApplicationsService: builder.mutation<void, UpdateApplicationAppType>({ updateApplicationsService: builder.mutation<void, UpdateApplicationAppType>(
query: (updateApplications) => ({ {
url: apiPaths.createUpdateApplication, query: (updateApplications) => ({
data: updateApplications url: apiPaths.createUpdateApplication,
}), data: updateApplications
invalidatesTags: ['Applications'] }),
}), invalidatesTags: ['Applications']
}
),
removeApplicationsService: builder.mutation<void, number[]>({ removeApplicationsService: builder.mutation<void, number[]>({
query: ([id]) => ({ query: ([id]) => ({
url: apiPaths.deleteApplication, url: apiPaths.deleteApplication,
data: [ id] data: [id]
}), }),
invalidatesTags: ['Applications'] invalidatesTags: ['Applications']
}) })
+21 -4
View File
@@ -1,9 +1,11 @@
import { createApi } from '@reduxjs/toolkit/query/react' import { createApi } from '@reduxjs/toolkit/query/react'
import { apiPaths } from '@constants/api/apiPaths.ts' import { apiPaths } from '@constants/api/apiPaths.ts'
import { import {
ApplicationTokenType, ApplicationTokenType,
NewApplicationTokenType, NewApplicationTokenType,
RevokeTokenType
} from '@pages/ApplicationsPage/applications.type.ts' } from '@pages/ApplicationsPage/applications.type.ts'
import { axiosBaseQuery } from '@utils/apiUtils.ts' import { axiosBaseQuery } from '@utils/apiUtils.ts'
@@ -15,15 +17,30 @@ const tokensApi = createApi({
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
endpoints: (builder) => ({ endpoints: (builder) => ({
createToken: builder.mutation< createToken: builder.mutation<
ApplicationTokenType, ApplicationTokenType,
NewApplicationTokenType NewApplicationTokenType
>({ >({
query: ( NewApplicationTokenType) => ({ query: (NewApplicationTokenType) => ({
url: apiPaths.createToken, url: apiPaths.createToken,
data: NewApplicationTokenType data: NewApplicationTokenType
}), }),
invalidatesTags: ['Tokens'] invalidatesTags: ['Tokens']
}), }),
getTokensByAppId: builder.query<ApplicationTokenType[], { id: number }>({
query: (id) => ({
url: apiPaths.getTokensByAppId,
data: id
}),
providesTags: ['Tokens']
}),
revokeTokens: builder.mutation<void, RevokeTokenType>({
query: (el) => ({
url: apiPaths.revokeTokens,
data: el
}),
invalidatesTags: ['Tokens']
})
}) })
}) })
+5 -2
View File
@@ -12,6 +12,7 @@ import roleApi from '@services/roleService.ts'
import routeApi from '@services/routeService.ts' import routeApi from '@services/routeService.ts'
import securityLogServiceApi from '@services/securityLogService.ts' import securityLogServiceApi from '@services/securityLogService.ts'
import sessionServiceApi from '@services/sessionService.ts' import sessionServiceApi from '@services/sessionService.ts'
import tokensApi from '@services/tokensService.ts'
import userServiceApi from '@services/userService.ts' import userServiceApi from '@services/userService.ts'
import profileReducer from './redusers/ProfileSlice.ts' import profileReducer from './redusers/ProfileSlice.ts'
@@ -39,7 +40,8 @@ const rootReducer = combineReducers({
[routeApi.reducerPath]: routeApi.reducer, [routeApi.reducerPath]: routeApi.reducer,
[modulesServiceApi.reducerPath]: modulesServiceApi.reducer, [modulesServiceApi.reducerPath]: modulesServiceApi.reducer,
[applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer, [applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer,
[applicationsApi.reducerPath]: applicationsApi.reducer [applicationsApi.reducerPath]: applicationsApi.reducer,
[tokensApi.reducerPath]: tokensApi.reducer
}) })
export const setupStore = () => export const setupStore = () =>
@@ -57,7 +59,8 @@ export const setupStore = () =>
sessionServiceApi.middleware, sessionServiceApi.middleware,
modulesServiceApi.middleware, modulesServiceApi.middleware,
applicationsGroupApi.middleware, applicationsGroupApi.middleware,
applicationsApi.middleware applicationsApi.middleware,
tokensApi.middleware
) )
}) })