Merge branch 'MSP-3237_style-header' into 'main'
MSP-3237 "Style header" See merge request isp/isp-admin-ui!23
This commit is contained in:
commit
aa6853211b
23 files changed
+234
-47
No files matched your search
@@ -1,3 +1,6 @@
|
||||
## 0.10.1
|
||||
- В index.html добавлен config.js
|
||||
- Добавлены динамические стили для админок
|
||||
## 0.10.0
|
||||
- - Добавлена страница 'Модули'
|
||||
## 0.9.0
|
||||
|
||||
+3
-1
@@ -8,7 +8,9 @@
|
||||
<script type="module">
|
||||
window.AppVersion = APP_VERSION
|
||||
</script>
|
||||
</head>
|
||||
<script type="module" src="/config.js"></script>
|
||||
<title>Панель администратора</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "isp-admin-ui",
|
||||
"private": true,
|
||||
"version": "0.10.0",
|
||||
"version": "0.10.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
|
||||
Whitespace-only changes.
@@ -7,7 +7,7 @@
|
||||
|
||||
&__wrap-table {
|
||||
overflow-x: scroll;
|
||||
height: calc(100vh - 30px);
|
||||
height: calc(100vh - 100px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,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'
|
||||
@@ -23,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
|
||||
@@ -39,6 +42,7 @@ const LayoutComponent = () => {
|
||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeysType[]>(
|
||||
[]
|
||||
)
|
||||
const [title, setTitle] = useState('')
|
||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
||||
const dispatch = useAppDispatch()
|
||||
const {
|
||||
@@ -143,6 +147,7 @@ const LayoutComponent = () => {
|
||||
useEffect(() => {
|
||||
if (userToken) {
|
||||
dispatch(fetchProfile())
|
||||
dispatch(fetchUI())
|
||||
}
|
||||
}, [])
|
||||
|
||||
@@ -152,6 +157,7 @@ const LayoutComponent = () => {
|
||||
const menuItem = menuKeys[menuKey]
|
||||
|
||||
if (menuItem) {
|
||||
setTitle(MenuItemLabelsType[menuItem.key])
|
||||
setSelectedMenuKeys([menuItem.key])
|
||||
setOpenKeys(menuItem.parent)
|
||||
}
|
||||
@@ -197,37 +203,40 @@ const LayoutComponent = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
{status === StateProfileStatus.pending ? (
|
||||
<Spin size="large" />
|
||||
) : (
|
||||
<>
|
||||
<Sider
|
||||
width="250px"
|
||||
data-cy="aside"
|
||||
theme="light"
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={(value) => setCollapsed(value)}
|
||||
>
|
||||
<Menu
|
||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
||||
openKeys={openKeys}
|
||||
selectedKeys={selectedMenuKeys}
|
||||
onClick={handlerOnClickMenu}
|
||||
<section>
|
||||
<Header title={title} />
|
||||
<Layout className="layout" data-cy="homePage">
|
||||
{status === StateProfileStatus.pending ? (
|
||||
<Spin size="large" />
|
||||
) : (
|
||||
<>
|
||||
<Sider
|
||||
width="250px"
|
||||
data-cy="aside"
|
||||
theme="light"
|
||||
mode="inline"
|
||||
items={menuItems}
|
||||
/>
|
||||
</Sider>
|
||||
<Layout className="site-layout">
|
||||
<Content className="site-layout__content">
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
</>
|
||||
)}
|
||||
</Layout>
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={(value) => setCollapsed(value)}
|
||||
>
|
||||
<Menu
|
||||
onOpenChange={(keys) => setOpenKeys(keys)}
|
||||
openKeys={openKeys}
|
||||
selectedKeys={selectedMenuKeys}
|
||||
onClick={handlerOnClickMenu}
|
||||
theme="light"
|
||||
mode="inline"
|
||||
items={menuItems}
|
||||
/>
|
||||
</Sider>
|
||||
<Layout className="site-layout">
|
||||
<Content className="site-layout__content">
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
</>
|
||||
)}
|
||||
</Layout>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@import 'src/constants/style/styleConst';
|
||||
|
||||
.layout {
|
||||
min-height: 100vh !important;
|
||||
min-height: calc(100vh - 65px) !important;
|
||||
position: relative;
|
||||
|
||||
.hide-item {
|
||||
|
||||
@@ -9,7 +9,18 @@ export enum MenuItemKeysType {
|
||||
logout = 'logout',
|
||||
profile = 'profile',
|
||||
modules = 'modules',
|
||||
applications = 'applications',
|
||||
applications = 'applications'
|
||||
}
|
||||
export enum MenuItemLabelsType {
|
||||
users = 'Пользователи',
|
||||
sessions = 'Пользовательские сессии',
|
||||
securityLog = 'Просмотр журналов ИБ',
|
||||
appAccess = 'Доступы приложений',
|
||||
roles = 'Роли',
|
||||
profile = 'Профиль',
|
||||
modules = 'Модули',
|
||||
applications = 'Группа приложений',
|
||||
logout = 'Выход',
|
||||
}
|
||||
|
||||
interface MenuItem {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
.app{
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
padding: 0 $basic-padding;
|
||||
min-height: 0;
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ type PathKeys =
|
||||
| 'getTokensByAppId'
|
||||
| 'revokeTokens'
|
||||
| 'revokeTokensForApp'
|
||||
| 'getUI'
|
||||
|
||||
export const apiPaths: Record<PathKeys, string> = {
|
||||
baseUrl: '/api/kkd-configuration-service',
|
||||
@@ -61,6 +62,7 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
logout: '/api/admin/auth/logout',
|
||||
// ======= PROFILE ======
|
||||
getProfile: '/api/admin/user/get_profile',
|
||||
getUI: '/api/admin/user/get_design',
|
||||
// ======= USERS ======
|
||||
getUsers: '/get_users',
|
||||
createUser: '/create_user',
|
||||
@@ -99,7 +101,7 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
getServicesByDomainId: '/service/get_services_by_domain_id',
|
||||
// ======= TOKENS ======
|
||||
createToken: '/token/create_token',
|
||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
||||
getTokensByAppId: '/token/get_tokens_by_app_id',
|
||||
revokeTokens: '/token/revoke_tokens',
|
||||
revokeTokensForApp: '/token/revoke_tokens_for_app'
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.applications-page {
|
||||
height: 100vh;
|
||||
height: 100%;
|
||||
.three-columns {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
|
||||
@@ -55,7 +55,6 @@ const ApplicationsPage = () => {
|
||||
applicationsGroupApi.useRemoveApplicationsGroupMutation()
|
||||
|
||||
const isPageAvailable = hasPermission(PermissionKeysType.read)
|
||||
const hasRevokePermission = hasPermission(PermissionKeysType.write)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPageAvailable) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
&__tabs {
|
||||
overflow-x: scroll;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-list-item {
|
||||
|
||||
@@ -15,3 +15,14 @@ export type ProfileType = {
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
|
||||
export type UIDataType = {
|
||||
name: string
|
||||
primaryColor: string
|
||||
}
|
||||
|
||||
export type UIType = {
|
||||
ui: UIDataType
|
||||
status: StateProfileStatus
|
||||
error: string
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import { createContext, Dispatch, SetStateAction } from 'react'
|
||||
|
||||
import accessListApi from '@services/accessListService.ts'
|
||||
import appApi from '@services/appService.ts'
|
||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import routeApi from '@services/routeService.ts'
|
||||
@@ -13,8 +15,7 @@ import sessionServiceApi from '@services/sessionService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import profileReducer from './redusers/ProfileSlice.ts'
|
||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
import UIReducer from './redusers/UISlice.ts'
|
||||
|
||||
export interface ContextProps {
|
||||
setTheme: Dispatch<
|
||||
@@ -28,6 +29,7 @@ export const Context = createContext<ContextProps>({
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
profileReducer,
|
||||
UIReducer,
|
||||
[roleApi.reducerPath]: roleApi.reducer,
|
||||
[userServiceApi.reducerPath]: userServiceApi.reducer,
|
||||
[sessionServiceApi.reducerPath]: sessionServiceApi.reducer,
|
||||
@@ -37,7 +39,7 @@ const rootReducer = combineReducers({
|
||||
[routeApi.reducerPath]: routeApi.reducer,
|
||||
[modulesServiceApi.reducerPath]: modulesServiceApi.reducer,
|
||||
[applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer,
|
||||
[applicationsApi.reducerPath]: applicationsApi.reducer,
|
||||
[applicationsApi.reducerPath]: applicationsApi.reducer
|
||||
})
|
||||
|
||||
export const setupStore = () =>
|
||||
|
||||
@@ -2,11 +2,15 @@ import { createAsyncThunk } from '@reduxjs/toolkit'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ProfileDataType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
import {
|
||||
ProfileDataType,
|
||||
UIDataType
|
||||
} from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { initUI } from '@utils/UIUtiles.tsx'
|
||||
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
|
||||
export const fetchProfile = createAsyncThunk(
|
||||
'profile/fetchProfile',
|
||||
async (_, { rejectWithValue }) => {
|
||||
@@ -20,3 +24,15 @@ export const fetchProfile = createAsyncThunk(
|
||||
}
|
||||
}
|
||||
)
|
||||
export const fetchUI = createAsyncThunk(
|
||||
'ui/fetchUI',
|
||||
async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await apiService.post<UIDataType>(apiPaths.getUI)
|
||||
initUI(response.data)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
return rejectWithValue(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
ActionReducerMapBuilder,
|
||||
createSlice,
|
||||
PayloadAction
|
||||
} from '@reduxjs/toolkit'
|
||||
|
||||
import { UIDataType, UIType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
||||
|
||||
import { fetchUI } from './ActionCreators.ts'
|
||||
|
||||
export const initialState: UIType = {
|
||||
ui: {
|
||||
name: '',
|
||||
primaryColor: ''
|
||||
},
|
||||
status: StateProfileStatus.notInit,
|
||||
error: ''
|
||||
}
|
||||
|
||||
export const UISlice = createSlice({
|
||||
name: 'ui',
|
||||
initialState,
|
||||
reducers: {
|
||||
clearUI(state) {
|
||||
state.ui = initialState.ui
|
||||
}
|
||||
},
|
||||
extraReducers: (builder: ActionReducerMapBuilder<UIType>) => {
|
||||
builder
|
||||
.addCase(
|
||||
fetchUI.fulfilled,
|
||||
(state, action: PayloadAction<UIDataType>) => {
|
||||
state.status = StateProfileStatus.resolved
|
||||
state.ui = { ...action.payload }
|
||||
}
|
||||
)
|
||||
.addCase(fetchUI.pending, (state) => {
|
||||
state.status = StateProfileStatus.pending
|
||||
})
|
||||
.addCase(fetchUI.rejected, (state, action: any) => {
|
||||
state.status = StateProfileStatus.rejected
|
||||
state.error = action.payload
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default UISlice.reducer
|
||||
@@ -0,0 +1,26 @@
|
||||
import { UIDataType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
const drawSVG = (color: string) =>
|
||||
`<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" fill="${color}"><path d="M24 19h-1v-2.2c-1.853 4.237-6.083 7.2-11 7.2-6.623 0-12-5.377-12-12h1c0 6.071 4.929 11 11 11 4.66 0 8.647-2.904 10.249-7h-2.249v-1h4v4zm-11.036 0h-1.886c-.34-.957-.437-1.571-1.177-1.878h-.001c-.743-.308-1.251.061-2.162.494l-1.333-1.333c.427-.899.804-1.415.494-2.163-.308-.74-.926-.839-1.878-1.177v-1.886c.954-.339 1.57-.437 1.878-1.178.308-.743-.06-1.248-.494-2.162l1.333-1.333c.918.436 1.421.801 2.162.494l.001-.001c.74-.307.838-.924 1.177-1.877h1.886c.34.958.437 1.57 1.177 1.877l.001.001c.743.308 1.252-.062 2.162-.494l1.333 1.333c-.435.917-.801 1.421-.494 2.161v.001c.307.739.915.835 1.878 1.178v1.886c-.953.338-1.571.437-1.878 1.178-.308.743.06 1.249.494 2.162l-1.333 1.333c-.92-.438-1.42-.802-2.157-.496-.746.31-.844.926-1.183 1.88zm-.943-4.667c-1.289 0-2.333-1.044-2.333-2.333 0-1.289 1.044-2.334 2.333-2.334 1.289 0 2.333 1.045 2.333 2.334 0 1.289-1.044 2.333-2.333 2.333zm-8.021-5.333h-4v-4h1v2.2c1.853-4.237 6.083-7.2 11-7.2 6.623 0 12 5.377 12 12h-1c0-6.071-4.929-11-11-11-4.66 0-8.647 2.904-10.249 7h2.249v1z"></path></svg>`
|
||||
|
||||
export const createSVG = (color: string) => {
|
||||
const svgString = drawSVG(color)
|
||||
return btoa(svgString) // base64
|
||||
}
|
||||
|
||||
export const initSVG = (color: string) => {
|
||||
const favicon = document.createElement('link')
|
||||
favicon.id = 'favicon'
|
||||
favicon.rel = 'shortcut icon'
|
||||
favicon.type = 'image/x-icon'
|
||||
favicon.href = `data:image/svg+xml;base64,${createSVG(color)}`
|
||||
return favicon
|
||||
}
|
||||
|
||||
export const initUI = (ui: UIDataType) => {
|
||||
let favicon = document.getElementById('favicon')
|
||||
favicon = initSVG(ui.primaryColor)
|
||||
const titles = document.getElementsByTagName('title')
|
||||
document.head.insertBefore(favicon, titles[0])
|
||||
document.title = `${ui.name} — MSP`
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
.access-list-tree{
|
||||
overflow-y: scroll;
|
||||
height: calc(100vh - 130px);
|
||||
height: calc(100vh - 250px);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 28px;
|
||||
width: 100%;
|
||||
height: 65px;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface HeaderPropsType {
|
||||
title: string
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { HomeOutlined } from '@ant-design/icons'
|
||||
import { Breadcrumb } from 'antd'
|
||||
|
||||
import { HeaderPropsType } from '@widgets/Header/header.type.ts'
|
||||
|
||||
import { useAppSelector } from '@hooks/redux.ts'
|
||||
|
||||
import './header.scss'
|
||||
|
||||
const Header = ({ title }: HeaderPropsType) => {
|
||||
const {
|
||||
ui: { name, primaryColor }
|
||||
} = useAppSelector((state) => state.UIReducer)
|
||||
|
||||
return (
|
||||
<section
|
||||
className="header"
|
||||
style={{
|
||||
backgroundColor: primaryColor
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{
|
||||
href: '/',
|
||||
title: (
|
||||
<>
|
||||
<HomeOutlined />
|
||||
<span>Главная</span>
|
||||
</>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: <span>{title}</span>
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<span>{name}</span>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Header
|
||||
@@ -8,6 +8,6 @@
|
||||
border: 1px dashed $grey;
|
||||
|
||||
overflow-y: scroll;
|
||||
height: calc(100vh - 130px);
|
||||
height: calc(100vh - 160px);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user