diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89465ac..ef6ab92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/index.html b/index.html
index 11c6825..e6b7b28 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,9 @@
-
+
+
Панель администратора
+
diff --git a/package-lock.json b/package-lock.json
index 2b2868a..de17851 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -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",
diff --git a/package.json b/package.json
index 97da8fc..cfe918c 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/public/config.js b/public/config.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/components/ApplicationsContent/applications-content.scss b/src/components/ApplicationsContent/applications-content.scss
new file mode 100644
index 0000000..ed9183c
--- /dev/null
+++ b/src/components/ApplicationsContent/applications-content.scss
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx
new file mode 100644
index 0000000..883c5b9
--- /dev/null
+++ b/src/components/ApplicationsContent/index.tsx
@@ -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 = (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()
+
+ const {
+ handleSubmit,
+ control: controlApplicationApp,
+ reset
+ } = useForm({
+ mode: 'onChange'
+ })
+
+ const { handleSubmit: handleSubmitTokens, control: controlTokens } =
+ useForm({
+ 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 = [
+ {
+ 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 (
+
+
+ )
+ }
+ }
+ ]
+
+ const tokensOptions = [
+ {
+ value: -1,
+ label: 'Бессрочно'
+ },
+ {
+ value: 3600000,
+ label: 'Один час'
+ },
+ {
+ value: 86400000,
+ label: 'Один день'
+ },
+ {
+ value: 2592000000,
+ label: '30 дней'
+ },
+ {
+ value: 31536000000,
+ label: 'Один год'
+ }
+ ]
+
+ if (!id) {
+ return
+ }
+
+ if (isLoadingApplicationsContent) {
+ return
+ }
+
+ return (
+
+
+
+ Добавить
+
+
+ (
+
+ handleShowAddModalToken(record.app)}
+ >
+ Добавить токен
+
+
+ )
+ }}
+ className="appliactions-content__table"
+ rowKey={(record) => record.app.id}
+ pagination={false}
+ dataSource={applications}
+ columns={columns}
+ />
+
+
+ setShowApplicationsModal({
+ ...showApplicationsModal,
+ updateModal: false
+ })
+ }
+ >
+
+
+
+
+ setShowApplicationsModal({
+ ...showApplicationsModal,
+ addModal: false
+ })
+ }
+ >
+
+
+
+
+ setShowApplicationsModal({
+ ...showApplicationsModal,
+ addToken: false
+ })
+ }
+ >
+
+
+
+ )
+}
+
+export default ApplicationsContent
diff --git a/src/components/AdminPermission/index.tsx b/src/components/CanEdit/index.tsx
similarity index 62%
rename from src/components/AdminPermission/index.tsx
rename to src/components/CanEdit/index.tsx
index 557861f..a2c9993 100644
--- a/src/components/AdminPermission/index.tsx
+++ b/src/components/CanEdit/index.tsx
@@ -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
diff --git a/src/components/Connections/connections.scss b/src/components/Connections/connections.scss
new file mode 100644
index 0000000..67f6a98
--- /dev/null
+++ b/src/components/Connections/connections.scss
@@ -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);
+ }
+}
diff --git a/src/components/Connections/index.tsx b/src/components/Connections/index.tsx
new file mode 100644
index 0000000..90420b6
--- /dev/null
+++ b/src/components/Connections/index.tsx
@@ -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([])
+
+ 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
+ }
+
+ 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 (
+
+ {endpoints.map(({ path, inner }) => (
+ -
+ {path}
+ {inner && (
+
+ Внутренний
+
+ )}
+
+ ))}
+
+ )
+ }
+
+ return (
+ Нет реализованных методов
+ )
+ }
+
+ 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) => (
+ {moment(val).fromNow()}
+ )
+ },
+ {
+ title: 'Реализованные методы',
+ dataIndex: 'endpoints',
+ key: 'endpoints',
+ render: (value: EndpointType[]) => (value && value.length) || '0'
+ }
+ ]
+
+ return (
+
+
+
+
renderEndpoints(i)
+ }}
+ />
+
+
+
+ )
+}
+
+export default Connections
diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx
index cb4d411..b32fc0e 100644
--- a/src/components/Layout/index.tsx
+++ b/src/components/Layout/index.tsx
@@ -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(
[]
)
+ const [title, setTitle] = useState('')
const [openKeys, setOpenKeys] = useState([])
const dispatch = useAppDispatch()
const {
@@ -81,6 +86,12 @@ const LayoutComponent = () => {
}
]
},
+ {
+ label: 'Группа приложений',
+ key: 'applications',
+ className: hideItem([PermissionKeysType.read]),
+ icon:
+ },
{
label: 'Доступы приложений',
key: 'appAccess',
@@ -114,6 +125,12 @@ const LayoutComponent = () => {
className: hideItem(PermissionKeysType.read)
}
]
+ },
+ {
+ label: 'Модули',
+ key: 'modules',
+ className: hideItem(PermissionKeysType.read),
+ icon:
}
]
@@ -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 (
-
- {status === StateProfileStatus.pending ? (
-
- ) : (
- <>
- setCollapsed(value)}
- >
-
-
-
-
-
-
- >
- )}
-
+ collapsible
+ collapsed={collapsed}
+ onCollapse={(value) => setCollapsed(value)}
+ >
+