Unverified Commit d89485df authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-2460][studio] Optimize task preview result (#2461)

parent d72dd525
......@@ -39,13 +39,6 @@ public class DebugDTO {
notes = "The ID of Task which is debugged")
private Integer id;
@ApiModelProperty(
value = "Use Result",
dataType = "boolean",
example = "true",
notes = "Flag indicating whether to preview table result")
private boolean useResult = true;
@ApiModelProperty(
value = "Use ChangeLog",
dataType = "boolean",
......
......@@ -145,7 +145,8 @@ public class Job2MysqlHandler implements JobHandler {
clusterId = clusterInstance.getId();
}
} else if (GatewayType.LOCAL.equalsValue(job.getJobConfig().getType())
&& Asserts.isNotNullString(job.getJobManagerAddress())) {
&& Asserts.isNotNullString(job.getJobManagerAddress())
&& Asserts.isNotNullString(job.getJobId())) {
clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO(
job.getJobManagerAddress(),
job.getJobId(),
......
......@@ -266,8 +266,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
}
// 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);
JobResult jobResult = taskServiceBean.executeJob(taskDTO);
if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
......@@ -288,16 +286,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
initTenantByTaskId(debugDTO.getId());
TaskDTO taskDTO = this.getTaskInfoById(debugDTO.getId());
taskDTO.setUseResult(debugDTO.isUseResult());
// Debug mode need return result
taskDTO.setUseResult(true);
taskDTO.setUseChangeLog(debugDTO.isUseChangeLog());
taskDTO.setUseAutoCancel(debugDTO.isUseAutoCancel());
taskDTO.setMaxRowNum(debugDTO.getMaxRowNum());
// 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);
JobResult jobResult = taskServiceBean.executeJob(taskDTO);
if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
log.info("Job debug success");
Task task = new Task(debugDTO.getId(), jobResult.getJobInstanceId());
......
......@@ -53,7 +53,6 @@ import cn.hutool.extra.expression.engine.jexl.JexlEngine;
* @since 2021/6/7 22:06
*/
public final class VariableManager {
public static final String VARIABLE = "variable";
static final String SHOW_VARIABLES = "SHOW VARIABLES";
private final Map<String, String> variables;
......@@ -92,17 +91,10 @@ public final class VariableManager {
*
* @param variableName name under which to register the given sql variable
* @param variable a variable of sql to register
* @throws CatalogException if the registration of the sql variable under the given name failed.
* But at the moment, with CatalogException, not SqlException
*/
public void registerVariable(String variableName, String variable) {
checkArgument(!StringUtils.isNullOrWhitespaceOnly(variableName), "sql variable name cannot be null or empty.");
checkNotNull(variable, "sql variable cannot be null");
if (variables.containsKey(variableName)) {
throw new CatalogException(format("The variable of sql %s already exists.", variableName));
}
variables.put(variableName, variable);
}
......
......@@ -361,9 +361,6 @@ export default {
'pages.datastudio.label.execConfig.selectDatabase.tip': 'Select the database to be used',
'pages.datastudio.label.execConfig.maxrow': 'Maximum number of rows',
'pages.datastudio.label.execConfig.maxrow.tip': 'The maximum number of rows of preview data',
'pages.datastudio.label.execConfig.preview.result': 'Preview Result',
'pages.datastudio.label.execConfig.preview.result.tip':
'Open the preview result, it will run synchronously and return the data result',
'pages.datastudio.label.jobConfig': 'Job Config',
'pages.datastudio.label.jobConfig.addConfig': 'Add Config item',
'pages.datastudio.label.jobConfig.addConfig.params': 'parameters',
......
......@@ -349,8 +349,6 @@ export default {
'pages.datastudio.label.execConfig.selectDatabase.tip': '选择 Sql 语句执行的数据源',
'pages.datastudio.label.execConfig.maxrow': '最大行数',
'pages.datastudio.label.execConfig.maxrow.tip': '预览数据的最大行数',
'pages.datastudio.label.execConfig.preview.result': '预览结果',
'pages.datastudio.label.execConfig.preview.result.tip': '开启预览结果,将同步运行并返回数据结果',
'pages.datastudio.label.jobConfig': '作业配置',
'pages.datastudio.label.jobConfig.addConfig': '添加配置项',
'pages.datastudio.label.jobConfig.addConfig.params': '参数',
......
......@@ -126,8 +126,9 @@ const Result = (props: any) => {
}
const params = currentTabs.params;
if (params.resultData && !isRefresh) {
setData(params.resultData);
const consoleData = currentTabs.console;
if (consoleData.result && !isRefresh) {
setData(consoleData.result);
} else {
if (isSql(current.dialect)) {
// common sql
......@@ -135,13 +136,12 @@ const Result = (props: any) => {
taskId: params.taskId
});
if (res.datas) {
params.resultData = res.datas;
consoleData.result = res.datas;
setData(res.datas);
}
} else {
// flink sql
// to do: get job data by history id list, not flink jid
console.log(current);
if (current.id) {
const res = await handleGetOptionWithoutMsg(API_CONSTANTS.GET_LATEST_HISTORY_BY_ID, {
id: current.id
......@@ -154,10 +154,10 @@ const Result = (props: any) => {
});
const datas = tableData.datas;
if (datas.success) {
params.resultData = datas;
consoleData.result = datas;
setData(datas);
} else {
params.resultData = {};
consoleData.result = {};
setData({});
}
}
......@@ -170,7 +170,7 @@ const Result = (props: any) => {
useEffect(() => {
setData({});
loadData();
}, [currentTabs]);
}, [currentTabs, currentTabs?.console.result]);
const getColumns = (columns: string[]) => {
return columns?.map((item) => {
......
......@@ -152,6 +152,7 @@ const HeaderContainer = (props: any) => {
});
messageApi.success(l('pages.datastudio.editor.debug.success'));
currentData.status = JOB_STATUS.RUNNING;
if (currentTab) currentTab.console.result = res.datas.result;
saveTabs({ ...props.tabs });
};
......
......@@ -43,6 +43,7 @@ type TreeProps = {
onRightClick: (info: any) => void;
style?: React.CSSProperties;
selectedKeys: Key[];
selectKeyChange: (keys: Key[]) => void;
};
const JobTree: React.FC<TreeProps & connect> = (props) => {
......@@ -52,7 +53,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
style,
height,
onRightClick,
selectedKeys: selectedKey
selectKeyChange,
selectedKeys
} = props;
const [searchValue, setSearchValueValue] = useState('');
......@@ -64,7 +66,6 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
const [expandedKeys, setExpandedKeys] = useState<Key[]>();
const [autoExpandParent, setAutoExpandParent] = useState(true);
const [selectedKeys, setSelectedKeys] = useState(selectedKey);
const onChangeSearch = (e: any) => {
let { value } = e.target;
if (!value) {
......@@ -110,7 +111,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
.filter((item: any, i: number, self: any) => item && self.indexOf(item) === i);
setExpandedKeys(expandedKeys);
setAutoExpandParent(true);
setSelectedKeys([treeKey]);
selectKeyChange([treeKey])
}
};
......
......@@ -83,25 +83,6 @@ export const buildProjectTree = (
const currentPath = path ? [...path, item.name] : [item.name];
// 构造生命周期的值
const stepValue = buildStepValue(item.task?.step);
// 渲染生命周期的徽标
const renderStepBadge = item.isLeaf && showBadge(item.type) && (
<>
<Badge.Ribbon
style={{
top: -14,
left: -57,
width: '56px',
height: '18px',
fontSize: '6px',
lineHeight: '18px'
}}
key={item.id}
placement={'start'}
text={stepValue.title}
color={stepValue.color}
/>
</>
);
// 渲染生命周期的 标记点
const renderPreFixState = item.isLeaf && showBadge(item.type) && (
<>
......@@ -116,7 +97,6 @@ export const buildProjectTree = (
const renderTitle = (
<>
<Space align={'baseline'} size={2}>
{renderStepBadge}
{searchTreeNode(item.name, searchValue)}
</Space>
</>
......@@ -138,7 +118,7 @@ export const buildProjectTree = (
type: item.type,
title: (
<>
{item.isLeaf && showBadge(item.type) && <>{'\u00A0'.repeat(16)}</>} {renderTitle}
{item.isLeaf && showBadge(item.type) && <>{'\u00A0'.repeat(2)}</>} {renderTitle}
</>
),
fullInfo: item,
......
......@@ -39,7 +39,7 @@ import { ProjectState } from '@/types/Studio/state.d';
import { l } from '@/utils/intl';
import { Modal, Typography } from 'antd';
import { MenuInfo } from 'rc-menu/es/interface';
import React, { useEffect, useState } from 'react';
import React, {Key, useEffect, useState} from 'react';
import { connect } from 'umi';
const { Text } = Typography;
......@@ -120,6 +120,7 @@ const Project: React.FC = (props: connect) => {
taskId: taskId
},
type: 'project',
console: {},
subType: type
}
});
......@@ -353,6 +354,7 @@ const Project: React.FC = (props: connect) => {
return (
<div style={{ paddingInline: 5 }}>
<JobTree
selectKeyChange={(keys: Key[]) => setProjectState((prevState) => ({ ...prevState, selectedKeys: keys }))}
selectedKeys={projectState.selectedKeys}
onRightClick={handleRightClick}
onNodeClick={(info: any) => onNodeClick(info)}
......
......@@ -63,16 +63,6 @@ const ExecuteConfigFlinkSql = (props: any) => {
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'
......@@ -82,8 +72,6 @@ const ExecuteConfigFlinkSql = (props: any) => {
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')}
name='useAutoCancel'
......@@ -93,6 +81,8 @@ const ExecuteConfigFlinkSql = (props: any) => {
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')}
......
......@@ -101,7 +101,6 @@ export type TaskType = {
session: string;
maxRowNum: number;
jobName: string;
useResult: boolean;
useChangeLog: boolean;
useAutoCancel: boolean;
};
......@@ -133,7 +132,6 @@ export type TaskDataType = TaskDataBaseType & Record<string, any>;
export type DataStudioParams = {
taskId: number;
taskData: TaskDataType;
resultData: Record<string, any>;
};
export enum TabsPageType {
......
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