2024-05-13 10:51:12: merge [main:6f6359c4c01bf3e0cef37b14d6b016b7d5a1fa84];
This commit is contained in:
1 parent
2989c66a65
commit
739a9a3a4b
45 files changed
+4018
-309
No files matched your search
@@ -0,0 +1,36 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
|
||||
.active-configurations-table {
|
||||
&__title {
|
||||
margin-bottom: $basic-margin*2;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
&__table {
|
||||
&__name-field {
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: $basic-margin;
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
gap: $basic-margin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.active-config {
|
||||
tr {
|
||||
background: $blue-light;
|
||||
}
|
||||
|
||||
.ant-table-cell-row-hover {
|
||||
background: $blue-color-2 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ActiveConfigurationsTablePropsType {
|
||||
isActiveTable?: boolean
|
||||
data: ConfigType[]
|
||||
handleShowConfig: (config: ConfigType) => void
|
||||
handleShowCompareModal: (config: ConfigType) => void
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'
|
||||
import { Button, message, Table, Tag, Tooltip } from 'antd'
|
||||
import { FC, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons'
|
||||
|
||||
import {
|
||||
ActiveConfigurationsTablePropsType
|
||||
} from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts'
|
||||
|
||||
import configApi from '@services/configService.ts'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
|
||||
import './active-configurations-table.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
|
||||
const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
||||
({
|
||||
isActiveTable = false,
|
||||
handleShowConfig,
|
||||
handleShowCompareModal,
|
||||
data
|
||||
}) => {
|
||||
const [editKeyConfig, setEditKeyConfig] = useState<string>('')
|
||||
const [tempEditValues, setTempEditValues] = useState<any>()
|
||||
const inputRefs = useRef<Record<string, HTMLInputElement | null>>({})
|
||||
const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation()
|
||||
const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation()
|
||||
const [deleteConfig] = configApi.useDeleteConfigMutation()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRefs.current[editKeyConfig]) {
|
||||
inputRefs.current[editKeyConfig]?.focus()
|
||||
}
|
||||
}, [editKeyConfig])
|
||||
const handleEditStart = (record: ConfigType) => {
|
||||
setEditKeyConfig(record.id)
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleCancelEdit = (record: ConfigType) => {
|
||||
setEditKeyConfig('')
|
||||
setTempEditValues({
|
||||
...tempEditValues,
|
||||
[record.id]: record.name
|
||||
} as ConfigType)
|
||||
}
|
||||
|
||||
const handleSaveEdit = (record: ConfigType) => {
|
||||
const sendData = { ...record, name: tempEditValues[record.id] }
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно сохранен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось сохранить элемент')
|
||||
})
|
||||
}
|
||||
const handleDeleteConfig = (record: ConfigType) => {
|
||||
deleteConfig(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const handleMarkConfigActive = (record: ConfigType) => {
|
||||
markConfigAsActive(record.id)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно обновлен')
|
||||
setEditKeyConfig('')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось обновить элемент')
|
||||
})
|
||||
}
|
||||
|
||||
const renderNameField = (value: string, record: ConfigType) => {
|
||||
const canEdit = editKeyConfig === record.id
|
||||
const inputValue = canEdit ? tempEditValues[record.id] : value
|
||||
|
||||
return (
|
||||
<div className="active-configurations-table__table__name-field">
|
||||
<input
|
||||
ref={(inputRef) => (inputRefs.current[record.id] = inputRef)}
|
||||
onChange={(event) => {
|
||||
const { value } = event.target
|
||||
setTempEditValues({ ...tempEditValues, [record.id]: value })
|
||||
}}
|
||||
disabled={!canEdit}
|
||||
value={inputValue}
|
||||
/>
|
||||
{canEdit ? (
|
||||
<div className="active-configurations-table__table__name-field__actions">
|
||||
<Tooltip title="Сохранить">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => handleSaveEdit(record)}
|
||||
icon={<CheckOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Отменить">
|
||||
<Button
|
||||
onClick={() => handleCancelEdit(record)}
|
||||
icon={<CloseOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать название">
|
||||
<Button
|
||||
onClick={() => handleEditStart(record)}
|
||||
icon={<EditOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ConfigType> = [
|
||||
{
|
||||
title: 'Наименование',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: renderNameField,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Версия',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Статус конфигурации',
|
||||
dataIndex: 'valid',
|
||||
key: 'version',
|
||||
align: 'center',
|
||||
render: (value: boolean) => {
|
||||
if (value) {
|
||||
return <Tag color="#4fc14f">Корректная</Tag>
|
||||
}
|
||||
return <Tag color="red">Некорректная</Tag>
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Дата обновления',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
key: 'actions',
|
||||
align: 'center',
|
||||
render: (_: unknown, record: ConfigType) => (
|
||||
<ActiveTableActionButtons
|
||||
isActive={isActiveTable}
|
||||
handleShowConfig={handleShowConfig}
|
||||
handleShowCompareModal={handleShowCompareModal}
|
||||
handleDeleteConfig={handleDeleteConfig}
|
||||
handleMarkConfigActive={handleMarkConfigActive}
|
||||
record={record}
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}`
|
||||
return (
|
||||
<div className="active-configurations-table">
|
||||
<h2 className="active-configurations-table__title">
|
||||
{isActiveTable ? 'Активная конфигурация' : 'Другие конфигурации'}
|
||||
</h2>
|
||||
<Table
|
||||
className={className}
|
||||
rowKey={(record) => record.id}
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActiveConfigurationsTable
|
||||
@@ -0,0 +1,37 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.compare-version-modal {
|
||||
.modal__wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
justify-content: initial;
|
||||
}
|
||||
|
||||
.modal__content {
|
||||
overflow: initial;
|
||||
}
|
||||
|
||||
&__header {
|
||||
margin-top: $basic-margin;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: $basic-margin;
|
||||
|
||||
}
|
||||
|
||||
&__content {
|
||||
.cm-merge-theme {
|
||||
overflow-y: scroll;
|
||||
height: calc(90vh - 150px);
|
||||
}
|
||||
|
||||
&__table {
|
||||
overflow-y: auto;
|
||||
height: calc(90vh - 50px);
|
||||
|
||||
&__row {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface CompareVersionModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
currentConfigId: string
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { EditorState, EditorView } from '@uiw/react-codemirror'
|
||||
import { Button, Spin, Table } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import { FC, useState } from 'react'
|
||||
import CodeMirrorMerge from 'react-codemirror-merge'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { CompareVersionModalPropsType } from '@components/CompareVersionModal/compare-version-modal.type'
|
||||
|
||||
import { sortObject } from '@utils/objectUtils.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { VersionType } from '@type/version.type'
|
||||
|
||||
import './compare-version-modal.scss'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
|
||||
const Original = CodeMirrorMerge.Original
|
||||
const Modified = CodeMirrorMerge.Modified
|
||||
|
||||
const CompareVersionModal: FC<CompareVersionModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
config,
|
||||
currentConfigId
|
||||
}) => {
|
||||
const [selectedItem, setSelectedItem] = useState<VersionType>()
|
||||
const { data: versions = [], isLoading: isVersionLoading } =
|
||||
configServiceApi.useGetAllVersionQuery(currentConfigId)
|
||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||
userServiceApi.useGetAllUsersQuery()
|
||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
||||
const isLoading = isVersionLoading || isUsersLoading
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
const columns: ColumnsType<VersionType> = [
|
||||
{
|
||||
key: 'configVersion',
|
||||
title: 'Версия конфигурации',
|
||||
dataIndex: 'configVersion'
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'user',
|
||||
title: 'Автор',
|
||||
dataIndex: 'adminId',
|
||||
render: (value: number) => {
|
||||
const user = allUsers.find((user) => user.id === value)
|
||||
if (user) {
|
||||
return `${user.lastName} ${user.firstName}`
|
||||
}
|
||||
return `${profile.lastName} ${profile.firstName}`
|
||||
}
|
||||
}
|
||||
]
|
||||
return (
|
||||
<div className="compare-version-modal">
|
||||
<Modal title="Сравнение версий" open={open} onClose={onClose}>
|
||||
{selectedItem ? (
|
||||
<div className="compare-version-modal__content">
|
||||
<Button onClick={() => setSelectedItem(undefined)}>Назад</Button>
|
||||
<div className="compare-version-modal__header">
|
||||
<span> Версия: {selectedItem.configVersion}</span>
|
||||
<span>Текущая версия : {config?.version || config?.configVersion}</span>
|
||||
</div>
|
||||
<CodeMirrorMerge orientation="a-b">
|
||||
<Original
|
||||
value={JSON.stringify(sortObject(selectedItem.data), null, 2)}
|
||||
/>
|
||||
<Modified
|
||||
value={JSON.stringify(sortObject(config?.data), null, 2)}
|
||||
extensions={[
|
||||
EditorView.editable.of(false),
|
||||
EditorState.readOnly.of(true)
|
||||
]}
|
||||
/>
|
||||
</CodeMirrorMerge>
|
||||
</div>
|
||||
) : (
|
||||
<div className="compare-version-modal__content__table">
|
||||
<Table
|
||||
rowClassName="compare-version-modal__content__table__row"
|
||||
size="small"
|
||||
columns={columns}
|
||||
pagination={{ pageSize: 30 }}
|
||||
dataSource={versions}
|
||||
rowKey={(record) => record.id}
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: () => setSelectedItem(record)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CompareVersionModal
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
import { JSONSchema } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
|
||||
export interface ConfigSchemaModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
schema: JSONSchema
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.config-schema-modal {
|
||||
.modal__wrap {
|
||||
min-width: 880px;
|
||||
}
|
||||
|
||||
.json-schema-view {
|
||||
padding: $basic-padding
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { JsonSchemaViewer } from '@stoplight/json-schema-viewer'
|
||||
import { FC } from 'react'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts'
|
||||
|
||||
import './config-schema-modal.scss'
|
||||
|
||||
const ConfigSchemaModal: FC<ConfigSchemaModalPropsType> = ({
|
||||
open,
|
||||
onClose,
|
||||
schema
|
||||
}) => {
|
||||
return (
|
||||
<div className="config-schema-modal">
|
||||
<Modal title="Текущая схема конфигурации" open={open} onClose={onClose}>
|
||||
<JsonSchemaViewer
|
||||
viewMode="view"
|
||||
className="json-schema-view"
|
||||
schema={schema}
|
||||
emptyText="No schema defined"
|
||||
defaultExpandedDepth={99}
|
||||
/>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigSchemaModal
|
||||
@@ -0,0 +1,5 @@
|
||||
.configuration-preview-modal {
|
||||
.react-json-view {
|
||||
width: 100vw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModalPropsType } from '@widgets/Modal/modal.type.ts'
|
||||
|
||||
export interface ConfigurationPreviewModalPropsType
|
||||
extends Omit<ModalPropsType, 'title' | 'children'> {
|
||||
config: Record<string, any>
|
||||
versionCompare?: boolean
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ReactJsonView } from 'isp-ui-kit'
|
||||
import { FC } from 'react'
|
||||
|
||||
import Modal from '@widgets/Modal'
|
||||
|
||||
import { ConfigurationPreviewModalPropsType } from '@components/ConfigurationPreviewModal/configuration-preview-modal.type.ts'
|
||||
|
||||
import './configuration-preview-modal.scss'
|
||||
|
||||
|
||||
const ConfigurationPreviewModal: FC<ConfigurationPreviewModalPropsType> = ({
|
||||
versionCompare = false,
|
||||
config,
|
||||
open,
|
||||
onClose
|
||||
}) => {
|
||||
const data = JSON.parse(JSON.stringify(config.data || {}))
|
||||
const configName = versionCompare
|
||||
? `Версия: ${config.configVersion}`
|
||||
: config.name
|
||||
return (
|
||||
<div className="configuration-preview-modal">
|
||||
<Modal title={configName || ''} open={open} onClose={onClose}>
|
||||
<ReactJsonView
|
||||
src={data}
|
||||
name={false}
|
||||
sortKeys={true}
|
||||
displayDataTypes={false}
|
||||
editKeys={false}
|
||||
/>
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfigurationPreviewModal
|
||||
@@ -1,8 +1,9 @@
|
||||
import {
|
||||
AppstoreAddOutlined,
|
||||
LockOutlined,
|
||||
LogoutOutlined,
|
||||
ProfileOutlined,
|
||||
AppstoreAddOutlined
|
||||
ProductOutlined,
|
||||
ProfileOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { ConfigProvider, Layout, Menu, Spin } from 'antd'
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
@@ -33,6 +34,8 @@ import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import Header from 'src/widgets/Header'
|
||||
|
||||
|
||||
|
||||
import './layout.scss'
|
||||
|
||||
const { Content, Sider } = Layout
|
||||
@@ -130,7 +133,7 @@ const LayoutComponent = () => {
|
||||
label: 'Модули',
|
||||
key: 'modules',
|
||||
className: hideItem(PermissionKeysType.read),
|
||||
icon: <ProfileOutlined />
|
||||
icon: <ProductOutlined />
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ type PathKeys =
|
||||
| 'getTokensByAppId'
|
||||
| 'revokeTokens'
|
||||
| 'revokeTokensForApp'
|
||||
| 'getConfigsByModuleId'
|
||||
| 'getConfigById'
|
||||
| 'getAllVersions'
|
||||
| 'createUpdateConfig'
|
||||
| 'deleteVersion'
|
||||
| 'deleteConfig'
|
||||
| 'markConfigAsActive'
|
||||
| 'getUI'
|
||||
|
||||
export const apiPaths: Record<PathKeys, string> = {
|
||||
@@ -103,5 +110,13 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
createToken: '/token/create_token',
|
||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
||||
revokeTokens: '/token/revoke_tokens',
|
||||
revokeTokensForApp: '/token/revoke_tokens_for_app'
|
||||
revokeTokensForApp: '/token/revoke_tokens_for_app',
|
||||
// ======= CONFIGS ======
|
||||
getConfigsByModuleId: '/config/get_configs_by_module_id',
|
||||
getConfigById: '/config/get_config_by_id',
|
||||
getAllVersions: '/config/get_all_version',
|
||||
createUpdateConfig: '/config/create_update_config',
|
||||
deleteVersion: '/config/delete_version',
|
||||
deleteConfig: '/config/delete_config',
|
||||
markConfigAsActive: '/config/mark_config_as_active'
|
||||
}
|
||||
@@ -15,4 +15,6 @@ $border-color: #F0F0F0;
|
||||
|
||||
$blue-color: #40A9FF;
|
||||
$blue-light: #E6F7FF;
|
||||
$text-color-blue: #1890FF;
|
||||
$text-color-blue: #1890FF;
|
||||
|
||||
$blue-color-2: #bae0ff;
|
||||
@@ -6,10 +6,13 @@ import { BrowserRouter } from 'react-router-dom'
|
||||
import App from './components/App.tsx'
|
||||
|
||||
import { setupStore } from './stores'
|
||||
import 'dayjs/locale/ru'
|
||||
|
||||
import 'react-resizable/css/styles.css'
|
||||
import 'simplebar-react/dist/simplebar.min.css'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
dayjs.locale('ru')
|
||||
const store = setupStore()
|
||||
setupListeners(store.dispatch)
|
||||
const root = createRoot(document.getElementById('root') as HTMLElement)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.all-version-page {
|
||||
padding: $basic-padding*2 0;
|
||||
|
||||
&__back-btn {
|
||||
margin-bottom: $basic-margin*2;
|
||||
}
|
||||
|
||||
&__table {
|
||||
overflow: auto;
|
||||
height: calc(100vh - 150px);
|
||||
}
|
||||
|
||||
&__actions-field {
|
||||
display: flex;
|
||||
gap: $basic-margin
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
import {
|
||||
DeleteOutlined,
|
||||
EyeOutlined,
|
||||
ReloadOutlined,
|
||||
SwapOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd'
|
||||
import { ColumnsType } from 'antd/es/table'
|
||||
import dayjs from 'dayjs'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Navigate, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import CompareVersionModal from '@components/CompareVersionModal'
|
||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
import { VersionType } from '@type/version.type.ts'
|
||||
|
||||
import './all-versions-page.scss'
|
||||
|
||||
|
||||
const AllVersionsPage = () => {
|
||||
const [showCompareModal, setShowCompareModal] = useState<boolean>(false)
|
||||
const [showPreviewModal, setShowPreviewModal] = useState<boolean>(false)
|
||||
|
||||
const [currentClickVersion, setCurrentClickVersion] = useState<VersionType>(
|
||||
{} as VersionType
|
||||
)
|
||||
const navigate = useNavigate()
|
||||
const { id = '', configId = '' } = useParams()
|
||||
const {
|
||||
data: versions = [],
|
||||
isLoading: isVersionLoading,
|
||||
isError: isVersionError
|
||||
} = configServiceApi.useGetAllVersionQuery(configId)
|
||||
const {
|
||||
data: currentConfig,
|
||||
isLoading: isCurrentConfigLoading,
|
||||
isError: isCurrentConfigError
|
||||
} = configServiceApi.useGetConfigByIdQuery(configId)
|
||||
const [deleteVersion] = configServiceApi.useDeleteVersionMutation()
|
||||
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
||||
|
||||
const {
|
||||
data: allUsers = [],
|
||||
isLoading: isUsersLoading,
|
||||
isError: isUsersError
|
||||
} = userServiceApi.useGetAllUsersQuery()
|
||||
const { profile } = useAppSelector((state) => state.profileReducer)
|
||||
|
||||
const { role, hasPermission } = useRole()
|
||||
|
||||
const isLoading = isVersionLoading || isCurrentConfigLoading || isUsersLoading
|
||||
const isError = isVersionError || isCurrentConfigError || isUsersError
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
if (isError) {
|
||||
return <Navigate to={routePaths.error} />
|
||||
}
|
||||
|
||||
const handeRemoveVersion = (versionId: string) => {
|
||||
deleteVersion(versionId)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Элемент успешно удален')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось удалить элемент')
|
||||
})
|
||||
}
|
||||
const handleRevertVersion = (newData: Record<string, unknown>) => {
|
||||
const sendData = { ...currentConfig, data: newData } as ConfigType
|
||||
createUpdateConfig(sendData)
|
||||
.unwrap()
|
||||
.then(() => {
|
||||
message.success('Версия успешно восстановлена')
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('Не удалось восстановить версию')
|
||||
})
|
||||
}
|
||||
const renderActionsField = (_: unknown, record: VersionType) => {
|
||||
return (
|
||||
<div className="all-version-page__actions-field">
|
||||
<CanEdit>
|
||||
<Tooltip title="Установить выбранную версию">
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите установить выбранную версию ?"
|
||||
onConfirm={() => handleRevertVersion(record.data)}
|
||||
>
|
||||
<Button icon={<ReloadOutlined />} />
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
<Tooltip title="Просмотр версии">
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCurrentClickVersion(record)
|
||||
setShowPreviewModal(true)
|
||||
}}
|
||||
icon={<EyeOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Сравнение версий">
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCurrentClickVersion(record)
|
||||
setShowCompareModal(true)
|
||||
}}
|
||||
icon={<SwapOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<CanEdit>
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите удалить выбранную версию ?"
|
||||
onConfirm={() => handeRemoveVersion(record.id)}
|
||||
>
|
||||
<Button danger icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
</CanEdit>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const columns: ColumnsType<VersionType> = [
|
||||
{
|
||||
key: 'configVersion',
|
||||
title: 'Версия конфигурации',
|
||||
dataIndex: 'configVersion'
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: 'Создано',
|
||||
dataIndex: 'createdAt',
|
||||
render: (value: string) => {
|
||||
return dayjs(value).format('HH:mm:ss DD.MM.YYYY')
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'user',
|
||||
title: 'Автор',
|
||||
dataIndex: 'adminId',
|
||||
render: (value: number) => {
|
||||
const user = allUsers.find((user) => user.id === value)
|
||||
if (user) {
|
||||
return `${user.lastName} ${user.firstName}`
|
||||
}
|
||||
return `${profile.lastName} ${profile.firstName}`
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
title: 'Действия',
|
||||
dataIndex: 'actions',
|
||||
render: renderActionsField
|
||||
}
|
||||
]
|
||||
return (
|
||||
<section className="all-version-page">
|
||||
{showPreviewModal && (
|
||||
<ConfigurationPreviewModal
|
||||
versionCompare={true}
|
||||
config={currentClickVersion}
|
||||
open={showPreviewModal}
|
||||
onClose={() => setShowPreviewModal(false)}
|
||||
/>
|
||||
)}
|
||||
{showCompareModal && (
|
||||
<CompareVersionModal
|
||||
currentConfigId={currentConfig?.id || ''}
|
||||
config={currentClickVersion}
|
||||
open={showCompareModal}
|
||||
onClose={() => setShowCompareModal(false)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
className="all-version-page__back-btn"
|
||||
onClick={() => navigate(`${routePaths.modules}/${id}/configurations`)}
|
||||
>
|
||||
Назад
|
||||
</Button>
|
||||
<div className="all-version-page__table">
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={versions}
|
||||
pagination={{ pageSize: 30 }}
|
||||
rowKey={(record) => record.id}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default AllVersionsPage
|
||||
@@ -3,12 +3,13 @@
|
||||
.app-access-page {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
|
||||
.ant-tree {
|
||||
background: none;
|
||||
}
|
||||
|
||||
&__content-wrap{
|
||||
&__content-wrap {
|
||||
width: 100%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ const AppAccessPage = () => {
|
||||
return (
|
||||
<section className="app-access-page">
|
||||
<Column
|
||||
showUpdateBtn={false}
|
||||
showAddBtn={false}
|
||||
showRemoveBtn={false}
|
||||
items={filterFirstColumnItems(
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.configurations {
|
||||
height: calc(100vh - 150px);
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
&__buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: $basic-margin*2;
|
||||
|
||||
}
|
||||
|
||||
.active-configurations-table:last-child {
|
||||
margin-top: $basic-margin*3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import { injectStyles } from '@stoplight/mosaic'
|
||||
import { Button, Spin } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { Outlet, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
import CompareVersionModal from '@components/CompareVersionModal'
|
||||
import ConfigSchemaModal from '@components/ConfigSchemaModal'
|
||||
import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal'
|
||||
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
import configServiceApi from '@services/configService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './configurations.scss'
|
||||
|
||||
|
||||
const Configurations = () => {
|
||||
const {
|
||||
data: modulesList = [],
|
||||
isLoading: isModulesLoading,
|
||||
isError: isModulesError
|
||||
} = modulesServiceApi.useGetModulesQuery('modules')
|
||||
const { id: selectedItemId = '', configId = '' } = useParams()
|
||||
const {
|
||||
data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] },
|
||||
isLoading: isConfigsLoading,
|
||||
isError: isConfigsError
|
||||
} = configServiceApi.useGetConfigsByModuleIdQuery(selectedItemId)
|
||||
|
||||
const { role, hasPermission } = useRole()
|
||||
const navigate = useNavigate()
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
const [isShowModalOpen, setisShowModalOpen] = useState(false)
|
||||
const [isCompareModalOpen, setIsCompareModalOpen] = useState(false)
|
||||
|
||||
const [currentConfig, setCurrentConfig] = useState<ConfigType>(
|
||||
{} as ConfigType
|
||||
)
|
||||
const { activeConfigs, inactiveConfigs } = data
|
||||
const currentModule = useMemo(
|
||||
() => modulesList.find((module) => module.id === selectedItemId),
|
||||
[selectedItemId, modulesList]
|
||||
)
|
||||
const isLoading = isModulesLoading || isConfigsLoading
|
||||
const isError = isModulesError || isConfigsError
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
navigate(routePaths.home)
|
||||
}
|
||||
}, [isPageAvailable])
|
||||
useEffect(() => {
|
||||
if (!role) {
|
||||
navigate(routePaths.error)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
if (isLoading) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
if (configId) {
|
||||
return <Outlet />
|
||||
}
|
||||
injectStyles()
|
||||
return (
|
||||
<section className="configurations">
|
||||
<ConfigurationPreviewModal
|
||||
config={currentConfig}
|
||||
open={isShowModalOpen}
|
||||
onClose={() => setisShowModalOpen(false)}
|
||||
/>
|
||||
<ConfigSchemaModal
|
||||
schema={currentModule?.configSchema || {}}
|
||||
open={isModalOpen}
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
/>
|
||||
{isCompareModalOpen && (
|
||||
<CompareVersionModal
|
||||
currentConfigId={currentConfig.id}
|
||||
config={currentConfig}
|
||||
open={isCompareModalOpen}
|
||||
onClose={() => setIsCompareModalOpen(false)}
|
||||
/>
|
||||
)}
|
||||
<div className="configurations__buttons">
|
||||
<Button
|
||||
className="configurations____buttons__show-schema-btn"
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
>
|
||||
Текущая схема конфигурации
|
||||
</Button>
|
||||
<CanEdit>
|
||||
<Button
|
||||
type="primary"
|
||||
className="configurations__buttons__new-config-brn"
|
||||
onClick={() => {
|
||||
// TODO создание новой конфигурации
|
||||
}}
|
||||
>
|
||||
Создать конфигурацию
|
||||
</Button>
|
||||
</CanEdit>
|
||||
</div>
|
||||
<ActiveConfigurationsTable
|
||||
isActiveTable
|
||||
data={isError ? [] : activeConfigs}
|
||||
handleShowConfig={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setisShowModalOpen(true)
|
||||
}}
|
||||
handleShowCompareModal={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setIsCompareModalOpen(true)
|
||||
}}
|
||||
/>
|
||||
<ActiveConfigurationsTable
|
||||
data={isError ? [] : inactiveConfigs}
|
||||
handleShowConfig={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setisShowModalOpen(true)
|
||||
}}
|
||||
handleShowCompareModal={(config) => {
|
||||
setCurrentConfig(config)
|
||||
setIsCompareModalOpen(true)
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Configurations
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.connection-page {
|
||||
&__content {
|
||||
@@ -43,4 +43,7 @@
|
||||
white-space: nowrap;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
&__inner-tag{
|
||||
margin-left: $basic-margin !important;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,9 @@
|
||||
import { Spin, Table, Tooltip } from 'antd'
|
||||
import { Spin, Table, Tag, 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 { AddressType, EndpointType, ModuleStatusType, ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import useRole from '@hooks/useRole.tsx'
|
||||
|
||||
@@ -21,6 +14,8 @@ import { routePaths } from '@routes/routePaths.ts'
|
||||
import { PermissionKeysType } from '@type/roles.type.ts'
|
||||
|
||||
import './connections.scss'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
|
||||
const Connections = () => {
|
||||
const { data: ConnectionsList = [], isLoading: isModulesLoading } =
|
||||
@@ -56,12 +51,12 @@ const Connections = () => {
|
||||
}
|
||||
|
||||
const formatFullDate = (obj: string) =>
|
||||
moment(obj).format('YYYY-MM-DD, HH:mm:ss')
|
||||
dayjs(obj).format('YYYY-MM-DD, HH:mm:ss')
|
||||
|
||||
const keySelector = ({
|
||||
address: { ip, port },
|
||||
establishedAt
|
||||
}: ModuleStatusType) => ip + port + establishedAt
|
||||
address: { ip, port },
|
||||
establishedAt
|
||||
}: ModuleStatusType) => ip + port + establishedAt
|
||||
|
||||
const renderEndpoints = ({ endpoints }: ModuleStatusType) => {
|
||||
if (endpoints && endpoints.length) {
|
||||
@@ -71,9 +66,9 @@ const Connections = () => {
|
||||
<li className="connection-page__endpoint-list__item" key={path}>
|
||||
{path}
|
||||
{inner && (
|
||||
<span className="connection-page__endpoint-list__inner-marker">
|
||||
<Tag className="connection-page__inner-tag" color="processing" bordered={false}>
|
||||
Внутренний
|
||||
</span>
|
||||
</Tag>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
@@ -117,9 +112,13 @@ const Connections = () => {
|
||||
title: 'Соединение установлено',
|
||||
dataIndex: 'establishedAt',
|
||||
key: 'establishedAt',
|
||||
render: (val: string) => (
|
||||
<Tooltip title={formatFullDate(val)}>{moment(val).fromNow()}</Tooltip>
|
||||
)
|
||||
render: (val: string) => {
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
return (
|
||||
<Tooltip title={formatFullDate(val)}>{dayjs(val).fromNow()}</Tooltip>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Реализованные методы',
|
||||
@@ -220,7 +220,6 @@ const ModulesPage = () => {
|
||||
navigate(path)
|
||||
}}
|
||||
className="modules-page__tabs"
|
||||
tabPosition={'left'}
|
||||
items={secondColumnItems.map((item) => {
|
||||
return {
|
||||
disabled: selectedItemId === '',
|
||||
|
||||
@@ -87,3 +87,9 @@ export interface ModuleType {
|
||||
status: ModuleStatusType[]
|
||||
configSchema: JSONSchema
|
||||
}
|
||||
|
||||
export interface ConfigResponse {
|
||||
originalResponse: ConfigType[]
|
||||
activeConfigs: ConfigType[]
|
||||
inactiveConfigs:ConfigType[]
|
||||
}
|
||||
@@ -4,8 +4,9 @@
|
||||
height: 100%;
|
||||
|
||||
&__tabs {
|
||||
overflow-x: scroll;
|
||||
padding: $basic-padding*3 $basic-padding*2;
|
||||
width: 100%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.ant-list-item {
|
||||
@@ -120,17 +121,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
@import '../../constants/style/styleConst';
|
||||
|
||||
.profile-page {
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: start;
|
||||
|
||||
+172
-164
@@ -9,6 +9,7 @@ import HomePage from '@pages/HomePage'
|
||||
import PrivateRoute from '@routes/PrivateRoute'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
|
||||
const LoginPage = lazy(() => import('@pages/LoginPage'))
|
||||
const ErrorPage = lazy(() => import('@components/ErrorPage'))
|
||||
const ProfilePage = lazy(() => import('@pages/ProfilePage'))
|
||||
@@ -19,179 +20,186 @@ 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 Connections = lazy(() => import('src/pages/ConnectionsPage'))
|
||||
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
||||
const Configurations = lazy(() => import('src/pages/ConfigurationsPage'))
|
||||
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
|
||||
|
||||
const Routers = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<PrivateRoute />}>
|
||||
<Route path={routePaths.home} element={<Layout />}>
|
||||
<Route
|
||||
index
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<HomePage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.profile}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ProfilePage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.users}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<UsersPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.users}/:id`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<UserEditor />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.roles}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<RolesPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<RolesPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.applicationsGroup}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path={routePaths.application}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":appId"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
</Route>
|
||||
|
||||
<Route
|
||||
path={routePaths.sessions}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<SessionsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.securityLog}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<SecurityLogPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.appAccess}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.modules}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ModulesPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route path=":id">
|
||||
<Route
|
||||
path="configurations"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<div>Configurations</div>
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="connections"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<Connections />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
</Route>
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<PrivateRoute />}>
|
||||
<Route path={routePaths.home} element={<Layout />}>
|
||||
<Route
|
||||
index
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<HomePage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.profile}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ProfilePage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.users}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<UsersPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.users}/:id`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<UserEditor />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.roles}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<RolesPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<RolesPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.applicationsGroup}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path={routePaths.application}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path=":appId"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ApplicationsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
</Route>
|
||||
|
||||
<Route
|
||||
path={routePaths.sessions}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<SessionsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.securityLog}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<SecurityLogPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.appAccess}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path={routePaths.error}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ErrorPage />
|
||||
</Suspense>
|
||||
}
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.login}
|
||||
element={
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.modules}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ModulesPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route path=":id">
|
||||
<Route
|
||||
path={routePaths.configurations}
|
||||
element={<Configurations />}
|
||||
>
|
||||
<Route
|
||||
path={routePaths.allVersions}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<LoginPage />
|
||||
<AllVersionsPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.connections}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<Connections />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
)
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
</Route>
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.error}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ErrorPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routePaths.login}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<LoginPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
)
|
||||
}
|
||||
|
||||
export default Routers
|
||||
@@ -13,6 +13,9 @@ type RoutePaths =
|
||||
| 'configuration'
|
||||
| 'modules'
|
||||
| 'application'
|
||||
| 'connections'
|
||||
| 'configurations'
|
||||
| 'allVersions'
|
||||
|
||||
export const routePaths: Record<RoutePaths, string> = {
|
||||
home: '/',
|
||||
@@ -28,5 +31,8 @@ export const routePaths: Record<RoutePaths, string> = {
|
||||
applicationsGroup: '/applications_group',
|
||||
configuration: '/configuration',
|
||||
modules: '/modules',
|
||||
application: 'application'
|
||||
application: 'application',
|
||||
connections: 'connections',
|
||||
configurations: 'configurations',
|
||||
allVersions: ':configId/all_versions'
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ConfigResponse, ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
import { VersionType } from '@type/version.type.ts'
|
||||
|
||||
|
||||
const configServiceApi = createApi({
|
||||
reducerPath: 'configApi',
|
||||
tagTypes: ['configs', 'versions', 'config'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getConfigsByModuleId: builder.query<ConfigResponse, string>({
|
||||
query: (moduleId) => ({
|
||||
url: apiPaths.getConfigsByModuleId,
|
||||
data: { moduleId }
|
||||
}),
|
||||
transformResponse: (response: ConfigType[]): ConfigResponse => {
|
||||
const activeObjects: ConfigType[] = []
|
||||
const inactiveObjects: ConfigType[] = []
|
||||
response.forEach((obj) => {
|
||||
if (obj.active) {
|
||||
activeObjects.push(obj)
|
||||
} else {
|
||||
inactiveObjects.push(obj)
|
||||
}
|
||||
})
|
||||
return {
|
||||
originalResponse: response,
|
||||
activeConfigs: activeObjects,
|
||||
inactiveConfigs: inactiveObjects
|
||||
}
|
||||
},
|
||||
providesTags: () => ['configs']
|
||||
}),
|
||||
getConfigById: builder.query<ConfigType, string>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getConfigById,
|
||||
data: { id }
|
||||
}),
|
||||
providesTags: () => ['config']
|
||||
}),
|
||||
getAllVersion: builder.query<VersionType[], string>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.getAllVersions,
|
||||
data: { id }
|
||||
}),
|
||||
transformResponse: (response: VersionType[]) => {
|
||||
return response.sort((a, b) => b.configVersion - a.configVersion)
|
||||
},
|
||||
providesTags: () => ['versions']
|
||||
}),
|
||||
createUpdateConfig: builder.mutation<ConfigType, ConfigType>({
|
||||
query: (data) => ({ url: apiPaths.createUpdateConfig, data }),
|
||||
invalidatesTags: () => ['configs', 'versions']
|
||||
}),
|
||||
deleteVersion: builder.mutation<void, string>({
|
||||
query: (id) => ({ url: apiPaths.deleteVersion, data: { id } }),
|
||||
invalidatesTags: () => ['versions']
|
||||
}),
|
||||
deleteConfig: builder.mutation<void, string>({
|
||||
query: (id) => ({ url: apiPaths.deleteVersion, data: [id] }),
|
||||
invalidatesTags: () => ['versions']
|
||||
}),
|
||||
markConfigAsActive: builder.mutation<void, string>({
|
||||
query: (id) => ({ url: apiPaths.markConfigAsActive, data: { id } }),
|
||||
invalidatesTags: () => ['configs']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default configServiceApi
|
||||
@@ -7,6 +7,7 @@ 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 configServiceApi from '@services/configService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import routeApi from '@services/routeService.ts'
|
||||
@@ -41,6 +42,7 @@ const rootReducer = combineReducers({
|
||||
[modulesServiceApi.reducerPath]: modulesServiceApi.reducer,
|
||||
[applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer,
|
||||
[applicationsApi.reducerPath]: applicationsApi.reducer,
|
||||
[configServiceApi.reducerPath]: configServiceApi.reducer,
|
||||
[tokensApi.reducerPath]: tokensApi.reducer
|
||||
})
|
||||
|
||||
@@ -60,7 +62,8 @@ export const setupStore = () =>
|
||||
modulesServiceApi.middleware,
|
||||
applicationsGroupApi.middleware,
|
||||
applicationsApi.middleware,
|
||||
tokensApi.middleware
|
||||
tokensApi.middleware,
|
||||
configServiceApi.middleware
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface VersionType {
|
||||
id: string
|
||||
configId: string
|
||||
configVersion: number
|
||||
createdAt: string
|
||||
data: Record<string, unknown>
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
const sortObject = (obj: any): any => {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(sortObject)
|
||||
}
|
||||
|
||||
const sorted: any = {}
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach((key) => {
|
||||
sorted[key] = sortObject(obj[key])
|
||||
})
|
||||
return sorted
|
||||
}
|
||||
|
||||
export { sortObject }
|
||||
Vendored
+1
@@ -1,2 +1,3 @@
|
||||
/// <reference types="vite/client" />
|
||||
declare const APP_VERSION: string
|
||||
declare module '@stoplight/json-schema-viewer'
|
||||
@@ -1,5 +1,9 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.access-list-tree{
|
||||
overflow-y: scroll;
|
||||
height: calc(100vh - 250px);
|
||||
|
||||
&__inner-tag{
|
||||
margin-left: $basic-margin;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ const AccessListTree: FC<AccessListTreePropsType> = ({
|
||||
<span className={`${unknown ? 'unknown-label' : ''}`}>
|
||||
{obj.path}
|
||||
{obj.inner ? (
|
||||
<Tag color="processing" bordered={false}>
|
||||
<Tag className="access-list-tree__inner-tag" color="processing" bordered={false}>
|
||||
Внутренний
|
||||
</Tag>
|
||||
) : null}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
|
||||
.active-configurations-table-actions-field {
|
||||
display: flex;
|
||||
gap: $basic-margin;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
display: flex;
|
||||
gap: $basic-margin;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ActiveTableActionButtonsPropsType {
|
||||
isActive: boolean
|
||||
record: ConfigType
|
||||
handleShowConfig: (record: ConfigType) => void
|
||||
handleShowCompareModal: (record: ConfigType) => void
|
||||
handleDeleteConfig: (record: ConfigType) => void
|
||||
handleMarkConfigActive: (record: ConfigType) => void
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import {
|
||||
AlertOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
EyeOutlined,
|
||||
HistoryOutlined,
|
||||
SwapOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
||||
import { FC } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons.type.ts'
|
||||
|
||||
import './active-table-action-buttons.scss'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
||||
({
|
||||
isActive,
|
||||
record,
|
||||
handleShowCompareModal,
|
||||
handleShowConfig,
|
||||
handleDeleteConfig,
|
||||
handleMarkConfigActive
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const navigateToAllVersion = () => navigate(`${record.id}/all_versions`)
|
||||
|
||||
const renderDropDown = (record: any) => {
|
||||
return (
|
||||
<div className="dropdown">
|
||||
<Tooltip key="1" title="Сравнение версий">
|
||||
<Button
|
||||
onClick={() => handleShowCompareModal(record)}
|
||||
icon={<SwapOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip key="2" title="Просмотр истории">
|
||||
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
||||
</Tooltip>
|
||||
<CanEdit>
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите удалить выбранный конфиг?"
|
||||
onConfirm={() => handleDeleteConfig(record)}
|
||||
>
|
||||
<Tooltip key="3" title="Удалить конфиг">
|
||||
<Button danger icon={<DeleteOutlined />} />
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
</CanEdit>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const renderAdditionalButtons = () => {
|
||||
if (isActive) {
|
||||
return (
|
||||
<>
|
||||
<Tooltip key="1" title="Сравнение версий">
|
||||
<Button
|
||||
onClick={() => handleShowCompareModal(record)}
|
||||
icon={<SwapOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip key="2" title="Просмотр истории">
|
||||
<Button
|
||||
onClick={navigateToAllVersion}
|
||||
icon={<HistoryOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<CanEdit>
|
||||
<Tooltip key="3" title="Сделать конфигурацию активной">
|
||||
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
<Dropdown dropdownRender={() => renderDropDown(record)}>
|
||||
<Button>...</Button>
|
||||
</Dropdown>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div className="active-configurations-table-actions-field">
|
||||
<Tooltip title="Просмотр конфигурации">
|
||||
<Button
|
||||
onClick={() => handleShowConfig(record)}
|
||||
icon={<EyeOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать конфигурацию">
|
||||
<Button icon={<EditOutlined />} />
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
{renderAdditionalButtons()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActiveTableActionButtons
|
||||
Reference in new issue
Block a user