Skip to content

Commit

Permalink
[Optimization-2460][studio] Optimize task preview result
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwenmo committed Oct 30, 2023
1 parent 75c432a commit 795b171
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 73 deletions.
7 changes: 0 additions & 7 deletions dinky-admin/src/main/java/org/dinky/data/dto/DebugDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public boolean success() {
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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ public JobResult submitTask(Integer id, String savePointPath) throws Exception {
}
// 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);

JobResult jobResult = taskServiceBean.executeJob(taskDTO);

if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
Expand All @@ -288,16 +286,14 @@ public JobResult debugTask(DebugDTO debugDTO) throws Exception {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
* @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;
Expand Down Expand Up @@ -92,17 +91,10 @@ public List<String> listVariablesName() {
*
* @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);
}

Expand Down
3 changes: 0 additions & 3 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '参数',
Expand Down
14 changes: 7 additions & 7 deletions dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,22 @@ 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
const res = await handleGetOption('api/studio/getCommonSqlData', 'Get Data', {
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
Expand All @@ -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({});
}
}
Expand All @@ -170,7 +170,7 @@ const Result = (props: any) => {
useEffect(() => {
setData({});
loadData();
}, [currentTabs]);
}, [currentTabs, currentTabs?.console.result]);

const getColumns = (columns: string[]) => {
return columns?.map((item) => {
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -52,7 +53,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
style,
height,
onRightClick,
selectedKeys: selectedKey
selectKeyChange,
selectedKeys
} = props;

const [searchValue, setSearchValueValue] = useState('');
Expand All @@ -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) {
Expand Down Expand Up @@ -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])
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) && (
<>
Expand All @@ -116,7 +97,6 @@ export const buildProjectTree = (
const renderTitle = (
<>
<Space align={'baseline'} size={2}>
{renderStepBadge}
{searchTreeNode(item.name, searchValue)}
</Space>
</>
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,6 +120,7 @@ const Project: React.FC = (props: connect) => {
taskId: taskId
},
type: 'project',
console: {},
subType: type
}
});
Expand Down Expand Up @@ -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)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -82,8 +72,6 @@ const ExecuteConfigFlinkSql = (props: any) => {
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormSwitch
label={l('pages.datastudio.label.execConfig.autostop')}
name='useAutoCancel'
Expand All @@ -93,6 +81,8 @@ const ExecuteConfigFlinkSql = (props: any) => {
}}
{...SWITCH_OPTIONS()}
/>
</ProFormGroup>
<ProFormGroup>
<ProFormDigit
width={'xs'}
label={l('pages.datastudio.label.execConfig.maxrow')}
Expand Down
2 changes: 0 additions & 2 deletions dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export type TaskType = {
session: string;
maxRowNum: number;
jobName: string;
useResult: boolean;
useChangeLog: boolean;
useAutoCancel: boolean;
};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 795b171

Please sign in to comment.