Unverified Commit 6b4dd627 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Optimization] Optimization right silder layout (#2181)

* op op-right-layout * modify code
parent 2da857a7
......@@ -17,7 +17,7 @@
import {
LogoutOutlined,
TeamOutlined,
TeamOutlined, UserOutlined,
UserSwitchOutlined
} from '@ant-design/icons';
import { setAlpha } from '@ant-design/pro-components';
......@@ -57,7 +57,7 @@ const Name = () => {
};
});
return <span className={`${nameClassName} anticon`}>{currentUser?.user.username} ({currentUser?.currentTenant.tenantCode})</span>;
return <span className={`${nameClassName} anticon`}>{currentUser?.user.username}</span>;
};
const AvatarLogo = () => {
......@@ -193,9 +193,17 @@ const AvatarDropdown = () => {
const menuItems = [
{
key: 'currentTenant',
icon: <TeamOutlined />,
label: l('menu.account.tenant','', {tenantCode: currentUser?.currentTenant.tenantCode}),
},
{
type: 'divider' as const,
},
{
key: 'center',
icon: <TeamOutlined />,
icon: <UserOutlined />,
label: l('menu.account.center'),
onClick: () => history.push('/account/center'),
},
......
......@@ -427,3 +427,7 @@ h5 {
}
}
.ant-pro-form-list-item {
display: flex!important;
align-items: baseline!important;
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ export default {
'menu.login': 'Login',
'menu.account.settings': 'Account Settings',
'menu.account.tenant': 'Tenant: {tenantCode}',
'menu.account.center': 'Account Center',
'menu.account.logout': 'Logout',
'menu.account.changePassword': 'Change Password',
......
......@@ -1009,4 +1009,16 @@ export default {
'pages.datastudio.footer.codeEncoding': "File Encoding: ",
'pages.datastudio.footer.codePosition': "Ln {Ln}:Col {Col} ",
'datastudio.middle.qg': 'Quick Guide',
'datastudio.middle.qg.clusterInstance': 'Register Session Cluster',
'datastudio.middle.qg.clusterConfiguration': 'Register Cluster Configuration',
'datastudio.middle.qg.database': 'Register DataSource',
'datastudio.middle.qg.alertInstance': 'Register Alert Instance',
'datastudio.middle.qg.alertGroup': 'Register Alert Group',
'datastudio.middle.qg.fragment': 'Global Variables',
'datastudio.middle.qg.document': 'Document',
'datastudio.middle.qg.gitprojects': 'Git Projects',
'datastudio.middle.qg.udf': 'UDF',
'datastudio.middle.qg.resource': 'Resource',
};
......@@ -27,6 +27,7 @@ export default {
'menu.login': '登录',
'menu.account.center': '个人中心',
'menu.account.tenant': '租户: {tenantCode}',
'menu.account.settings': '个人设置',
'menu.account.logout': '退出登录',
'menu.account.changePassword': '修改密码',
......
......@@ -1020,4 +1020,17 @@ export default {
'pages.datastudio.footer.lineSeparator': "行分隔符:",
'pages.datastudio.footer.codeEncoding': "文件编码:",
'pages.datastudio.footer.codePosition': "行{Ln}:列{Col} ",
'datastudio.middle.qg': '快捷引导',
'datastudio.middle.qg.clusterInstance': '注册 Session 集群',
'datastudio.middle.qg.clusterConfiguration': '注册集群配置',
'datastudio.middle.qg.database': '注册数据源',
'datastudio.middle.qg.alertInstance': '注册告警实例',
'datastudio.middle.qg.alertGroup': '注册告警组',
'datastudio.middle.qg.fragment': '全局变量',
'datastudio.middle.qg.document': '文档',
'datastudio.middle.qg.gitprojects': 'Git 项目',
'datastudio.middle.qg.udf': 'UDF',
'datastudio.middle.qg.resource': '资源',
};
const escape2Html = (str: string) => {
let arrEntities:Record<string, string> = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'};
return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
return arrEntities[t];
});
}
const getRangeText = (str: string) => {
str = escape2Html(str);
// @ts-ignore
const canvas = getRangeText.canvas || (getRangeText.canvas = document.createElement("canvas"));
const context = canvas.getContext("2d");
context.font = "10px sans-serif";
let result = '';
let count = 1;
for (let i = 0, len = str.length; i < len; i++) {
result += str[i];
let width = context.measureText(result).width;
if (width >= 110 * count) {
result += '\r\n';
count++;
}
}
return result;
};
export const buildGraphData = (data:any) => {
const edges = [];
for (const i in data.nodes) {
......@@ -28,27 +54,3 @@ export const buildGraphData = (data:any) => {
data.edges = edges;
return data;
};
const getRangeText = (str: string) => {
str = escape2Html(str);
// @ts-ignore
const canvas = getRangeText.canvas || (getRangeText.canvas = document.createElement("canvas"));
const context = canvas.getContext("2d");
context.font = "10px sans-serif";
let result = '';
let count = 1;
for (let i = 0, len = str.length; i < len; i++) {
result += str[i];
let width = context.measureText(result).width;
if (width >= 110 * count) {
result += '\r\n';
count++;
}
}
return result;
};
const escape2Html = (str: string) => {
let arrEntities:Record<string, string> = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'};
return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
return arrEntities[t];
});
}
......@@ -141,7 +141,8 @@ const HeaderContainer = (props: any) => {
title: l('button.save'),
click: () => {
const current = getCurrentData(panes, activeKey);
handlePutDataJson("/api/task", current)
current.configJson = JSON.stringify(current.config)
handlePutDataJson("/api/task", current).then(()=>saveTabs({...props.tabs}))
},
hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's',
hotKeyDesc: "Ctrl+S",
......
......@@ -3,7 +3,7 @@ import { StateType} from "../../model";
import {Spin, Tag} from "antd";
import React, {useEffect, useState} from "react";
import {
DatabaseOutlined, ReloadOutlined,
DatabaseOutlined,
TableOutlined
} from "@ant-design/icons";
import {clearMetaDataTable, showMetaDataTable} from "./service";
......@@ -12,7 +12,6 @@ import {Key, ProForm, ProFormSelect} from "@ant-design/pro-components";
import {TagAlignLeft} from "@/components/StyledComponents";
import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree";
import {DataSources} from "@/types/RegCenter/data";
import ContentScroll from "@/components/Scroll/ContentScroll";
import {BtnRoute} from "@/pages/DataStudio/route";
const MetaData = (props: any) => {
......@@ -26,16 +25,16 @@ const MetaData = (props: any) => {
* @description: 刷新树数据
* @param {number} databaseId
*/
const onRefreshTreeData = (databaseId: number) => {
const onRefreshTreeData = async (databaseId: number) => {
if (!databaseId) {
setIsLoadingDatabase(false);
return;
}
setIsLoadingDatabase(true);
const res = showMetaDataTable(databaseId);
res.then((tables) => {
await showMetaDataTable(databaseId).then(res => {
setIsLoadingDatabase(false);
const {datas: tables} = res;
if (!tables) return;
for (let table of tables) {
table.title = table.name;
......
......@@ -19,7 +19,7 @@
import {l} from "@/utils/intl";
export const KEY_BOARD = [
export const KEY_BOARD_MIDDLE = [
{
key: 'ctrls',
label: 'Ctrl + S',
......@@ -45,6 +45,9 @@ export const KEY_BOARD = [
label: 'Esc',
description: l('shortcut.key.fullscreenClose'),
},
]
export const KEY_BOARD_RIGHT_SLIDER = [
{
key: 'f1',
label: 'F1',
......
......@@ -18,7 +18,7 @@
*/
import {Divider, Typography} from "antd";
import {KEY_BOARD} from "@/pages/DataStudio/MiddleContainer/KeyBoard/constant";
import {KEY_BOARD_MIDDLE} from "@/pages/DataStudio/MiddleContainer/KeyBoard/constant";
import {l} from "@/utils/intl";
import React from "react";
......@@ -29,9 +29,9 @@ const KeyBoard = () => {
const buildKeyBoard = () => {
return KEY_BOARD.map((item,index) => {
return KEY_BOARD_MIDDLE.map((item,index) => {
return <>
{index % 6 === 0 ? <>
{index % 5 === 0 ? <>
<Divider plain orientationMargin={0}/>
<Text keyboard>{item.label}</Text>{item.description}<Divider type="vertical"/>
</>: <>
......
......@@ -18,55 +18,57 @@
*/
import {l} from "@/utils/intl";
export const QUICK_GUIDE = [
{
key: 'clusterInstance',
label: '注册 Session 集群',
label: l('datastudio.middle.qg.clusterInstance'),
link: '/registration/cluster/instance'
},
{
key: 'clusterConfiguration',
label: '注册集群配置',
label: l('datastudio.middle.qg.clusterConfiguration'),
link: '/registration/cluster/configuration'
},
{
key: 'database',
label: '注册数据源',
label: l('datastudio.middle.qg.database'),
link: '/registration/database'
},
{
key: 'alertInstance',
label: '注册告警实例',
label: l('datastudio.middle.qg.alertInstance'),
link: '/registration/alert/instance'
},
{
key: 'alertGroup',
label: '注册告警组',
label: l('datastudio.middle.qg.alertGroup'),
link: '/registration/alert/group'
},
{
key: 'fragment',
label: '全局变量',
label: l('datastudio.middle.qg.fragment'),
link: '/registration/fragment'
},
{
key: 'document',
label: '文档',
label: l('datastudio.middle.qg.document'),
link: '/registration/document'
},
{
key: 'gitprojects',
label: 'Git 项目',
label: l('datastudio.middle.qg.gitprojects'),
link: '/registration/gitprojects'
},
{
key: 'udf',
label: 'UDF',
label: l('datastudio.middle.qg.udf'),
link: '/registration/udf'
},
{
key: 'resource',
label: '资源',
label: l('datastudio.middle.qg.resource'),
link: '/registration/resource'
}
];
\ No newline at end of file
......@@ -21,6 +21,7 @@ import {Divider, Typography} from "antd";
import React from "react";
import {QUICK_GUIDE} from "@/pages/DataStudio/MiddleContainer/QuickGuide/constant";
import { Link } from "@umijs/max";
import { l } from "@/utils/intl";
const {Title, Paragraph} = Typography;
......@@ -31,7 +32,7 @@ const QuickGuide = () => {
const buildQuickGuide = () => {
return QUICK_GUIDE.map((item,index) => {
return <>
{index % 10 === 0 ? <>
{index % 5 === 0 ? <>
<Divider plain orientationMargin={0}/>
<Link to={item.link} key={item.key}>{item.label}</Link>
</> : <>
......@@ -44,7 +45,7 @@ const QuickGuide = () => {
return <>
<Typography style={{padding: '2px', textAlign: 'center', border: 'salmon'}}>
<Title level={4}>快捷引导</Title>
<Title level={4}>{l('datastudio.middle.qg')}</Title>
<Paragraph style={{padding: 0, margin: 0, textAlign: 'center', border: 'salmon'}} >
{buildQuickGuide()}
</Paragraph>
......
......@@ -262,7 +262,7 @@ const MiddleContainer = (props: any) => {
if (tabItems?.length === 0) {
return <>
<KeyBoard/>
<Divider/>
<Divider/><br/><br/><br/>
<QuickGuide/>
</>
} else {
......
......@@ -17,7 +17,6 @@
*
*/
import {Form, InputNumber, Space, Switch} from "antd";
import {InfoCircleOutlined} from "@ant-design/icons";
import {l} from "@/utils/intl";
import {connect} from "umi";
......@@ -25,75 +24,81 @@ import {StateType} from "@/pages/DataStudio/model";
import {useForm} from "antd/es/form/Form";
import {getCurrentData} from "@/pages/DataStudio/function";
import {SWITCH_OPTIONS} from "@/services/constants";
import {ProForm, ProFormDigit, ProFormGroup, ProFormSwitch} from "@ant-design/pro-components";
const ExecuteConfig = (props: any) => {
const { dispatch, tabs:{panes, activeKey}} = props;
const [form] = useForm();
const current = getCurrentData(panes, activeKey);
const {dispatch, tabs: {panes, activeKey}} = props;
const [form] = useForm();
const current = getCurrentData(panes, activeKey);
form.setFieldsValue(current);
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
panes[i].params.taskData[key] = all[key];
form.setFieldsValue(current);
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
panes[i].params.taskData[key] = all[key];
}
break;
}
}
break;
}
}
dispatch({
type: "Studio/saveTabs",
payload: {...props.tabs},
});
};
dispatch({
type: "Studio/saveTabs",
payload: {...props.tabs},
});
};
return (
<>
<Form
initialValues={{
maxRowNum:"100"
}}
style={{padding: "10px"}}
form={form}
layout="vertical"
onValuesChange={onValuesChange}
>
<Space size={[50, 16]} wrap>
<Form.Item
label={l('pages.datastudio.label.execConfig.preview.result')} name="useResult" valuePropName="checked"
tooltip={{title: l('pages.datastudio.label.execConfig.preview.result.tip'), icon: <InfoCircleOutlined/>}}
>
<Switch defaultChecked {...SWITCH_OPTIONS()}/>
</Form.Item>
<Form.Item
label={l('pages.datastudio.label.execConfig.changelog')} name="useChangeLog" valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.execConfig.changelog.tip'),
icon: <InfoCircleOutlined/>
}}
>
<Switch {...SWITCH_OPTIONS()}/>
</Form.Item>
<Form.Item
label={l('pages.datastudio.label.execConfig.maxrow')} name="maxRowNum"
tooltip={l('pages.datastudio.label.execConfig.maxrow.tip')}
>
<InputNumber min={1} max={9999}/>
</Form.Item>
<Form.Item
label={l('pages.datastudio.label.execConfig.autostop')} name="useAutoCancel" valuePropName="checked"
tooltip={{title: l('pages.datastudio.label.execConfig.autostop.tip'), icon: <InfoCircleOutlined/>}}
>
<Switch {...SWITCH_OPTIONS()}/>
</Form.Item>
</Space>
</Form>
</>
);
return (
<>
<ProForm
initialValues={{
maxRowNum: 100,
}}
style={{padding: "10px"}}
form={form}
submitter={false}
layout="vertical"
onValuesChange={onValuesChange}
>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.preview.result')} name="useResult"
tooltip={{
title: l('pages.datastudio.label.execConfig.preview.result.tip'),
icon: <InfoCircleOutlined/>
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.changelog')} name="useChangeLog"
tooltip={{
title: l('pages.datastudio.label.execConfig.changelog.tip'),
icon: <InfoCircleOutlined/>
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')} name="useAutoCancel"
tooltip={{title: l('pages.datastudio.label.execConfig.autostop.tip'), icon: <InfoCircleOutlined/>}}
{...SWITCH_OPTIONS()}
/>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')} name="maxRowNum"
tooltip={l('pages.datastudio.label.execConfig.maxrow.tip')}
min={1} max={9999}
/>
</ProFormGroup>
</ProForm>
</>
);
};
export default connect(({Studio}: { Studio: StateType }) => ({
tabs: Studio.tabs,
tabs: Studio.tabs,
}))(ExecuteConfig);
......@@ -89,7 +89,6 @@ const HistoryVersion = (props: any) => {
</Tag>
</div>
<br/>
{/*<Scrollbars style={{height: "98%"}}>*/}
<React.StrictMode>
<DiffEditor height={"95%"} options={{
readOnly: true,
......@@ -99,12 +98,28 @@ const HistoryVersion = (props: any) => {
automaticLayout:true,
}} language={"sql"} theme={"vs-dark"} original={originalValue} modified={currentValue}/>
</React.StrictMode>
{/*</Scrollbars>*/}
</Modal>
</>
)
}
const onRollBackVersion = async (row: TaskHistoryTableListItem) => {
Modal.confirm({
title: l('pages.datastudio.label.version.rollback.flinksql'),
content: l('pages.datastudio.label.version.rollback.flinksqlConfirm','',{versionId: row.versionId }),
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
const TaskHistoryRollbackItem = {
id: current.key, versionId: row.versionId
}
await handleOption('api/task/rollbackTask', l('pages.datastudio.label.version.rollback.flinksql'), TaskHistoryRollbackItem);
actionRef.current?.reloadAndRest?.();
}
});
};
const columns: ProColumns<TaskHistoryTableListItem>[] = [
{
title: l('pages.datastudio.label.version.id'),
......@@ -126,7 +141,7 @@ const HistoryVersion = (props: any) => {
valueType: 'option',
render: (text, record) => (
<>
<Button type="link" onClick={() => onRollBackVersion(record)}>{l('pages.datastudio.label.version.rollback')}</Button>
<Button type="link" onClick={async () => onRollBackVersion(record)}>{l('pages.datastudio.label.version.rollback')}</Button>
<Button type="link" title={l('pages.datastudio.label.version.diff.tip')} onClick={() => {
setVersionDiffRow(record)
setVersionDiffVisible(true)
......@@ -138,21 +153,6 @@ const HistoryVersion = (props: any) => {
];
const onRollBackVersion = (row: TaskHistoryTableListItem) => {
Modal.confirm({
title: l('pages.datastudio.label.version.rollback.flinksql'),
content: l('pages.datastudio.label.version.rollback.flinksqlConfirm','',{versionId: row.versionId }),
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
const TaskHistoryRollbackItem = {
id: current.key, versionId: row.versionId
}
await handleOption('api/task/rollbackTask', l('pages.datastudio.label.version.rollback.flinksql'), TaskHistoryRollbackItem);
actionRef.current?.reloadAndRest?.();
}
});
};
return (
<>
......
/*
*
* 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 {TagAlignLeft} from "@/components/StyledComponents";
import {Badge, Tag} from "antd";
import {Alert, Cluster} from "@/types/RegCenter/data";
import {PaperClipOutlined} from "@ant-design/icons";
import {l} from "@/utils/intl";
import {DefaultOptionType} from "antd/es/select";
import {RUN_MODE} from "@/services/constants";
/**
* build job run model
* @returns {DefaultOptionType[]}
*/
export const buildRunModelOptions = () => {
let resultReturn: DefaultOptionType[] = [];
resultReturn.push(
{
label: 'Local',
value: RUN_MODE.LOCAL,
},
{
label: 'Standalone',
value: RUN_MODE.STANDALONE,
},
{
label: 'Yarn Session',
value: RUN_MODE.YARN_SESSION,
},
{
label: 'Yarn Per-Job',
value: RUN_MODE.YARN_PER_JOB,
},
{
label: 'Yarn Application',
value: RUN_MODE.YARN_APPLICATION,
},
{
label: 'Kubernetes Session',
value: RUN_MODE.KUBERNETES_SESSION,
},
{
label: 'Kubernetes Application',
value: RUN_MODE.KUBERNETES_APPLICATION,
},
{
label: 'Kubernetes Operator Application',
value: RUN_MODE.KUBERNETES_APPLICATION_OPERATOR,
}
);
return resultReturn;
}
/**
* build cluster options
* @param {Cluster.Instance[]} sessionCluster
* @returns {any[]}
*/
export const buildClusterOptions = (sessionCluster: Cluster.Instance[]) => {
const sessionClusterOptions: DefaultOptionType[] = [];
for (const item of sessionCluster) {
const tag = (
<TagAlignLeft>
<Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}
</TagAlignLeft>
);
sessionClusterOptions.push({
label: tag,
value: item.id,
key: item.id,
})
}
return sessionClusterOptions;
};
/**
* build cluster config options
* @param current
* @param {Cluster.Config[]} clusterConfiguration
* @returns {any[]}
*/
export const buildClusterConfigOptions = (current: any, clusterConfiguration: Cluster.Config[]) => {
const clusterConfigOptions: DefaultOptionType[] = [];
for (const item of clusterConfiguration) {
if (current.type.search(item.type.toLowerCase()) === -1) {
continue;
}
const tag = (
<TagAlignLeft>
<Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}
</TagAlignLeft>
);
clusterConfigOptions.push({
label: tag,
value: item.id,
key: item.id,
})
}
return clusterConfigOptions;
};
/**
* build env options
* @param {any[]} env
* @returns {JSX.Element[]}
*/
export const buildEnvOptions = (env: any[]) => {
const envList:DefaultOptionType[] = [
{
label: l('button.disable'),
value: 0,
key: 0,
}
];
for (const item of env) {
const tag = (
<>
<TagAlignLeft>
{item.enabled ? <Badge status="success"/> : <Badge status="error"/>}{item.fragment ?
<PaperClipOutlined/> : undefined}{item.name}
</TagAlignLeft>
</>
);
envList.push({
label: tag,
value: item.id,
key: item.id,
})
}
return envList;
};
/**
* build job alert groups
* @param {Alert.AlertGroup[]} alertGroups
* @returns {JSX.Element[]}
*/
export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[]) => {
const alertGroupOptions:DefaultOptionType[] = [{
label: l('button.disable'),
value: 0,
}];
for (const item of alertGroups) {
alertGroupOptions.push({
label: item.name,
value: item.id,
key: item.id,
})
}
return alertGroupOptions;
};
\ No newline at end of file
......@@ -17,332 +17,240 @@
*
*/
import {InfoCircleOutlined, MinusCircleOutlined, PaperClipOutlined, PlusOutlined} from "@ant-design/icons";
import {Badge, Button, Col, Form, Input, InputNumber, Row, Select, Space, Switch, Tag, Typography} from "antd";
import {useEffect} from "react";
import {InfoCircleOutlined} from "@ant-design/icons";
import {Badge, Space, Typography} from "antd";
import {l} from "@/utils/intl";
import {RUN_MODE} from "@/services/constants";
import {RUN_MODE, SWITCH_OPTIONS} from "@/services/constants";
import {connect} from "umi";
import {SessionType, StateType} from "@/pages/DataStudio/model";
import {AlertStateType} from "@/pages/RegCenter/Alert/AlertInstance/model";
import {getCurrentData} from "@/pages/DataStudio/function";
import {useForm} from "antd/es/form/Form";
import {
buildAlertGroupOptions,
buildClusterConfigOptions,
buildClusterOptions,
buildEnvOptions,
buildRunModelOptions
} from "@/pages/DataStudio/RightContainer/JobConfig/function";
import {
ProForm,
ProFormDigit,
ProFormGroup,
ProFormList,
ProFormSelect,
ProFormSwitch,
ProFormText
} from "@ant-design/pro-components";
import {SAVE_POINT_TYPE} from "@/pages/DataStudio/constants";
import React from "react";
const {Option} = Select;
const {Text} = Typography;
const JobConfig = (props: any) => {
const {
sessionCluster,
clusterConfiguration,
dispatch,
tabs: {panes, activeKey},
env,
group,
} = props;
const current = getCurrentData(panes, activeKey);
const currentSession: SessionType = {
connectors: [], sessionConfig: {
clusterId: current.clusterId,
clusterName: current.clusterName,
}
}
const [form] = useForm();
form.setFieldsValue(current);
const getClusterOptions = () => {
const itemList = [];
for (const item of sessionCluster) {
const tag = (<><Tag
color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}</>);
itemList.push(<Option key={item.id} value={item.id} label={tag}>
{tag}
</Option>)
}
return itemList;
};
const getClusterConfigurationOptions = () => {
const itemList = [];
for (const item of clusterConfiguration) {
if (current.type.search(item.type.toLowerCase()) === -1) {
continue;
}
const tag = (<><Tag
color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}</>);
itemList.push(<Option key={item.id} value={item.id} label={tag}>
{tag}
</Option>)
}
return itemList;
};
const {
sessionCluster,
clusterConfiguration,
dispatch,
tabs: {panes, activeKey},
env,
group,
rightContainer,
} = props;
const getEnvOptions = () => {
const itemList = [<Option key={0} value={0} label='无'>
无
</Option>];
for (const item of env) {
const tag = (<>{item.enabled ? <Badge status="success"/> : <Badge status="error"/>}
{item.fragment ? <PaperClipOutlined/> : undefined}{item.name}</>);
itemList.push(<Option key={item.id} value={item.id} label={tag}>
{tag}
</Option>)
const current = getCurrentData(panes, activeKey);
const currentSession: SessionType = {
connectors: [], sessionConfig: {
clusterId: current.clusterId,
clusterName: current.clusterName,
}
}
return itemList;
};
const [form] = useForm();
form.setFieldsValue(current);
const getGroupOptions = () => {
const itemList = [<Option key={0} value={0} label={l('button.disable')}>
{l('button.disable')}
</Option>];
for (const item of group) {
itemList.push(<Option key={item.id} value={item.id} label={item.name}>
{item.name}
</Option>)
}
return itemList;
};
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (const key in change) {
panes[i].params.taskData[key] = all[key];
const onValuesChange = (change: any, all: any) => {
for (let i = 0; i < panes.length; i++) {
if (panes[i].key === activeKey) {
for (let key in change) {
panes[i].params.taskData[key] = all[key];
}
break;
}
}
break;
}
}
dispatch({
type: "Studio/saveTabs",
payload: {...props.tabs},
});
};
dispatch({
type: "Studio/saveTabs",
payload: {...props.tabs},
});
};
const onChangeClusterSession = () => {
//todo 这里需要验证
const onChangeClusterSession = () => {
//todo 这里需要验证
// showTables(currentSession.session, dispatch);
};
// showTables(currentSession.session, dispatch);
};
return (
<Form
initialValues={{
name: RUN_MODE.LOCAL,
envId: 0,
parallelism: 1,
savePointStrategy: 0,
alertGroupId: 0,
}}
className={"data-studio-form"}
style={{paddingInline: '10px'}}
form={form}
layout="vertical"
onValuesChange={onValuesChange}
>
<Form.Item
label={l('global.table.execmode')} name="type"
tooltip={l('pages.datastudio.label.jobConfig.execmode.tip')}
>
<Select value={RUN_MODE.LOCAL}>
<Option value={RUN_MODE.LOCAL}>Local</Option>
<Option value={RUN_MODE.STANDALONE}>Standalone</Option>
<Option value={RUN_MODE.YARN_SESSION}>Yarn Session</Option>
<Option value={RUN_MODE.YARN_PER_JOB}>Yarn Per-Job</Option>
<Option value={RUN_MODE.YARN_APPLICATION}>Yarn Application</Option>
<Option value={RUN_MODE.KUBERNETES_SESSION}>Kubernetes Session</Option>
<Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application</Option>
<Option value={RUN_MODE.KUBERNETES_APPLICATION_OPERATOR}>Kubernetes Operator Application</Option>
</Select>
</Form.Item>
{(current.type === RUN_MODE.YARN_SESSION || current.type === RUN_MODE.KUBERNETES_SESSION || current.type === RUN_MODE.STANDALONE) ? (
<Row>
<Col span={24}>
<Form.Item label={l('pages.datastudio.label.jobConfig.cluster')}
tooltip={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', {
type: current.type
})}
name="clusterId"
>
{
currentSession.session ?
(currentSession.sessionConfig && currentSession.sessionConfig.clusterId ?
(<><Badge status="success"/><Text
type="success">{currentSession.sessionConfig.clusterName}</Text></>)
: (<><Badge status="error"/><Text type="danger">{l('pages.devops.jobinfo.localenv')}</Text></>)
) : (<Select
style={{width: '100%'}}
placeholder={l('pages.datastudio.label.jobConfig.cluster.tip')}
optionLabelProp="label"
onChange={onChangeClusterSession}
>
{getClusterOptions()}
</Select>)
}
</Form.Item>
</Col>
</Row>) : undefined}
{(current.type === RUN_MODE.YARN_PER_JOB || current.type === RUN_MODE.YARN_APPLICATION
|| current.type === RUN_MODE.KUBERNETES_APPLICATION || current.type === RUN_MODE.KUBERNETES_APPLICATION_OPERATOR) ? (
<Row>
<Col span={24}>
<Form.Item label={l('pages.datastudio.label.jobConfig.clusterConfig')}
tooltip={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', {
type: current.type
})}
name="clusterConfigurationId"
>
<Select
style={{width: '100%'}}
placeholder={l('pages.datastudio.label.jobConfig.clusterConfig.tip2')}
optionLabelProp="label"
>
{getClusterConfigurationOptions()}
</Select>
</Form.Item>
</Col>
</Row>) : undefined}
<Form.Item label={l('pages.datastudio.label.jobConfig.flinksql.env')}
tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')}
name="envId">
<Select
style={{width: '100%'}}
placeholder={l('pages.datastudio.label.jobConfig.flinksql.env.tip2')}
allowClear
optionLabelProp="label"
value={0}
return <div style={{maxHeight: rightContainer.height}}>
<ProForm size={'middle'}
initialValues={{
name: RUN_MODE.LOCAL,
envId: 0,
parallelism: 1,
savePointStrategy: 0,
alertGroupId: 0,
}}
className={"data-studio-form"}
style={{paddingInline: '15px' ,overflow: 'scroll'}}
form={form}
submitter={false}
layout="vertical"
onValuesChange={onValuesChange}
>
{getEnvOptions()}
</Select>
</Form.Item>
<Row>
<Col span={12}>
<Form.Item
label={l('pages.datastudio.label.jobConfig.parallelism')}
name="parallelism"
tooltip={l('pages.datastudio.label.jobConfig.parallelism.tip')}
>
<InputNumber min={1} max={9999}/>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label={l('pages.datastudio.label.jobConfig.insert')} name="statementSet"
valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.jobConfig.insert.tip'),
icon: <InfoCircleOutlined/>
}}
>
<Switch checkedChildren={l('button.enable')} unCheckedChildren={l('button.disable')}
<ProFormSelect
name="type"
label={l('global.table.execmode')}
tooltip={l('pages.datastudio.label.jobConfig.execmode.tip')}
options={buildRunModelOptions()}
showSearch
/>
</Form.Item>
</Col>
</Row>
<Row>
<Col span={12}>
<Form.Item
label={l('pages.datastudio.label.jobConfig.fragment')} name="fragment"
valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.jobConfig.fragment.tip'),
icon: <InfoCircleOutlined/>
}}
>
<Switch checkedChildren={l('button.enable')} unCheckedChildren={l('button.disable')}
{(current.type === RUN_MODE.YARN_SESSION || current.type === RUN_MODE.KUBERNETES_SESSION || current.type === RUN_MODE.STANDALONE) &&
<>
{
currentSession.session ?
(currentSession.sessionConfig && currentSession.sessionConfig.clusterId ?
<><Badge status="success"/><Text
type="success">{currentSession.sessionConfig.clusterName}</Text></>
: <><Badge status="error"/><Text
type="danger">{l('pages.devops.jobinfo.localenv')}</Text></>
) :
<>
<ProFormSelect
style={{width: '100%'}}
placeholder={l('pages.datastudio.label.jobConfig.cluster.tip')}
label={l('pages.datastudio.label.jobConfig.cluster')}
tooltip={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', {type: current.type})}
name="clusterId"
options={buildClusterOptions(sessionCluster)}
fieldProps={{
onChange: onChangeClusterSession,
}}
/>
</>
}
</>
}
{(current.type === RUN_MODE.YARN_PER_JOB || current.type === RUN_MODE.YARN_APPLICATION
|| current.type === RUN_MODE.KUBERNETES_APPLICATION || current.type === RUN_MODE.KUBERNETES_APPLICATION_OPERATOR) && <>
<ProFormSelect
name="clusterConfigurationId"
placeholder={l('pages.datastudio.label.jobConfig.clusterConfig.tip2')}
label={l('pages.datastudio.label.jobConfig.clusterConfig')}
tooltip={l('pages.datastudio.label.jobConfig.clusterConfig.tip1', '', {
type: current.type
})}
options={buildClusterConfigOptions(current, clusterConfiguration)}
/>
</>}
<ProFormSelect
name="envId"
label={l('pages.datastudio.label.jobConfig.flinksql.env')}
tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')}
options={buildEnvOptions(env)}
showSearch
/>
<ProFormGroup>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.jobConfig.parallelism')}
name="parallelism"
tooltip={l('pages.datastudio.label.jobConfig.parallelism.tip')}
max={9999} min={1}
/>
<ProFormSwitch
label={l('pages.datastudio.label.jobConfig.insert')} name="statementSet"
valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.jobConfig.insert.tip'),
icon: <InfoCircleOutlined/>
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch
label={l('pages.datastudio.label.jobConfig.fragment')} name="fragment"
valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.jobConfig.fragment.tip'),
icon: <InfoCircleOutlined/>
}}
{...SWITCH_OPTIONS()}
/>
<ProFormSwitch
label={l('pages.datastudio.label.jobConfig.batchmode')} name="batchModel"
valuePropName="checked"
tooltip={{
title: l('pages.datastudio.label.jobConfig.batchmode.tip'),
icon: <InfoCircleOutlined/>
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormSelect
label={l('pages.datastudio.label.jobConfig.savePointStrategy')}
name="savePointStrategy"
tooltip={l('pages.datastudio.label.jobConfig.savePointStrategy.tip')}
options={SAVE_POINT_TYPE}
/>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label={l('pages.datastudio.label.jobConfig.batchmode')} name="batchModel"
valuePropName="checked"
tooltip={{title: l('pages.datastudio.label.jobConfig.batchmode.tip'), icon: <InfoCircleOutlined/>}}
>
<Switch checkedChildren={l('button.enable')} unCheckedChildren={l('button.disable')}
{current.savePointStrategy === 3 &&
<>
<ProFormText
label={l('pages.datastudio.label.jobConfig.savePointpath')}
name="savePointPath"
tooltip={l('pages.datastudio.label.jobConfig.savePointpath.tip1')}
placeholder={l('pages.datastudio.label.jobConfig.savePointpath.tip2')}
/>
</>
}
<ProFormSelect
label={l('pages.datastudio.label.jobConfig.alertGroup')} name="alertGroupId"
placeholder={l('pages.datastudio.label.jobConfig.alertGroup.tip')}
options={buildAlertGroupOptions(group)}
/>
</Form.Item>
</Col>
</Row>
<Form.Item
label={l('pages.datastudio.label.jobConfig.savePointStrategy')}
name="savePointStrategy"
tooltip={l('pages.datastudio.label.jobConfig.savePointStrategy.tip')}
>
<Select>
<Option value={0}>{l('global.savepoint.strategy.disabled')}</Option>
<Option value={1}>{l('global.savepoint.strategy.latest')}</Option>
<Option value={2}>{l('global.savepoint.strategy.earliest')}</Option>
<Option value={3}>{l('global.savepoint.strategy.custom')}</Option>
</Select>
</Form.Item>
{current.savePointStrategy === 3 ?
(<Form.Item
label={l('pages.datastudio.label.jobConfig.savePointpath')}
name="savePointPath"
tooltip={l('pages.datastudio.label.jobConfig.savePointpath.tip1')}
>
<Input placeholder={l('pages.datastudio.label.jobConfig.savePointpath.tip2')}/>
</Form.Item>) : ''
}
<Row>
<Col span={24}>
<Form.Item label={l('pages.datastudio.label.jobConfig.alertGroup')} name="alertGroupId"
>
<Select
style={{width: '100%'}}
placeholder={l('pages.datastudio.label.jobConfig.alertGroup.tip')}
optionLabelProp="label"
{/*todo 这里需要优化,有有异常抛出*/}
<ProFormList
label={l('pages.datastudio.label.jobConfig.other')}
tooltip={l('pages.datastudio.label.jobConfig.other.tip')}
name={'config'}
copyIconProps={false}
creatorButtonProps={{
style: {width: '100%'},
creatorButtonText: l('pages.datastudio.label.jobConfig.addConfig'),
}}
>
{getGroupOptions()}
</Select>
</Form.Item>
</Col>
</Row>
<Form.Item
label={l('pages.datastudio.label.jobConfig.other')}
tooltip={{title: l('pages.datastudio.label.jobConfig.other.tip'), icon: <InfoCircleOutlined/>}}
>
{/*todo 这里需要优化,有有异常抛出*/}
<Form.List name="config"
>
{(fields, {add, remove}) => (
<>
{fields.map(({key, name, ...restField}) => (
<Space key={key} style={{display: 'flex'}} align="baseline">
<Form.Item
{...restField}
name={[name, 'key']}
style={{marginBottom: '5px'}}
>
<Input placeholder={l('pages.datastudio.label.jobConfig.addConfig.params')}/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
style={{marginBottom: '5px'}}
>
<Input placeholder={l('pages.datastudio.label.jobConfig.addConfig.value')}/>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)}/>
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined/>}>
{l('pages.datastudio.label.jobConfig.addConfig')}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
</Form>
);
<ProFormGroup style={{display: 'flex',width: '100%'}} >
<Space key={'config'} style={{display: 'flex'}} align="baseline">
<ProFormText name="key"
placeholder={l('pages.datastudio.label.jobConfig.addConfig.params')}/>
<ProFormText name="value"
placeholder={l('pages.datastudio.label.jobConfig.addConfig.value')}/>
</Space>
</ProFormGroup>
</ProFormList>
</ProForm>
</div>
};
export default connect(({Studio, Alert}: { Studio: StateType, Alert: AlertStateType }) => ({
sessionCluster: Studio.sessionCluster,
clusterConfiguration: Studio.clusterConfiguration,
tabs: Studio.tabs,
env: Studio.env,
group: Alert.group,
sessionCluster: Studio.sessionCluster,
clusterConfiguration: Studio.clusterConfiguration,
rightContainer: Studio.rightContainer,
tabs: Studio.tabs,
env: Studio.env,
group: Alert.group,
}))(JobConfig);
import {Col, Descriptions, Form, Row } from "antd";
import TextArea from "antd/es/input/TextArea";
import {l} from "@/utils/intl";
import Paragraph from "antd/es/typography/Paragraph";
import {connect} from "umi";
import {DataStudioParams, StateType, TabsItemType, TabsPageType} from "@/pages/DataStudio/model";
import Editor from "@/pages/DataStudio/MiddleContainer/Editor";
import React from "react";
import {getCurrentData} from "@/pages/DataStudio/function";
import {useForm} from "antd/es/form/Form";
import {c} from "@umijs/utils/compiled/tar";
/*
*
......@@ -28,6 +17,17 @@ import {c} from "@umijs/utils/compiled/tar";
* limitations under the License.
*
*/
import {Col, Descriptions, Form, Row } from "antd";
import TextArea from "antd/es/input/TextArea";
import {l} from "@/utils/intl";
import Paragraph from "antd/es/typography/Paragraph";
import {connect} from "umi";
import { StateType } from "@/pages/DataStudio/model";
import React from "react";
import {getCurrentData} from "@/pages/DataStudio/function";
import {useForm} from "antd/es/form/Form";
const JobInfo = (props: any) => {
const { dispatch, tabs: {panes, activeKey}} = props;
const current = getCurrentData(panes, activeKey);
......
......@@ -19,6 +19,8 @@
import {MenuItemType} from "rc-menu/lib/interface";
import {l} from "@/utils/intl";
import {Select} from "antd";
import {DefaultOptionType} from "antd/es/select";
export const STUDIO_TAG_RIGHT_CONTEXT_MENU: MenuItemType[] = [
{
......@@ -30,3 +32,23 @@ export const STUDIO_TAG_RIGHT_CONTEXT_MENU: MenuItemType[] = [
label: l('right.menu.closeOther'),
}
]
export const SAVE_POINT_TYPE :DefaultOptionType[] = [
{
label: l('global.savepoint.strategy.disabled'),
value: 0,
},
{
label: l('global.savepoint.strategy.latest'),
value: 1,
},
{
label: l('global.savepoint.strategy.earliest'),
value: 2,
},
{
label: l('global.savepoint.strategy.custom'),
value: 3,
}
];
\ No newline at end of file
......@@ -24,7 +24,7 @@ import {getDataBase} from "@/pages/DataStudio/LeftContainer/MetaData/service";
import MiddleContainer from "@/pages/DataStudio/MiddleContainer";
import LeftContainer from "@/pages/DataStudio/LeftContainer";
import {LeftBottomMoreTabs, LeftBottomSide, LeftSide, RightSide} from "@/pages/DataStudio/route";
import {getCurrentData, getCurrentTab, mapDispatchToProps} from "@/pages/DataStudio/function";
import {getCurrentTab, mapDispatchToProps} from "@/pages/DataStudio/function";
import BottomContainer from "@/pages/DataStudio/BottomContainer";
import HeaderContainer from "@/pages/DataStudio/HeaderContainer";
import RightContainer from "@/pages/DataStudio/RightContainer";
......
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