From e6ce9ba7d5dd3f4b037fd5d27e6336e310265b1e Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:22:05 +0300 Subject: [PATCH 01/11] MSP-3204 install compare-versions and moment --- package-lock.json | 15 +++++++++++++++ package.json | 2 ++ 2 files changed, 17 insertions(+) diff --git a/package-lock.json b/package-lock.json index b7f65f0..de17851 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,8 @@ "@types/react-router-dom": "^5.3.3", "axios": "^1.6.8", "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", @@ -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", diff --git a/package.json b/package.json index 4c7381c..79eb3e2 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "@reduxjs/toolkit": "^2.2.3", "@types/react-router-dom": "^5.3.3", "axios": "^1.6.8", + "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", From 1f39286a40c87199c62abc5c6ba22340da5a4f6e Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:27:00 +0300 Subject: [PATCH 02/11] MSP-3204 add paths in apiPaths and create modulesServiceApi --- src/constants/api/apiPaths.ts | 5 +++++ src/services/modulesService.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/services/modulesService.ts diff --git a/src/constants/api/apiPaths.ts b/src/constants/api/apiPaths.ts index 68f1761..1d66e55 100644 --- a/src/constants/api/apiPaths.ts +++ b/src/constants/api/apiPaths.ts @@ -28,6 +28,8 @@ type PathKeys = | 'setList' | 'setOne' | 'getAllRoutes' + | 'getModules' + | 'deleteModule' | 'createUpdateService' | 'deleteService' | 'getAllService' @@ -86,6 +88,9 @@ export const apiPaths: Record = { setList: '/access_list/set_list', setOne: '/access_list/set_one', 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', diff --git a/src/services/modulesService.ts b/src/services/modulesService.ts new file mode 100644 index 0000000..3fb7392 --- /dev/null +++ b/src/services/modulesService.ts @@ -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({ + query: () => ({ url: apiPaths.getModules, data: { limit: 1000 } }), + providesTags: () => ['modules'] + }), + removeModule: builder.mutation({ + query: (id) => ({ + url: apiPaths.deleteModule, + data: [id] + }), + invalidatesTags: ['modules'] + }) + }) +}) + +export default modulesServiceApi From b897b284ecbd5fb9cb4588af498862136ac36d67 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:27:47 +0300 Subject: [PATCH 03/11] MSP-3204 add modulesServiceApi in store and paths in routePaths --- src/routes/routePaths.ts | 2 ++ src/stores/index.tsx | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/routes/routePaths.ts b/src/routes/routePaths.ts index ab051aa..25ecfc6 100644 --- a/src/routes/routePaths.ts +++ b/src/routes/routePaths.ts @@ -9,6 +9,7 @@ type RoutePaths = | 'securityLog' | 'roles' | 'appAccess' + | 'modules' | 'applications' export const routePaths: Record = { @@ -22,5 +23,6 @@ export const routePaths: Record = { securityLog: '/securityLog', roles: '/roles', appAccess: '/appAccess', + modules: '/modules', applications: '/applications' } diff --git a/src/stores/index.tsx b/src/stores/index.tsx index 7b8403f..a2f01c1 100644 --- a/src/stores/index.tsx +++ b/src/stores/index.tsx @@ -3,13 +3,14 @@ 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 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 applicationsGroupApi from '@services/applicationsGroupService.ts' @@ -34,6 +35,7 @@ const rootReducer = combineReducers({ [appApi.reducerPath]: appApi.reducer, [accessListApi.reducerPath]: accessListApi.reducer, [routeApi.reducerPath]: routeApi.reducer, + [modulesServiceApi.reducerPath]: modulesServiceApi.reducer, [applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer, [applicationsApi.reducerPath]: applicationsApi.reducer, }) @@ -51,6 +53,7 @@ export const setupStore = () => routeApi.middleware, userServiceApi.middleware, sessionServiceApi.middleware, + modulesServiceApi.middleware, applicationsGroupApi.middleware, applicationsApi.middleware ) From a7344417d82338fa6c105fa95c67e9e959ddec72 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:28:42 +0300 Subject: [PATCH 04/11] MSP-3204 add style for ModulesPage --- src/pages/ModulesPage/modules-page.scss | 135 ++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/pages/ModulesPage/modules-page.scss diff --git a/src/pages/ModulesPage/modules-page.scss b/src/pages/ModulesPage/modules-page.scss new file mode 100644 index 0000000..d24b813 --- /dev/null +++ b/src/pages/ModulesPage/modules-page.scss @@ -0,0 +1,135 @@ +@import "../../constants/style/styleConst"; + +.modules-page { + height: 100%; + + &__tabs { + overflow-x: scroll; + } + + .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; +} \ No newline at end of file From 536f718465edbc2d456d535499d0d162a1e67d56 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Wed, 24 Apr 2024 13:00:20 +0300 Subject: [PATCH 05/11] MSP-3204 add type for ModulesPage --- src/pages/ModulesPage/module.type.ts | 89 ++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/pages/ModulesPage/module.type.ts diff --git a/src/pages/ModulesPage/module.type.ts b/src/pages/ModulesPage/module.type.ts new file mode 100644 index 0000000..cdb7d1d --- /dev/null +++ b/src/pages/ModulesPage/module.type.ts @@ -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 + 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 + 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 + dependencies?: Record + 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 + properties?: Record + 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 +} From ca7ac9d8b82517b1b38c1bc3d7c529b197418f11 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:41:47 +0300 Subject: [PATCH 06/11] MSP-3204 create ModulesPage --- src/pages/ModulesPage/index.tsx | 239 ++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 src/pages/ModulesPage/index.tsx diff --git a/src/pages/ModulesPage/index.tsx b/src/pages/ModulesPage/index.tsx new file mode 100644 index 0000000..e5e6e37 --- /dev/null +++ b/src/pages/ModulesPage/index.tsx @@ -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 + } + + 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 ( + } color="warning"> + {lastVersion} + + ) + } + if (isSame && lastVersion) { + return {lastVersion} + } + return '' + } + + return ( + +
+
+ {item.name} + + {renderVersion()} + +
+
+ + активные экземпляры: + + + {(item.status && item.status.length) || '0'} + +
+
+
+ ) + } + + const renderMainContent = () => { + if (!selectedItemId) { + return + } + + if (!currentRole) { + return + } + + return + } + const secondColumnItems = [ + { + key: 'configurations', + name: 'Конфигурации' + }, + { key: 'connections', name: 'Подключения' } + ] + + return ( +
+ + { + 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: ( +
{renderMainContent()}
+ ) + } + })} + /> +
+ ) +} + +export default ModulesPage From b25f0954fd1aa09aacec2932e2276955b8a2f53c Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 23 Apr 2024 12:42:23 +0300 Subject: [PATCH 07/11] MSP-3204 add Route in Routers --- src/routes/Routers/index.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/routes/Routers/index.tsx b/src/routes/Routers/index.tsx index 23ea7ad..b66b702 100644 --- a/src/routes/Routers/index.tsx +++ b/src/routes/Routers/index.tsx @@ -18,6 +18,7 @@ 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 ApplicationsPage = lazy(() => import('@pages/ApplicationsPage')) const Routers = () => { @@ -124,6 +125,33 @@ const Routers = () => { } /> + }> + + + } + > + + }> +
Configurations
+ + } + /> + }> +
Connections
+ + } + /> +
+
Date: Tue, 23 Apr 2024 12:42:50 +0300 Subject: [PATCH 08/11] MSP-3204 add ModulesPage in menu in Layout --- src/components/Layout/index.tsx | 9 +++++++++ src/components/Layout/layout.type.ts | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 78b0218..41f8b12 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -121,6 +121,12 @@ const LayoutComponent = () => { className: hideItem(PermissionKeysType.read) } ] + }, + { + label: 'Модули', + key: 'modules', + className: hideItem(PermissionKeysType.read), + icon: } ] @@ -176,6 +182,9 @@ const LayoutComponent = () => { case MenuItemKeysType.roles: navigate(routePaths.roles) break + case MenuItemKeysType.modules: + navigate(routePaths.modules) + break case MenuItemKeysType.applications: navigate(routePaths.applications) break diff --git a/src/components/Layout/layout.type.ts b/src/components/Layout/layout.type.ts index 93a4422..493d35e 100644 --- a/src/components/Layout/layout.type.ts +++ b/src/components/Layout/layout.type.ts @@ -8,6 +8,7 @@ export enum MenuItemKeysType { roles = 'roles', logout = 'logout', profile = 'profile', + modules = 'modules', applications = 'applications', } @@ -44,6 +45,10 @@ export const menuKeys: Record = { key: MenuItemKeysType.profile, parent: [''] }, + [MenuItemKeysType.modules]: { + key: MenuItemKeysType.modules, + parent: [] + }, [MenuItemKeysType.applications]: { key: MenuItemKeysType.applications, parent: [''] From ab44c0ce22f2b1e9c4d85bed8d6b66a717069f71 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Wed, 24 Apr 2024 12:05:29 +0300 Subject: [PATCH 09/11] MSP-3204 create Connections component --- src/components/Connections/connections.scss | 46 ++++++ src/components/Connections/index.tsx | 151 ++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 src/components/Connections/connections.scss create mode 100644 src/components/Connections/index.tsx diff --git a/src/components/Connections/connections.scss b/src/components/Connections/connections.scss new file mode 100644 index 0000000..f9484c8 --- /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 - 30px); + } + } + + &__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 From 8258ddbf4ef8977c0fa8ea68f74051ea412365d8 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Wed, 24 Apr 2024 12:06:23 +0300 Subject: [PATCH 10/11] MSP-3204 add Route Connections in Routers --- src/routes/Routers/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/Routers/index.tsx b/src/routes/Routers/index.tsx index b66b702..b90aedf 100644 --- a/src/routes/Routers/index.tsx +++ b/src/routes/Routers/index.tsx @@ -19,6 +19,7 @@ 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 = () => { @@ -146,7 +147,7 @@ const Routers = () => { path="connections" element={ }> -
Connections
+
} /> From 4749feceb717f693ea2dbc608f1110fcd661b407 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Wed, 24 Apr 2024 12:13:50 +0300 Subject: [PATCH 11/11] MSP-3204 up version to 0.10.0 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e6efb..7af2902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.10.0 +- - Добавлена страница 'Модули' ## 0.9.0 -Добавлена страница приложений ## 0.8.1 diff --git a/package.json b/package.json index 79eb3e2..a74eb1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "isp-admin-ui", "private": true, - "version": "0.9.0", + "version": "0.10.0", "type": "module", "scripts": { "start": "vite",