Merge branch 'MSP-3103_login-page' into 'main'

MSP-3103 "Login page"

See merge request isp/isp-admin-ui!5
This commit is contained in:
Анастасия Ануфриева committed 2024-04-08 14:18:30 +00:00
commit fa744894d9
30 files changed
+603 -146

No files matched your search

+4 -7
View File
@@ -1,17 +1,14 @@
## 0.2.4
- Изменен Layout
## 0.2.3
- Добавлен экран входа
## 0.2.2
- Добавлен редирект после логина
## 0.2.1
- ThemeProvider заменен на ConfigProvider в компоненте <App>
## 0.2.0
- Добавлены роли и приватный роутер
## 0.1.0
- Инициализирован проект
- Добавлена темная тема antd
- Добавлен layout
+3 -2
View File
@@ -1,7 +1,7 @@
{
"name": "unsubscribe_landing",
"private": true,
"version": "0.2.2",
"version": "0.2.4",
"type": "module",
"scripts": {
"start": "vite",
@@ -17,9 +17,10 @@
"@reduxjs/toolkit": "^2.2.3",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.6.8",
"isp-ui-kit": "https://github.com/integration-system/isp-ui-kit.git",
"isp-ui-kit": "https://github.com/txix-open/isp-ui-kit",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.2",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.3"
},
+9
View File
@@ -0,0 +1,9 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="24" height="24" fill="url(#pattern0)"/>
<defs>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_121_5920" transform="scale(0.0025)"/>
</pattern>
<image id="image0_121_5920" width="400" height="400" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAgAElEQVR4Ae29e9AcVbnvn7JqV/mP5w/PH5YQuQgYRcIlBaRAkmACKBQ3cQPyCwUGs1Pctv5gi8IBIWhSapAtAmfDO+/7GhRPwQbMBSFbSDCH24YYCJDpSZBggSGFsnETiVwUj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Om+ZJMmgZ19NzukNMYNjgkbSFLfCzzB0tUVLXCUrmetiEEn6vRRfLAx1bQunnLlmnBFJRZYBBzVlKnmi2esUENpbr4Xyi4KAGZd7roumESSP8/tCzH2osmKFdDXJ3Rzb+Css6eA+h572X+r/yCL9w2XqyVXNEKiIRP1zXkw2F38SGr3TSystWIZiwUsqdpz1PWb/DtEfoM6Y9dvkjDwZfAaXxWbEDugAy+TX4dYKdGglXJmmPkGl8DuS5mDLyOcb37B7I74MdHqkTRuQb5+X8BDJwPa6L3+rcoZf8UvBX3vMnX05ZTH62TcX6DdMu6x7oeYsnp44nGzS8twIS6XRlqQ7g4gdwIFMif4IVcPSVnIXgd2W9QlKQA4B82sKNPkgDpAC4zdkcbacLnyEifEcQDgQRFLskCCJKxBCRqc2YtsqSs563vDmULine truncated
</defs>
</svg>

After

Width:  |  Height:  |  Size: 35 KiB

+3
View File
@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.2118 12.3535L9.15396 8.29564C9.78364 7.48158 10.1243 6.48627 10.1243 5.43939C10.1243 4.18627 9.6352 3.01127 8.75083 2.12533C7.86645 1.23939 6.68833 0.751892 5.43677 0.751892C4.1852 0.751892 3.00708 1.24095 2.1227 2.12533C1.23677 3.0097 0.749268 4.18627 0.749268 5.43939C0.749268 6.69095 1.23833 7.86908 2.1227 8.75345C3.00708 9.63939 4.18364 10.1269 5.43677 10.1269C6.48364 10.1269 7.47739 9.78627 8.29146 9.15814L12.3493 13.2144C12.3612 13.2263 12.3753 13.2357 12.3908 13.2422C12.4064 13.2486 12.4231 13.2519 12.4399 13.2519C12.4567 13.2519 12.4734 13.2486 12.4889 13.2422C12.5045 13.2357 12.5186 13.2263 12.5305 13.2144L13.2118 12.5347C13.2237 12.5228 13.2331 12.5087 13.2396 12.4931C13.246 12.4776 13.2493 12.4609 13.2493 12.4441C13.2493 12.4272 13.246 12.4106 13.2396 12.395C13.2331 12.3795 13.2237 12.3654 13.2118 12.3535ZM7.91177 7.91439C7.24927 8.57533 6.37114 8.93939 5.43677 8.93939C4.50239 8.93939 3.62427 8.57533 2.96177 7.91439C2.30083 7.25189 1.93677 6.37377 1.93677 5.43939C1.93677 4.50502 2.30083 3.62533 2.96177 2.96439C3.62427 2.30345 4.50239 1.93939 5.43677 1.93939C6.37114 1.93939 7.25083 2.30189 7.91177 2.96439C8.57271 3.62689 8.93677 4.50502 8.93677 5.43939C8.93677 6.37377 8.57271 7.25346 7.91177 7.91439Z" fill="black" fill-opacity="0.85"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

+81 -44
View File
@@ -1,54 +1,76 @@
import { Menu } from 'antd'
import { ProfileOutlined } from '@ant-design/icons'
import { Layout, Menu, Spin } from 'antd'
import { useEffect, useState } from 'react'
import { Navigate, Outlet, useNavigate } from 'react-router-dom'
import { Navigate, Outlet, useLocation } from 'react-router-dom'
import Header from '@components/Header'
import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { useAppSelector } from '@hooks/redux.ts'
import { useRole } from '@hooks/useRole.tsx'
import {
MenuItemKeys,
MenuItemType,
menuKeys
} from '@components/Layout/layout.type.ts'
import UserMenu from '@components/UserMenu'
import { LocalStorage } from '@utils/localStorageUtils.ts'
import { useAppDispatch, useAppSelector } from '@hooks/redux.ts'
import useRole from '@hooks/useRole.tsx'
import { fetchProfile } from '@stores/redusers/ActionCreators.ts'
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
import { routePaths } from '@routes/routePaths.ts'
import { PermissionKeys } from '@type/roles.type.ts'
import { MenuItemKeys, menuKeys } from './layout.type.ts'
import './layout.scss'
const Layout = () => {
const { hasPermission } = useRole()
const navigate = useNavigate()
const { status } = useAppSelector((state) => state.profileReducer)
const { Header, Content, Sider } = Layout
const [openKeys, setOpenKeys] = useState<string[]>([])
const LayoutComponent = () => {
const [collapsed, setCollapsed] = useState<boolean>(false)
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeys[]>([])
const [openKeys, setOpenKeys] = useState<string[]>([])
const dispatch = useAppDispatch()
const { status } = useAppSelector((state) => state.profileReducer)
const location = useLocation()
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
const { hasPermission } = useRole()
const hideItem = (permission: PermissionKeys | PermissionKeys[]) => {
if (Array.isArray(permission)) {
const result = permission.reduce((acc, currentValue) => {
const isHasPermission = hasPermission(currentValue)
return isHasPermission || acc
const hasPermissionFunc = hasPermission(currentValue)
return hasPermissionFunc || acc
}, false)
return result ? '' : 'hide-item'
}
return hasPermission(permission) ? '' : 'hide-item'
}
const menuItems = [
const menuItems: MenuItemType[] = [
{
label: 'Profile',
key: 'users',
className: hideItem(PermissionKeys.user_view)
},
{
label: 'Profile2',
key: 'roles',
className: hideItem(PermissionKeys.user_view)
label: 'Пользователи и роли',
key: 'sessionManagement',
className: hideItem([PermissionKeys.user_view]),
icon: <ProfileOutlined />,
children: [
{
label: 'Пользователи',
key: 'users',
className: hideItem(PermissionKeys.user_view)
}
]
}
]
useEffect(() => {
if (userToken) {
dispatch(fetchProfile())
}
}, [])
useEffect(() => {
const menuKey = location.pathname.split('/')[1] as MenuItemKeys
@@ -62,12 +84,6 @@ const Layout = () => {
const handlerOnClickMenu = ({ key }: any): void => {
switch (key) {
case MenuItemKeys.roles:
navigate(routePaths.error)
break
case MenuItemKeys.users:
navigate(routePaths.home)
break
default:
}
}
@@ -77,20 +93,41 @@ const Layout = () => {
}
return (
<section className="layout">
<Header />
<Menu
onOpenChange={(keys) => setOpenKeys(keys)}
openKeys={openKeys}
selectedKeys={selectedMenuKeys}
onClick={handlerOnClickMenu}
theme="light"
mode="inline"
items={menuItems}
/>
<Outlet />
</section>
<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}
theme="light"
mode="inline"
items={menuItems}
/>
</Sider>
<Layout className="site-layout">
<Header className="site-layout-background header" data-cy="header">
<UserMenu />
</Header>
<Content className="site-layout__content">
<Outlet />
</Content>
</Layout>
</>
)}
</Layout>
)
}
export default Layout
export default LayoutComponent
+63 -2
View File
@@ -1,4 +1,65 @@
.layout {
min-height: calc(100vh - 96px);
width: 100%;
min-height: 100vh !important;
position: relative;
.hide-item {
display: none !important;
}
.ant-spin {
position: absolute;
top: 50%;
left: 50%;
}
.header {
display: flex;
align-items: center;
justify-content: flex-end;
line-height: 18px;
background: #fff;
padding: 0;
&__search {
max-width: 300px;
border: none;
margin-right: auto;
padding-right: 40px;
position: relative;
&:after {
content: '';
background: url("/src/assets/icon/search-icon.svg");
width: 13px;
height: 13px;
position: absolute;
right: 45px;
top: 50%;
transform: translateY(-50%);
}
.ant-input-search .ant-input:focus, .ant-input-search .ant-input:hover {
border-color: red !important;
}
& .ant-input {
border: none;
}
& button {
border: none;
display: none;
}
}
& .user {
padding-right: 34px;
}
}
.ant-menu {
border-inline-end: none !important;
}
.ant-layout-sider {
padding-top: 64px;
}
.ant-menu-title-content {
color: #1B1B1B;
padding-left: 15px;
}
}
+1 -6
View File
@@ -1,8 +1,7 @@
import { MenuProps } from 'antd'
export enum MenuItemKeys {
users = 'users',
roles = 'roles'
users = 'users'
}
type MenuItem = {
@@ -13,10 +12,6 @@ export const menuKeys: Record<MenuItemKeys, MenuItem> = {
[MenuItemKeys.users]: {
key: MenuItemKeys.users,
parent: ['sessionManagement']
},
[MenuItemKeys.roles]: {
key: MenuItemKeys.roles,
parent: ['sessionManagement']
}
}
+70
View File
@@ -0,0 +1,70 @@
import { LogoutOutlined, ProfileOutlined } from '@ant-design/icons'
import { Dropdown, MenuProps } from 'antd'
import { useAuth } from 'isp-ui-kit'
import { useNavigate } from 'react-router-dom'
import { apiPaths } from '@constants/api/apiPaths.ts'
import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { UserMenuKeys } from '@components/UserMenu/user-menu.type.ts'
import { getConfigProperty } from '@utils/configUtils.ts'
import { LocalStorage } from '@utils/localStorageUtils.ts'
import { useAppSelector } from '@hooks/redux.ts'
import { routePaths } from '@routes/routePaths.ts'
import './user.scss'
const items: MenuProps['items'] = [
{
label: 'Профиль',
key: 'profile',
icon: <ProfileOutlined />
},
{
label: 'Выход',
key: 'logout',
icon: <LogoutOutlined />
}
]
export default function UserMenu() {
const navigate = useNavigate()
const { logout } = useAuth()
const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME)
const {
profile: { firstName }
} = useAppSelector((state) => state.profileReducer)
const handlerDropDownClick = (e: any) => {
if ((e.key as UserMenuKeys) === 'logout') {
logout(apiPaths.logout, {
'X-APPLICATION-TOKEN': getConfigProperty(
'APP_TOKEN',
import.meta.env.VITE_APP_TOKEN
),
[headerName]: LocalStorage.get(localStorageKeys.USER_TOKEN)
})
.then(() => {
LocalStorage.remove(localStorageKeys.USER_TOKEN)
LocalStorage.remove(localStorageKeys.HEADER_NAME)
navigate(routePaths.login, { replace: true })
})
.catch(() => {})
}
}
return (
<Dropdown
trigger={['click']}
menu={{ items, onClick: handlerDropDownClick }}
className="user"
>
<div role="presentation" onClick={(e) => e.preventDefault()}>
<span className="user__avatar" />
<span className="user__name">{firstName || ''}</span>
</div>
</Dropdown>
)
}
@@ -0,0 +1 @@
export type UserMenuKeys = 'logout' | 'profile'
+16
View File
@@ -0,0 +1,16 @@
@import "src/constants/styleConstants";
.user {
cursor: pointer;
display: flex;
align-items: center;
background: transparent;
border: none;
&__avatar {
width: 24px;
height: 24px;
background: url("/src/assets/icon/default-user.svg") no-repeat, center left;
}
&__name {
margin-left: $basic-margin;
}
}
+12 -3
View File
@@ -1,4 +1,13 @@
#root {
width: 100%;
text-align: center;
@import "src/constants/styleConstants";
*, html {
margin:0;
padding:0;
box-sizing: border-box;
}
.app{
padding: 0 $basic-padding;
min-height: 0;
min-width: 500px;
}
+4 -2
View File
@@ -1,5 +1,7 @@
type PathKeys = 'baseUrl'
type PathKeys = 'baseUrl' | 'login' | 'logout'
export const apiPaths: Record<PathKeys, string> = {
baseUrl: '/'
baseUrl: '/',
login: '/api/admin/auth/login',
logout: '/api/admin/auth/logout'
}
+5
View File
@@ -0,0 +1,5 @@
type ValidationRulesKeys = 'required'
export const ValidationRules: Record<ValidationRulesKeys, any> = {
required: { value: true, message: 'Поле не может быть пустым' }
}
+6
View File
@@ -0,0 +1,6 @@
type MessagesKey = 'serverError' | 'loginError'
export const messages: Record<MessagesKey, string> = {
serverError: 'Внутренняя ошибка сервиса',
loginError: 'Неверный логин или пароль'
}
+18
View File
@@ -0,0 +1,18 @@
$background-color: #F0F2F5;
$text-color-gray: var(--ant-primary-color);
$text-color-blue: #1890FF;
$basic-margin: 8px;
$basic-padding: 8px;
$text-size: 14px;
$border-color: #F0F0F0;
$blue-color: #40A9FF;
$blue-light: #E6F7FF;
$grey:#606060;
$red: #FF4D4F;
$green: #52C41A;
$yellow: #FAAD14;
-4
View File
@@ -1,4 +0,0 @@
body {
margin: 0;
min-height: 100vh;
}
-1
View File
@@ -5,7 +5,6 @@ import { BrowserRouter } from 'react-router-dom'
import App from './components/App.tsx'
import './index.css'
import { setupStore } from './stores'
const store = setupStore()
+13
View File
@@ -0,0 +1,13 @@
.home-page {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-image: url("/src/assets/images/home-background.png");
font-size: calc(1.5vw + 1.5vh);
font-family: 'Roboto',sans-serif;
font-style: normal;
font-weight: 400;
line-height: 56px;
}
-5
View File
@@ -1,5 +0,0 @@
.main {
min-height: 100vh;
display: flex;
justify-content: center;
}
+3 -27
View File
@@ -1,29 +1,5 @@
import { Button, theme } from 'antd'
import './home-page.scss'
import { useRole } from '@hooks/useRole.tsx'
import { PermissionKeys } from '@type/roles.type.ts'
import './home.scss'
const HomePages = () => {
const { hasPermission } = useRole()
const { useToken } = theme
const { token } = useToken()
const isPageAvailable = hasPermission(PermissionKeys.user_view)
return (
<main className="main" style={{ backgroundColor: token.colorBgLayout }}>
{isPageAvailable && (
<Button ghost type="primary">
Border
</Button>
)}
<div>Проверка шрифтов</div>
<Button type="primary">Primary</Button>
</main>
)
export default function HomePage() {
return <div className="home-page">Добро пожаловать!</div>
}
export default HomePages
+108 -11
View File
@@ -1,21 +1,118 @@
import { LockOutlined, UserOutlined } from '@ant-design/icons'
import { Button, Divider } from 'antd'
import { AxiosError } from 'axios'
import { FormComponents, useAuth } from 'isp-ui-kit'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { apiPaths } from '@constants/api/apiPaths.ts'
import { ValidationRules } from '@constants/form/validationRules.ts'
import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { messages } from '@constants/messages.ts'
import { getConfigProperty } from '@utils/configUtils.ts'
import { LocalStorage } from '@utils/localStorageUtils.ts'
import { routePaths } from '@routes/routePaths.ts'
import { MSPError } from '@type/index.ts'
import { LoginRequest } from '@type/login.type.ts'
import './login-page.scss'
const passwordLoginEnabled = getConfigProperty('ENABLE_PASSWORD_LOGIN', true)
const LoginPage = () => {
const { login, isLoading } = useAuth()
const { handleSubmit, control, setError } = useForm<LoginRequest>({
mode: 'onChange'
})
const navigate = useNavigate()
const setFormError = (statusText: string, message: string): void => {
setError('email', {})
setError('password', {
message,
type: statusText
})
}
const handleError = (err: AxiosError<MSPError>): void => {
const { response } = err
if (response && response.status === 401) {
setFormError(response.statusText, messages.loginError)
} else {
setFormError('serverError', messages.serverError)
}
}
const handleSubmitForm = (data: LoginRequest): void => {
login(apiPaths.login, data, {
'X-APPLICATION-TOKEN': getConfigProperty(
'APP_TOKEN',
import.meta.env.VITE_APP_TOKEN
)
})
.then((response) => {
LocalStorage.set(localStorageKeys.HEADER_NAME, response.headerName)
LocalStorage.set(localStorageKeys.USER_TOKEN, response.token)
const redirectUrl =
localStorage.getItem('redirectUrl') || routePaths.home
navigate(redirectUrl, { replace: true })
localStorage.removeItem('redirectUrl')
})
.catch((err: any) => handleError(err))
}
const renderInternalAuthForm = () => {
if (!passwordLoginEnabled) {
return null
}
return (
<>
<FormComponents.FormInput
data-cy="email-input"
control={control}
name="email"
className="login-page__content__email-field"
prefix={<UserOutlined className="color" />}
placeholder="Логин"
rules={{ required: ValidationRules.required }}
/>
<FormComponents.FormInput
data-cy="password-input"
control={control}
name="password"
className="login-page__content__password-field"
prefix={<LockOutlined className="color" />}
type="password"
placeholder="Пароль"
rules={{ required: ValidationRules.required }}
/>
<Button
data-cy="submit-btn"
disabled={isLoading}
loading={isLoading}
type="primary"
className="login-page__content__submit-btn"
onClick={handleSubmit(handleSubmitForm)}
>
Войти
</Button>
</>
)
}
return (
<main className="login-page">
<button
onClick={() => {
const url = localStorage.getItem('redirectUrl')
if (url) {
navigate(url)
localStorage.removeItem('redirectUrl')
}
}}
>
Зарегистрироваться
</button>
<form className="login-page__content">
<h1 data-cy="login-title" className="login-page__content__title">
Вход в систему
</h1>
<Divider />
{renderInternalAuthForm()}
</form>
</main>
)
}
+52
View File
@@ -0,0 +1,52 @@
@import "src/constants/styleConstants";
.login-page {
height: 100vh;
background: $background-color;
display: flex;
.ant-input {
width: 300px;
text-align: center;
}
.ant-divider-horizontal {
margin-top: $basic-margin !important;
}
.ant-form-item-explain-error {
margin-bottom: $basic-margin;
}
.color {
color: $text-color-gray;
}
&__content {
max-width: 360px;
margin: auto;
display: flex;
flex-direction: column;
&__title {
text-align: center;
font-family: 'Roboto', sans-serif;
font-size: 14px;
line-height: 20px;
color: $text-color-gray;
}
&__submit-sudir-btn {
background: #0000000f;
margin-top: 4 * $basic-margin;
&:hover {
background: rgba(0, 0, 0, 0.09) !important;
}
}
}
.requiredInput::after {
content: "";
}
}
-4
View File
@@ -1,4 +0,0 @@
.login-page {
display: flex;
justify-content: center;
}
+36 -14
View File
@@ -1,28 +1,50 @@
import { App } from 'antd'
import { Spin } from 'antd'
import { Suspense, lazy } from 'react'
import { Route, Routes } from 'react-router-dom'
import ErrorPage from '@components/ErrorPage'
import Layout from '@components/Layout'
import HomePages from '@pages/HomePage'
import LoginPage from '@pages/LoginPage'
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 Routers = () => {
return (
<App>
<Routes>
<Route element={<PrivateRoute />}>
<Route path="/" element={<Layout />}>
<Route index element={<HomePages />} />
</Route>
<Routes>
<Route element={<PrivateRoute />}>
<Route path={routePaths.home} element={<Layout />}>
<Route
index
element={
<Suspense fallback={<Spin />}>
<HomePage />
</Suspense>
}
/>
</Route>
<Route path={routePaths.login} element={<LoginPage />} />
<Route path={routePaths.error} element={<ErrorPage />} />
</Routes>
</App>
</Route>
<Route
path={routePaths.error}
element={
<Suspense fallback={<Spin />}>
<ErrorPage />
</Suspense>
}
/>
<Route
path={routePaths.login}
element={
<Suspense fallback={<Spin />}>
<LoginPage />
</Suspense>
}
/>
</Routes>
)
}
+5 -3
View File
@@ -1,8 +1,10 @@
import { createAsyncThunk } from '@reduxjs/toolkit'
import { apiPaths } from '../../constants/api/apiPaths.ts'
import { apiService } from '../../services/apiService.ts'
import { ProfileDataType } from '../../type/profile.type.ts'
import { apiPaths } from '@constants/api/apiPaths.ts'
import { apiService } from '@services/apiService.ts'
import { ProfileDataType } from '@type/profile.type.ts'
export const fetchProfile = createAsyncThunk(
'profile/fetchProfile',
+2 -1
View File
@@ -4,7 +4,8 @@ import {
createSlice
} from '@reduxjs/toolkit'
import { ProfileDataType, ProfileType } from '../../type/profile.type.ts'
import { ProfileDataType, ProfileType } from '@type/profile.type.ts'
import { fetchProfile } from './ActionCreators.ts'
export enum StateProfileStatus {
+9
View File
@@ -0,0 +1,9 @@
export interface LoginRequest {
email: string
password: string
}
export interface LoginResponse {
expired: string
headerName: string
token: string
}
+4 -1
View File
@@ -5,7 +5,10 @@ export enum RoleKeys {
export enum PermissionKeys {
user_view = 'user_view', // Просмотр списка пользователей
admin_view = 'admin_view' // роль суперадмина, требуется для интерфейса
admin_view = 'admin_view', // роль суперадмина, требуется для интерфейса
session_view = 'session_view', // Просмотр списка пользовательских сессий
security_log_view = 'security_log_view', // Просмотр журналов ИБ
role_view = 'role_view', // Просмотр экрана ролей
}
export type ConfigRoles = {
+75 -9
View File
@@ -40,7 +40,7 @@
resolved "https://registry.yarnpkg.com/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz#ed2be7fb4d82ac7e1d45a54a5b06d6cecf8be6f6"
integrity sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA==
"@ant-design/icons@^5.3.5":
"@ant-design/icons@^5.3.5", "@ant-design/icons@^5.3.6":
version "5.3.6"
resolved "https://registry.yarnpkg.com/@ant-design/icons/-/icons-5.3.6.tgz#172bbcfcfa39f9a1d9ef73ad5cf98c6184fb83f8"
integrity sha512-JeWsgNjvkTTC73YDPgWOgdScRku/iHN9JU0qk39OSEmJSCiRghQMLlxGTCY5ovbRRoXjxHXnUKgQEgBDnQfKmA==
@@ -51,7 +51,7 @@
classnames "^2.2.6"
rc-util "^5.31.1"
"@ant-design/react-slick@~1.1.1":
"@ant-design/react-slick@~1.1.1", "@ant-design/react-slick@~1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@ant-design/react-slick/-/react-slick-1.1.2.tgz#f84ce3e4d0dc941f02b16f1d1d6d7a371ffbb4f1"
integrity sha512-EzlvzE6xQUBrZuuhSAFTdsr4P2bBBHGZwKFemEfq8gIGyIQCxalYfZW/T2ORbtQx5rU69o+WycP3exY/7T1hGA==
@@ -1035,14 +1035,14 @@
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
"@babel/runtime@^7.10.1", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.7", "@babel/runtime@^7.18.0", "@babel/runtime@^7.18.3", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.6", "@babel/runtime@^7.23.9", "@babel/runtime@^7.24.1":
"@babel/runtime@^7.10.1", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.7", "@babel/runtime@^7.18.0", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.6", "@babel/runtime@^7.23.9", "@babel/runtime@^7.24.1":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.1.tgz#431f9a794d173b53720e69a6464abc6f0e2a5c57"
integrity sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==
dependencies:
regenerator-runtime "^0.14.0"
"@babel/runtime@^7.8.4":
"@babel/runtime@^7.18.6", "@babel/runtime@^7.24.4", "@babel/runtime@^7.8.4":
version "7.24.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.4.tgz#de795accd698007a66ba44add6cc86542aff1edd"
integrity sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==
@@ -2145,7 +2145,7 @@ ansi-styles@^4.1.0:
dependencies:
color-convert "^2.0.1"
antd@5.16.0, antd@^5.12.2:
antd@5.16.0:
version "5.16.0"
resolved "https://registry.yarnpkg.com/antd/-/antd-5.16.0.tgz#6173057ecc9fbf917aa3518c9d55d409e407f754"
integrity sha512-2JcZSxTcX5J2Faro5PB85ETAP64cuU91pBqQ2NVHWelmhLXvN3q70R5Qht+E9k3WVsVO8ZbqBJciYqj8K/RbZw==
@@ -2199,6 +2199,60 @@ antd@5.16.0, antd@^5.12.2:
scroll-into-view-if-needed "^3.1.0"
throttle-debounce "^5.0.0"
antd@^5.12.2:
version "5.16.1"
resolved "https://registry.yarnpkg.com/antd/-/antd-5.16.1.tgz#a258e73cac8c6e63c4ec44588e5474f0403cd33a"
integrity sha512-XAlLRrgYV+nj9FHnkXEPS6HNcKcluEa8v44e7Cixjlp8aOXRhUI6IfZaKpc2MPGjQ+06rp62/dsxOUNJW9kfLA==
dependencies:
"@ant-design/colors" "^7.0.2"
"@ant-design/cssinjs" "^1.18.5"
"@ant-design/icons" "^5.3.6"
"@ant-design/react-slick" "~1.1.2"
"@babel/runtime" "^7.24.4"
"@ctrl/tinycolor" "^3.6.1"
"@rc-component/color-picker" "~1.5.3"
"@rc-component/mutate-observer" "^1.1.0"
"@rc-component/tour" "~1.14.2"
"@rc-component/trigger" "^2.0.0"
classnames "^2.5.1"
copy-to-clipboard "^3.3.3"
dayjs "^1.11.10"
qrcode.react "^3.1.0"
rc-cascader "~3.24.0"
rc-checkbox "~3.2.0"
rc-collapse "~3.7.3"
rc-dialog "~9.4.0"
rc-drawer "~7.1.0"
rc-dropdown "~4.2.0"
rc-field-form "~1.44.0"
rc-image "~7.6.0"
rc-input "~1.4.5"
rc-input-number "~9.0.0"
rc-mentions "~2.11.1"
rc-menu "~9.13.0"
rc-motion "^2.9.0"
rc-notification "~5.4.0"
rc-pagination "~4.0.4"
rc-picker "~4.3.0"
rc-progress "~4.0.0"
rc-rate "~2.12.0"
rc-resize-observer "^1.4.0"
rc-segmented "~2.3.0"
rc-select "~14.13.0"
rc-slider "~10.5.0"
rc-steps "~6.0.1"
rc-switch "~4.1.0"
rc-table "~7.45.4"
rc-tabs "~14.1.1"
rc-textarea "~1.6.3"
rc-tooltip "~6.2.0"
rc-tree "~5.8.5"
rc-tree-select "~5.19.0"
rc-upload "~4.5.2"
rc-util "^5.39.1"
scroll-into-view-if-needed "^3.1.0"
throttle-debounce "^5.0.0"
anymatch@~3.1.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e"
@@ -3687,9 +3741,9 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
"isp-ui-kit@https://github.com/integration-system/isp-ui-kit.git":
version "0.3.0"
resolved "https://github.com/integration-system/isp-ui-kit.git#0f4f9b29fb3311cb63c46029082ba2591feb0ca3"
"isp-ui-kit@https://github.com/txix-open/isp-ui-kit":
version "0.3.3"
resolved "https://github.com/txix-open/isp-ui-kit#508a5bd9cb4efac0e9389ad2f9f8c60683d1712e"
dependencies:
"@codemirror/lang-javascript" "^6.2.1"
"@codemirror/lang-json" "^6.0.1"
@@ -4486,6 +4540,18 @@ rc-table@~7.45.0:
rc-util "^5.37.0"
rc-virtual-list "^3.11.1"
rc-table@~7.45.4:
version "7.45.4"
resolved "https://registry.yarnpkg.com/rc-table/-/rc-table-7.45.4.tgz#8657450d836f691e94ff2282a1c8ee344fe551e6"
integrity sha512-6aSbGrnkN2GLSt3s1x+wa4f3j/VEgg1uKPpaLY5qHH1/nFyreS2V7DFJ0TfUb18allf2FQl7oVYEjTixlBXEyQ==
dependencies:
"@babel/runtime" "^7.10.1"
"@rc-component/context" "^1.4.0"
classnames "^2.2.5"
rc-resize-observer "^1.1.0"
rc-util "^5.37.0"
rc-virtual-list "^3.11.1"
rc-tabs@~14.1.1:
version "14.1.1"
resolved "https://registry.yarnpkg.com/rc-tabs/-/rc-tabs-14.1.1.tgz#f49467feb69af0156c7864d04c21396e4c5c7911"
@@ -4576,7 +4642,7 @@ react-dom@^18.2.0:
loose-envify "^1.1.0"
scheduler "^0.23.0"
react-hook-form@^7.49.1:
react-hook-form@^7.49.1, react-hook-form@^7.51.2:
version "7.51.2"
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.51.2.tgz#79f7f72ee217c5114ff831012d1a7ec344096e7f"
integrity sha512-y++lwaWjtzDt/XNnyGDQy6goHskFualmDlf+jzEZvjvz6KWDf7EboL7pUvRCzPTJd0EOPpdekYaQLEvvG6m6HA==