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; ...@@ -31,6 +31,7 @@ import lombok.Setter;
@Setter @Setter
public class ModifyPasswordDTO { public class ModifyPasswordDTO {
private String id;
private String username; private String username;
private String password; private String password;
private String newPassword; private String newPassword;
......
...@@ -29,7 +29,7 @@ import java.util.List; ...@@ -29,7 +29,7 @@ import java.util.List;
/** role select permissions mapper interface */ /** role select permissions mapper interface */
@Mapper @Mapper
public interface RoleSelectPermissionsMapper extends SuperMapper<RowPermissions> { public interface RowPermissionsMapper extends SuperMapper<RowPermissions> {
/** /**
* delete user role select permissions by role id * delete user role select permissions by role id
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
package org.dinky.service.impl; package org.dinky.service.impl;
import org.dinky.data.model.RowPermissions; 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.mybatis.service.impl.SuperServiceImpl;
import org.dinky.service.RowPermissionsService; import org.dinky.service.RowPermissionsService;
...@@ -32,7 +32,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -32,7 +32,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@Service @Service
public class RoleSelectPermissionsServiceImpl public class RoleSelectPermissionsServiceImpl
extends SuperServiceImpl<RoleSelectPermissionsMapper, RowPermissions> extends SuperServiceImpl<RowPermissionsMapper, RowPermissions>
implements RowPermissionsService { implements RowPermissionsService {
@Override @Override
......
...@@ -116,7 +116,7 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen ...@@ -116,7 +116,7 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen
@Override @Override
public Result<Void> modifyPassword(ModifyPasswordDTO modifyPasswordDTO) { public Result<Void> modifyPassword(ModifyPasswordDTO modifyPasswordDTO) {
User user = getUserByUsername(modifyPasswordDTO.getUsername()); User user = getById(modifyPasswordDTO.getId());
if (Asserts.isNull(user)) { if (Asserts.isNull(user)) {
return Result.failed(Status.USER_NOT_EXIST); return Result.failed(Status.USER_NOT_EXIST);
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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 id="selectForProTable" resultType="org.dinky.data.model.RowPermissions">
select select
a.*, a.*,
b.role_code, b.role_code,
b.role_name b.role_name
from from
dinky_role_select_permissions a dinky_row_permissions a
join dinky_role b on b.id = a.role_id join dinky_role b on b.id = a.role_id
<where> <where>
1=1 1=1
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</select> </select>
<delete id="deleteByRoleIds" parameterType="java.util.List"> <delete id="deleteByRoleIds" parameterType="java.util.List">
DELETE FROM dinky_role_select_permissions DELETE FROM dinky_row_permissions
WHERE role_id IN WHERE role_id IN
<foreach collection="roleIds" item="item" open="(" separator="," close=")"> <foreach collection="roleIds" item="item" open="(" separator="," close=")">
${item} ${item}
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
b.role_code, b.role_code,
b.role_name b.role_name
from from
dinky_role_select_permissions a, dinky_role b dinky_row_permissions a, dinky_role b
WHERE WHERE
b.id = a.role_id b.id = a.role_id
and a.role_id IN and a.role_id IN
......
...@@ -32,6 +32,7 @@ const Settings: ProLayoutProps & { ...@@ -32,6 +32,7 @@ const Settings: ProLayoutProps & {
fixedHeader: false, fixedHeader: false,
fixSiderbar: true, fixSiderbar: true,
colorWeak: false, colorWeak: false,
// 这里不能删除,需要先设置,否则会导致页面白屏, 然后在 layout 进行重新赋值
title: 'Dinky Real-time Platform ', title: 'Dinky Real-time Platform ',
pwa: true, pwa: true,
logo: '/dinky.svg', logo: '/dinky.svg',
......
...@@ -239,6 +239,11 @@ export default [ ...@@ -239,6 +239,11 @@ export default [
footerRender: false, footerRender: false,
component: './Other/About', component: './Other/About',
}, },
{
path: '/account/center',
footerRender: false,
component: './Other/PersonCenter',
},
{ {
path: '*', path: '*',
component: './Other/404', component: './Other/404',
......
...@@ -46,19 +46,19 @@ ...@@ -46,19 +46,19 @@
], ],
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.0.1", "@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-layout": "^7.13.3",
"@ant-design/pro-table": "^3.6.9", "@ant-design/pro-table": "^3.6.9",
"@ant-design/use-emotion-css": "^1.0.4", "@ant-design/use-emotion-css": "^1.0.4",
"@umijs/route-utils": "^4.0.1", "@umijs/route-utils": "^4.0.1",
"antd": "^5.4.7", "antd": "^5.6.1",
"classnames": "^2.3.2", "classnames": "^2.3.2",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.4", "moment": "^2.29.4",
"omit.js": "^2.0.2", "omit.js": "^2.0.2",
"rc-menu": "^9.8.4", "rc-menu": "^9.8.4",
"rc-util": "^5.30.0", "rc-util": "^5.33.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dev-inspector": "^1.8.1", "react-dev-inspector": "^1.8.1",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
"react-monaco-editor": "^0.52.0", "react-monaco-editor": "^0.52.0",
"react-spring": "^9.7.1", "react-spring": "^9.7.1",
"screenfull": "^6.0.2", "screenfull": "^6.0.2",
"styled-components": "^6.0.0-rc.1", "styled-components": "^6.0.0-rc.3",
"use-sse": "^2.0.1" "use-sse": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
import RightContent from "@/components/RightContent"; import RightContent from "@/components/RightContent";
import {PageLoading, Settings as LayoutSettings} from "@ant-design/pro-components"; import {PageLoading, Settings as LayoutSettings} from "@ant-design/pro-components";
// import {SettingDrawer} from "@ant-design/pro-components";
import type {RunTimeLayoutConfig} from "@umijs/max"; import type {RunTimeLayoutConfig} from "@umijs/max";
import {history} from "@umijs/max"; import {history} from "@umijs/max";
import defaultSettings from "../config/defaultSettings"; import defaultSettings from "../config/defaultSettings";
...@@ -27,6 +26,8 @@ import {currentUser as queryCurrentUser} from "./services/BusinessCrud"; ...@@ -27,6 +26,8 @@ import {currentUser as queryCurrentUser} from "./services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants"; import {API_CONSTANTS} from "@/services/constants";
import {THEME} from "@/types/Public/data"; import {THEME} from "@/types/Public/data";
import {UnAccessible} from "@/pages/Other/403"; import {UnAccessible} from "@/pages/Other/403";
import {l} from "@/utils/intl";
import Settings from "../config/defaultSettings";
// const isDev = process.env.NODE_ENV === "development"; // const isDev = process.env.NODE_ENV === "development";
const loginPath = API_CONSTANTS.LOGIN_PATH; const loginPath = API_CONSTANTS.LOGIN_PATH;
...@@ -91,6 +92,15 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) => ...@@ -91,6 +92,15 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
const theme = localStorage.getItem("navTheme"); const theme = localStorage.getItem("navTheme");
return { 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 />, rightContentRender: () => <RightContent />,
footerRender: () => <Footer />, footerRender: () => <Footer />,
siderWidth: 180, siderWidth: 180,
...@@ -106,7 +116,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) => ...@@ -106,7 +116,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
history.push(loginPath); history.push(loginPath);
} }
}, },
menuHeaderRender: undefined,
// 自定义 403 页面 // 自定义 403 页面
unAccessible:<UnAccessible/>, unAccessible:<UnAccessible/>,
// 增加一个 loading 的状态 // 增加一个 loading 的状态
...@@ -115,18 +124,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) => ...@@ -115,18 +124,6 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
return ( return (
<> <>
{children} {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 @@ ...@@ -15,21 +15,29 @@
* limitations under the License. * 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 { setAlpha } from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css'; import { useEmotionCss } from '@ant-design/use-emotion-css';
import { history, useModel } from '@umijs/max'; import { history, useModel } from '@umijs/max';
import { Avatar, Spin } from 'antd'; import {Avatar, Modal, Spin} from 'antd';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import type { MenuInfo } from 'rc-menu/lib/interface'; import type { MenuInfo } from 'rc-menu/lib/interface';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
import HeaderDropdown from '../HeaderDropdown'; 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 Name = () => {
const { initialState } = useModel('@@initialState'); const { initialState } = useModel('@@initialState');
...@@ -73,7 +81,7 @@ const AvatarLogo = () => { ...@@ -73,7 +81,7 @@ const AvatarLogo = () => {
); );
}; };
const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { const AvatarDropdown = () => {
/** /**
* 退出登录,并且将当前的 url 保存 * 退出登录,并且将当前的 url 保存
*/ */
...@@ -93,6 +101,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { ...@@ -93,6 +101,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
}); });
} }
}; };
const actionClassName = useEmotionCss(({ token }) => { const actionClassName = useEmotionCss(({ token }) => {
return { return {
display: 'flex', display: 'flex',
...@@ -111,17 +120,14 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { ...@@ -111,17 +120,14 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
}); });
const { initialState, setInitialState } = useModel('@@initialState'); const { initialState, setInitialState } = useModel('@@initialState');
const onMenuClick = useCallback( const loginOutHandler = useCallback(
async (event: MenuInfo) => { async (event: MenuInfo) => {
const { key } = event; const { key } = event;
if (key === 'logout') {
flushSync(() => { flushSync(() => {
setInitialState((s) => ({ ...s, currentUser: undefined })); setInitialState((s) => ({ ...s, currentUser: undefined }));
}); });
await loginOut(); await loginOut();
return; return;
}
history.push(`/account/${key}`);
}, },
[setInitialState], [setInitialState],
); );
...@@ -146,28 +152,70 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { ...@@ -146,28 +152,70 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
return loading; 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 = [ const menuItems = [
...(menu
? [
{ {
key: 'center', key: 'center',
icon: <UserOutlined />, icon: <TeamOutlined />,
label: '个人中心', label: l('menu.account.center'),
onClick: () => history.push('/account/center'),
},
{
type: 'divider' as const,
}, },
{ {
key: 'settings', key: 'switching',
icon: <SettingOutlined />, icon: <UserSwitchOutlined />,
label: '个人设置', label: l('menu.account.checkTenant'),
children: renderTenantList(),
}, },
{ {
type: 'divider' as const, type: 'divider' as const,
}, },
]
: []),
{ {
key: 'logout', key: 'logout',
icon: <LogoutOutlined />, icon: <LogoutOutlined />,
label: '退出登录', label: l('menu.account.logout'),
onClick: loginOutHandler,
}, },
]; ];
...@@ -175,7 +223,6 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { ...@@ -175,7 +223,6 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
<HeaderDropdown <HeaderDropdown
menu={{ menu={{
selectedKeys: [], selectedKeys: [],
onClick: onMenuClick,
items: menuItems, items: menuItems,
}} }}
> >
......
...@@ -18,10 +18,8 @@ ...@@ -18,10 +18,8 @@
import {STORY_LANGUAGE, VERSION} from '@/services/constants'; import {STORY_LANGUAGE, VERSION} from '@/services/constants';
import { import {
getLocalStorageLanguage, getValueFromLocalStorage, getLocalStorageLanguage, getValueFromLocalStorage,
parseJsonStr,
setCookieByKey, setCookieByKey,
setKeyToLocalStorage, setKeyToLocalStorage,
setTenantStorageAndCookie
} from '@/utils/function'; } from '@/utils/function';
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import { import {
...@@ -29,19 +27,14 @@ import { ...@@ -29,19 +27,14 @@ import {
FullscreenOutlined, FullscreenOutlined,
GlobalOutlined GlobalOutlined
} from "@ant-design/icons"; } from "@ant-design/icons";
import {ActionType} from "@ant-design/pro-components";
import {useEmotionCss} from "@ant-design/use-emotion-css"; import {useEmotionCss} from "@ant-design/use-emotion-css";
import {SelectLang, useModel} from "@umijs/max"; import {SelectLang, useModel} from "@umijs/max";
import {Modal, Select, Space, Switch, Tooltip} from "antd"; import {Space, Switch, Tooltip} from "antd";
import {OptionType} from "dayjs"; import React, {useEffect, useState} from "react";
import React, {useEffect, useRef, useState} from "react";
import screenfull from "screenfull"; import screenfull from "screenfull";
import Avatar from "./AvatarDropdown"; import Avatar from "./AvatarDropdown";
import {ThemeCloud, ThemeStar} from "@/components/ThemeSvg/ThemeSvg"; 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 {THEME} from "@/types/Public/data";
import cookies from 'js-cookie';
const GlobalHeaderRight: React.FC = () => { const GlobalHeaderRight: React.FC = () => {
...@@ -79,7 +72,7 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -79,7 +72,7 @@ const GlobalHeaderRight: React.FC = () => {
locale: lang, locale: lang,
})); }));
} }
}, [initialState?.settings?.locale]); }, [initialState?.settings]);
if (!initialState || !initialState.settings) { if (!initialState || !initialState.settings) {
...@@ -128,32 +121,6 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -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 * full screen or exit full screen
...@@ -165,20 +132,7 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -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 = { const fullScreenProps = {
style: {color: "white"}, style: {color: "white"},
...@@ -192,29 +146,13 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -192,29 +146,13 @@ const GlobalHeaderRight: React.FC = () => {
{fullScreen ? <FullscreenOutlined {...fullScreenProps} onClick={screenFull}/> : {fullScreen ? <FullscreenOutlined {...fullScreenProps} onClick={screenFull}/> :
<FullscreenExitOutlined {...fullScreenProps} onClick={screenFull}/>} <FullscreenExitOutlined {...fullScreenProps} onClick={screenFull}/>}
</Tooltip> </Tooltip>
<Avatar menu={true}/> <Avatar/>
<>
<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>
</>
<Tooltip <Tooltip
placement="bottom" placement="bottom"
title={<span>{l("menu.version", "", {version: VERSION})}</span>} title={<span>{l("menu.version", "", {version: VERSION})}</span>}
> >
<Space className={actionClassName}>{l("menu.version", "", {version: VERSION})}</Space> <Space className={actionClassName}>{l("menu.version", "", {version: VERSION})}</Space>
</Tooltip> </Tooltip>
<SelectLang icon={<GlobalOutlined/>} className={actionClassName}/> <SelectLang icon={<GlobalOutlined/>} className={actionClassName}/>
<Switch <Switch
key={"themeSwitch"} key={"themeSwitch"}
......
...@@ -30,8 +30,7 @@ export default { ...@@ -30,8 +30,7 @@ export default {
'menu.account.center': 'Account Center', 'menu.account.center': 'Account Center',
'menu.account.logout': 'Logout', 'menu.account.logout': 'Logout',
'menu.account.changePassword': 'Change Password', 'menu.account.changePassword': 'Change Password',
'menu.account.checkTenant': 'Check Tenant', 'menu.account.checkTenant': 'Switch Tenant',
'menu.tenants': 'Tenant: ',
'menu.account.checkTenantConfirm': 'Are you sure to switch tenant [ {tenantCode} ] ?', 'menu.account.checkTenantConfirm': 'Are you sure to switch tenant [ {tenantCode} ] ?',
'menu.datastudio': 'Data Studio', 'menu.datastudio': 'Data Studio',
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
export default { export default {
//-------------------------------- common -------------------------------- //-------------------------------- 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.error': 'Login failed, please try again! Reason:{msg}',
'login.result': '{msg}\t\t{time}', 'login.result': '{msg}\t\t{time}',
'login.notbindtenant': 'You have not bound a tenant, please contact the administrator', 'login.notbindtenant': 'You have not bound a tenant, please contact the administrator',
...@@ -83,6 +83,12 @@ export default { ...@@ -83,6 +83,12 @@ export default {
'user.newpwdPlaceholder': 'Please enter new password', 'user.newpwdPlaceholder': 'Please enter new password',
'user.repeatpwdPlaceholder': 'Please enter repeat new password', 'user.repeatpwdPlaceholder': 'Please enter repeat new password',
'user.oldNewPwdNoMatch': 'The new passwords do not match', '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
'tenant.TenantManager': 'Tenant Management', 'tenant.TenantManager': 'Tenant Management',
......
...@@ -31,7 +31,6 @@ export default { ...@@ -31,7 +31,6 @@ export default {
'menu.account.logout': '退出登录', 'menu.account.logout': '退出登录',
'menu.account.changePassword': '修改密码', 'menu.account.changePassword': '修改密码',
'menu.account.checkTenant': '切换租户', 'menu.account.checkTenant': '切换租户',
'menu.tenants': '租户:',
'menu.account.checkTenantConfirm': '你确定切换租户【{tenantCode}】吗?', 'menu.account.checkTenantConfirm': '你确定切换租户【{tenantCode}】吗?',
'menu.datastudio': '数据开发', 'menu.datastudio': '数据开发',
......
...@@ -80,6 +80,12 @@ export default { ...@@ -80,6 +80,12 @@ export default {
'user.newpwdPlaceholder': '请输入新密码', 'user.newpwdPlaceholder': '请输入新密码',
'user.repeatpwdPlaceholder': '请重复输入新密码', 'user.repeatpwdPlaceholder': '请重复输入新密码',
'user.oldNewPwdNoMatch': '两次输入的新密码不一致', 'user.oldNewPwdNoMatch': '两次输入的新密码不一致',
// -- personal info
'user.info': '个人信息',
'user.tenant': '租户',
'user.role': '角色',
'user.op': '操作记录',
'user.current.tenant': '当前登录租户',
// tenant // tenant
'tenant.TenantManager': '租户管理', 'tenant.TenantManager': '租户管理',
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import React from "react"; import React from "react";
import {PageContainer} from '@ant-design/pro-layout'; import {PageContainer} from '@ant-design/pro-layout';
import RoleProTable from "@/pages/AuthCenter/Role/components/RoleProTable"; import RoleProTable from "@/pages/AuthCenter/Role/components/RoleProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => { export default () => {
...@@ -28,9 +29,9 @@ export default () => { ...@@ -28,9 +29,9 @@ export default () => {
/** /**
* render * render
*/ */
return <> return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<RoleProTable/> <RoleProTable/>
</PageContainer> </PageContainer>
</> </SlowlyAppear>
}; };
...@@ -19,15 +19,16 @@ ...@@ -19,15 +19,16 @@
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import PermissionsProTable from "@/pages/AuthCenter/RowPermissions/components/PermissionsProTable"; import PermissionsProTable from "@/pages/AuthCenter/RowPermissions/components/PermissionsProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => { export default () => {
/** /**
* render * render
*/ */
return <> return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<PermissionsProTable /> <PermissionsProTable />
</PageContainer> </PageContainer>
</> </SlowlyAppear>
} }
\ No newline at end of file
...@@ -20,17 +20,18 @@ ...@@ -20,17 +20,18 @@
import React from "react"; import React from "react";
import {PageContainer} from '@ant-design/pro-layout'; import {PageContainer} from '@ant-design/pro-layout';
import TenantProTable from "./components/TenantProTable"; import TenantProTable from "./components/TenantProTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
const TenantFormList: React.FC = () => { const TenantFormList: React.FC = () => {
/** /**
* render * render
*/ */
return <> return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<TenantProTable/> <TenantProTable/>
</PageContainer> </PageContainer>
</> </SlowlyAppear>
}; };
export default TenantFormList; export default TenantFormList;
...@@ -25,10 +25,13 @@ import {UserBaseInfo} from "@/types/User/data"; ...@@ -25,10 +25,13 @@ import {UserBaseInfo} from "@/types/User/data";
import React from "react"; import React from "react";
import {FormInstance} from "antd/es/form/hooks/useForm"; import {FormInstance} from "antd/es/form/hooks/useForm";
import {Values} from "async-validator"; import {Values} from "async-validator";
import {Button} from "antd";
type PasswordFormProps = { type PasswordFormProps = {
values: Partial<UserBaseInfo.ChangePasswordParams>; values: UserBaseInfo.User;
form: FormInstance<Values> form: FormInstance<Values>
renderSubmit?: boolean;
onSubmit?: (values: UserBaseInfo.ChangePasswordParams) => void;
}; };
...@@ -37,7 +40,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => { ...@@ -37,7 +40,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
/** /**
* init 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 * render changePassword form
...@@ -45,7 +56,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => { ...@@ -45,7 +56,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
const pwdFormRender = () => { const pwdFormRender = () => {
return <> return <>
<ProFormText.Password <ProFormText.Password
width="md" width="xl"
name="password" name="password"
hasFeedback hasFeedback
label={l('user.oldpwd')} label={l('user.oldpwd')}
...@@ -53,7 +64,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => { ...@@ -53,7 +64,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
rules={[{required: true, message: l('user.oldpwdPlaceholder')}]} rules={[{required: true, message: l('user.oldpwdPlaceholder')}]}
/> />
<ProFormText.Password <ProFormText.Password
width="md" width="xl"
name="newPassword" name="newPassword"
hasFeedback hasFeedback
label={l('user.newpwd')} label={l('user.newpwd')}
...@@ -61,7 +72,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => { ...@@ -61,7 +72,7 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
rules={[{required: true, message: l('user.newpwdPlaceholder')}]} rules={[{required: true, message: l('user.newpwdPlaceholder')}]}
/> />
<ProFormText.Password <ProFormText.Password
width="md" width="xl"
name="newPasswordCheck" name="newPasswordCheck"
hasFeedback hasFeedback
dependencies={['newPassword']} dependencies={['newPassword']}
...@@ -95,7 +106,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => { ...@@ -95,7 +106,15 @@ const PasswordModal: React.FC<PasswordFormProps> = (props) => {
form={form} form={form}
initialValues={values} initialValues={values}
layout={"horizontal"} layout={"horizontal"}
submitter={false} submitter={{
render: (submitProps, doms) => {
return renderSubmit?<>
<Button type="primary" onClick={async ()=>{
await handleSubmit();
}}>{l('button.submit')}</Button>
</>:<></>
},
}}
> >
{pwdFormRender()} {pwdFormRender()}
</ProForm> </ProForm>
......
...@@ -28,9 +28,9 @@ import PasswordForm from "@/pages/AuthCenter/User/components/PasswordModal/Passw ...@@ -28,9 +28,9 @@ import PasswordForm from "@/pages/AuthCenter/User/components/PasswordModal/Passw
type PasswordModalFormProps = { type PasswordModalFormProps = {
onCancel: (flag?: boolean) => void; onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<UserBaseInfo.ChangePasswordParams>) => void; onSubmit: (values: UserBaseInfo.ChangePasswordParams) => void;
modalVisible: boolean; modalVisible: boolean;
values: Partial<UserBaseInfo.ChangePasswordParams>; values: Partial<UserBaseInfo.User>;
}; };
...@@ -66,9 +66,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => { ...@@ -66,9 +66,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => {
}, [modalVisible, values, form]); }, [modalVisible, values, form]);
const [formVals, setFormVals] = useState<Partial<UserBaseInfo.ChangePasswordParams>>({ const [formVals, setFormVals] = useState<Partial<UserBaseInfo.ChangePasswordParams>>({...values});
username: values.username,
});
/** /**
...@@ -100,7 +98,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => { ...@@ -100,7 +98,7 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => {
onCancel={() => handleCancel()} onCancel={() => handleCancel()}
onOk={() => submitForm()} onOk={() => submitForm()}
> >
<PasswordForm values={values} form={form}/> <PasswordForm values={values as any} form={form}/>
</Modal> </Modal>
</> </>
}; };
......
...@@ -132,7 +132,7 @@ const UserProTable = () => { ...@@ -132,7 +132,7 @@ const UserProTable = () => {
* change password submit * change password submit
* @param value * @param value
*/ */
const handlePasswordChangeSubmit = async (value: any) => { const handlePasswordChangeSubmit = async (value: UserBaseInfo.ChangePasswordParams) => {
await executeAndCallbackRefresh(async () => { await executeAndCallbackRefresh(async () => {
await handleOption(API_CONSTANTS.USER_MODIFY_PASSWORD, l("button.changePassword"), value); await handleOption(API_CONSTANTS.USER_MODIFY_PASSWORD, l("button.changePassword"), value);
await handlePasswordModalOpen(false); await handlePasswordModalOpen(false);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import React from "react"; import React from "react";
import UserProTable from "@/pages/AuthCenter/User/components/UserProTable"; import UserProTable from "@/pages/AuthCenter/User/components/UserProTable";
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => { export default () => {
...@@ -28,10 +29,10 @@ export default () => { ...@@ -28,10 +29,10 @@ export default () => {
/** /**
* render * render
*/ */
return <> return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<UserProTable/> <UserProTable/>
</PageContainer> </PageContainer>
</> </SlowlyAppear>
}; };
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
import {PageContainer} from '@ant-design/pro-layout'; import {PageContainer} from '@ant-design/pro-layout';
import JobList from '@/pages/DevOps/JobList'; import JobList from '@/pages/DevOps/JobList';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => { export default () => {
/** /**
* breadcrumb={{style:{display:'none'}}} is used to hide the breadcrumb || 隐藏右上角的路由导航面包屑 * breadcrumb={{style:{display:'none'}}} is used to hide the breadcrumb || 隐藏右上角的路由导航面包屑
*/ */
return <> return <SlowlyAppear>
<PageContainer title={false} breadcrumb={{style:{display:'none'}}}> <PageContainer title={false} breadcrumb={{style:{display:'none'}}}>
<JobList/> <JobList/>
</PageContainer> </PageContainer>
</>; </SlowlyAppear>;
} }
...@@ -114,6 +114,7 @@ const Login: React.FC = () => { ...@@ -114,6 +114,7 @@ const Login: React.FC = () => {
try { try {
// login // login
const result = await login({...values}); const result = await login({...values});
setInitialState((s) => ({...s, currentUser: result.datas}));
await SuccessMessageAsync(l("login.result", "", {msg: result.msg, time: result.time})); await SuccessMessageAsync(l("login.result", "", {msg: result.msg, time: result.time}));
/** /**
* After successful login, set the tenant list * 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"; ...@@ -34,6 +34,7 @@ import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons"; import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import DescriptionsItem from "antd/es/descriptions/Item"; import DescriptionsItem from "antd/es/descriptions/Item";
import AlertGroupForm from "@/pages/RegCenter/Alert/AlertGroup/components/AlertGroupForm"; import AlertGroupForm from "@/pages/RegCenter/Alert/AlertGroup/components/AlertGroupForm";
import Pop from "@/components/Animation/Pop";
const AlertGroupTableList: React.FC = (props: any) => { const AlertGroupTableList: React.FC = (props: any) => {
/** /**
...@@ -220,7 +221,7 @@ const AlertGroupTableList: React.FC = (props: any) => { ...@@ -220,7 +221,7 @@ const AlertGroupTableList: React.FC = (props: any) => {
})); }));
return ( return <Pop>
<PageContainer title={false}> <PageContainer title={false}>
{/* alert group list */} {/* alert group list */}
<ProList<Alert.AlertGroup> <ProList<Alert.AlertGroup>
...@@ -250,7 +251,7 @@ const AlertGroupTableList: React.FC = (props: any) => { ...@@ -250,7 +251,7 @@ const AlertGroupTableList: React.FC = (props: any) => {
} }
</PageContainer> </PageContainer>
); </Pop>
}; };
const mapDispatchToProps = (dispatch: Dispatch) => ({ const mapDispatchToProps = (dispatch: Dispatch) => ({
......
...@@ -19,11 +19,14 @@ ...@@ -19,11 +19,14 @@
import React from 'react'; import React from 'react';
import AlertInstanceList from '@/pages/RegCenter/Alert/AlertInstance/components/AlertInstanceList'; import AlertInstanceList from '@/pages/RegCenter/Alert/AlertInstance/components/AlertInstanceList';
import {PageContainer} from '@ant-design/pro-components'; import {PageContainer} from '@ant-design/pro-components';
import Scale from '@/components/Animation/Scale';
export default () => { export default () => {
return <PageContainer title={false}> return <Scale>
<PageContainer title={false}>
<AlertInstanceList/> <AlertInstanceList/>
</PageContainer>; </PageContainer>
</Scale>;
} }
...@@ -20,9 +20,12 @@ ...@@ -20,9 +20,12 @@
import React from "react"; import React from "react";
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import InstanceList from "@/pages/RegCenter/Cluster/Instance/components/InstanceList"; import InstanceList from "@/pages/RegCenter/Cluster/Instance/components/InstanceList";
import Pop from "@/components/Animation/Pop";
export default () => { export default () => {
return <PageContainer title={false}> return <Pop>
<PageContainer title={false}>
<InstanceList/> <InstanceList/>
</PageContainer> </PageContainer>
</Pop>
} }
\ No newline at end of file
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import DataSourceTable from "@/pages/RegCenter/DataSource/components/DataSourceList"; import DataSourceTable from "@/pages/RegCenter/DataSource/components/DataSourceList";
import Pop from "@/components/Animation/Pop";
/** /**
* render DataSource page * render DataSource page
*/ */
export default () => { export default () => {
return <> return <Pop>
<PageContainer title={false}> <PageContainer title={false}>
<DataSourceTable/> <DataSourceTable/>
</PageContainer> </PageContainer>
</>; </Pop>;
} }
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import React from 'react'; import React from 'react';
import {PageContainer} from '@ant-design/pro-layout'; import {PageContainer} from '@ant-design/pro-layout';
import DocumentProTable from "@/pages/RegCenter/Document/components/DocumentProTable"; import DocumentProTable from "@/pages/RegCenter/Document/components/DocumentProTable";
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => { export default () => {
...@@ -27,9 +28,9 @@ export default () => { ...@@ -27,9 +28,9 @@ export default () => {
/** /**
* render * render
*/ */
return ( return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<DocumentProTable/> <DocumentProTable/>
</PageContainer> </PageContainer>
); </SlowlyAppear>
}; };
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
import {PageContainer} from "@ant-design/pro-layout"; import {PageContainer} from "@ant-design/pro-layout";
import ProjectProTable from "@/pages/RegCenter/GitProject/components/ProjectProTable"; import ProjectProTable from "@/pages/RegCenter/GitProject/components/ProjectProTable";
import FadeIn from "@/components/Animation/FadeIn";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => { export default () => {
...@@ -26,7 +28,9 @@ export default () => { ...@@ -26,7 +28,9 @@ export default () => {
/** /**
* render * render
*/ */
return <PageContainer title={false}> return <SlowlyAppear>
<PageContainer title={false}>
<ProjectProTable/> <ProjectProTable/>
</PageContainer>; </PageContainer>
</SlowlyAppear>;
}; };
...@@ -20,15 +20,16 @@ ...@@ -20,15 +20,16 @@
import React from 'react'; import React from 'react';
import {PageContainer} from '@ant-design/pro-layout'; import {PageContainer} from '@ant-design/pro-layout';
import GlobalVarProTable from "@/pages/RegCenter/GlobalVar/components/GlobalVarProTable"; import GlobalVarProTable from "@/pages/RegCenter/GlobalVar/components/GlobalVarProTable";
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
export default () => { export default () => {
/** /**
* render * render
*/ */
return ( return <SlowlyAppear>
<PageContainer title={false}> <PageContainer title={false}>
<GlobalVarProTable/> <GlobalVarProTable/>
</PageContainer> </PageContainer>
); </SlowlyAppear>
}; };
...@@ -17,9 +17,12 @@ ...@@ -17,9 +17,12 @@
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import TemplateTable from "@/pages/RegCenter/UDF/components/TemplateTable"; import TemplateTable from "@/pages/RegCenter/UDF/components/TemplateTable";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default ()=>{ export default ()=>{
return <PageContainer title={false}> return <SlowlyAppear>
<PageContainer title={false}>
<TemplateTable/> <TemplateTable/>
</PageContainer> </PageContainer>
</SlowlyAppear>
} }
...@@ -25,10 +25,11 @@ import {MavenConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/M ...@@ -25,10 +25,11 @@ import {MavenConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/M
import {DSConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/DSConfig'; import {DSConfig} from '@/pages/SettingCenter/GlobalSetting/SettingOverView/DSConfig';
import {LdapConfig} from "@/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig"; import {LdapConfig} from "@/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig";
import {l} from '@/utils/intl'; import {l} from '@/utils/intl';
import FadeIn from "@/components/Animation/FadeIn";
const SettingOverView = () => { 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 () => { const fetchData = async () => {
...@@ -65,9 +66,9 @@ const SettingOverView = () => { ...@@ -65,9 +66,9 @@ const SettingOverView = () => {
}; };
return <> return <FadeIn>
{renderData()} {renderData()}
</>; </FadeIn>;
}; };
export default memo(SettingOverView); export default memo(SettingOverView);
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import ProcessList from "./components/ProcessList"; import ProcessList from "./components/ProcessList";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default ()=> { export default ()=> {
return <PageContainer title={false}> return <SlowlyAppear>
<PageContainer title={false}>
<ProcessList /> <ProcessList />
</PageContainer> </PageContainer>
</SlowlyAppear>
} }
...@@ -41,20 +41,24 @@ const TagInfo = () => { ...@@ -41,20 +41,24 @@ const TagInfo = () => {
}, },
]; ];
// tab props
const restTabProps = {
activeKey: activeKey,
type: 'card',
animated: true,
onChange: (key: string) => setActiveKey(key),
items: tabList,
};
/** /**
* render * render
*/ */
return <> 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 @@ ...@@ -17,9 +17,12 @@
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer} from "@ant-design/pro-components";
import TagInfo from "@/pages/SettingCenter/SystemLogs/TagInfo"; import TagInfo from "@/pages/SettingCenter/SystemLogs/TagInfo";
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => { export default () => {
return <PageContainer title={false}> return <SlowlyAppear>
<PageContainer title={false}>
<TagInfo/> <TagInfo/>
</PageContainer> </PageContainer>
</SlowlyAppear>
} }
...@@ -32,10 +32,11 @@ declare namespace UserBaseInfo { ...@@ -32,10 +32,11 @@ declare namespace UserBaseInfo {
}; };
export type ChangePasswordParams = { export type ChangePasswordParams = {
id: number;
username: string; username: string;
password?: string; password: string;
newPassword?: string; newPassword: string;
newPasswordCheck?: string; newPasswordCheck: string;
}; };
export type Tenant = ExcludeNameAndEnableColumns & { 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