Unverified Commit 1215b221 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor][web] custom header Title use i18n && Optimization layout (#2036)

* custom header Title use i18n * custom header Title use i18n * 优化布局 && fix bug * fix bug * 优化布局 && fix bug * fix bug * fix change password bug * change password layout
parent 33886c4a
......@@ -31,6 +31,7 @@ import lombok.Setter;
@Setter
public class ModifyPasswordDTO {
private String id;
private String username;
private String password;
private String newPassword;
......
......@@ -29,7 +29,7 @@ import java.util.List;
/** role select permissions mapper interface */
@Mapper
public interface RoleSelectPermissionsMapper extends SuperMapper<RowPermissions> {
public interface RowPermissionsMapper extends SuperMapper<RowPermissions> {
/**
* delete user role select permissions by role id
......
......@@ -20,7 +20,7 @@
package org.dinky.service.impl;
import org.dinky.data.model.RowPermissions;
import org.dinky.mapper.RoleSelectPermissionsMapper;
import org.dinky.mapper.RowPermissionsMapper;
import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.service.RowPermissionsService;
......@@ -32,7 +32,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@Service
public class RoleSelectPermissionsServiceImpl
extends SuperServiceImpl<RoleSelectPermissionsMapper, RowPermissions>
extends SuperServiceImpl<RowPermissionsMapper, RowPermissions>
implements RowPermissionsService {
@Override
......
......@@ -116,7 +116,7 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen
@Override
public Result<Void> modifyPassword(ModifyPasswordDTO modifyPasswordDTO) {
User user = getUserByUsername(modifyPasswordDTO.getUsername());
User user = getById(modifyPasswordDTO.getId());
if (Asserts.isNull(user)) {
return Result.failed(Status.USER_NOT_EXIST);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dinky.mapper.RoleSelectPermissionsMapper">
<mapper namespace="org.dinky.mapper.RowPermissionsMapper">
<select id="selectForProTable" resultType="org.dinky.data.model.RowPermissions">
select
a.*,
b.role_code,
b.role_name
from
dinky_role_select_permissions a
dinky_row_permissions a
join dinky_role b on b.id = a.role_id
<where>
1=1
......@@ -33,7 +33,7 @@
</select>
<delete id="deleteByRoleIds" parameterType="java.util.List">
DELETE FROM dinky_role_select_permissions
DELETE FROM dinky_row_permissions
WHERE role_id IN
<foreach collection="roleIds" item="item" open="(" separator="," close=")">
${item}
......@@ -46,7 +46,7 @@
b.role_code,
b.role_name
from
dinky_role_select_permissions a, dinky_role b
dinky_row_permissions a, dinky_role b
WHERE
b.id = a.role_id
and a.role_id IN
......
......@@ -32,6 +32,7 @@ const Settings: ProLayoutProps & {
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
// 这里不能删除,需要先设置,否则会导致页面白屏, 然后在 layout 进行重新赋值
title: 'Dinky Real-time Platform ',
pwa: true,
logo: '/dinky.svg',
......
......@@ -239,6 +239,11 @@ export default [
footerRender: false,
component: './Other/About',
},
{
path: '/account/center',
footerRender: false,
component: './Other/PersonCenter',
},
{
path: '*',
component: './Other/404',
......
......@@ -46,19 +46,19 @@
],
"dependencies": {
"@ant-design/icons": "^5.0.1",
"@ant-design/pro-components": "^2.4.14",
"@ant-design/pro-components": "^2.5.5",
"@ant-design/pro-layout": "^7.13.3",
"@ant-design/pro-table": "^3.6.9",
"@ant-design/use-emotion-css": "^1.0.4",
"@umijs/route-utils": "^4.0.1",
"antd": "^5.4.7",
"antd": "^5.6.1",
"classnames": "^2.3.2",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"omit.js": "^2.0.2",
"rc-menu": "^9.8.4",
"rc-util": "^5.30.0",
"rc-util": "^5.33.0",
"react": "^18.2.0",
"react-dev-inspector": "^1.8.1",
"react-dom": "^18.0.0",
......@@ -66,7 +66,7 @@
"react-monaco-editor": "^0.52.0",
"react-spring": "^9.7.1",
"screenfull": "^6.0.2",
"styled-components": "^6.0.0-rc.1",
"styled-components": "^6.0.0-rc.3",
"use-sse": "^2.0.1"
},
"devDependencies": {
......
......@@ -18,7 +18,6 @@
import Footer from "@/components/Footer";
import RightContent from "@/components/RightContent";
import {PageLoading, Settings as LayoutSettings} from "@ant-design/pro-components";
// import {SettingDrawer} from "@ant-design/pro-components";
import type {RunTimeLayoutConfig} from "@umijs/max";
import {history} from "@umijs/max";
import defaultSettings from "../config/defaultSettings";
......@@ -27,6 +26,8 @@ import {currentUser as queryCurrentUser} from "./services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
import {THEME} from "@/types/Public/data";
import {UnAccessible} from "@/pages/Other/403";
import {l} from "@/utils/intl";
import Settings from "../config/defaultSettings";
// const isDev = process.env.NODE_ENV === "development";
const loginPath = API_CONSTANTS.LOGIN_PATH;
......@@ -91,6 +92,15 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
const theme = localStorage.getItem("navTheme");
return {
headerTitleRender: () => {
// 重新对 title 的设置进行设置
Settings.title =l('layouts.userLayout.title');
// 重新对 logo 的设置进行设置 由于 logo 是一个组件,所以需要重新渲染, 重新渲染的时候,会重新执行一次 layout
return <>
<img height={50} width={50} src={Settings.logo}/>
<span style={{marginLeft: 10 ,color:'white'}}>{Settings.title}</span>
</>;
},
rightContentRender: () => <RightContent />,
footerRender: () => <Footer />,
siderWidth: 180,
......@@ -106,7 +116,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
history.push(loginPath);
}
},
menuHeaderRender: undefined,
// 自定义 403 页面
unAccessible:<UnAccessible/>,
// 增加一个 loading 的状态
......@@ -115,18 +124,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
return (
<>
{children}
{/*{isDev && <SettingDrawer*/}
{/* disableUrlParams*/}
{/* enableDarkTheme*/}
{/* settings={initialState?.settings}*/}
{/* onSettingChange={(settings) => {*/}
{/* setInitialState((preInitialState) => ({*/}
{/* ...preInitialState,*/}
{/* settings,*/}
{/* }));*/}
{/* }}*/}
{/*/>*/}
{/*}*/}
</>
);
},
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// 淡入效果并从上方滑入
import {useSpring, animated} from 'react-spring';
const FadeInSlideDown = (props: any) => {
const {children} = props;
const style = useSpring({
from: {opacity: 0, transform: 'translateY(-100px)'},
to: {opacity: 1, transform: 'translateY(0)'},
config: {duration: 500},
});
return <animated.div style={style}>{children}</animated.div>;
};
export default FadeInSlideDown
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// 淡入效果并从上方滑入
import {useSpring, animated} from 'react-spring';
const FadeInSlideUp = (props: any) => {
const {children} = props;
const style = useSpring({
from: { opacity: 0, transform: 'translateY(100px)' },
to: { opacity: 1, transform: 'translateY(0)' },
config: { duration: 1000 },
});
return <animated.div style={style}>{children}</animated.div>;
};
export default FadeInSlideUp
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { useSpring, animated } from 'react-spring';
//渐变背景颜色效果:
const GradientBackground =(props:any) => {
const {children} = props;
const style = useSpring({
from: { background: 'linear-gradient(45deg, #ff0000, #00ff00)' },
to: { background: 'linear-gradient(45deg, #00ff00, #0000ff)' },
config: { duration: 2000 },
});
return <animated.div style={style}>{children}</animated.div>;
};
export default GradientBackground
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { useSpring, animated } from 'react-spring';
//弹出效果:
const Pop = (props: any) => {
const {children} = props;
const style = useSpring({
from: { transform: 'scale(0)', opacity: 0 },
to: { transform: 'scale(1)', opacity: 1 },
config: { tension: 300, friction: 20 },
});
return <animated.div style={style}>{children}</animated.div>;
};
export default Pop
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { useSpring, animated } from 'react-spring';
//抖动效果
const Shake = (props: any) => {
const {children} = props;
const style = useSpring({
from: { transform: 'translateX(0)' },
to: async (next) => {
while (true) {
await next({ transform: 'translateX(-10px)' });
await next({ transform: 'translateX(10px)' });
}
},
config: { duration: 500 },
});
return <animated.div style={style}>{children}</animated.div>;
};
export default Shake;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { useSpring, animated } from 'react-spring';
// 平移效果
const Slide = (props:any) => {
const {children} = props;
const style = useSpring({
from: { transform: 'translateX(-100%)' },
to: { transform: 'translateX(0%)' },
config: { duration: 1000 },
});
return <animated.div style={{...style}}>{children}</animated.div>;
};
export default Slide
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { useSpring, animated } from 'react-spring';
const SlideInFromLeft = (props: any) => {
const { children } = props;
const style = useSpring({
from: { transform: 'translateX(100%)' },
to: { transform: 'translateX(10%)' },
config: { duration: 1000 },
});
return <animated.div style={style}>{children}</animated.div>;
};
export default SlideInFromLeft
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React from 'react';
import { useSpring, animated } from 'react-spring';
// 缓慢出现
const SlowlyAppear = (props: any) => {
const { children } = props;
const slowlyAppearProps = useSpring({
opacity: 1,
from: { opacity: 0 },
config: { duration: 1000 },
});
return (
<animated.h1 style={slowlyAppearProps}>
{children}
</animated.h1>
);
};
export default SlowlyAppear;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {useSpring, animated} from 'react-spring';
// 变形效果
const Transform = (props: any) => {
const {children} = props;
const style = useSpring({
from: {transform: 'scale(1) rotate(0deg)'},
to: {transform: 'scale(0.5) rotate(180deg)'},
config: {duration: 1000},
});
return <animated.div style={style}>{children}</animated.div>;
};
export default Transform
\ No newline at end of file
......@@ -15,21 +15,29 @@
* limitations under the License.
*/
import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
import {
LogoutOutlined,
TeamOutlined,
UserSwitchOutlined
} from '@ant-design/icons';
import { setAlpha } from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css';
import { history, useModel } from '@umijs/max';
import { Avatar, Spin } from 'antd';
import {Avatar, Modal, Spin} from 'antd';
import { stringify } from 'querystring';
import type { MenuInfo } from 'rc-menu/lib/interface';
import React, { useCallback } from 'react';
import { flushSync } from 'react-dom';
import HeaderDropdown from '../HeaderDropdown';
import {outLogin} from "@/services/BusinessCrud";
import {chooseTenantSubmit, outLogin} from "@/services/BusinessCrud";
import {l} from "@/utils/intl";
import {setTenantStorageAndCookie} from "@/utils/function";
import {ErrorNotification, SuccessNotification} from "@/utils/messages";
import {
ItemType,
} from "rc-menu/es/interface";
export type GlobalHeaderRightProps = {
menu?: boolean;
};
const Name = () => {
const { initialState } = useModel('@@initialState');
......@@ -73,7 +81,7 @@ const AvatarLogo = () => {
);
};
const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
const AvatarDropdown = () => {
/**
* 退出登录,并且将当前的 url 保存
*/
......@@ -93,6 +101,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
});
}
};
const actionClassName = useEmotionCss(({ token }) => {
return {
display: 'flex',
......@@ -111,17 +120,14 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
});
const { initialState, setInitialState } = useModel('@@initialState');
const onMenuClick = useCallback(
const loginOutHandler = useCallback(
async (event: MenuInfo) => {
const { key } = event;
if (key === 'logout') {
flushSync(() => {
setInitialState((s) => ({ ...s, currentUser: undefined }));
setInitialState((s) => ({ ...s, currentUser: undefined }));
});
await loginOut();
return;
}
history.push(`/account/${key}`);
},
[setInitialState],
);
......@@ -146,36 +152,77 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
return loading;
}
/**
*
* @param option
*/
const tenantHandleChange = (option:any) => {
const tenantCode = option.domEvent.target.innerText;
const tenantId = option.key as number;
Modal.confirm({
title: l("menu.account.checkTenant"),
content: l("menu.account.checkTenantConfirm", "", {tenantCode}),
okText: l("button.confirm"),
cancelText: l("button.cancel"),
onOk: async () => {
const result = await chooseTenantSubmit({tenantId});
setTenantStorageAndCookie(tenantId);
if (result.code === 0) {
SuccessNotification(result.msg);
} else {
ErrorNotification(result.msg);
}
// trigger global refresh, such as reload page
window.location.reload();
},
});
};
const renderTenantList = () => {
let chooseTenantList: ItemType[] = [];
currentUser.tenantList?.map((item) => {
return chooseTenantList.push({
key: item.id,
label: item.tenantCode,
disabled: item.id === currentUser.currentTenant?.id,
onClick: (e) => tenantHandleChange(e),
})
})
return chooseTenantList;
}
const menuItems = [
...(menu
? [
{
key: 'center',
icon: <UserOutlined />,
label: '个人中心',
},
{
key: 'settings',
icon: <SettingOutlined />,
label: '个人设置',
},
{
type: 'divider' as const,
},
]
: []),
{
key: 'logout',
icon: <LogoutOutlined />,
label: '退出登录',
},
{
key: 'center',
icon: <TeamOutlined />,
label: l('menu.account.center'),
onClick: () => history.push('/account/center'),
},
{
type: 'divider' as const,
},
{
key: 'switching',
icon: <UserSwitchOutlined />,
label: l('menu.account.checkTenant'),
children: renderTenantList(),
},
{
type: 'divider' as const,
},
{
key: 'logout',
icon: <LogoutOutlined />,
label: l('menu.account.logout'),
onClick: loginOutHandler,
},
];
return (
<HeaderDropdown
menu={{
selectedKeys: [],
onClick: onMenuClick,
items: menuItems,
}}
>
......
......@@ -18,10 +18,8 @@
import {STORY_LANGUAGE, VERSION} from '@/services/constants';
import {
getLocalStorageLanguage, getValueFromLocalStorage,
parseJsonStr,
setCookieByKey,
setKeyToLocalStorage,
setTenantStorageAndCookie
} from '@/utils/function';
import {l} from "@/utils/intl";
import {
......@@ -29,19 +27,14 @@ import {
FullscreenOutlined,
GlobalOutlined
} from "@ant-design/icons";
import {ActionType} from "@ant-design/pro-components";
import {useEmotionCss} from "@ant-design/use-emotion-css";
import {SelectLang, useModel} from "@umijs/max";
import {Modal, Select, Space, Switch, Tooltip} from "antd";
import {OptionType} from "dayjs";
import React, {useEffect, useRef, useState} from "react";
import {Space, Switch, Tooltip} from "antd";
import React, {useEffect, useState} from "react";
import screenfull from "screenfull";
import Avatar from "./AvatarDropdown";
import {ThemeCloud, ThemeStar} from "@/components/ThemeSvg/ThemeSvg";
import {chooseTenantSubmit} from "@/services/BusinessCrud";
import {ErrorNotification, SuccessNotification} from "@/utils/messages";
import {THEME} from "@/types/Public/data";
import cookies from 'js-cookie';
const GlobalHeaderRight: React.FC = () => {
......@@ -79,7 +72,7 @@ const GlobalHeaderRight: React.FC = () => {
locale: lang,
}));
}
}, [initialState?.settings?.locale]);
}, [initialState?.settings]);
if (!initialState || !initialState.settings) {
......@@ -128,32 +121,6 @@ const GlobalHeaderRight: React.FC = () => {
};
});
/**
*
* @param option
*/
const tenantHandleChange = (option: OptionType) => {
const result = parseJsonStr(option as string);
const tenantId = result.value;
Modal.confirm({
title: l("menu.account.checkTenant"),
content: l("menu.account.checkTenantConfirm", "", {tenantCode: result.children}),
okText: l("button.confirm"),
cancelText: l("button.cancel"),
onOk: async () => {
const result = await chooseTenantSubmit({tenantId});
setTenantStorageAndCookie(tenantId);
if (result.code === 0) {
SuccessNotification(result.msg);
} else {
ErrorNotification(result.msg);
}
// trigger global refresh, such as reload page
window.location.reload();
},
});
};
/**
* full screen or exit full screen
......@@ -165,20 +132,7 @@ const GlobalHeaderRight: React.FC = () => {
}
};
/**
* generate tenant list card
*/
const genTenantListForm = () => {
const tenants: any[] = [];
currentUser?.tenantList?.forEach((item) => {
tenants.push(
<Select.Option key={item.id} value={item.id}>
{item.tenantCode}
</Select.Option>,
);
});
return tenants;
};
const fullScreenProps = {
style: {color: "white"},
......@@ -192,29 +146,13 @@ const GlobalHeaderRight: React.FC = () => {
{fullScreen ? <FullscreenOutlined {...fullScreenProps} onClick={screenFull}/> :
<FullscreenExitOutlined {...fullScreenProps} onClick={screenFull}/>}
</Tooltip>
<Avatar menu={true}/>
<>
<span className={actionClassName}>{l("menu.tenants")}</span>
<Select
className={actionClassName}
style={{width: "18vh"}}
value={currentUser?.currentTenant?.tenantCode?.toString()}
defaultValue={currentUser?.currentTenant?.tenantCode?.toString() || ""}
onChange={(value, option) => {
tenantHandleChange(option as OptionType);
}}
>
{genTenantListForm()}
</Select>
</>
<Avatar/>
<Tooltip
placement="bottom"
title={<span>{l("menu.version", "", {version: VERSION})}</span>}
>
<Space className={actionClassName}>{l("menu.version", "", {version: VERSION})}</Space>
</Tooltip>
<SelectLang icon={<GlobalOutlined/>} className={actionClassName}/>
<Switch
key={"themeSwitch"}
......
......@@ -30,8 +30,7 @@ export default {
'menu.account.center': 'Account Center',
'menu.account.logout': 'Logout',
'menu.account.changePassword': 'Change Password',
'menu.account.checkTenant': 'Check Tenant',
'menu.tenants': 'Tenant: ',
'menu.account.checkTenant': 'Switch Tenant',
'menu.account.checkTenantConfirm': 'Are you sure to switch tenant [ {tenantCode} ] ?',
'menu.datastudio': 'Data Studio',
......
......@@ -17,7 +17,7 @@
export default {
//-------------------------------- common --------------------------------
'layouts.userLayout.title': 'Dinky Real-time Computing Platform',
'layouts.userLayout.title': 'Dinky Real-time Platform ',
'login.error': 'Login failed, please try again! Reason:{msg}',
'login.result': '{msg}\t\t{time}',
'login.notbindtenant': 'You have not bound a tenant, please contact the administrator',
......@@ -83,6 +83,12 @@ export default {
'user.newpwdPlaceholder': 'Please enter new password',
'user.repeatpwdPlaceholder': 'Please enter repeat new password',
'user.oldNewPwdNoMatch': 'The new passwords do not match',
// -- personal info
'user.info': 'Personal Info',
'user.tenant': 'Tenant',
'user.role': 'Role',
'user.op': 'Operation',
'user.current.tenant': 'Current Tenant',
// tenant
'tenant.TenantManager': 'Tenant Management',
......
......@@ -31,7 +31,6 @@ export default {
'menu.account.logout': '退出登录',
'menu.account.changePassword': '修改密码',
'menu.account.checkTenant': '切换租户',
'menu.tenants': '租户:',
'menu.account.checkTenantConfirm': '你确定切换租户【{tenantCode}】吗?',
'menu.datastudio': '数据开发',
......
......@@ -80,6 +80,12 @@ export default {
'user.newpwdPlaceholder': '请输入新密码',
'user.repeatpwdPlaceholder': '请重复输入新密码',
'user.oldNewPwdNoMatch': '两次输入的新密码不一致',
// -- personal info
'user.info': '个人信息',
'user.tenant': '租户',
'user.role': '角色',
'user.op': '操作记录',
'user.current.tenant': '当前登录租户',
// tenant
'tenant.TenantManager': '租户管理',
......
......@@ -21,6 +21,7 @@
import React from "react";
import {PageContainer} from '@ant-design/pro-layout';
import RoleProTable from "@/pages/AuthCenter/Role/components/RoleProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
......@@ -28,9 +29,9 @@ export default () => {
/**
* render
*/
return <>
return <SlowlyAppear>
<PageContainer title={false}>
<RoleProTable/>
</PageContainer>
</>
</SlowlyAppear>
};
......@@ -19,15 +19,16 @@
import {PageContainer} from "@ant-design/pro-components";
import PermissionsProTable from "@/pages/AuthCenter/RowPermissions/components/PermissionsProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
/**
* render
*/
return <>
return <SlowlyAppear>
<PageContainer title={false}>
<PermissionsProTable />
</PageContainer>
</>
</SlowlyAppear>
}
\ No newline at end of file
......@@ -20,17 +20,18 @@
import React from "react";
import {PageContainer} from '@ant-design/pro-layout';
import TenantProTable from "./components/TenantProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
const TenantFormList: React.FC = () => {
/**
* render
*/
return <>
return <SlowlyAppear>
<PageContainer title={false}>
<TenantProTable/>
</PageContainer>
</>
</SlowlyAppear>
};
export default TenantFormList;
......@@ -25,10 +25,13 @@ import {UserBaseInfo} from "@/types/User/data";
import React from "react";
import {FormInstance} from "antd/es/form/hooks/useForm";
import {Values} from "async-validator";
import {Button} from "antd";
type PasswordFormProps = {
values: Partial<UserBaseInfo.ChangePasswordParams>;
values: UserBaseInfo.User;
form: FormInstance<Values>
renderSubmit?: boolean;
onSubmit?: (values: UserBaseInfo.ChangePasswordParams) => void;
};
......@@ -37,7 +40,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
/**
* init props
*/
const {values, form} = props;
const {values, form,renderSubmit=false, onSubmit} = props;
const handleSubmit = async () => {
const value = await form?.validateFields()
if (onSubmit) {
const {password, newPassword, newPasswordCheck} = value;
onSubmit({id: values.id, newPassword, newPasswordCheck: newPasswordCheck, password: password , username: values.username})
}
}
/**
* render changePassword form
......@@ -45,7 +56,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
const pwdFormRender = () => {
return <>
<ProFormText.Password
width="md"
width="xl"
name="password"
hasFeedback
label={l('user.oldpwd')}
......@@ -53,7 +64,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
rules={[{required: true, message: l('user.oldpwdPlaceholder')}]}
/>
<ProFormText.Password
width="md"
width="xl"
name="newPassword"
hasFeedback
label={l('user.newpwd')}
......@@ -61,7 +72,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
rules={[{required: true, message: l('user.newpwdPlaceholder')}]}
/>
<ProFormText.Password
width="md"
width="xl"
name="newPasswordCheck"
hasFeedback
dependencies={['newPassword']}
......@@ -95,7 +106,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
form={form}
initialValues={values}
layout={"horizontal"}
submitter={false}
submitter={{
render: (submitProps, doms) => {
return renderSubmit?<>
<Button type="primary" onClick={async ()=>{
await handleSubmit();
}}>{l('button.submit')}</Button>
</>:<></>
},
}}
>
{pwdFormRender()}
</ProForm>
......
......@@ -28,9 +28,9 @@ import PasswordForm from "@/pages/AuthCenter/User/components/PasswordModal/Passw
type PasswordModalFormProps = {
onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<UserBaseInfo.ChangePasswordParams>) => void;
onSubmit: (values: UserBaseInfo.ChangePasswordParams) => void;
modalVisible: boolean;
values: Partial<UserBaseInfo.ChangePasswordParams>;
values: Partial<UserBaseInfo.User>;
};
......@@ -66,9 +66,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => {
}, [modalVisible, values, form]);
const [formVals, setFormVals] = useState<Partial<UserBaseInfo.ChangePasswordParams>>({
username: values.username,
});
const [formVals, setFormVals] = useState<Partial<UserBaseInfo.ChangePasswordParams>>({...values});
/**
......@@ -100,7 +98,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => {
onCancel={() => handleCancel()}
onOk={() => submitForm()}
>
<PasswordForm values={values} form={form}/>
<PasswordForm values={values as any} form={form}/>
</Modal>
</>
};
......
......@@ -132,7 +132,7 @@ const UserProTable = () => {
* change password submit
* @param value
*/
const handlePasswordChangeSubmit = async (value: any) => {
const handlePasswordChangeSubmit = async (value: UserBaseInfo.ChangePasswordParams) => {
await executeAndCallbackRefresh(async () => {
await handleOption(API_CONSTANTS.USER_MODIFY_PASSWORD, l("button.changePassword"), value);
await handlePasswordModalOpen(false);
......
......@@ -21,6 +21,7 @@
import React from "react";
import UserProTable from "@/pages/AuthCenter/User/components/UserProTable";
import {PageContainer} from "@ant-design/pro-components";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
......@@ -28,10 +29,10 @@ export default () => {
/**
* render
*/
return <>
return <SlowlyAppear>
<PageContainer title={false}>
<UserProTable/>
</PageContainer>
</>
</SlowlyAppear>
};
......@@ -17,14 +17,15 @@
import {PageContainer} from '@ant-design/pro-layout';
import JobList from '@/pages/DevOps/JobList';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => {
/**
* breadcrumb={{style:{display:'none'}}} is used to hide the breadcrumb || 隐藏右上角的路由导航面包屑
*/
return <>
return <SlowlyAppear>
<PageContainer title={false} breadcrumb={{style:{display:'none'}}}>
<JobList/>
</PageContainer>
</>;
</SlowlyAppear>;
}
......@@ -114,6 +114,7 @@ const Login: React.FC = () => {
try {
// login
const result = await login({...values});
setInitialState((s) => ({...s, currentUser: result.datas}));
await SuccessMessageAsync(l("login.result", "", {msg: result.msg, time: result.time}));
/**
* After successful login, set the tenant list
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Avatar, Descriptions, Divider, Tag} from "antd";
import {l} from "@/utils/intl";
import React from "react";
const BaseInfo = (props: any) => {
const {user, currentTenant} = props;
return <>
<Avatar style={{alignSelf: 'center', marginBottom: 50,}} draggable size={200} src={user.avatar} />
<Divider orientation={'left'} plain >{l('user.info')}</Divider>
<Descriptions size={'small'} column={2}>
<Descriptions.Item label={l('user.username')}>{user.username}</Descriptions.Item>
<Descriptions.Item label={l('user.nickname')}>{user.nickname}</Descriptions.Item>
<Descriptions.Item label={l('user.phone')}>{user.mobile}</Descriptions.Item>
<Descriptions.Item label={l('user.jobnumber')}>{user.worknum}</Descriptions.Item>
<Descriptions.Item label={l('user.current.tenant')}>
<Tag color={'processing'}>{currentTenant?.tenantCode}</Tag>
</Descriptions.Item>
</Descriptions>
</>
};
export default BaseInfo;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React, {useState} from "react";
import {useModel} from "@@/exports";
import {Divider, Empty, Form, Space, Tag} from "antd";
import {PageContainer, PageLoading, ProCard} from "@ant-design/pro-components";
import {UserBaseInfo} from "@/types/User/data";
import {l} from "@/utils/intl";
import {LogSvg} from "@/components/Icons/CodeLanguageIcon";
import PasswordForm from "@/pages/AuthCenter/User/components/PasswordModal/PasswordForm";
import {SecurityScanTwoTone} from "@ant-design/icons";
import {handleOption} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
import BaseInfo from "@/pages/Other/PersonCenter/BaseInfo";
import Pop from "@/components/Animation/Pop";
const PersonCenter = () => {
const [form] = Form.useForm();
const { initialState, setInitialState } = useModel('@@initialState');
const [activeKey, setActiveKey] = useState('operation');
const loading = <PageLoading/>;
if (!initialState) {
return loading;
}
const { currentUser } = initialState;
if (!currentUser || !currentUser.user.username) {
return loading;
}
const { roleList, tenantList,currentTenant,user } = currentUser;
/**
* renderTenantTagList
* @param {UserBaseInfo.Tenant[]} items
* @returns {JSX.Element[] | undefined}
*/
const renderTenantTagList = (items: UserBaseInfo.Tenant[]) => {
return items?.map((item: UserBaseInfo.Tenant) => {
return <>
<Tag color={'success'} key={item.id}>{item.tenantCode} </Tag>
</>
})
};
/**
* renderRoleTagList
* @param {UserBaseInfo.Role[]} items
* @returns {JSX.Element[] | undefined}
*/
const renderRoleTagList = (items: UserBaseInfo.Role[]) => {
return items?.map((item: UserBaseInfo.Role) => {
return <>
<Tag color={'success'} key={item.id}>{item.roleCode}</Tag>
</>
})
};
/**
* handleSubmitPassWord
* @param value
* @returns {Promise<void>}
*/
const handleSubmitPassWord = async (value: UserBaseInfo.ChangePasswordParams) => {
await handleOption(API_CONSTANTS.USER_MODIFY_PASSWORD, l("button.changePassword"), value);
form.resetFields();
}
/**
* tabList
* @type {({children: JSX.Element, label: JSX.Element, key: string} | {children: JSX.Element, label: JSX.Element, key: string})[]}
*/
const tabList = [
{
key: 'operation',
label: <><LogSvg/>{l('user.op')}</>,
children: <><Empty description={l('global.stay.tuned')} image={Empty.PRESENTED_IMAGE_DEFAULT}/></>,
},
{
key: 'changePassword',
label: <><SecurityScanTwoTone/>{l('button.changePassword')}</>,
children: <PasswordForm form={form} renderSubmit values={user} onSubmit={handleSubmitPassWord} />,
},
];
/**
* render
*/
return <Pop>
<PageContainer title={false}>
<ProCard ghost gutter={[16, 16]} hoverable loading={!loading && currentUser}>
<ProCard style={{height: '91vh',textAlign:'center'}} colSpan="30%" hoverable bordered>
<BaseInfo user={user} currentTenant={currentTenant} />
<Divider orientation={'left'} plain >{l('user.tenant')}</Divider>
<Space>{renderTenantTagList(tenantList || [])}</Space>
<Divider plain ></Divider>
<Divider orientation={'left'} plain >{l('user.role')}</Divider>
<Space>{renderRoleTagList(roleList || [])}</Space>
</ProCard>
<ProCard
style={{height: '91vh',textAlign:'center'}}
tabs={{
activeKey: activeKey,
type: 'card',
animated: true,
onChange: (key: string) => setActiveKey(key),
items: tabList,
}}
/>
</ProCard>
</PageContainer>
</Pop>;
}
export default PersonCenter;
\ No newline at end of file
......@@ -34,6 +34,7 @@ import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import DescriptionsItem from "antd/es/descriptions/Item";
import AlertGroupForm from "@/pages/RegCenter/Alert/AlertGroup/components/AlertGroupForm";
import Pop from "@/components/Animation/Pop";
const AlertGroupTableList: React.FC = (props: any) => {
/**
......@@ -220,7 +221,7 @@ const AlertGroupTableList: React.FC = (props: any) => {
}));
return (
return <Pop>
<PageContainer title={false}>
{/* alert group list */}
<ProList<Alert.AlertGroup>
......@@ -250,7 +251,7 @@ const AlertGroupTableList: React.FC = (props: any) => {
}
</PageContainer>
);
</Pop>
};
const mapDispatchToProps = (dispatch: Dispatch) => ({
......
......@@ -19,11 +19,14 @@
import React from 'react';
import AlertInstanceList from '@/pages/RegCenter/Alert/AlertInstance/components/AlertInstanceList';
import {PageContainer} from '@ant-design/pro-components';
import Scale from '@/components/Animation/Scale';
export default () => {
return <PageContainer title={false}>
<AlertInstanceList/>
</PageContainer>;
return <Scale>
<PageContainer title={false}>
<AlertInstanceList/>
</PageContainer>
</Scale>;
}
......@@ -20,9 +20,12 @@
import React from "react";
import {PageContainer} from "@ant-design/pro-components";
import InstanceList from "@/pages/RegCenter/Cluster/Instance/components/InstanceList";
import Pop from "@/components/Animation/Pop";
export default () => {
return <PageContainer title={false}>
<InstanceList/>
</PageContainer>
return <Pop>
<PageContainer title={false}>
<InstanceList/>
</PageContainer>
</Pop>
}
\ No newline at end of file
......@@ -17,14 +17,15 @@
import {PageContainer} from "@ant-design/pro-components";
import DataSourceTable from "@/pages/RegCenter/DataSource/components/DataSourceList";
import Pop from "@/components/Animation/Pop";
/**
* render DataSource page
*/
export default () => {
return <>
return <Pop>
<PageContainer title={false}>
<DataSourceTable/>
</PageContainer>
</>;
</Pop>;
}
......@@ -20,6 +20,7 @@
import React from 'react';
import {PageContainer} from '@ant-design/pro-layout';
import DocumentProTable from "@/pages/RegCenter/Document/components/DocumentProTable";
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => {
......@@ -27,9 +28,9 @@ export default () => {
/**
* render
*/
return (
return <SlowlyAppear>
<PageContainer title={false}>
<DocumentProTable/>
</PageContainer>
);
</SlowlyAppear>
};
......@@ -19,6 +19,8 @@
import {PageContainer} from "@ant-design/pro-layout";
import ProjectProTable from "@/pages/RegCenter/GitProject/components/ProjectProTable";
import FadeIn from "@/components/Animation/FadeIn";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
......@@ -26,7 +28,9 @@ export default () => {
/**
* render
*/
return <PageContainer title={false}>
<ProjectProTable/>
</PageContainer>;
return <SlowlyAppear>
<PageContainer title={false}>
<ProjectProTable/>
</PageContainer>
</SlowlyAppear>;
};
......@@ -20,15 +20,16 @@
import React from 'react';
import {PageContainer} from '@ant-design/pro-layout';
import GlobalVarProTable from "@/pages/RegCenter/GlobalVar/components/GlobalVarProTable";
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => {
/**
* render
*/
return (
return <SlowlyAppear>
<PageContainer title={false}>
<GlobalVarProTable/>
</PageContainer>
);
</SlowlyAppear>
};
......@@ -17,9 +17,12 @@
import {PageContainer} from "@ant-design/pro-components";
import TemplateTable from "@/pages/RegCenter/UDF/components/TemplateTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default ()=>{
return <PageContainer title={false}>
<TemplateTable/>
</PageContainer>
return <SlowlyAppear>
<PageContainer title={false}>
<TemplateTable/>
</PageContainer>
</SlowlyAppear>
}
......@@ -25,10 +25,11 @@ import {MavenConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/M
import {DSConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/DSConfig';
import {LdapConfig} from "@/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig";
import {l} from '@/utils/intl';
import FadeIn from "@/components/Animation/FadeIn";
const SettingOverView = () => {
const [data, setData] = React.useState<Settings>({dolphinscheduler: [], env: [], flink: [], maven: []});
const [data, setData] = React.useState<Settings>({dolphinscheduler: [], env: [], flink: [], maven: [] , ldap: []});
const fetchData = async () => {
......@@ -65,9 +66,9 @@ const SettingOverView = () => {
};
return <>
return <FadeIn>
{renderData()}
</>;
</FadeIn>;
};
export default memo(SettingOverView);
......@@ -17,10 +17,13 @@
import {PageContainer} from "@ant-design/pro-components";
import ProcessList from "./components/ProcessList";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default ()=> {
return <PageContainer title={false}>
<ProcessList />
</PageContainer>
return <SlowlyAppear>
<PageContainer title={false}>
<ProcessList />
</PageContainer>
</SlowlyAppear>
}
......@@ -41,20 +41,24 @@ const TagInfo = () => {
},
];
// tab props
const restTabProps = {
activeKey: activeKey,
type: 'card',
animated: true,
onChange: (key: string) => setActiveKey(key),
items: tabList,
};
/**
* render
*/
return <>
<ProCard ghost className={'schemaTree'} size="small" bordered tabs={{...restTabProps}}/>
<ProCard
ghost
className={'schemaTree'}
size="small"
bordered
tabs={{
activeKey: activeKey,
type: 'card',
animated: true,
onChange: (key: string) => setActiveKey(key),
items: tabList,
}}
/>
</>;
};
......
......@@ -17,9 +17,12 @@
import {PageContainer} from "@ant-design/pro-components";
import TagInfo from "@/pages/SettingCenter/SystemLogs/TagInfo";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
return <PageContainer title={false}>
<TagInfo/>
</PageContainer>
return <SlowlyAppear>
<PageContainer title={false}>
<TagInfo/>
</PageContainer>
</SlowlyAppear>
}
......@@ -32,10 +32,11 @@ declare namespace UserBaseInfo {
};
export type ChangePasswordParams = {
id: number;
username: string;
password?: string;
newPassword?: string;
newPasswordCheck?: string;
password: string;
newPassword: string;
newPasswordCheck: string;
};
export type Tenant = ExcludeNameAndEnableColumns & {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment