forked from DataLinkDC/dinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize datastudio (DataLinkDC#2387)
* save job when submit * disable edit when task online * optimize job edit * optimize job diff modal * merge dev
- Loading branch information
1 parent
5bd9efc
commit 3cbe7ed
Showing
14 changed files
with
419 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/DiffModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* | ||
* 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 { | ||
DIFF_EDITOR_PARAMS, | ||
PARAM_DIFF_TABLE_COL | ||
} from '@/pages/DataStudio/MiddleContainer/Editor/constants'; | ||
import { l } from '@/utils/intl'; | ||
import { DiffEditor } from '@monaco-editor/react'; | ||
import { Col, Modal, Row, Space, Table, Tabs, Typography } from 'antd'; | ||
import React from 'react'; | ||
import styles from './index.less'; | ||
|
||
const { Text, Link } = Typography; | ||
|
||
export type DiffModalProps = { | ||
diffs: any[]; | ||
open: boolean; | ||
fileName?: string; | ||
onUse: (server: boolean) => void; | ||
}; | ||
|
||
const DiffModal: React.FC<DiffModalProps> = (props) => { | ||
const { diffs, open, fileName, onUse } = props; | ||
// Find the diff object with key 'statement' | ||
const statementDiff = diffs.find((diff) => diff.key === 'statement'); | ||
// Filter out the diff objects with key other than 'statement' | ||
const paramDiff = diffs.filter((diff) => diff.key != 'statement'); | ||
|
||
// Render the statement diff section | ||
const renderStatementDiff = () => { | ||
return ( | ||
<> | ||
{statementDiff ? ( | ||
<div className={styles.diff_content}> | ||
<Row style={{ marginBottom: '5px' }}> | ||
<Col span={12}> | ||
<Text type={'secondary'}>{l('pages.datastudio.sql.serverVersion')}</Text> | ||
</Col> | ||
<Col span={12}> | ||
<Text type={'secondary'}>{l('pages.datastudio.sql.cacheVersion')}</Text> | ||
</Col> | ||
</Row> | ||
<DiffEditor | ||
{...DIFF_EDITOR_PARAMS} | ||
original={statementDiff?.server} | ||
modified={statementDiff?.cache} | ||
/> | ||
</div> | ||
) : ( | ||
<Text className={styles.no_diff_content} type={'success'}> | ||
{l('pages.datastudio.sql.nochange')} | ||
</Text> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
// Render the parameter diff section | ||
const renderParamDiff = () => { | ||
return ( | ||
<div className={styles.diff_content}> | ||
{paramDiff.length > 0 ? ( | ||
<Table size={'small'} dataSource={paramDiff} columns={PARAM_DIFF_TABLE_COL} /> | ||
) : ( | ||
<Text className={styles.no_diff_content} type={'success'}> | ||
{l('pages.datastudio.sql.nochange')} | ||
</Text> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
title={ | ||
<div className={styles.header}> | ||
{l('pages.datastudio.sql.sqlChanged')}-{fileName} | ||
</div> | ||
} | ||
open={open} | ||
footer={null} | ||
width={'60%'} | ||
> | ||
<div style={{ margin: '10px 0' }}> | ||
<Text>{l('pages.datastudio.sql.sqlChangedPrompt')}</Text> | ||
</div> | ||
<Tabs | ||
tabBarExtraContent={ | ||
<Space> | ||
<Link onClick={() => onUse(false)}>{l('pages.datastudio.sql.useCache')}</Link> | ||
<Link onClick={() => onUse(true)}>{l('pages.datastudio.sql.useServer')}</Link> | ||
</Space> | ||
} | ||
items={[ | ||
{ | ||
key: '1', | ||
label: l('pages.datastudio.sql.sqldiff.title'), | ||
children: renderStatementDiff() | ||
}, | ||
{ | ||
key: '2', | ||
label: l('pages.datastudio.sql.paramdiff.title'), | ||
children: renderParamDiff() | ||
} | ||
]} | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
export default DiffModal; |
53 changes: 53 additions & 0 deletions
53
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/constants.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* | ||
* 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 { l } from '@/utils/intl'; | ||
|
||
export const PARAM_DIFF_TABLE_COL = [ | ||
{ title: l('pages.datastudio.sql.configItem'), key: 'key', dataIndex: 'key' }, | ||
{ title: l('pages.datastudio.sql.cacheConfigItem'), key: 'cache', dataIndex: 'cache' }, | ||
{ title: l('pages.datastudio.sql.serverConfigItem'), key: 'server', dataIndex: 'server' } | ||
]; | ||
|
||
export const DIFF_EDITOR_PARAMS = { | ||
width: '100%', | ||
height: '90%', | ||
options: { | ||
readOnly: true, | ||
selectOnLineNumbers: true, | ||
lineDecorationsWidth: 20, | ||
mouseWheelZoom: true, | ||
automaticLayout: true | ||
}, | ||
language: 'sql', | ||
theme: 'vs-dark' | ||
}; | ||
|
||
export const TASK_VAR_FILTER = [ | ||
'updateTime', | ||
'createTime', | ||
'jobInstanceId', | ||
'useResult', | ||
'maxRowNum', | ||
'useChangeLog', | ||
'useAutoCancel', | ||
'status', | ||
'step', | ||
'jobConfig' | ||
]; |
Oops, something went wrong.