Unverified Commit 8546bb14 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-2284][web] Optimize dinky web and fix some bugs (#2285)

* [Optimization-2284][web] Optimize dinky web and fix some bugs * spotless apply * Resolve code conflicts --------- Co-authored-by: 's avatarwenmo <32723967+wenmo@users.noreply.github.com>
parent bca2f9e3
......@@ -19,8 +19,11 @@
package org.dinky.data.model;
import org.dinky.assertion.Asserts;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -54,7 +57,9 @@ public class TaskExtConfig implements Serializable {
// 获取自定义配置的所有key-value
public Map<String, String> getCustomConfigMaps() {
return customConfig.stream().collect(Collectors.toMap(ConfigItem::getKey, ConfigItem::getValue));
return Asserts.isNotNullCollection(customConfig)
? customConfig.stream().collect(Collectors.toMap(ConfigItem::getKey, ConfigItem::getValue))
: new HashMap<>();
}
// 是否包含某个key
......
......@@ -61,7 +61,6 @@ const queryUserInfo = async () => {
return getDataByParamsReturnResult(API_CONSTANTS.CURRENT_USER).then(
(result) => {
const { user, roleList, tenantList, currentTenant, menuList, saTokenInfo } = result.datas;
extraRoutes = menuList;
const currentUser: API.CurrentUser = {
user: {
...user,
......@@ -74,17 +73,10 @@ const queryUserInfo = async () => {
tokenInfo: saTokenInfo
};
return currentUser;
},
(error) => {
history.push(loginPath);
console.log(error);
return undefined;
}
);
};
const fetchUserInfo = async () => await queryUserInfo();
/**
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
* */
......@@ -94,10 +86,21 @@ export async function getInitialState(): Promise<{
loading?: boolean;
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
}> {
const fetchUserInfo = async () => {
try {
return await queryUserInfo();
} catch (error) {
history.push(loginPath);
}
return undefined;
};
// 如果不是登录页面,执行
const { location } = history;
if (location.pathname !== loginPath) {
const currentUser = await fetchUserInfo();
extraRoutes = currentUser?.menuList;
return {
fetchUserInfo,
currentUser,
......@@ -129,11 +132,11 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
rightContentRender: () => <RightContent />,
footerRender: () => <Footer />,
siderWidth: 180,
waterMarkProps: {
/*waterMarkProps: {
content: initialState?.currentUser?.user.username + ' ' + new Date().toLocaleString(),
fontColor:
theme === THEME.light || undefined ? 'rgba(0, 0, 0, 0.15)' : 'rgba(255, 255, 255, 0.15)'
},
},*/
isChildrenLayout: true,
onPageChange: () => {
const { location } = history;
......@@ -191,7 +194,7 @@ const patch = (oldRoutes: any, routes: SysMenu[]) => {
oldRoutes[1].routes = oldRoutes[1].routes.map(
(route: { routes: { path: any; element: JSX.Element }[]; path: string }) => {
if (route.routes?.length) {
const redirect = routes.filter((r) => r.path.startsWith(route.path));
const redirect = routes?.filter((r) => r.path.startsWith(route.path));
if (redirect.length) {
route.routes.shift();
route.routes.unshift({
......@@ -221,7 +224,7 @@ export function onRouteChange({
clientRoutes,
routes,
action
}: {
}: {
location: any;
clientRoutes: any;
routes: any;
......@@ -229,7 +232,7 @@ export function onRouteChange({
}) {
if (location.pathname !== loginPath && !rendered) {
const filterMenus = (menus: SysMenu[]) => {
return menus.filter((menu) => menu.type !== 'F');
return menus?.filter((menu) => menu.type !== 'F');
};
extraRoutes = filterMenus(extraRoutes);
patchClientRoutes({ routes: clientRoutes });
......
......@@ -60,8 +60,7 @@ const GlobalHeaderRight: React.FC = () => {
/**
* css
*/
const actionClassName = useEmotionCss(({ token }) => {
return {
const actionClassName = {
display: 'flex',
float: 'right',
justifyContent: 'center',
......@@ -72,18 +71,15 @@ const GlobalHeaderRight: React.FC = () => {
cursor: 'pointer',
padding: '0 9px',
color: '#fff',
borderRadius: token.borderRadius,
'&:hover': {
backgroundColor: token.colorBgTextHover
backgroundColor: '#fff'
}
};
});
/**
* full screen css
*/
const fullScreenClassName = useEmotionCss(({ token }) => {
return {
const fullScreenClassName = {
display: 'flex',
float: 'right',
height: '48px',
......@@ -91,13 +87,11 @@ const GlobalHeaderRight: React.FC = () => {
overflow: 'hidden',
cursor: 'pointer',
padding: '0 12px',
borderRadius: token.borderRadius,
color: 'red',
color: '#fff',
'&:hover': {
backgroundColor: token.colorPrimary
backgroundColor: '#fff'
}
};
});
/**
* full screen or exit full screen
......@@ -110,8 +104,7 @@ const GlobalHeaderRight: React.FC = () => {
};
const fullScreenProps = {
style: { color: 'white' },
className: fullScreenClassName
style: fullScreenClassName
};
const menuVersion = l('menu.version', '', { version: VERSION });
......@@ -129,9 +122,9 @@ const GlobalHeaderRight: React.FC = () => {
</Tooltip>
<Avatar />
<Tooltip placement='bottom' title={<span>{menuVersion}</span>}>
<Space className={actionClassName}>{menuVersion}</Space>
<Space style={actionClassName}>{menuVersion}</Space>
</Tooltip>
<SelectLang icon={<GlobalOutlined />} className={actionClassName} />
<SelectLang icon={<GlobalOutlined />} style={actionClassName} />
<Switch
key={'themeSwitch'}
checked={theme === THEME.dark}
......
......@@ -48,8 +48,8 @@ body,
.logo {
position: absolute;
top: -5vh;
left: -30vw;
top: 10vh;
left: 20vw;
display: flex;
flex: auto;
flex-flow: column-reverse;
......@@ -57,6 +57,8 @@ body,
}
.desc {
font-weight: 600;
font-size: 24px;
margin-top: 2rem;
margin-bottom: 1rem;
//color: @text-color-secondary;
......@@ -82,6 +84,7 @@ body,
margin-bottom: -15vh;
margin-left: 60vw;
box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.4);
border-radius: 10px;
}
.loginform {
......@@ -244,18 +247,12 @@ ol {
.ant-tree-node-content-wrapper {
display: flex;
:hover {
color: #1eef07;
}
}
}
}
.ant-tree-node-content-wrapper {
display: flex;
:hover {
color: #1eef07;
}
}
.gitCodeTree {
min-height: 70vh;
......@@ -381,7 +378,7 @@ h5 {
justify-content: space-between;
line-height: 32px;
padding-inline: 10px;
padding-block: 5px;
padding-block: 1px;
border-block: 1px solid;
}
......@@ -421,3 +418,4 @@ h5 {
display: flex !important;
align-items: baseline !important;
}
......@@ -71,12 +71,14 @@ export default {
'home.job.failed.name': 'Job Name',
'home.job.failed.time': 'Abnormal Time',
'home.develop': 'Data Develop',
'home.job.development': 'Development',
'home.job.batch': 'Batch Job',
'home.job.stream': 'Streaming Job',
'home.job.total': 'Number of Jobs',
'home.job.onlineRate': 'Number of Jobs Online Rate',
'home.job.type': 'Job Type',
'home.job.rate': 'Proportion of Jobs',
'home.develop.re': 'Resource Registration',
'home.develop.re.ci': 'Flink Cluster Instance',
'home.develop.re.cc': 'Cluster Configuration',
'home.develop.re.ds': 'Data Source',
......
......@@ -68,12 +68,14 @@ export default {
'home.job.failed.name': '任务名称',
'home.job.failed.time': '已异常时间',
'home.develop': ' 数据开发',
'home.job.development': '建设情况',
'home.job.batch': '批作业',
'home.job.stream': '流作业',
'home.job.total': '作业数',
'home.job.onlineRate': '作业上线率',
'home.job.type': '作业类型',
'home.job.rate': '作业占比',
'home.develop.re': '资源注册情况',
'home.develop.re.ci': 'Flink 集群实例',
'home.develop.re.cc': '集群配置',
'home.develop.re.ds': '数据源',
......
......@@ -125,7 +125,6 @@ const JobModal: React.FC<JobModalProps> = (props) => {
name='note'
label={l('catalog.note')}
placeholder={l('catalog.note.placeholder')}
rules={[{ required: true, message: l('catalog.note.placeholder') }]}
/>
{isUDF(jobType) && (
<>
......
......@@ -41,7 +41,7 @@ export const buildProjectTree = (
searchValue: string = '',
path?: string[]
): any =>
data.map((item: Catalogue) => {
data?data.map((item: Catalogue) => {
const currentPath = path ? [...path, item.name] : [item.name];
return {
// isLeaf: (item.type && item.children.length === 0) ,
......@@ -60,7 +60,7 @@ export const buildProjectTree = (
taskId: item.taskId,
children: buildProjectTree(item.children, searchValue, currentPath)
};
});
}):[];
export const isUDF = (jobType: string) => {
return jobType === 'Scala' || jobType === 'Python' || jobType === 'Java';
......
......@@ -49,6 +49,7 @@ import { Layout, Menu, Modal, theme, Typography } from 'antd';
import { useEffect, useState } from 'react';
import { PersistGate } from 'redux-persist/integration/react';
import { connect, getDvaApp } from 'umi';
import { PageContainer } from '@ant-design/pro-layout';
const { Text } = Typography;
......@@ -177,7 +178,7 @@ const DataStudio = (props: any) => {
return false;
}
if (JSON.stringify(res[key]) !== JSON.stringify(params.taskData[key])) {
if (res && JSON.stringify(res[key]) !== JSON.stringify(params.taskData[key])) {
return true;
}
});
......@@ -226,6 +227,7 @@ const DataStudio = (props: any) => {
const access = useAccess();
return (
<PageContainer title={false} breadcrumb={{ style: { display: 'none' } }}>
<PersistGate loading={null} persistor={persist}>
<div style={{ marginInline: -10, marginBlock: -5 }}>
{/* 渲染 header */}
......@@ -354,6 +356,7 @@ const DataStudio = (props: any) => {
{<FooterContainer token={token} />}
</div>
</PersistGate>
</PageContainer>
);
};
......
......@@ -27,6 +27,11 @@ import { Badge } from 'antd';
import RcResizeObserver from 'rc-resize-observer';
import React, { useState } from 'react';
const noPadding = {
paddingInline: '0',
paddingBlock: '0'
};
const DevOverView: React.FC = () => {
const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical');
......@@ -48,9 +53,10 @@ const DevOverView: React.FC = () => {
bordered
size='small'
split={split}
bodyStyle={noPadding}
>
<ProCard split='vertical'>
<ProCard split='horizontal' colSpan={'40%'}>
<ProCard split='vertical' bodyStyle={noPadding}>
<ProCard title={l('home.job.development')} split='horizontal' colSpan={'40%'} bodyStyle={noPadding}>
<ProCard>
<BatchStreamProportion />
</ProCard>
......@@ -59,10 +65,10 @@ const DevOverView: React.FC = () => {
</ProCard>
</ProCard>
<ProCard colSpan={'30%'}>
<ProCard title={l('home.job.onlineRate')} colSpan={'30%'} bodyStyle={noPadding}>
<TaskDialectRadar />
</ProCard>
<ProCard>
<ProCard title={l('home.develop.re')} bodyStyle={noPadding}>
<ResourceView />
</ProCard>
</ProCard>
......
......@@ -129,7 +129,7 @@ const JobErrorView: React.FC = () => {
/>
<ProTable
columns={columns}
scroll={{ y: 230 }}
scroll={{ y: 200 }}
dataSource={data}
search={false}
toolBarRender={false}
......
......@@ -23,11 +23,16 @@ import JobRecoveryView from '@/pages/Home/JobOverView/JobRecoveryView';
import JobRunView from '@/pages/Home/JobOverView/JobRunView';
import JobStatusPie from '@/pages/Home/JobOverView/JobStatusPie';
import LoadScoreGauge from '@/pages/Home/JobOverView/LoadScoreGauge';
import { l } from '@/utils/intl';
import { ProCard } from '@ant-design/pro-components';
import { Badge } from 'antd';
import {l} from '@/utils/intl';
import {ProCard} from '@ant-design/pro-components';
import {Badge} from 'antd';
import RcResizeObserver from 'rc-resize-observer';
import React, { useState } from 'react';
import React, {useState} from 'react';
const noPadding = {
paddingInline: '0',
paddingBlock: '0'
};
const JobOverView: React.FC = () => {
const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical');
......@@ -42,7 +47,7 @@ const JobOverView: React.FC = () => {
<ProCard
title={
<>
<Badge status='processing' />
<Badge status='processing'/>
{l('home.job.metrics')}
</>
}
......@@ -50,29 +55,30 @@ const JobOverView: React.FC = () => {
bordered
size='small'
split={split}
bodyStyle={noPadding}
>
<ProCard split={split}>
<ProCard split={split} bodyStyle={noPadding}>
<ProCard split='horizontal'>
<ProCard bodyStyle={{ padding: '0 12px' }}>
<JobRunView />
<ProCard bodyStyle={{padding: '0 12px'}}>
<JobRunView/>
</ProCard>
<ProCard bodyStyle={{ padding: '0 12px' }}>
<JobFinishedView />
<ProCard bodyStyle={{padding: '0 12px'}}>
<JobFinishedView/>
</ProCard>
<ProCard bodyStyle={{ padding: '0 12px' }}>
<JobRecoveryView />
<ProCard bodyStyle={{padding: '0 12px'}}>
<JobRecoveryView/>
</ProCard>
</ProCard>
<ProCard title={l('home.job.running.status')}>
<JobStatusPie />
<ProCard title={l('home.job.running.status')} bodyStyle={noPadding}>
<JobStatusPie/>
</ProCard>
</ProCard>
<ProCard split={split}>
<ProCard title={l('home.server.load')}>
<LoadScoreGauge />
<ProCard split={split} bodyStyle={noPadding}>
<ProCard title={l('home.server.load')} bodyStyle={noPadding}>
<LoadScoreGauge/>
</ProCard>
<ProCard split='horizontal'>
<JobErrorView />
<ProCard split='horizontal' bodyStyle={noPadding}>
<JobErrorView/>
</ProCard>
</ProCard>
</ProCard>
......
......@@ -25,12 +25,9 @@ const MainWithStyle = (props: any) => {
return (
<div className={style.loginformMain} style={{ backgroundImage: `url('/icons/main-bg.svg')` }}>
<Scale>
<img className={style.logo} src={Settings.logo} />
</Scale>
<div className={style.form}>
<div className={style.top}>
<div className={style.header}>Dinky</div>
<div className={style.desc}>{l('layouts.userLayout.title')}</div>
</div>
{children}
......
......@@ -17,16 +17,16 @@
*
*/
import Pop from '@/components/Animation/Pop';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import ConfigurationList from '@/pages/RegCenter/Cluster/Configuration/components/ConfigurationList';
import { PageContainer } from '@ant-design/pro-components';
export default () => {
return (
<Pop>
<SlowlyAppear>
<PageContainer title={false}>
<ConfigurationList />
</PageContainer>
</Pop>
</SlowlyAppear>
);
};
......@@ -17,16 +17,16 @@
*
*/
import Pop from '@/components/Animation/Pop';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import InstanceList from '@/pages/RegCenter/Cluster/Instance/components/InstanceList';
import { PageContainer } from '@ant-design/pro-components';
export default () => {
return (
<Pop>
<SlowlyAppear>
<PageContainer title={false}>
<InstanceList />
</PageContainer>
</Pop>
</SlowlyAppear>
);
};
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
import Pop from '@/components/Animation/Pop';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import DataSourceTable from '@/pages/RegCenter/DataSource/components/DataSourceList';
import { PageContainer } from '@ant-design/pro-components';
......@@ -24,10 +24,10 @@ import { PageContainer } from '@ant-design/pro-components';
*/
export default () => {
return (
<Pop>
<SlowlyAppear>
<PageContainer title={false}>
<DataSourceTable />
</PageContainer>
</Pop>
</SlowlyAppear>
);
};
......@@ -17,16 +17,16 @@
*
*/
import Scale from '@/components/Animation/Scale';
import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import ResourceOverView from '@/pages/RegCenter/Resource/components/ResourceOverView';
import { PageContainer } from '@ant-design/pro-components';
export default () => {
return (
<Scale>
<SlowlyAppear>
<PageContainer breadcrumb={{ style: { display: 'none' } }} title={false}>
<ResourceOverView />
</PageContainer>
</Scale>
</SlowlyAppear>
);
};
......@@ -17,13 +17,14 @@
import SettingOverView from '@/pages/SettingCenter/GlobalSetting/SettingOverView';
import { PageContainer } from '@ant-design/pro-components';
import SlowlyAppear from "@/components/Animation/SlowlyAppear";
export default () => {
return (
<>
<SlowlyAppear>
<PageContainer title={false}>
<SettingOverView />
</PageContainer>
</>
</SlowlyAppear>
);
};
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