Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
3cbe7ed7
Unverified
Commit
3cbe7ed7
authored
Oct 14, 2023
by
gaoyan
Committed by
GitHub
Oct 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize datastudio (#2387)
* save job when submit * disable edit when task online * optimize job edit * optimize job diff modal * merge dev
parent
5bd9efcc
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
419 additions
and
180 deletions
+419
-180
pages.ts
dinky-web/src/locales/en-US/pages.ts
+20
-0
pages.ts
dinky-web/src/locales/zh-CN/pages.ts
+18
-2
index.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
+27
-20
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
+15
-19
DiffModal.tsx
...src/pages/DataStudio/MiddleContainer/Editor/DiffModal.tsx
+127
-0
constants.tsx
...src/pages/DataStudio/MiddleContainer/Editor/constants.tsx
+53
-0
index.less
...eb/src/pages/DataStudio/MiddleContainer/Editor/index.less
+44
-0
index.tsx
...web/src/pages/DataStudio/MiddleContainer/Editor/index.tsx
+69
-35
index.tsx
dinky-web/src/pages/DataStudio/MiddleContainer/index.tsx
+34
-5
index.tsx
...b/src/pages/DataStudio/RightContainer/JobConfig/index.tsx
+1
-1
function.ts
dinky-web/src/pages/DataStudio/function.ts
+1
-1
index.tsx
dinky-web/src/pages/DataStudio/index.tsx
+4
-95
model.ts
dinky-web/src/pages/DataStudio/model.ts
+2
-1
endpoints.tsx
dinky-web/src/services/endpoints.tsx
+4
-1
No files found.
dinky-web/src/locales/en-US/pages.ts
View file @
3cbe7ed7
...
...
@@ -309,6 +309,11 @@ export default {
'pages.datastudio.editor.stop.job'
:
'Stop job'
,
'pages.datastudio.editor.stop.jobConfirm'
:
'Are you sure to stop the job [{jobName}]? '
,
'pages.datastudio.editor.submitting'
:
'The new task [{jobName}] is executing'
,
'pages.datastudio.editor.onlyread'
:
'Task has been published, modification is prohibited, please go offline first'
,
'pages.datastudio.editor.notsave'
:
'Current changes are not saved! '
,
'pages.datastudio.editor.notsave.note'
:
'Continue will discard the changes, are you sure to continue?'
,
'pages.datastudio.to.jobDetail'
:
'Operation Center'
,
'pages.datastudio.explain.validate'
:
'Validating...'
,
'pages.datastudio.explain.validate.allright'
:
'All Right'
,
...
...
@@ -323,6 +328,21 @@ export default {
'pages.datastudio.footer.codeType'
:
'Code Type'
,
'pages.datastudio.footer.lineSeparator'
:
'Line Separator'
,
'pages.datastudio.footer.memDetails'
:
'Maximum heap size'
,
'pages.datastudio.sql.sqlChanged'
:
'Code recovery'
,
'pages.datastudio.sql.sqlChangedPrompt'
:
'The code you modified is not saved, it is inconsistent with the server, we cached the last modification for you, please select the version'
,
'pages.datastudio.sql.sqldiff.title'
:
'Code comparison'
,
'pages.datastudio.sql.paramdiff.title'
:
'Configuration comparison'
,
'pages.datastudio.sql.nochange'
:
'No change in job content'
,
'pages.datastudio.sql.useCache'
:
'Use cached version'
,
'pages.datastudio.sql.useServer'
:
'Use server version'
,
'pages.datastudio.sql.cacheVersion'
:
'Local cache code'
,
'pages.datastudio.sql.serverVersion'
:
'server-side code'
,
'pages.datastudio.sql.configItem'
:
'Configuration Item'
,
'pages.datastudio.sql.cacheConfigItem'
:
'Local cache configuration'
,
'pages.datastudio.sql.serverConfigItem'
:
'server-side configuration'
,
'pages.datastudio.help.sqlChanged'
:
'Sql context or configure changed'
,
'pages.datastudio.help.sqlChangedPrompt'
:
'the remote context is not the same as the current page , will the data be flushed?'
,
...
...
dinky-web/src/locales/zh-CN/pages.ts
View file @
3cbe7ed7
...
...
@@ -302,6 +302,9 @@ export default {
'pages.datastudio.editor.stop.job'
:
'停止作业'
,
'pages.datastudio.editor.stop.jobConfirm'
:
'确定停止作业【{jobName}】吗?'
,
'pages.datastudio.editor.submitting'
:
'新任务【{jobName}】正在执行'
,
'pages.datastudio.editor.onlyread'
:
'任务已发布,禁止修改,请先下线任务'
,
'pages.datastudio.editor.notsave'
:
'当前修改内容未保存!'
,
'pages.datastudio.editor.notsave.note'
:
'继续将抛弃所修改内容,确定继续吗?'
,
'pages.datastudio.to.jobDetail'
:
'运维'
,
'pages.datastudio.explain.validate'
:
'正在校验中...'
,
'pages.datastudio.explain.validate.allright'
:
'全部正确'
,
...
...
@@ -316,8 +319,21 @@ export default {
'pages.datastudio.footer.codeType'
:
'代码类型:'
,
'pages.datastudio.footer.lineSeparator'
:
'行分隔符:'
,
'pages.datastudio.footer.memDetails'
:
'最大堆大小:{max}
\
n已使用: {used}M'
,
'pages.datastudio.help.sqlChanged'
:
'Sql内容或配置变更'
,
'pages.datastudio.help.sqlChangedPrompt'
:
'检测到当前页与远端不一致,是否刷新更新数据?'
,
'pages.datastudio.sql.sqlChanged'
:
'代码恢复'
,
'pages.datastudio.sql.sqlChangedPrompt'
:
'您修改的代码未保存,与服务端不一致,我们为您缓存了上次修改,请选择版本'
,
'pages.datastudio.sql.sqldiff.title'
:
'代码对比'
,
'pages.datastudio.sql.paramdiff.title'
:
'配置对比'
,
'pages.datastudio.sql.nochange'
:
'作业内容无变化'
,
'pages.datastudio.sql.useCache'
:
'使用缓存版本'
,
'pages.datastudio.sql.useServer'
:
'使用服务器版本'
,
'pages.datastudio.sql.cacheVersion'
:
'本地缓存代码'
,
'pages.datastudio.sql.serverVersion'
:
'服务端代码'
,
'pages.datastudio.sql.configItem'
:
'配置项'
,
'pages.datastudio.sql.cacheConfigItem'
:
'本地缓存配置'
,
'pages.datastudio.sql.serverConfigItem'
:
'服务端配置'
,
'pages.datastudio.label.execConfig'
:
'执行配置'
,
'pages.datastudio.label.execConfig.autostop'
:
'自动停止'
,
'pages.datastudio.label.execConfig.autostop.tip'
:
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
View file @
3cbe7ed7
...
...
@@ -38,6 +38,7 @@ import {
DataStudioTabsItemType
,
MetadataTabsItemType
,
StateType
,
TabsPageSubType
,
TabsPageType
,
TaskDataType
,
VIEW
...
...
@@ -126,8 +127,10 @@ const HeaderContainer = (props: any) => {
},
[
dsConfig
]);
const
handleSave
=
async
()
=>
{
await
handlePutDataJson
(
'/api/task'
,
currentData
);
const
saved
=
await
handlePutDataJson
(
'/api/task'
,
currentData
);
saveTabs
({
...
props
.
tabs
});
if
(
currentTab
)
currentTab
.
isModified
=
false
;
return
saved
;
};
const
handlerStop
=
()
=>
{
...
...
@@ -151,23 +154,24 @@ const HeaderContainer = (props: any) => {
const
handlerSubmit
=
async
()
=>
{
if
(
!
currentData
)
return
;
const
saved
=
currentData
.
step
==
JOB_LIFE_CYCLE
.
ONLINE
?
true
:
await
handleSave
();
if
(
saved
)
{
const
res
=
await
executeSql
(
l
(
'pages.datastudio.editor.submitting'
,
''
,
{
jobName
:
currentData
.
name
}),
currentData
.
id
);
if
(
!
res
)
return
;
const
res
=
await
executeSql
(
l
(
'pages.datastudio.editor.submitting'
,
''
,
{
jobName
:
currentData
.
name
}),
currentData
.
id
);
if
(
!
res
)
return
;
updateJobRunningMsg
({
taskId
:
currentData
.
id
,
jobName
:
currentData
.
name
,
jobState
:
res
.
datas
.
status
,
runningLog
:
res
.
msg
});
messageApi
.
success
(
l
(
'pages.datastudio.editor.exec.success'
));
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
saveTabs
({
...
props
.
tabs
});
updateJobRunningMsg
({
taskId
:
currentData
.
id
,
jobName
:
currentData
.
name
,
jobState
:
res
.
datas
.
status
,
runningLog
:
res
.
msg
});
messageApi
.
success
(
l
(
'pages.datastudio.editor.exec.success'
));
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
saveTabs
({
...
props
.
tabs
});
}
};
const
handleChangeJobLife
=
async
()
=>
{
...
...
@@ -176,8 +180,11 @@ const HeaderContainer = (props: any) => {
await
offLinelTask
(
currentData
.
id
);
currentData
.
step
=
JOB_LIFE_CYCLE
.
DEVELOP
;
}
else
{
await
onLineTask
(
currentData
.
id
);
currentData
.
step
=
JOB_LIFE_CYCLE
.
ONLINE
;
const
saved
=
await
handleSave
();
if
(
saved
)
{
await
onLineTask
(
currentData
.
id
);
currentData
.
step
=
JOB_LIFE_CYCLE
.
ONLINE
;
}
}
saveTabs
({
...
props
.
tabs
});
};
...
...
@@ -253,7 +260,7 @@ const HeaderContainer = (props: any) => {
isShow
:
currentTab
?.
type
==
TabsPageType
.
project
&&
currentData
?.
jobInstanceId
&&
currentTab
.
subType
==
'flinksql'
,
currentTab
.
subType
==
TabsPageSubType
.
flinkSql
,
props
:
{
href
:
`/#/devops/job-detail?id=
${
currentData
?.
jobInstanceId
}
`,
target: '_blank'
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
View file @
3cbe7ed7
...
...
@@ -25,7 +25,6 @@ import {
import
FolderModal
from
'@/pages/DataStudio/LeftContainer/Project/FolderModal'
;
import
JobModal
from
'@/pages/DataStudio/LeftContainer/Project/JobModal'
;
import
JobTree
from
'@/pages/DataStudio/LeftContainer/Project/JobTree'
;
import
{
getTaskDetails
}
from
'@/pages/DataStudio/LeftContainer/Project/service'
;
import
{
StateType
,
STUDIO_MODEL
,
STUDIO_MODEL_ASYNC
}
from
'@/pages/DataStudio/model'
;
import
{
handleAddOrUpdate
,
...
...
@@ -108,24 +107,21 @@ const Project: React.FC = (props: connect) => {
return
;
}
getTaskDetails
(
taskId
).
then
((
res
)
=>
{
path
.
pop
();
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
type
,
id
:
parentId
+
name
,
treeKey
:
key
,
breadcrumbLabel
:
path
.
join
(
'/'
),
label
:
name
,
params
:
{
taskId
:
taskId
,
taskData
:
{
...
res
,
useResult
:
true
,
maxRowNum
:
100
}
},
type
:
'project'
,
subType
:
type
.
toLowerCase
()
}
});
path
.
pop
();
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
type
,
id
:
parentId
+
name
,
treeKey
:
key
,
breadcrumbLabel
:
path
.
join
(
'/'
),
label
:
name
,
params
:
{
taskId
:
taskId
},
type
:
'project'
,
subType
:
type
}
});
};
...
...
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/DiffModal.tsx
0 → 100644
View file @
3cbe7ed7
/*
*
* 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
;
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/constants.tsx
0 → 100644
View file @
3cbe7ed7
/*
*
* 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'
];
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/index.less
0 → 100644
View file @
3cbe7ed7
/*
*
* 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.
*
*/
.no_diff_content {
display: flex;
align-items: center;
justify-content: center;
height: 50vh;
text-align: center;
}
.diff_content {
height: 50vh;
padding: 10px;
border: 1px solid #fdfdfd1f;
}
.header {
border-bottom: 1px dotted #1677ff;
border-left: 5px solid #1677ff;
border-radius: 0;
padding-inline-start: 5px;
}
.use_version_btn {
float: right;
margin-right: 20px;
}
dinky-web/src/pages/DataStudio/MiddleContainer/Editor/index.tsx
View file @
3cbe7ed7
import
{
getCurrentData
}
from
'@/pages/DataStudio/function'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'@/pages/DataStudio/model'
;
import
{
connect
}
from
'@@/exports'
;
import
{
getCurrentTab
}
from
'@/pages/DataStudio/function'
;
import
{
TASK_VAR_FILTER
}
from
'@/pages/DataStudio/MiddleContainer/Editor/constants'
;
import
DiffModal
from
'@/pages/DataStudio/MiddleContainer/Editor/DiffModal'
;
import
{
DataStudioTabsItemType
,
StateType
,
STUDIO_MODEL
,
TaskDataType
}
from
'@/pages/DataStudio/model'
;
import
{
JOB_LIFE_CYCLE
}
from
'@/pages/DevOps/constants'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
connect
,
useRequest
}
from
'@@/exports'
;
import
{
Editor
}
from
'@monaco-editor/react'
;
import
{
Spin
}
from
'antd'
;
import
{
editor
}
from
'monaco-editor'
;
import
React
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
export
type
EditorProps
=
{
statement
:
string
;
taskId
:
number
;
};
const
CodeEditor
:
React
.
FC
<
EditorProps
&
any
>
=
(
props
)
=>
{
const
{
statement
,
taskId
,
tabs
:
{
panes
,
activeKey
},
dispatch
}
=
props
;
const
current
=
getCurrentData
(
panes
,
activeKey
);
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
[
diff
,
setDiff
]
=
useState
<
any
>
([]);
const
currentTab
=
getCurrentTab
(
panes
,
activeKey
)
as
DataStudioTabsItemType
;
const
currentData
=
currentTab
.
params
.
taskData
;
const
loadTask
=
(
cache
:
TaskDataType
,
serverParams
:
TaskDataType
)
=>
{
if
(
!
cache
)
{
currentTab
.
params
.
taskData
=
{
...
serverParams
,
useResult
:
true
,
maxRowNum
:
100
};
dispatch
({
type
:
STUDIO_MODEL
.
saveTabs
,
payload
:
{
...
props
.
tabs
}
});
return
;
}
const
diff
:
any
[]
=
[];
Object
.
keys
(
serverParams
).
forEach
((
key
)
=>
{
if
(
TASK_VAR_FILTER
.
includes
(
key
))
{
cache
[
key
]
=
serverParams
[
key
];
}
else
if
(
JSON
.
stringify
(
serverParams
[
key
])
!==
JSON
.
stringify
(
cache
[
key
]))
{
diff
.
push
({
key
:
key
,
server
:
serverParams
[
key
],
cache
:
cache
[
key
]
});
}
});
if
(
diff
.
length
>
0
)
{
setDiff
(
diff
);
setIsModalOpen
(
true
);
}
};
const
{
loading
,
data
}
=
useRequest
(
{
url
:
API_CONSTANTS
.
TASK
,
params
:
{
id
:
taskId
}
},
{
onSuccess
:
(
data
:
any
)
=>
loadTask
(
currentTab
.
params
.
taskData
,
data
)
}
);
const
upDateTask
=
(
useServerVersion
:
boolean
)
=>
{
if
(
useServerVersion
)
{
currentTab
.
params
.
taskData
=
{
...
data
,
useResult
:
true
,
maxRowNum
:
100
};
currentTab
.
isModified
=
false
;
}
else
{
currentTab
.
isModified
=
true
;
}
dispatch
({
type
:
STUDIO_MODEL
.
saveTabs
,
payload
:
{
...
props
.
tabs
}
});
setIsModalOpen
(
false
);
};
return
(
<>
<
Spin
spinning=
{
loading
}
>
<
DiffModal
diffs=
{
diff
}
open=
{
isModalOpen
}
fileName=
{
currentData
?.
name
}
onUse=
{
upDateTask
}
/>
<
Editor
width=
{
'100%'
}
height=
{
'
100%
'
}
value=
{
statement
}
height=
{
'
84vh
'
}
value=
{
currentTab
?.
params
?.
taskData
?.
statement
}
language=
{
'sql'
}
options=
{
{
readOnlyMessage
:
{
value
:
l
(
'pages.datastudio.editor.onlyread'
)
},
readOnly
:
currentData
?.
step
==
JOB_LIFE_CYCLE
.
ONLINE
,
scrollBeyondLastLine
:
false
,
wordWrap
:
'on'
,
autoDetectHighContrast
:
true
,
scrollbar
:
{
// Subtle shadows to the left & top. Defaults to true.
useShadows
:
false
,
// Render vertical arrows. Defaults to false.
// verticalHasArrows: true,
// Render horizontal arrows. Defaults to false.
// horizontalHasArrows: true,
// Render vertical scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
vertical
:
'visible'
,
// Render horizontal scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
horizontal
:
'visible'
,
verticalScrollbarSize
:
8
,
...
...
@@ -64,14 +109,14 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
});
}
}
onChange=
{
(
v
)
=>
{
if
(
!
current
)
{
if
(
!
current
Data
||
!
currentTab
)
{
return
;
}
if
(
typeof
v
===
'string'
)
{
current
.
statement
=
v
;
current
Data
.
statement
=
v
;
}
currentTab
.
isModified
=
true
;
dispatch
({
type
:
STUDIO_MODEL
.
saveTabs
,
payload
:
{
...
props
.
tabs
}
...
...
@@ -79,18 +124,7 @@ const CodeEditor: React.FC<EditorProps & any> = (props) => {
}
}
theme=
{
'vs-dark'
}
/>
{
/*<CodeEdit code={statement} language={"sql"}*/
}
{
/* onChange={(v,d) => {*/
}
{
/* current.statement = v;*/
}
{
/* dispatch({*/
}
{
/* type: STUDIO_MODEL.saveTabs,*/
}
{
/* payload: {...props.tabs},*/
}
{
/* });*/
}
{
/* }}*/
}
{
/*/>*/
}
</>
</
Spin
>
);
};
...
...
dinky-web/src/pages/DataStudio/MiddleContainer/index.tsx
View file @
3cbe7ed7
...
...
@@ -18,7 +18,11 @@
import
ContentScroll
from
'@/components/Scroll/ContentScroll'
;
import
useThemeValue
from
'@/hooks/useThemeValue'
;
import
{
STUDIO_TAG_RIGHT_CONTEXT_MENU
}
from
'@/pages/DataStudio/constants'
;
import
{
isDataStudioTabsItemType
,
isMetadataTabsItemType
}
from
'@/pages/DataStudio/function'
;
import
{
getCurrentTab
,
isDataStudioTabsItemType
,
isMetadataTabsItemType
}
from
'@/pages/DataStudio/function'
;
import
Editor
from
'@/pages/DataStudio/MiddleContainer/Editor'
;
import
{
getTabIcon
}
from
'@/pages/DataStudio/MiddleContainer/function'
;
import
KeyBoard
from
'@/pages/DataStudio/MiddleContainer/KeyBoard'
;
...
...
@@ -26,11 +30,16 @@ import QuickGuide from '@/pages/DataStudio/MiddleContainer/QuickGuide';
import
{
StateType
,
STUDIO_MODEL
,
TabsItemType
,
TabsPageType
}
from
'@/pages/DataStudio/model'
;
import
{
RightSide
}
from
'@/pages/DataStudio/route'
;
import
RightTagsRouter
from
'@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
connect
}
from
'@@/exports'
;
import
{
ConfigProvider
,
Divider
,
Dropdown
,
Space
,
Tabs
}
from
'antd'
;
import
{
ExclamationCircleFilled
}
from
'@ant-design/icons'
;
import
{
ConfigProvider
,
Divider
,
Dropdown
,
Modal
,
Space
,
Tabs
,
Typography
}
from
'antd'
;
import
{
MenuInfo
}
from
'rc-menu/es/interface'
;
import
React
,
{
useState
}
from
'react'
;
const
{
Text
}
=
Typography
;
const
{
confirm
}
=
Modal
;
type
TargetKey
=
React
.
MouseEvent
|
React
.
KeyboardEvent
|
string
;
const
MiddleContainer
=
(
props
:
any
)
=>
{
...
...
@@ -211,7 +220,7 @@ const MiddleContainer = (props: any) => {
}
const
v
=
item
.
params
;
return
<
Editor
statement=
{
v
.
taskData
.
statement
}
/>;
return
<
Editor
taskId=
{
v
.
taskId
}
/>;
}
if
(
isMetadataTabsItemType
(
item
))
{
...
...
@@ -232,7 +241,10 @@ const MiddleContainer = (props: any) => {
key=
{
item
.
key
}
>
{
getTabIcon
(
item
.
icon
,
16
)
}
{
item
.
label
}
<
Text
type=
{
item
.
isModified
?
'success'
:
undefined
}
>
{
item
.
label
}
{
item
.
isModified
?
'*'
:
''
}
</
Text
>
</
Space
>
),
children
:
(
...
...
@@ -247,7 +259,7 @@ const MiddleContainer = (props: any) => {
* 关闭tab
* @param {TargetKey} targetKey
*/
const
closeTab
=
(
targetKey
:
TargetKey
)
=>
{
const
handleCloseTab
=
(
targetKey
:
string
)
=>
{
if
(
panes
.
length
===
1
)
{
dispatch
({
type
:
STUDIO_MODEL
.
updateSelectRightKey
,
...
...
@@ -260,6 +272,23 @@ const MiddleContainer = (props: any) => {
payload
:
targetKey
});
};
const
closeTab
=
(
targetKey
:
TargetKey
)
=>
{
if
(
typeof
targetKey
==
'string'
)
{
const
tab
=
getCurrentTab
(
panes
,
targetKey
);
if
(
tab
?.
isModified
)
{
confirm
({
title
:
l
(
'pages.datastudio.editor.notsave'
),
icon
:
<
ExclamationCircleFilled
/>,
content
:
l
(
'pages.datastudio.editor.notsave.note'
),
onOk
()
{
handleCloseTab
(
targetKey
);
}
});
}
else
{
handleCloseTab
(
targetKey
);
}
}
};
/**
* render middle content
...
...
dinky-web/src/pages/DataStudio/RightContainer/JobConfig/index.tsx
View file @
3cbe7ed7
...
...
@@ -102,7 +102,7 @@ const JobConfig = (props: any) => {
pane
.
params
.
taskData
[
key
]
=
all
[
key
];
}
});
pane
.
isModified
=
true
;
dispatch
({
type
:
STUDIO_MODEL
.
saveTabs
,
payload
:
{
...
props
.
tabs
}
...
...
dinky-web/src/pages/DataStudio/function.ts
View file @
3cbe7ed7
...
...
@@ -165,7 +165,7 @@ export const getFooterValue = (panes: any, activeKey: string): Partial<FooterTyp
return
isDataStudioTabsItemType
(
currentTab
)
?
{
codePosition
:
[
1
,
1
],
codeType
:
currentTab
.
params
.
taskData
.
dialect
codeType
:
currentTab
.
subType
}
:
{};
};
dinky-web/src/pages/DataStudio/index.tsx
View file @
3cbe7ed7
...
...
@@ -20,23 +20,13 @@ import useThemeValue from '@/hooks/useThemeValue';
import
BottomContainer
from
'@/pages/DataStudio/BottomContainer'
;
import
{
getConsoleData
}
from
'@/pages/DataStudio/BottomContainer/Console/service'
;
import
FooterContainer
from
'@/pages/DataStudio/FooterContainer'
;
import
{
getCurrentTab
,
isDataStudioTabsItemType
,
mapDispatchToProps
}
from
'@/pages/DataStudio/function'
;
import
{
mapDispatchToProps
}
from
'@/pages/DataStudio/function'
;
import
SecondHeaderContainer
from
'@/pages/DataStudio/HeaderContainer'
;
import
LeftContainer
from
'@/pages/DataStudio/LeftContainer'
;
import
{
getDataBase
}
from
'@/pages/DataStudio/LeftContainer/MetaData/service'
;
import
{
getTaskData
,
getTaskDetails
}
from
'@/pages/DataStudio/LeftContainer/Project/service'
;
import
{
getTaskData
}
from
'@/pages/DataStudio/LeftContainer/Project/service'
;
import
MiddleContainer
from
'@/pages/DataStudio/MiddleContainer'
;
import
{
StateType
,
TabsItemType
,
TabsPageType
,
TaskDataType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
{
StateType
,
TabsItemType
,
TabsPageType
,
VIEW
}
from
'@/pages/DataStudio/model'
;
import
RightContainer
from
'@/pages/DataStudio/RightContainer'
;
import
{
getClusterConfigurationData
,
...
...
@@ -44,15 +34,12 @@ import {
getSessionData
}
from
'@/pages/DataStudio/RightContainer/JobConfig/service'
;
import
{
LeftBottomMoreTabs
,
LeftBottomSide
,
LeftSide
,
RightSide
}
from
'@/pages/DataStudio/route'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
import
{
Layout
,
Menu
,
Modal
,
theme
,
Typography
}
from
'antd'
;
import
{
Layout
,
Menu
,
theme
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
PersistGate
}
from
'redux-persist/integration/react'
;
import
{
connect
,
getDvaApp
}
from
'umi'
;
const
{
Text
}
=
Typography
;
const
{
Sider
,
Content
}
=
Layout
;
const
{
useToken
}
=
theme
;
...
...
@@ -68,7 +55,6 @@ const DataStudio = (props: any) => {
updateBottomConsole
,
saveSession
,
saveEnv
,
saveTabs
,
updateCenterContentHeight
,
updateSelectLeftKey
,
updateSelectRightKey
,
...
...
@@ -80,8 +66,6 @@ const DataStudio = (props: any) => {
}
=
props
;
const
{
token
}
=
useToken
();
const
themeValue
=
useThemeValue
();
const
[
isModalUpdateTabContentOpen
,
setIsModalUpdateTabContentOpen
]
=
useState
(
false
);
const
[
newTabData
,
setNewTabData
]
=
useState
<
TaskDataType
>
();
const
app
=
getDvaApp
();
// 获取dva的实例
const
persist
=
app
.
_store
.
persist
;
const
bottomHeight
=
bottomContainer
.
selectKey
===
''
?
0
:
bottomContainer
.
height
;
...
...
@@ -112,23 +96,6 @@ const DataStudio = (props: any) => {
return
()
=>
window
.
removeEventListener
(
'resize'
,
onResize
);
},
[]);
useEffect
(()
=>
{
if
(
isModalUpdateTabContentOpen
)
{
Modal
.
confirm
({
title
:
l
(
'pages.datastudio.help.sqlChanged'
),
keyboard
:
true
,
content
:
(
<>
{
' '
}
<
Text
type=
{
'danger'
}
>
{
l
(
'pages.datastudio.help.sqlChangedPrompt'
)
}
</
Text
>
</>
),
onOk
:
updateTabContent
,
onCancel
:
()
=>
setIsModalUpdateTabContentOpen
(
false
)
});
}
},
[
isModalUpdateTabContentOpen
]);
const
loadData
=
async
()
=>
{
Promise
.
all
([
getDataBase
(),
...
...
@@ -145,51 +112,6 @@ const DataStudio = (props: any) => {
saveEnv
(
res
[
4
]);
saveClusterConfiguration
(
res
[
5
]);
});
// 判断是否需要更新tab内容
if
(
!
tabs
.
activeKey
)
{
return
;
}
const
currentTab
=
getCurrentTab
(
tabs
.
panes
,
tabs
.
activeKey
);
if
(
!
isDataStudioTabsItemType
(
currentTab
))
{
return
;
}
const
params
=
currentTab
.
params
;
const
res
=
await
getTaskDetails
(
params
.
taskId
);
if
(
!
res
)
{
return
true
;
}
const
info
=
res
as
{
[
key
:
string
]:
any
};
const
changed
=
Object
.
keys
(
params
.
taskData
).
some
((
key
)
=>
{
// ignore this property
if
(
[
'updateTime'
,
'createTime'
,
'jobInstanceId'
,
'useResult'
,
'maxRowNum'
,
'useChangeLog'
,
'useAutoCancel'
].
includes
(
key
)
)
{
return
false
;
}
if
(
JSON
.
stringify
(
info
[
key
])
!==
JSON
.
stringify
(
params
.
taskData
[
key
]))
{
console
.
log
(
'changed'
,
key
,
info
[
key
],
params
.
taskData
[
key
]);
return
true
;
}
return
false
;
});
if
(
changed
)
{
setIsModalUpdateTabContentOpen
(
true
);
setNewTabData
(
res
);
}
};
useEffect
(()
=>
{
...
...
@@ -197,19 +119,6 @@ const DataStudio = (props: any) => {
onResize
();
},
[]);
const
updateTabContent
=
()
=>
{
const
currentTab
=
getCurrentTab
(
tabs
.
panes
,
tabs
.
activeKey
);
if
(
!
isDataStudioTabsItemType
(
currentTab
))
{
return
;
}
if
(
!
newTabData
)
return
;
currentTab
.
params
.
taskData
=
newTabData
;
saveTabs
({
...
tabs
});
setIsModalUpdateTabContentOpen
(
false
);
};
const
access
=
useAccess
();
const
LeftTopMenu
=
(
...
...
dinky-web/src/pages/DataStudio/model.ts
View file @
3cbe7ed7
...
...
@@ -103,6 +103,7 @@ export type TaskDataBaseType = {
id
:
number
;
name
:
string
;
statement
:
string
;
step
:
number
;
};
export
type
TaskDataType
=
TaskDataBaseType
&
Record
<
string
,
any
>
;
...
...
@@ -120,7 +121,7 @@ export enum TabsPageType {
}
export
enum
TabsPageSubType
{
flinkSql
=
'
flinks
ql'
flinkSql
=
'
FlinkS
ql'
}
export
interface
TabsItemType
{
...
...
dinky-web/src/services/endpoints.tsx
View file @
3cbe7ed7
...
...
@@ -277,5 +277,8 @@ export enum API_CONSTANTS {
SAVE_OR_UPDATE_TASK_URL
=
'/api/catalogue/saveOrUpdateCatalogueAndTask'
,
SAVE_OR_UPDATE_CATALOGUE_URL
=
'/api/catalogue/saveOrUpdateCatalogue'
,
COPY_TASK_URL
=
'/api/catalogue/copyTask'
,
MOVE_CATALOGUE_URL
=
'/api/catalogue/moveCatalogue'
MOVE_CATALOGUE_URL
=
'/api/catalogue/moveCatalogue'
,
//task
TASK
=
'/api/task'
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment