Skip to content

Commit 0da1714

Browse files
authored
[Optimize][Web] Optimize blood relationship acquisition, add Savepoint, optimize udf class name display (#4024)
Co-authored-by: zackyoungh <[email protected]>
1 parent be98771 commit 0da1714

File tree

9 files changed

+133
-8
lines changed

9 files changed

+133
-8
lines changed

dinky-admin/src/main/java/org/dinky/data/dto/StudioLineageDTO.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.dinky.data.dto;
2121

22+
import org.dinky.data.model.ext.TaskExtConfig;
23+
2224
import io.swagger.annotations.ApiModel;
2325
import io.swagger.annotations.ApiModelProperty;
2426
import lombok.Getter;
@@ -41,9 +43,6 @@ public class StudioLineageDTO extends AbstractStatementDTO {
4143
notes = "Flag indicating whether to use Statement Set")
4244
private Boolean statementSet;
4345

44-
@ApiModelProperty(value = "Type", dataType = "Integer", example = "1", notes = "The type of the SQL query")
45-
private Integer type;
46-
4746
@ApiModelProperty(value = "Dialect", dataType = "String", example = "MySQL", notes = "The SQL dialect")
4847
private String dialect;
4948

@@ -56,4 +55,10 @@ public class StudioLineageDTO extends AbstractStatementDTO {
5655

5756
@ApiModelProperty(value = "Task ID", dataType = "Integer", example = "1", notes = "The identifier of the task")
5857
private Integer taskId;
58+
59+
@ApiModelProperty(
60+
value = "Configuration JSON",
61+
dataType = "TaskExtConfig",
62+
notes = "Extended configuration in JSON format for the task")
63+
private TaskExtConfig configJson;
5964
}

dinky-admin/src/main/java/org/dinky/service/impl/StudioServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public LineageResult getLineage(StudioLineageDTO studioCADTO) {
122122
TaskDTO taskDTO = taskService.getTaskInfoById(studioCADTO.getTaskId());
123123
taskDTO.setStatement(taskService.buildEnvSql(taskDTO) + studioCADTO.getStatement());
124124
JobConfig jobConfig = taskDTO.getJobConfig();
125+
jobConfig.setUdfRefer(studioCADTO.getConfigJson().getUdfReferMaps());
126+
jobConfig.setConfigJson(studioCADTO.getConfigJson().getCustomConfigMaps());
127+
125128
return LineageBuilder.getColumnLineageByLogicalPlan(taskDTO.getStatement(), jobConfig);
126129
}
127130
}

dinky-web/src/locales/en-US/pages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ export default {
578578
'pages.datastudio.label.jobInfo.versionId': 'Version number',
579579
'pages.datastudio.label.jobInfo.firstLevelOwner': 'Owner',
580580
'pages.datastudio.label.jobInfo.secondLevelOwners': 'Maintainer',
581+
'pages.datastudio.label.jobInfo.className': 'ClassName',
581582
'pages.datastudio.label.result.query.latest.data': 'Get the latest data',
582583
'pages.datastudio.label.result.query.latest.data.truncate':
583584
'The data is too long to be displayed in full',

dinky-web/src/locales/zh-CN/pages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ export default {
515515
'pages.datastudio.label.jobInfo.versionId': '版本号',
516516
'pages.datastudio.label.jobInfo.firstLevelOwner': '责任人',
517517
'pages.datastudio.label.jobInfo.secondLevelOwners': '维护人',
518+
'pages.datastudio.label.jobInfo.className': '类名',
518519
'pages.datastudio.label.result.query.latest.data': '获取最新数据',
519520
'pages.datastudio.label.result.query.latest.data.truncate': '数据过长无法全部显示',
520521
'pages.datastudio.label.version': '版本历史',
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one or more
4+
* contributor license agreements. See the NOTICE file distributed with
5+
* this work for additional information regarding copyright ownership.
6+
* The ASF licenses this file to You under the Apache License, Version 2.0
7+
* (the "License"); you may not use this file except in compliance with
8+
* the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
import { postAll } from '@/services/api';
21+
import { API_CONSTANTS } from '@/services/endpoints';
22+
import { l } from '@/utils/intl';
23+
import { ActionType, ProColumns, ProDescriptions, ProTable } from '@ant-design/pro-components';
24+
import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
25+
import { Drawer } from 'antd';
26+
import { useRef, useState } from 'react';
27+
28+
export type SavePointData = {
29+
id: number;
30+
taskId: number;
31+
name: string;
32+
type: string;
33+
path: string;
34+
createTime: Date;
35+
};
36+
37+
export const SavePoint = (props: { taskId: number }) => {
38+
const { taskId } = props;
39+
40+
const [row, setRow] = useState<SavePointData>();
41+
const actionRef = useRef<ActionType>();
42+
actionRef.current?.reloadAndRest?.();
43+
44+
const columns: ProDescriptionsItemProps<SavePointData>[] | ProColumns<SavePointData>[] = [
45+
{
46+
title: l('pages.task.savePointPath'),
47+
dataIndex: 'path',
48+
hideInForm: true,
49+
hideInSearch: true
50+
},
51+
{
52+
title: l('global.table.createTime'),
53+
dataIndex: 'createTime',
54+
valueType: 'dateTime',
55+
hideInForm: true,
56+
hideInSearch: true,
57+
render: (dom: any, entity: SavePointData) => {
58+
return <a onClick={() => setRow(entity)}>{dom}</a>;
59+
}
60+
}
61+
];
62+
63+
return (
64+
<>
65+
<ProTable<SavePointData>
66+
className={'datastudio-theme'}
67+
actionRef={actionRef}
68+
rowKey='id'
69+
request={(params, sorter, filter) =>
70+
postAll(API_CONSTANTS.GET_SAVEPOINT_LIST, { ...params, sorter, filter })
71+
}
72+
params={{ taskId }}
73+
columns={columns as ProColumns<SavePointData>[]}
74+
search={false}
75+
/>
76+
<Drawer
77+
width={600}
78+
open={!!row}
79+
onClose={() => {
80+
setRow(undefined);
81+
}}
82+
closable={false}
83+
>
84+
{row?.name && (
85+
<ProDescriptions<SavePointData>
86+
column={2}
87+
title={row?.name}
88+
request={async () => ({
89+
data: row || {}
90+
})}
91+
params={{
92+
id: row?.name
93+
}}
94+
columns={columns as ProDescriptionsItemProps<SavePointData>[]}
95+
/>
96+
)}
97+
</Drawer>
98+
</>
99+
);
100+
};

dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/TaskInfo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ import Paragraph from 'antd/es/typography/Paragraph';
2323
import { TaskState } from '@/pages/DataStudio/type';
2424
import { showFirstLevelOwner, showSecondLevelOwners } from '@/pages/DataStudio/function';
2525
import { UserBaseInfo } from '@/types/AuthCenter/data';
26+
import { isUDF } from '@/pages/DataStudio/Toolbar/Project/function';
2627

2728
export const TaskInfo = (props: { params: TaskState; users: UserBaseInfo.User[] }) => {
2829
const {
29-
params: { taskId, name, dialect, versionId, firstLevelOwner, secondLevelOwners },
30+
params: { taskId, name, dialect, versionId, firstLevelOwner, secondLevelOwners, savePointPath },
3031
users
3132
} = props;
3233

34+
console.log(savePointPath);
3335
return (
3436
<div style={{ paddingInline: 8 }}>
3537
<Descriptions bordered size='small' column={1}>
@@ -51,6 +53,11 @@ export const TaskInfo = (props: { params: TaskState; users: UserBaseInfo.User[]
5153
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.secondLevelOwners')}>
5254
{showSecondLevelOwners(secondLevelOwners, users)}
5355
</Descriptions.Item>
56+
{isUDF(dialect) && (
57+
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.className')}>
58+
{savePointPath}
59+
</Descriptions.Item>
60+
)}
5461
</Descriptions>
5562
</div>
5663
);

dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import { SseData, Topic } from '@/models/UseWebSocketModel';
9797
import { ResourceInfo } from '@/types/RegCenter/data';
9898
import { buildResourceTreeDataAtTreeForm } from '@/pages/RegCenter/Resource/components/FileTree/function';
9999
import { ProFormDependency } from '@ant-design/pro-form';
100+
import { SavePoint } from '@/pages/DataStudio/CenterTabContent/SqlTask/SavePoint';
100101

101102
export type FlinkSqlProps = {
102103
showDesc: boolean;
@@ -390,6 +391,11 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
390391
/>
391392
)
392393
});
394+
rightToolbarItem.push({
395+
label: l('menu.datastudio.savePoint'),
396+
key: 'savePoint',
397+
children: <SavePoint taskId={currentState.taskId} />
398+
});
393399
}
394400

395401
rightToolbarItem.push({
@@ -443,17 +449,17 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
443449
}, [currentState, updateAction]);
444450

445451
const handleLineage = useCallback(async () => {
446-
const { type, dialect, databaseId, statement, envId, fragment, taskId } = currentState;
452+
const { dialect, databaseId, statement, envId, fragment, taskId } = currentState;
447453
const params: StudioLineageParams = {
448-
type: 1, // todo: 暂时写死 ,后续优化
449454
dialect: dialect,
450455
envId: envId ?? -1,
451456
fragment: fragment,
452457
statement: statement,
453458
statementSet: true,
454459
databaseId: databaseId ?? 0,
455460
variables: {},
456-
taskId: taskId
461+
taskId: taskId,
462+
configJson: currentState.configJson
457463
};
458464
const data = (await getDataByParams(
459465
API_CONSTANTS.STUDIO_GET_LINEAGE,

dinky-web/src/pages/DataStudio/Toolbar/Resource/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ const Resource = (props: {
309309
ghost
310310
size={'small'}
311311
bodyStyle={{ height: 'calc(100vh - 180px)', overflow: 'auto' }}
312+
className={'datastudio-theme'}
312313
>
313314
<Result
314315
status='warning'
@@ -333,6 +334,7 @@ const Resource = (props: {
333334
<>
334335
<ProCard
335336
style={{ height: '100%' }}
337+
className={'datastudio-theme'}
336338
bodyStyle={{
337339
paddingTop: 10,
338340
paddingInline: 5,

dinky-web/src/pages/DataStudio/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ export type TaskState = {
279279
* en: Task Lineage params.
280280
*/
281281
export interface StudioLineageParams {
282-
type: number;
283282
statementSet: boolean;
284283
dialect: string;
285284
databaseId: number;
@@ -288,6 +287,7 @@ export interface StudioLineageParams {
288287
fragment: boolean;
289288
variables: any;
290289
taskId: number;
290+
configJson: TaskExtConfig;
291291
}
292292
export type TreeVo = {
293293
name: string;

0 commit comments

Comments
 (0)