2024-04-27 16:21:14: merge [main:aa6853211bb46e321bc26b3b8132b18c03592910];
This commit is contained in:
1 parent
a31c44eb7b
commit
a6f4c85231
38 files changed
+1966
-60
No files matched your search
@@ -1,3 +1,10 @@
|
||||
## 0.10.1
|
||||
- В index.html добавлен config.js
|
||||
- Добавлены динамические стили для админок
|
||||
## 0.10.0
|
||||
- - Добавлена страница 'Модули'
|
||||
## 0.9.0
|
||||
-Добавлена страница приложений
|
||||
## 0.8.1
|
||||
- Перенос UserMenu в список главного меню в Layout
|
||||
## 0.8.0
|
||||
|
||||
+3
-1
@@ -8,7 +8,9 @@
|
||||
<script type="module">
|
||||
window.AppVersion = APP_VERSION
|
||||
</script>
|
||||
</head>
|
||||
<script type="module" src="/config.js"></script>
|
||||
<title>Панель администратора</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
|
||||
Generated
+20
-7
@@ -1,17 +1,19 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"version": "0.8.0",
|
||||
"version": "0.8.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "isp-admin-ui",
|
||||
"version": "0.8.0",
|
||||
"version": "0.8.1",
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"axios": "^1.6.8",
|
||||
"isp-ui-kit": "https://github.com/txix-open/isp-ui-kit",
|
||||
"isp-ui-kit": "github:txix-open/isp-ui-kit",
|
||||
"moment": "^2.30.1",
|
||||
"compare-versions": "^6.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.51.2",
|
||||
@@ -4969,6 +4971,11 @@
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/compare-versions": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.0.tgz",
|
||||
"integrity": "sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg=="
|
||||
},
|
||||
"node_modules/compute-scroll-into-view": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-3.1.0.tgz",
|
||||
@@ -7055,8 +7062,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/isp-ui-kit": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#508a5bd9cb4efac0e9389ad2f9f8c60683d1712e",
|
||||
"version": "0.3.4",
|
||||
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#ee517a533f9e4934d08bf6d70cdfda31198cba4c",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@codemirror/lang-javascript": "^6.2.1",
|
||||
@@ -7371,6 +7378,14 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.30.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
|
||||
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@@ -7430,7 +7445,6 @@
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@@ -7810,7 +7824,6 @@
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.4.0",
|
||||
"object-assign": "^4.1.1",
|
||||
|
||||
+4
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"private": true,
|
||||
"version": "0.8.1",
|
||||
"version": "0.10.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
@@ -17,7 +17,9 @@
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"axios": "^1.6.8",
|
||||
"isp-ui-kit": "https://github.com/txix-open/isp-ui-kit",
|
||||
"compare-versions": "^6.1.0",
|
||||
"moment": "^2.30.1",
|
||||
"isp-ui-kit": "github:txix-open/isp-ui-kit",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hook-form": "^7.51.2",
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,19 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-content {
|
||||
padding: $basic-padding *2 $basic-padding;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
&__add-btn {
|
||||
max-width: 240px;
|
||||
margin-left: auto;
|
||||
margin-bottom: $basic-margin * 2;
|
||||
}
|
||||
&__update-btn {
|
||||
margin-right: $basic-margin;
|
||||
}
|
||||
&__addToken-btn {
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
import {
|
||||
EditOutlined,
|
||||
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 { FC, 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 {
|
||||
ApplicationAppType,
|
||||
ApplicationsServiceType,
|
||||
ApplicationTokenType,
|
||||
NewApplicationAppType,
|
||||
NewApplicationTokenType,
|
||||
UpdateApplicationAppType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
import tokensApi from '@services/tokensService.ts'
|
||||
|
||||
import './applications-content.scss'
|
||||
|
||||
const { FormInput, FormSelect } = FormComponents
|
||||
const { EmptyData } = Layout
|
||||
|
||||
interface ApplicationsContentPropTypes {
|
||||
id: number
|
||||
}
|
||||
|
||||
const ApplicationsContent: FC<ApplicationsContentPropTypes> = (id) => {
|
||||
const { data: applications, isLoading: isLoadingApplicationsContent = [] } =
|
||||
applicationsApi.useGetApplicationsByServiceIdQuery(id)
|
||||
|
||||
const [createApplicationService] =
|
||||
applicationsApi.useCreateApplicationServiceMutation()
|
||||
const [updateApplication] =
|
||||
applicationsApi.useUpdateApplicationsServiceMutation()
|
||||
const [removeApplicationsService] =
|
||||
applicationsApi.useRemoveApplicationsServiceMutation()
|
||||
const [createToken] = tokensApi.useCreateTokenMutation()
|
||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
||||
addModal: false,
|
||||
updateModal: false,
|
||||
addToken: false
|
||||
})
|
||||
const [currentApplicationsApp, setCurrentApplicationsApp] =
|
||||
useState<ApplicationAppType>()
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control: controlApplicationApp,
|
||||
reset
|
||||
} = useForm<ApplicationAppType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
const { handleSubmit: handleSubmitTokens, control: controlTokens } =
|
||||
useForm<ApplicationTokenType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
const handleShowUpdateModalApplicationApp = (data: ApplicationAppType) => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: true
|
||||
})
|
||||
setCurrentApplicationsApp(data)
|
||||
}
|
||||
const handleShowCreateModalApplicationApp = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: true
|
||||
})
|
||||
}
|
||||
const handleShowAddModalToken = (data: ApplicationAppType) => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addToken: true
|
||||
})
|
||||
setCurrentApplicationsApp(data)
|
||||
}
|
||||
|
||||
const handleUpdateApplicationApp = (data: UpdateApplicationAppType) => {
|
||||
if (currentApplicationsApp) {
|
||||
const updateApplications: UpdateApplicationAppType = {
|
||||
id: currentApplicationsApp.id,
|
||||
name: data.name,
|
||||
description: data.description
|
||||
? data.description
|
||||
: currentApplicationsApp.description,
|
||||
serviceId: id.id,
|
||||
type: 'SYSTEM'
|
||||
}
|
||||
updateApplication({ ...currentApplicationsApp, ...updateApplications })
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
reset()
|
||||
message.info('Элемент сохранен')
|
||||
})
|
||||
.catch(() => message.error('Ошибка обновления элемента'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateApplicationApp = (data: NewApplicationAppType) => {
|
||||
const newApplicationApp: NewApplicationAppType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
serviceId: id.id,
|
||||
type: 'SYSTEM'
|
||||
}
|
||||
|
||||
createApplicationService(newApplicationApp)
|
||||
.unwrap()
|
||||
.then(message.info('Элемент сохранен'))
|
||||
.catch((e) => message.error(e))
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
reset()
|
||||
}
|
||||
const handleRemoveApplicationApp = (id: number) =>
|
||||
removeApplicationsService([id])
|
||||
.then(() => {
|
||||
message.info('Элемент удален')
|
||||
})
|
||||
.catch(message.error('Ошибка добавления элемента'))
|
||||
|
||||
const handleCreateToken = (data: NewApplicationTokenType) => {
|
||||
if (currentApplicationsApp) {
|
||||
const newToken: NewApplicationTokenType = {
|
||||
expireTimeMs: data.expireTimeMs,
|
||||
appId: currentApplicationsApp.id
|
||||
}
|
||||
|
||||
createToken(newToken)
|
||||
.then(() => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addToken: false
|
||||
})
|
||||
reset()
|
||||
message.info('Элемент добавлен')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Ошибка добавления элемента')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ApplicationsServiceType> = [
|
||||
{
|
||||
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 />
|
||||
}
|
||||
|
||||
if (isLoadingApplicationsContent) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="applications-content">
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="applications-content__add-btn"
|
||||
type="primary"
|
||||
onClick={handleShowCreateModalApplicationApp}
|
||||
>
|
||||
Добавить
|
||||
</Button>
|
||||
</CanEdit>
|
||||
<Table
|
||||
expandable={{
|
||||
expandedRowRender: (record) => (
|
||||
<CanEdit>
|
||||
<Button
|
||||
className="applications-content__addToken-btn"
|
||||
onClick={() => handleShowAddModalToken(record.app)}
|
||||
>
|
||||
<PlusSquareOutlined /> Добавить токен
|
||||
</Button>
|
||||
</CanEdit>
|
||||
)
|
||||
}}
|
||||
className="appliactions-content__table"
|
||||
rowKey={(record) => record.app.id}
|
||||
pagination={false}
|
||||
dataSource={applications}
|
||||
columns={columns}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleUpdateApplicationApp)}
|
||||
title="Редактировать"
|
||||
open={showApplicationsModal.updateModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleCreateApplicationApp)}
|
||||
title="Добавить"
|
||||
open={showApplicationsModal.addModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput
|
||||
control={controlApplicationApp}
|
||||
label="Описание"
|
||||
name="description"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<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>
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationsContent
|
||||
@@ -4,13 +4,13 @@ import { useRole } from '@hooks/useRole.tsx'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
const AdminPermission = ({ children }: PropsWithChildren) => {
|
||||
const CanEdit = ({ children }: PropsWithChildren) => {
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
if (hasPermission(PermissionKeysType.read)) {
|
||||
if (hasPermission(PermissionKeysType.write)) {
|
||||
return <>{children}</>
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export default AdminPermission
|
||||
export default CanEdit
|
||||
@@ -0,0 +1,46 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.connection-page {
|
||||
&__content {
|
||||
padding: 2 * $basic-padding 3 * $basic-padding 2 * $basic-padding 0;
|
||||
width: 100%;
|
||||
|
||||
&__wrap-table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 100px);
|
||||
}
|
||||
}
|
||||
|
||||
&__endpoint-list {
|
||||
&__item {
|
||||
height: 25px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
&__inner-marker {
|
||||
font-size: 11px;
|
||||
border: 1px solid #15D1E6;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
import { Spin, Table, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import moment from 'moment'
|
||||
import 'moment/dist/locale/ru'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
AddressType,
|
||||
EndpointType,
|
||||
ModuleStatusType,
|
||||
ModuleType
|
||||
} from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './connections.scss'
|
||||
|
||||
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) =>
|
||||
moment(obj).format('YYYY-MM-DD, HH:mm:ss')
|
||||
|
||||
const keySelector = ({
|
||||
address: { ip, port },
|
||||
establishedAt
|
||||
}: ModuleStatusType) => ip + port + establishedAt
|
||||
|
||||
const renderEndpoints = ({ endpoints }: ModuleStatusType) => {
|
||||
if (endpoints && endpoints.length) {
|
||||
return (
|
||||
<ul className="connection-page__endpoint-list">
|
||||
{endpoints.map(({ path, inner }) => (
|
||||
<li className="connection-page__endpoint-list__item" key={path}>
|
||||
{path}
|
||||
{inner && (
|
||||
<span className="connection-page__endpoint-list__inner-marker">
|
||||
Внутренний
|
||||
</span>
|
||||
)}
|
||||
</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) => (
|
||||
<Tooltip title={formatFullDate(val)}>{moment(val).fromNow()}</Tooltip>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Реализованные методы',
|
||||
dataIndex: 'endpoints',
|
||||
key: 'endpoints',
|
||||
render: (value: EndpointType[]) => (value && value.length) || '0'
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<section className="connection-page">
|
||||
<div className="connection-page__content">
|
||||
<div className="connection-page__content__wrap-table">
|
||||
<Table
|
||||
rowKey={keySelector}
|
||||
pagination={false}
|
||||
dataSource={obj}
|
||||
columns={columns}
|
||||
expandable={{
|
||||
expandedRowRender: (i) => renderEndpoints(i)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Connections
|
||||
@@ -1,7 +1,8 @@
|
||||
import {
|
||||
LockOutlined,
|
||||
LogoutOutlined,
|
||||
ProfileOutlined
|
||||
ProfileOutlined,
|
||||
AppstoreAddOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
@@ -12,6 +13,7 @@ import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
import DefaultUser from '@components/Icons/DefaultUser.tsx'
|
||||
import {
|
||||
MenuItemKeysType,
|
||||
MenuItemLabelsType,
|
||||
MenuItemType,
|
||||
menuKeys
|
||||
} from '@components/Layout/layout.type.ts'
|
||||
@@ -22,13 +24,15 @@ import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
|
||||
import useLogout from '@hooks/useLogout.tsx'
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import { fetchProfile } from '@stores/redusers/ActionCreators.ts'
|
||||
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 Header from 'src/widgets/Header'
|
||||
|
||||
import './layout.scss'
|
||||
|
||||
const { Content, Sider } = Layout
|
||||
@@ -38,6 +42,7 @@ const LayoutComponent = () => {
|
||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
|
||||
[]
|
||||
)
|
||||
const [title, setTitle] = useState('')
|
||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
||||
const dispatch = useAppDispatch()
|
||||
const {
|
||||
@@ -81,6 +86,12 @@ const LayoutComponent = () => {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Группа приложений',
|
||||
key: 'applications',
|
||||
className: hideItem([PermissionKeysType.read]),
|
||||
icon: <AppstoreAddOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Доступы приложений',
|
||||
key: 'appAccess',
|
||||
@@ -114,6 +125,12 @@ const LayoutComponent = () => {
|
||||
className: hideItem(PermissionKeysType.read)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Модули',
|
||||
key: 'modules',
|
||||
className: hideItem(PermissionKeysType.read),
|
||||
icon: <ProfileOutlined />
|
||||
}
|
||||
]
|
||||
|
||||
@@ -130,6 +147,7 @@ const LayoutComponent = () => {
|
||||
useEffect(() => {
|
||||
if (userToken) {
|
||||
dispatch(fetchProfile())
|
||||
dispatch(fetchUI())
|
||||
}
|
||||
}, [])
|
||||
|
||||
@@ -139,6 +157,7 @@ const LayoutComponent = () => {
|
||||
const menuItem = menuKeys[menuKey]
|
||||
|
||||
if (menuItem) {
|
||||
setTitle(MenuItemLabelsType[menuItem.key])
|
||||
setSelectedMenuKeys([menuItem.key])
|
||||
setOpenKeys(menuItem.parent)
|
||||
}
|
||||
@@ -169,6 +188,12 @@ const LayoutComponent = () => {
|
||||
case MenuItemKeysType.roles:
|
||||
navigate(routePaths.roles)
|
||||
break
|
||||
case MenuItemKeysType.modules:
|
||||
navigate(routePaths.modules)
|
||||
break
|
||||
case MenuItemKeysType.applications:
|
||||
navigate(routePaths.applications)
|
||||
break
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -178,37 +203,40 @@ const LayoutComponent = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
{status === StateProfileStatus.pending ? (
|
||||
<Spin size="large" />
|
||||
) : (
|
||||
<>
|
||||
<Sider
|
||||
width="250px"
|
||||
data-cy="aside"
|
||||
theme="light"
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={(value) => setCollapsed(value)}
|
||||
>
|
||||
<Menu
|
||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
||||
openKeys={openKeys}
|
||||
selectedKeys={selectedMenuKeys}
|
||||
onClick={handlerOnClickMenu}
|
||||
<section>
|
||||
<Header title={title} />
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
{status === StateProfileStatus.pending ? (
|
||||
<Spin size="large" />
|
||||
) : (
|
||||
<>
|
||||
<Sider
|
||||
width="250px"
|
||||
data-cy="aside"
|
||||
theme="light"
|
||||
mode="inline"
|
||||
items={menuItems}
|
||||
/>
|
||||
</Sider>
|
||||
<Layout className="site-layout">
|
||||
<Content className="site-layout__content">
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
</>
|
||||
)}
|
||||
</Layout>
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={(value) => setCollapsed(value)}
|
||||
>
|
||||
<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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@import 'src/constants/style/styleConst';
|
||||
|
||||
.layout {
|
||||
min-height: 100vh !important;
|
||||
min-height: calc(100vh - 65px) !important;
|
||||
position: relative;
|
||||
|
||||
.hide-item {
|
||||
|
||||
@@ -7,7 +7,20 @@ export enum MenuItemKeysType {
|
||||
appAccess = 'appAccess',
|
||||
roles = 'roles',
|
||||
logout = 'logout',
|
||||
profile = 'profile'
|
||||
profile = 'profile',
|
||||
modules = 'modules',
|
||||
applications = 'applications'
|
||||
}
|
||||
export enum MenuItemLabelsType {
|
||||
users = 'Пользователи',
|
||||
sessions = 'Пользовательские сессии',
|
||||
securityLog = 'Просмотр журналов ИБ',
|
||||
appAccess = 'Доступы приложений',
|
||||
roles = 'Роли',
|
||||
profile = 'Профиль',
|
||||
modules = 'Модули',
|
||||
applications = 'Группа приложений',
|
||||
logout = 'Выход',
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
@@ -42,6 +55,14 @@ export const menuKeys: Record<MenuItemKeysType, MenuItem> = {
|
||||
[MenuItemKeysType.profile]: {
|
||||
key: MenuItemKeysType.profile,
|
||||
parent: ['']
|
||||
},
|
||||
[MenuItemKeysType.modules]: {
|
||||
key: MenuItemKeysType.modules,
|
||||
parent: []
|
||||
},
|
||||
[MenuItemKeysType.applications]: {
|
||||
key: MenuItemKeysType.applications,
|
||||
parent: ['']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
.app{
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
padding: 0 $basic-padding;
|
||||
min-height: 0;
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,23 @@ type PathKeys =
|
||||
| 'setList'
|
||||
| 'setOne'
|
||||
| 'getAllRoutes'
|
||||
| 'getModules'
|
||||
| 'deleteModule'
|
||||
| 'createUpdateService'
|
||||
| 'deleteService'
|
||||
| 'getAllService'
|
||||
| 'getServiceById'
|
||||
| 'getServicesByDomainId'
|
||||
| 'createUpdateApplication'
|
||||
| 'deleteApplication'
|
||||
| 'getApplicationById'
|
||||
| 'getAllApplications'
|
||||
| 'getApplicationsByServiceId'
|
||||
| 'createToken'
|
||||
| 'getTokensByAppId'
|
||||
| 'revokeTokens'
|
||||
| 'revokeTokensForApp'
|
||||
| 'getUI'
|
||||
|
||||
export const apiPaths: Record<PathKeys, string> = {
|
||||
baseUrl: '/api/kkd-configuration-service',
|
||||
@@ -45,6 +62,7 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
logout: '/api/admin/auth/logout',
|
||||
// ======= PROFILE ======
|
||||
getProfile: '/api/admin/user/get_profile',
|
||||
getUI: '/api/admin/user/get_design',
|
||||
// ======= USERS ======
|
||||
getUsers: '/get_users',
|
||||
createUser: '/create_user',
|
||||
@@ -62,9 +80,28 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
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'
|
||||
getAllRoutes: '/routing/get_routes',
|
||||
// ======= MODULES ======
|
||||
getModules: '/module/get_modules_info',
|
||||
deleteModule: '/module/delete_module',
|
||||
// ======= 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'
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-page {
|
||||
height: 100%;
|
||||
.three-columns {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
box-shadow: inset -1px 0px 0px $border-color;
|
||||
|
||||
height: 100%;
|
||||
|
||||
.column__header {
|
||||
padding: $basic-padding * 2 $basic-padding;
|
||||
|
||||
svg {
|
||||
fill: $blue-color;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-input-affix-wrapper {
|
||||
.ant-input-prefix {
|
||||
margin-left: auto;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-input-affix-wrapper-focused {
|
||||
.ant-input-prefix {
|
||||
.anticon-search {
|
||||
svg {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-list-items {
|
||||
.column__items__item {
|
||||
.ant-list-item-meta-title {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
font-weight: 400;
|
||||
color: $text-color-gray;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $blue-light !important;
|
||||
|
||||
.ant-list-item-meta-title {
|
||||
color: $text-color-blue;
|
||||
}
|
||||
|
||||
svg {
|
||||
path {
|
||||
fill: $text-color-blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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 = Omit<ApplicationTokenType, 'createdAt' | 'token'>
|
||||
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 interface ApplicationTokenType {
|
||||
appId: number,
|
||||
createdAt: string,
|
||||
expireTimeMs: number,
|
||||
token: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
import { message, Spin } from 'antd'
|
||||
import { Layout, FormComponents } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import { ValidationRules } from '@constants/form/validationRules.ts'
|
||||
|
||||
import ListItem from '@widgets/ListItem'
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import ApplicationsContent from '@components/ApplicationsContent'
|
||||
|
||||
import {
|
||||
NewApplicationsGroupType,
|
||||
ApplicationsGroupType,
|
||||
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 './applications-page.scss'
|
||||
|
||||
const { Column, ContentColumn, EmptyData } = Layout
|
||||
const { FormInput } = FormComponents
|
||||
|
||||
const ApplicationsPage = () => {
|
||||
const navigate = useNavigate()
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const [searchParams, setSearchParams] = useSearchParams('')
|
||||
const { hasPermission } = useRole()
|
||||
|
||||
const {
|
||||
data: applicationsGroup = [],
|
||||
isError: isErrorApplicationsGroup,
|
||||
isLoading: isLoadingApplicationsGroup
|
||||
} = applicationsGroupApi.useGetApplicationsGroupByDomainIdQuery({ id: 2 })
|
||||
|
||||
const [createApplicationsGroup] =
|
||||
applicationsGroupApi.useCreateApplicationsGroupMutation()
|
||||
const [updateApplicationsGroup] =
|
||||
applicationsGroupApi.useUpdateApplicationsGroupMutation()
|
||||
|
||||
const [deleteApplicationsGroup] =
|
||||
applicationsGroupApi.useRemoveApplicationsGroupMutation()
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
|
||||
const [showApplicationsModal, setShowApplicationsModal] = useState({
|
||||
addModal: false,
|
||||
updateModal: false
|
||||
})
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
const { handleSubmit, control, reset } = useForm<ApplicationsGroupType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
if (isErrorApplicationsGroup) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
if (isLoadingApplicationsGroup) {
|
||||
return <Spin className="spin" />
|
||||
}
|
||||
|
||||
const renderColumnItems = (item: ColumnItem<any>) => <ListItem item={item} />
|
||||
|
||||
const addApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: true
|
||||
})
|
||||
}
|
||||
|
||||
const updateApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: true
|
||||
})
|
||||
}
|
||||
|
||||
const handleAddApplicationGroup = (data: any) => {
|
||||
const newService: NewApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
domainId: 2
|
||||
}
|
||||
createApplicationsGroup(newService)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
reset()
|
||||
message.info('Сервис успешно создан')
|
||||
}
|
||||
|
||||
const handleUpdateApplicationsGroup = (data: NewApplicationsGroupType) => {
|
||||
const updateService: UpdateApplicationsGroupType = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
domainId: 2,
|
||||
id: Number(selectedItemId)
|
||||
}
|
||||
|
||||
updateApplicationsGroup(updateService)
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
|
||||
reset()
|
||||
message.info('Сервис успешно отредактирован')
|
||||
}
|
||||
|
||||
const renderMainContent = () => {
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
return <ApplicationsContent id={Number(selectedItemId)} />
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="applications-page ">
|
||||
<div className="applications-page__wrap three-columns">
|
||||
<Column
|
||||
onUpdateItem={updateApplicationModal}
|
||||
showUpdateBtn={!!selectedItemId}
|
||||
onAddItem={addApplicationModal}
|
||||
onRemoveItem={() => deleteApplicationsGroup([Number(selectedItemId)])}
|
||||
items={filterFirstColumnItems(
|
||||
applicationsGroup as unknown as ColumnItem<ApplicationsGroupType>[],
|
||||
searchValue
|
||||
)}
|
||||
renderItems={renderColumnItems}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={(itemId) => {
|
||||
setSelectedItemId(
|
||||
`${routePaths.applications}`,
|
||||
itemId,
|
||||
searchValue,
|
||||
navigate
|
||||
)
|
||||
}}
|
||||
onChangeSearchValue={(value) =>
|
||||
setSearchValue(value, setSearchParams)
|
||||
}
|
||||
/>
|
||||
|
||||
<ContentColumn>{renderMainContent()}</ContentColumn>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleAddApplicationGroup)}
|
||||
title="Добавить"
|
||||
open={showApplicationsModal.addModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
addModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput control={control} label="Описание" name="description" />
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
onOk={handleSubmit(handleUpdateApplicationsGroup)}
|
||||
title="Редактировать"
|
||||
open={showApplicationsModal.updateModal}
|
||||
footer={{ onCanselText: 'Отмена', onOkText: 'Сохранить' }}
|
||||
onClose={() =>
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
updateModal: false
|
||||
})
|
||||
}
|
||||
>
|
||||
<form>
|
||||
<FormInput
|
||||
control={control}
|
||||
name="name"
|
||||
label="Наименование"
|
||||
rules={{ required: ValidationRules.required }}
|
||||
/>
|
||||
<FormInput control={control} label="Описание" name="description" />
|
||||
</form>
|
||||
</Modal>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationsPage
|
||||
@@ -0,0 +1,239 @@
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons'
|
||||
import { List, message, Spin, Tabs, Tag, Tooltip } from 'antd'
|
||||
import { compareVersions } from 'compare-versions'
|
||||
import { Layout } from 'isp-ui-kit'
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
createSearchParams,
|
||||
Outlet,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
useParams,
|
||||
useSearchParams
|
||||
} from 'react-router-dom'
|
||||
|
||||
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, EmptyData, NoData } = Layout
|
||||
|
||||
const ModulesPage = () => {
|
||||
const [activeTab, setActiveTab] = useState('configurations')
|
||||
const { id: selectedItemId = '' } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const { role, hasPermission } = useRole()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const { data: ModulesList = [], isLoading: isModulesLoading } =
|
||||
modulesServiceApi.useGetModulesQuery('modules', {
|
||||
pollingInterval: 1000,
|
||||
skipPollingIfUnfocused: true
|
||||
})
|
||||
const [removeModule] = modulesServiceApi.useRemoveModuleMutation()
|
||||
const location = useLocation()
|
||||
|
||||
const searchValue = searchParams.get('search') || ''
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
const isRemoveModule = hasPermission(PermissionKeysType.write)
|
||||
const isLoading = isModulesLoading
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [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 currentRole = ModulesList
|
||||
? ModulesList.find(
|
||||
(item: ModuleType) => item.id.toString() === selectedItemId
|
||||
)
|
||||
: null
|
||||
|
||||
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>
|
||||
<div className="module-item">
|
||||
<div className="module-item__name">
|
||||
<span>{item.name}</span>
|
||||
<Tooltip overlayInnerStyle={{ width: '300px' }} title={textTooltip}>
|
||||
{renderVersion()}
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className="module-item__content">
|
||||
<span className="module-item__content__description">
|
||||
активные экземпляры:
|
||||
</span>
|
||||
<strong
|
||||
className={`module-item__content__status ${
|
||||
!item.status || !item.status.length
|
||||
? 'module-item__content__status_zero'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
{(item.status && item.status.length) || '0'}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
|
||||
const renderMainContent = () => {
|
||||
if (!selectedItemId) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
if (!currentRole) {
|
||||
return <NoData />
|
||||
}
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
const secondColumnItems = [
|
||||
{
|
||||
key: 'configurations',
|
||||
name: 'Конфигурации'
|
||||
},
|
||||
{ key: 'connections', name: 'Подключения' }
|
||||
]
|
||||
|
||||
return (
|
||||
<section className="modules-page three-columns">
|
||||
<Column
|
||||
items={filterFirstColumnItems(ModulesList, searchValue)}
|
||||
showAddBtn={false}
|
||||
showRemoveBtn={isRemoveModule}
|
||||
onRemoveItem={handleRemoveModule}
|
||||
onChangeSearchValue={handleOnChangeSearchValue}
|
||||
renderItems={renderItems}
|
||||
searchValue={searchValue}
|
||||
selectedItemId={selectedItemId}
|
||||
setSelectedItemId={setSelectedItemId}
|
||||
/>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={(activeKey) => {
|
||||
setActiveTab(activeKey)
|
||||
const path = `${selectedItemId}/${activeKey}`
|
||||
navigate(path)
|
||||
}}
|
||||
className="modules-page__tabs"
|
||||
tabPosition={'left'}
|
||||
items={secondColumnItems.map((item) => {
|
||||
return {
|
||||
disabled: selectedItemId === '',
|
||||
label: item.name,
|
||||
key: item.key,
|
||||
children: (
|
||||
<div className="modules-page__content">{renderMainContent()}</div>
|
||||
)
|
||||
}
|
||||
})}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModulesPage
|
||||
@@ -0,0 +1,89 @@
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.modules-page {
|
||||
height: 100%;
|
||||
|
||||
&__tabs {
|
||||
overflow-x: scroll;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-list-item {
|
||||
padding-bottom: 20px;
|
||||
|
||||
}
|
||||
|
||||
.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;
|
||||
|
||||
&__description {
|
||||
color: $grey;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
&__status {
|
||||
border: 1px solid #15d1e6;
|
||||
border-radius: 12px;
|
||||
padding: 0 4px;
|
||||
font-family: sans-serif;
|
||||
opacity: .7;
|
||||
height: 22px;
|
||||
width: 22px;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__status_zero {
|
||||
border: 1px solid red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&__content {
|
||||
overflow-x: scroll;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.three-columns {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
box-shadow: inset -1px 0px 0px $border-color;
|
||||
|
||||
height: 100%;
|
||||
|
||||
.column__header {
|
||||
padding: $basic-padding * 2 $basic-padding;
|
||||
|
||||
svg {
|
||||
fill: $blue-color;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-input-affix-wrapper {
|
||||
.ant-input-prefix {
|
||||
margin-left: auto;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-input-affix-wrapper-focused {
|
||||
.ant-input-prefix {
|
||||
.anticon-search {
|
||||
svg {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-list-items {
|
||||
.column__items__item {
|
||||
.ant-list-item-meta-title {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
font-weight: 400;
|
||||
color: $text-color-gray;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $blue-light !important;
|
||||
|
||||
.ant-list-item-meta-title {
|
||||
color: $text-color-blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-tabs-nav-list {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.ant-tabs-tab {
|
||||
justify-content: flex-end;
|
||||
margin: 10px 0 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.column .column__items__item span {
|
||||
width: fit-content;
|
||||
}
|
||||
@@ -15,3 +15,14 @@ export type ProfileType = {
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
|
||||
export type UIDataType = {
|
||||
name: string
|
||||
primaryColor: string
|
||||
}
|
||||
|
||||
export type UIType = {
|
||||
ui: UIDataType
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
@@ -18,6 +18,9 @@ const UserEditor = lazy(() => import('src/pages/UserEditor'))
|
||||
const SessionsPage = lazy(() => import('@pages/SessionsPage'))
|
||||
const SecurityLogPage = lazy(() => import('@pages/SecurityLogPage'))
|
||||
const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
|
||||
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
|
||||
const Connections = lazy(() => import('@components/Connections'))
|
||||
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
||||
|
||||
const Routers = () => {
|
||||
return (
|
||||
@@ -73,6 +76,23 @@ const Routers = () => {
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.applications}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.sessions}
|
||||
element={
|
||||
@@ -106,6 +126,33 @@ const Routers = () => {
|
||||
}
|
||||
/>
|
||||
</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
|
||||
|
||||
@@ -9,6 +9,8 @@ type RoutePaths =
|
||||
| 'securityLog'
|
||||
| 'roles'
|
||||
| 'appAccess'
|
||||
| 'modules'
|
||||
| 'applications'
|
||||
|
||||
export const routePaths: Record<RoutePaths, string> = {
|
||||
home: '/',
|
||||
@@ -20,5 +22,7 @@ export const routePaths: Record<RoutePaths, string> = {
|
||||
sessions: '/sessions',
|
||||
securityLog: '/securityLog',
|
||||
roles: '/roles',
|
||||
appAccess: '/appAccess'
|
||||
appAccess: '/appAccess',
|
||||
modules: '/modules',
|
||||
applications: '/applications'
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { AppApiResponseType, DomainType } from '@type/app.type.ts'
|
||||
const appApi = createApi({
|
||||
reducerPath: 'appService',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['SystemTreeApps'],
|
||||
tagTypes: ['SystemTreeApps' , 'Application'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getSystemTree: builder.query<AppApiResponseType, void>({
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import {
|
||||
ApplicationsGroupType,
|
||||
NewApplicationsGroupType,
|
||||
UpdateApplicationsGroupType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
const applicationsGroupApi = createApi({
|
||||
reducerPath: 'applicationsGroupApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['ApplicationsGroup'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getApplicationsGroupByDomainId: builder.query<
|
||||
ApplicationsGroupType,
|
||||
{ id: number }
|
||||
>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getServicesByDomainId,
|
||||
data: id
|
||||
}),
|
||||
providesTags: () => ['ApplicationsGroup']
|
||||
}),
|
||||
|
||||
getApplicationsGroupByServiceId: builder.query<
|
||||
ApplicationsGroupType[],
|
||||
{ id: number }
|
||||
>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getServiceById,
|
||||
data: id
|
||||
}),
|
||||
providesTags: () => ['ApplicationsGroup']
|
||||
}),
|
||||
|
||||
getAllApplicationsGroup: builder.query<
|
||||
ApplicationsGroupType[],
|
||||
{ id: string }
|
||||
>({
|
||||
query: () => ({ url: apiPaths.getAllService }),
|
||||
providesTags: () => ['ApplicationsGroup']
|
||||
}),
|
||||
|
||||
createApplicationsGroup: builder.mutation<
|
||||
ApplicationsGroupType,
|
||||
NewApplicationsGroupType
|
||||
>({
|
||||
query: (newApplicationsGroup) => ({
|
||||
url: apiPaths.createUpdateService,
|
||||
data: newApplicationsGroup
|
||||
}),
|
||||
invalidatesTags: ['ApplicationsGroup']
|
||||
}),
|
||||
|
||||
updateApplicationsGroup: builder.mutation<
|
||||
void,
|
||||
UpdateApplicationsGroupType
|
||||
>({
|
||||
query: (updateApplicationsGroup) => ({
|
||||
url: apiPaths.createUpdateService,
|
||||
data: updateApplicationsGroup
|
||||
}),
|
||||
invalidatesTags: ['ApplicationsGroup']
|
||||
}),
|
||||
|
||||
removeApplicationsGroup: builder.mutation<void, number[]>({
|
||||
query: ([id]) => ({
|
||||
url: apiPaths.deleteService,
|
||||
data: [id]
|
||||
}),
|
||||
invalidatesTags: ['ApplicationsGroup']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default applicationsGroupApi
|
||||
@@ -0,0 +1,70 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import {
|
||||
ApplicationAppType,
|
||||
ApplicationsServiceType, NewApplicationAppType,
|
||||
UpdateApplicationAppType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
const applicationsApi = createApi({
|
||||
reducerPath: 'applicationsApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['Applications'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
|
||||
getAllApplicationsService: builder.query<
|
||||
ApplicationsServiceType[],
|
||||
{ id: string }
|
||||
>({
|
||||
query: () => ({ url: apiPaths.getAllApplications }),
|
||||
providesTags: () => ['Applications']
|
||||
}),
|
||||
|
||||
createApplicationService: builder.mutation<
|
||||
ApplicationAppType,
|
||||
NewApplicationAppType
|
||||
>({
|
||||
query: ( NewApplicationsService) => ({
|
||||
url: apiPaths.createUpdateApplication,
|
||||
data: NewApplicationsService
|
||||
}),
|
||||
invalidatesTags: ['Applications']
|
||||
}),
|
||||
|
||||
getApplicationsServiceById: builder.query<ApplicationsServiceType, { id : number}>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getApplicationById,
|
||||
data: id
|
||||
}),
|
||||
}),
|
||||
|
||||
getApplicationsByServiceId: builder.query<ApplicationsServiceType[], { id : number}>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getApplicationsByServiceId,
|
||||
data: id
|
||||
}),
|
||||
}),
|
||||
|
||||
updateApplicationsService: builder.mutation<void, UpdateApplicationAppType>({
|
||||
query: (updateApplications) => ({
|
||||
url: apiPaths.createUpdateApplication,
|
||||
data: updateApplications
|
||||
}),
|
||||
invalidatesTags: ['Applications']
|
||||
}),
|
||||
|
||||
removeApplicationsService: builder.mutation<void, number[]>({
|
||||
query: ([id]) => ({
|
||||
url: apiPaths.deleteApplication,
|
||||
data: [ id]
|
||||
}),
|
||||
invalidatesTags: ['Applications']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default applicationsApi
|
||||
@@ -0,0 +1,29 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
const modulesServiceApi = createApi({
|
||||
reducerPath: 'modulesServiceApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['modules'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getModules: builder.query<ModuleType[], string>({
|
||||
query: () => ({ url: apiPaths.getModules, data: { limit: 1000 } }),
|
||||
providesTags: () => ['modules']
|
||||
}),
|
||||
removeModule: builder.mutation<void, string>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.deleteModule,
|
||||
data: [id]
|
||||
}),
|
||||
invalidatesTags: ['modules']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default modulesServiceApi
|
||||
@@ -0,0 +1,30 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import {
|
||||
ApplicationTokenType,
|
||||
NewApplicationTokenType,
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
const tokensApi = createApi({
|
||||
reducerPath: 'tokensApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['Tokens'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
createToken: builder.mutation<
|
||||
ApplicationTokenType,
|
||||
NewApplicationTokenType
|
||||
>({
|
||||
query: ( NewApplicationTokenType) => ({
|
||||
url: apiPaths.createToken,
|
||||
data: NewApplicationTokenType
|
||||
}),
|
||||
invalidatesTags: ['Tokens']
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
export default tokensApi
|
||||
+16
-5
@@ -3,15 +3,19 @@ import { theme } from 'antd'
|
||||
import { MapToken, SeedToken } from 'antd/es/theme/interface'
|
||||
import { createContext, Dispatch, SetStateAction } from 'react'
|
||||
|
||||
import sessionServiceApi from '@services/sessionService.ts'
|
||||
import accessListApi from '@services/accessListService.ts'
|
||||
import appApi from '@services/appService.ts'
|
||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import securityLogServiceApi from '@services/securityLogService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
import routeApi from '@services/routeService.ts'
|
||||
import securityLogServiceApi from '@services/securityLogService.ts'
|
||||
import sessionServiceApi from '@services/sessionService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import profileReducer from './redusers/ProfileSlice.ts'
|
||||
import UIReducer from './redusers/UISlice.ts'
|
||||
|
||||
export interface ContextProps {
|
||||
setTheme: Dispatch<
|
||||
@@ -25,13 +29,17 @@ export const Context = createContext<ContextProps>({
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
profileReducer,
|
||||
UIReducer,
|
||||
[roleApi.reducerPath]: roleApi.reducer,
|
||||
[userServiceApi.reducerPath]: userServiceApi.reducer,
|
||||
[sessionServiceApi.reducerPath]: sessionServiceApi.reducer,
|
||||
[securityLogServiceApi.reducerPath]: securityLogServiceApi.reducer,
|
||||
[appApi.reducerPath]: appApi.reducer,
|
||||
[accessListApi.reducerPath]: accessListApi.reducer,
|
||||
[routeApi.reducerPath]: routeApi.reducer
|
||||
[routeApi.reducerPath]: routeApi.reducer,
|
||||
[modulesServiceApi.reducerPath]: modulesServiceApi.reducer,
|
||||
[applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer,
|
||||
[applicationsApi.reducerPath]: applicationsApi.reducer
|
||||
})
|
||||
|
||||
export const setupStore = () =>
|
||||
@@ -46,7 +54,10 @@ export const setupStore = () =>
|
||||
accessListApi.middleware,
|
||||
routeApi.middleware,
|
||||
userServiceApi.middleware,
|
||||
sessionServiceApi.middleware
|
||||
sessionServiceApi.middleware,
|
||||
modulesServiceApi.middleware,
|
||||
applicationsGroupApi.middleware,
|
||||
applicationsApi.middleware
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ import { createAsyncThunk } from '@reduxjs/toolkit'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ProfileDataType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
import {
|
||||
ProfileDataType,
|
||||
UIDataType
|
||||
} from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { initUI } from '@utils/UIUtiles.tsx'
|
||||
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
|
||||
export const fetchProfile = createAsyncThunk(
|
||||
'profile/fetchProfile',
|
||||
async (_, { rejectWithValue }) => {
|
||||
@@ -20,3 +24,15 @@ export const fetchProfile = createAsyncThunk(
|
||||
}
|
||||
}
|
||||
)
|
||||
export const fetchUI = createAsyncThunk(
|
||||
'ui/fetchUI',
|
||||
async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await apiService.post<UIDataType>(apiPaths.getUI)
|
||||
initUI(response.data)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
return rejectWithValue(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
ActionReducerMapBuilder,
|
||||
createSlice,
|
||||
PayloadAction
|
||||
} from '@reduxjs/toolkit'
|
||||
|
||||
import { UIDataType, UIType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
||||
|
||||
import { fetchUI } from './ActionCreators.ts'
|
||||
|
||||
export const initialState: UIType = {
|
||||
ui: {
|
||||
name: '',
|
||||
primaryColor: ''
|
||||
},
|
||||
status: StateProfileStatus.notInit,
|
||||
error: ''
|
||||
}
|
||||
|
||||
export const UISlice = createSlice({
|
||||
name: 'ui',
|
||||
initialState,
|
||||
reducers: {
|
||||
clearUI(state) {
|
||||
state.ui = initialState.ui
|
||||
}
|
||||
},
|
||||
extraReducers: (builder: ActionReducerMapBuilder<UIType>) => {
|
||||
builder
|
||||
.addCase(
|
||||
fetchUI.fulfilled,
|
||||
(state, action: PayloadAction<UIDataType>) => {
|
||||
state.status = StateProfileStatus.resolved
|
||||
state.ui = { ...action.payload }
|
||||
}
|
||||
)
|
||||
.addCase(fetchUI.pending, (state) => {
|
||||
state.status = StateProfileStatus.pending
|
||||
})
|
||||
.addCase(fetchUI.rejected, (state, action: any) => {
|
||||
state.status = StateProfileStatus.rejected
|
||||
state.error = action.payload
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default UISlice.reducer
|
||||
@@ -0,0 +1,26 @@
|
||||
import { UIDataType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
const drawSVG = (color: string) =>
|
||||
`<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" fill="${color}"><path d="M24 19h-1v-2.2c-1.853 4.237-6.083 7.2-11 7.2-6.623 0-12-5.377-12-12h1c0 6.071 4.929 11 11 11 4.66 0 8.647-2.904 10.249-7h-2.249v-1h4v4zm-11.036 0h-1.886c-.34-.957-.437-1.571-1.177-1.878h-.001c-.743-.308-1.251.061-2.162.494l-1.333-1.333c.427-.899.804-1.415.494-2.163-.308-.74-.926-.839-1.878-1.177v-1.886c.954-.339 1.57-.437 1.878-1.178.308-.743-.06-1.248-.494-2.162l1.333-1.333c.918.436 1.421.801 2.162.494l.001-.001c.74-.307.838-.924 1.177-1.877h1.886c.34.958.437 1.57 1.177 1.877l.001.001c.743.308 1.252-.062 2.162-.494l1.333 1.333c-.435.917-.801 1.421-.494 2.161v.001c.307.739.915.835 1.878 1.178v1.886c-.953.338-1.571.437-1.878 1.178-.308.743.06 1.249.494 2.162l-1.333 1.333c-.92-.438-1.42-.802-2.157-.496-.746.31-.844.926-1.183 1.88zm-.943-4.667c-1.289 0-2.333-1.044-2.333-2.333 0-1.289 1.044-2.334 2.333-2.334 1.289 0 2.333 1.045 2.333 2.334 0 1.289-1.044 2.333-2.333 2.333zm-8.021-5.333h-4v-4h1v2.2c1.853-4.237 6.083-7.2 11-7.2 6.623 0 12 5.377 12 12h-1c0-6.071-4.929-11-11-11-4.66 0-8.647 2.904-10.249 7h2.249v1z"></path></svg>`
|
||||
|
||||
export const createSVG = (color: string) => {
|
||||
const svgString = drawSVG(color)
|
||||
return btoa(svgString) // base64
|
||||
}
|
||||
|
||||
export const initSVG = (color: string) => {
|
||||
const favicon = document.createElement('link')
|
||||
favicon.id = 'favicon'
|
||||
favicon.rel = 'shortcut icon'
|
||||
favicon.type = 'image/x-icon'
|
||||
favicon.href = `data:image/svg+xml;base64,${createSVG(color)}`
|
||||
return favicon
|
||||
}
|
||||
|
||||
export const initUI = (ui: UIDataType) => {
|
||||
let favicon = document.getElementById('favicon')
|
||||
favicon = initSVG(ui.primaryColor)
|
||||
const titles = document.getElementsByTagName('title')
|
||||
document.head.insertBefore(favicon, titles[0])
|
||||
document.title = `${ui.name} — MSP`
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
.access-list-tree{
|
||||
overflow-y: scroll;
|
||||
height: calc(100vh - 130px);
|
||||
height: calc(100vh - 250px);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 28px;
|
||||
width: 100%;
|
||||
height: 65px;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface HeaderPropsType {
|
||||
title: string
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { HomeOutlined } from '@ant-design/icons'
|
||||
import { Breadcrumb } from 'antd'
|
||||
|
||||
import { HeaderPropsType } from '@widgets/Header/header.type.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
|
||||
import './header.scss'
|
||||
|
||||
const Header = ({ title }: HeaderPropsType) => {
|
||||
const {
|
||||
ui: { name, primaryColor }
|
||||
} = useAppSelector((state) => state.UIReducer)
|
||||
|
||||
return (
|
||||
<section
|
||||
className="header"
|
||||
style={{
|
||||
backgroundColor: primaryColor
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{
|
||||
href: '/',
|
||||
title: (
|
||||
<>
|
||||
<HomeOutlined />
|
||||
<span>Главная</span>
|
||||
</>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: <span>{title}</span>
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<span>{name}</span>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Header
|
||||
@@ -8,6 +8,6 @@
|
||||
border: 1px dashed $grey;
|
||||
|
||||
overflow-y: scroll;
|
||||
height: calc(100vh - 130px);
|
||||
height: calc(100vh - 160px);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user