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
1cd2930d
Unverified
Commit
1cd2930d
authored
Oct 27, 2023
by
ZackYoung
Committed by
GitHub
Oct 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix]fix_some_web_bug (#2448)
* fix_some_web_bug * fix_some_web_bug
parent
4d9e70dc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
404 additions
and
369 deletions
+404
-369
config.ts
dinky-web/config/config.ts
+1
-1
index.tsx
dinky-web/src/components/CustomEditor/CodeShow/index.tsx
+214
-208
index.tsx
...b/src/components/CustomEditor/languages/javalog/index.tsx
+21
-0
ConsoleContent.tsx
...ges/DataStudio/BottomContainer/Console/ConsoleContent.tsx
+142
-134
index.tsx
...eb/src/pages/DataStudio/HeaderContainer/Explain/index.tsx
+13
-13
function.tsx
dinky-web/src/utils/function.tsx
+13
-13
No files found.
dinky-web/config/config.ts
View file @
1cd2930d
...
@@ -193,5 +193,5 @@ export default defineConfig({
...
@@ -193,5 +193,5 @@ export default defineConfig({
strategy
:
'normal'
strategy
:
'normal'
},
},
// requestRecord: {},
// requestRecord: {},
dva
:
{}
dva
:
{}
,
});
});
dinky-web/src/components/CustomEditor/CodeShow/index.tsx
View file @
1cd2930d
...
@@ -18,16 +18,18 @@
...
@@ -18,16 +18,18 @@
*/
*/
import
EditorFloatBtn
from
'@/components/CustomEditor/EditorFloatBtn'
;
import
EditorFloatBtn
from
'@/components/CustomEditor/EditorFloatBtn'
;
import
{
MonacoEditorOptions
}
from
'@/types/Public/data'
;
import
{
CODE_EDIT_THEME
,
MonacoEditorOptions
,
THEME
}
from
'@/types/Public/data'
;
import
{
convertCodeEditTheme
}
from
'@/utils/function'
;
import
{
convertCodeEditTheme
}
from
'@/utils/function'
;
import
{
Editor
,
loader
}
from
'@monaco-editor/react'
;
import
{
Editor
,
loader
}
from
'@monaco-editor/react'
;
import
*
as
monaco
from
'monaco-editor'
;
import
*
as
monaco
from
'monaco-editor'
;
import
{
editor
}
from
'monaco-editor'
;
import
{
editor
}
from
'monaco-editor'
;
import
{
EditorLanguage
}
from
'monaco-editor/esm/metadata'
;
import
{
EditorLanguage
}
from
'monaco-editor/esm/metadata'
;
import
{
useState
}
from
'react'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
FullscreenBtn
from
'../FullscreenBtn'
;
import
FullscreenBtn
from
'../FullscreenBtn'
;
import
useThemeValue
from
"@/hooks/useThemeValue"
;
import
{
JavaLog
}
from
"@/components/CustomEditor/languages/javalog"
;
loader
.
config
({
monaco
});
// loader.config({monaco
});
/**
/**
* props
* props
* todo:
* todo:
...
@@ -36,230 +38,234 @@ loader.config({ monaco });
...
@@ -36,230 +38,234 @@ loader.config({ monaco });
* 2. Callback for right-clicking to clear logs (optional, not required)
* 2. Callback for right-clicking to clear logs (optional, not required)
*/
*/
export
type
CodeShowFormProps
=
{
export
type
CodeShowFormProps
=
{
height
?:
string
|
number
;
height
?:
string
|
number
;
width
?:
string
;
width
?:
string
;
language
?:
EditorLanguage
;
language
?:
EditorLanguage
|
string
;
options
?:
any
;
options
?:
any
;
code
:
string
;
code
:
string
;
lineNumbers
?:
string
;
lineNumbers
?:
string
;
theme
?:
string
;
autoWrap
?:
string
;
autoWrap
?:
string
;
showFloatButton
?:
boolean
;
showFloatButton
?:
boolean
;
refreshLogCallback
?:
()
=>
void
;
refreshLogCallback
?:
()
=>
void
;
fullScreenBtn
?:
boolean
;
fullScreenBtn
?:
boolean
;
style
?:
React
.
CSSProperties
;
};
};
const
CodeShow
=
(
props
:
CodeShowFormProps
)
=>
{
const
CodeShow
=
(
props
:
CodeShowFormProps
)
=>
{
/**
/**
* 1. height: edit height
* 1. height: edit height
* 2. width: edit width
* 2. width: edit width
* 3. language: edit language
* 3. language: edit language
* 4. options: edit options
* 4. options: edit options
* 5. code: content
* 5. code: content
* 6. readOnly: is readOnly, value: true | false
* 6. readOnly: is readOnly, value: true | false
* 7. lineNumbers: is show lineNumbers, value: on | off | relative | interval
* 7. lineNumbers: is show lineNumbers, value: on | off | relative | interval
* 8. theme: edit theme , value: vs-dark | vs | hc-black
* 8. theme: edit theme , value: vs-dark | vs | hc-black
* 9. autoWrap: is auto wrap, value: on | off | wordWrapColumn | bounded
* 9. autoWrap: is auto wrap, value: on | off | wordWrapColumn | bounded
*/
*/
const
{
const
{
height
=
'30vh'
,
// if null or undefined, set default value
height
=
'30vh'
,
// if null or undefined, set default value
width
=
'100%'
,
// if null or undefined, set default value
width
=
'100%'
,
// if null or undefined, set default value
language
,
language
,
options
=
{
options
=
{
...
MonacoEditorOptions
// set default options
...
MonacoEditorOptions
// set default options
},
},
code
,
// content
code
,
// content
lineNumbers
,
// show lineNumbers
lineNumbers
,
// show lineNumbers
theme
,
// edit theme
autoWrap
=
'on'
,
// auto wrap
autoWrap
=
'on'
,
// auto wrap
showFloatButton
=
false
,
showFloatButton
=
false
,
refreshLogCallback
,
refreshLogCallback
,
fullScreenBtn
=
false
fullScreenBtn
=
false
}
=
props
;
}
=
props
;
const
{
ScrollType
}
=
editor
;
const
{
ScrollType
}
=
editor
;
const
[
scrollBeyondLastLine
]
=
useState
<
boolean
>
(
options
.
scrollBeyondLastLine
);
const
[
scrollBeyondLastLine
]
=
useState
<
boolean
>
(
options
.
scrollBeyondLastLine
);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
stopping
,
setStopping
]
=
useState
<
boolean
>
(
false
);
const
[
stopping
,
setStopping
]
=
useState
<
boolean
>
(
false
);
const
[
autoRefresh
,
setAutoRefresh
]
=
useState
<
boolean
>
(
false
);
const
[
autoRefresh
,
setAutoRefresh
]
=
useState
<
boolean
>
(
false
);
const
[
fullScreen
,
setFullScreen
]
=
useState
<
boolean
>
(
false
);
const
[
fullScreen
,
setFullScreen
]
=
useState
<
boolean
>
(
false
);
const
[
editorRef
,
setEditorRef
]
=
useState
<
any
>
();
const
[
editorRef
,
setEditorRef
]
=
useState
<
any
>
();
const
[
timer
,
setTimer
]
=
useState
<
NodeJS
.
Timer
>
();
const
[
timer
,
setTimer
]
=
useState
<
NodeJS
.
Timer
>
();
const
themeValue
=
useThemeValue
();
useEffect
(()
=>
{
JavaLog
();
},
[])
// // register TypeScript language service, if language is not set default value is typescript!
// // register TypeScript language service, if language is not set default value is typescript!
// monaco.languages.register({
// monaco.languages.register({
// id: language || "typescript",
// id: language || "typescript",
// });
// });
/**
/**
* handle sync log
* handle sync log
* @returns {Promise<void>}
* @returns {Promise<void>}
*/
*/
const
handleSyncLog
=
async
()
=>
{
const
handleSyncLog
=
async
()
=>
{
setLoading
(
true
);
setLoading
(
true
);
setInterval
(()
=>
{
setInterval
(()
=>
{
refreshLogCallback
?.();
refreshLogCallback
?.();
setLoading
(
false
);
setLoading
(
false
);
},
1000
);
},
1000
);
};
};
/**
/**
* handle stop auto refresh log
* handle stop auto refresh log
*/
*/
const
handleStopAutoRefresh
=
()
=>
{
const
handleStopAutoRefresh
=
()
=>
{
setStopping
(
true
);
setStopping
(
true
);
setInterval
(()
=>
{
setInterval
(()
=>
{
clearInterval
(
timer
);
clearInterval
(
timer
);
setStopping
(
false
);
setStopping
(
false
);
setAutoRefresh
(
false
);
setAutoRefresh
(
false
);
},
1000
);
},
1000
);
};
};
/**
/**
* handle stop auto refresh log
* handle stop auto refresh log
*/
*/
const
handleStartAutoRefresh
=
async
()
=>
{
const
handleStartAutoRefresh
=
async
()
=>
{
setAutoRefresh
(
true
);
setAutoRefresh
(
true
);
const
timerSync
=
setInterval
(()
=>
{
const
timerSync
=
setInterval
(()
=>
{
handleSyncLog
();
handleSyncLog
();
},
5000
);
},
5000
);
setTimer
(
timerSync
);
setTimer
(
timerSync
);
};
};
/**
/**
* handle scroll to top
* handle scroll to top
*/
*/
const
handleBackTop
=
()
=>
{
const
handleBackTop
=
()
=>
{
editorRef
.
revealLine
(
1
);
editorRef
.
revealLine
(
1
);
};
};
/**
/**
* handle scroll to bottom
* handle scroll to bottom
*/
*/
const
handleBackBottom
=
()
=>
{
const
handleBackBottom
=
()
=>
{
editorRef
.
revealLine
(
editorRef
.
getModel
().
getLineCount
());
editorRef
.
revealLine
(
editorRef
.
getModel
().
getLineCount
());
};
};
/**
/**
* handle scroll to down
* handle scroll to down
*/
*/
const
handleDownScroll
=
()
=>
{
const
handleDownScroll
=
()
=>
{
editorRef
.
setScrollPosition
({
scrollTop
:
editorRef
.
getScrollTop
()
+
500
},
ScrollType
.
Smooth
);
editorRef
.
setScrollPosition
({
scrollTop
:
editorRef
.
getScrollTop
()
+
500
},
ScrollType
.
Smooth
);
};
};
/**
/**
* handle scroll to up
* handle scroll to up
*/
*/
const
handleUpScroll
=
()
=>
{
const
handleUpScroll
=
()
=>
{
editorRef
?.
setScrollPosition
({
scrollTop
:
editorRef
.
getScrollTop
()
-
500
},
ScrollType
.
Smooth
);
editorRef
?.
setScrollPosition
({
scrollTop
:
editorRef
.
getScrollTop
()
-
500
},
ScrollType
.
Smooth
);
};
};
/**
/**
* editorDidMount
* editorDidMount
* @param {editor.IStandaloneCodeEditor} editor
* @param {editor.IStandaloneCodeEditor} editor
*/
*/
const
editorDidMount
=
(
editor
:
editor
.
IStandaloneCodeEditor
)
=>
{
const
editorDidMount
=
(
editor
:
editor
.
IStandaloneCodeEditor
)
=>
{
setEditorRef
(
editor
);
setEditorRef
(
editor
);
editor
.
layout
();
editor
.
layout
();
editor
.
focus
();
editor
.
focus
();
if
(
scrollBeyondLastLine
)
{
if
(
scrollBeyondLastLine
)
{
editor
.
onDidChangeModelContent
(()
=>
{
editor
.
onDidChangeModelContent
(()
=>
{
const
lineCount
=
editor
.
getModel
()?.
getLineCount
()
as
number
;
const
lineCount
=
editor
.
getModel
()?.
getLineCount
()
as
number
;
if
(
lineCount
>
20
)
{
if
(
lineCount
>
20
)
{
editor
.
revealLine
(
lineCount
);
editor
.
revealLine
(
lineCount
);
}
else
{
}
else
{
editor
.
revealLine
(
1
);
editor
.
revealLine
(
1
);
}
});
}
}
});
};
}
};
const
restEditBtnProps
=
{
const
restEditBtnProps
=
{
refreshLogCallback
,
refreshLogCallback
,
autoRefresh
,
autoRefresh
,
stopping
,
stopping
,
loading
,
loading
,
handleSyncLog
,
handleSyncLog
,
handleStopAutoRefresh
,
handleStopAutoRefresh
,
handleStartAutoRefresh
,
handleStartAutoRefresh
,
handleBackTop
,
handleBackTop
,
handleBackBottom
,
handleBackBottom
,
handleUpScroll
,
handleUpScroll
,
handleDownScroll
handleDownScroll
};
};
/**
/**
* render
* render
*/
*/
return
(
return
(
<
div
className=
{
'monaco-float'
}
>
<
div
className=
{
'monaco-float'
}
style=
{
props
.
style
}
>
{
/* fullScreen button */
}
{
/* fullScreen button */
}
{
fullScreenBtn
&&
(
{
fullScreenBtn
&&
(
<
FullscreenBtn
<
FullscreenBtn
isFullscreen=
{
fullScreen
}
isFullscreen=
{
fullScreen
}
fullScreenCallBack=
{
()
=>
setFullScreen
(
!
fullScreen
)
}
fullScreenCallBack=
{
()
=>
setFullScreen
(
!
fullScreen
)
}
/>
/>
)
}
)
}
{
/* editor */
}
{
/* editor */
}
<
Editor
<
Editor
width=
{
width
}
width=
{
width
}
height=
{
height
}
height=
{
height
}
value=
{
loading
?
'loading...'
:
code
}
value=
{
loading
?
'loading...'
:
code
}
language=
{
language
}
language=
{
language
}
options=
{
{
options=
{
{
...
options
,
...
options
,
scrollBeyondLastLine
:
false
,
scrollBeyondLastLine
:
false
,
readOnly
:
true
,
readOnly
:
true
,
wordWrap
:
autoWrap
,
wordWrap
:
autoWrap
,
autoDetectHighContrast
:
true
,
autoDetectHighContrast
:
true
,
selectOnLineNumbers
:
true
,
selectOnLineNumbers
:
true
,
fixedOverflowWidgets
:
true
,
fixedOverflowWidgets
:
true
,
autoClosingDelete
:
'always'
,
autoClosingDelete
:
'always'
,
lineNumbers
,
lineNumbers
,
scrollbar
:
{
minimap
:
{
enabled
:
false
},
// Subtle shadows to the left & top. Defaults to true.
scrollbar
:
{
useShadows
:
false
,
// Subtle shadows to the left & top. Defaults to true.
useShadows
:
false
,
// Render vertical arrows. Defaults to false.
// Render vertical arrows. Defaults to false.
// verticalHasArrows: true,
// verticalHasArrows: true,
// Render horizontal arrows. Defaults to false.
// Render horizontal arrows. Defaults to false.
// horizontalHasArrows: true,
// horizontalHasArrows: true,
// Render vertical scrollbar.
// Render vertical scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
// Defaults to 'auto'
vertical
:
'visible'
,
vertical
:
'visible'
,
// Render horizontal scrollbar.
// Render horizontal scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
// Defaults to 'auto'
horizontal
:
'visible'
,
horizontal
:
'visible'
,
verticalScrollbarSize
:
8
,
verticalScrollbarSize
:
8
,
horizontalScrollbarSize
:
8
,
horizontalScrollbarSize
:
8
,
arrowSize
:
30
arrowSize
:
30
}
}
}
}
}
}
onMount=
{
editorDidMount
}
onMount=
{
editorDidMount
}
theme=
{
convertCodeEditTheme
()
}
theme=
{
convertCodeEditTheme
()
}
/>
/>
{
/* float button */
}
{
/* float button */
}
{
showFloatButton
&&
(
{
showFloatButton
&&
(
<
div
<
div
style=
{
{
style=
{
{
width
:
35
,
width
:
35
,
height
:
height
,
height
:
height
,
backgroundColor
:
'#f4f4f4'
,
backgroundColor
:
themeValue
.
borderColor
,
paddingBlock
:
10
paddingBlock
:
10
}
}
}
}
>
>
<
EditorFloatBtn
{
...
restEditBtnProps
}
/>
<
EditorFloatBtn
{
...
restEditBtnProps
}
/>
</
div
>
)
}
</
div
>
</
div
>
)
}
);
</
div
>
);
};
};
export
default
CodeShow
;
export
default
CodeShow
;
dinky-web/src/components/CustomEditor/languages/javalog/index.tsx
0 → 100644
View file @
1cd2930d
import
{
editor
}
from
"monaco-editor"
;
import
{
languages
}
from
"monaco-editor"
;
// todo 自定义语言不生效
export
const
JavaLog
=
()
=>
{
// Register a new language
languages
.
register
({
id
:
"java-log"
});
// Register a tokens provider for the language
languages
.
setMonarchTokensProvider
(
"java-log"
,
{
tokenizer
:
{
root
:
[
[
/
\[
error.*/
,
"custom-error"
],
[
/
\[
notice.*/
,
"custom-notice"
],
[
/.*/
,
"custom-info"
],
[
/
\[[
a-zA-Z 0-9:
]
+
\]
/
,
"custom-date"
],
],
},
});
}
\ No newline at end of file
dinky-web/src/pages/DataStudio/BottomContainer/Console/ConsoleContent.tsx
View file @
1cd2930d
...
@@ -19,159 +19,167 @@
...
@@ -19,159 +19,167 @@
import
CodeShow
from
'@/components/CustomEditor/CodeShow'
;
import
CodeShow
from
'@/components/CustomEditor/CodeShow'
;
import
MovableSidebar
from
'@/components/Sidebar/MovableSidebar'
;
import
MovableSidebar
from
'@/components/Sidebar/MovableSidebar'
;
import
{
SseData
}
from
'@/models/Sse'
;
import
{
SseData
}
from
'@/models/Sse'
;
import
{
DataStudioTabsItemType
,
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
DataStudioTabsItemType
,
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
SSE_TOPIC
}
from
'@/pages/DevOps/constants'
;
import
{
SSE_TOPIC
}
from
'@/pages/DevOps/constants'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
parseMilliSecondStr
}
from
'@/utils/function'
;
import
{
parseMilliSecondStr
}
from
'@/utils/function'
;
import
{
connect
,
useModel
,
useRequest
}
from
'@@/exports'
;
import
{
connect
,
useModel
,
useRequest
}
from
'@@/exports'
;
import
{
CheckOutlined
,
CloseCircleFilled
,
LoadingOutlined
}
from
'@ant-design/icons'
;
import
{
CheckOutlined
,
CloseCircleFilled
,
LoadingOutlined
}
from
'@ant-design/icons'
;
import
{
Empty
,
Space
,
Typography
}
from
'antd'
;
import
{
Empty
,
Space
,
Typography
}
from
'antd'
;
import
{
DataNode
}
from
'antd/es/tree'
;
import
{
DataNode
}
from
'antd/es/tree'
;
import
DirectoryTree
from
'antd/es/tree/DirectoryTree'
;
import
DirectoryTree
from
'antd/es/tree/DirectoryTree'
;
import
{
Key
,
useEffect
,
useState
}
from
'react'
;
import
{
Key
,
useEffect
,
useState
}
from
'react'
;
const
{
Text
}
=
Typography
;
import
useThemeValue
from
"@/hooks/useThemeValue"
;
const
{
Text
}
=
Typography
;
export
type
ConsoleProps
=
{
export
type
ConsoleProps
=
{
tab
:
DataStudioTabsItemType
;
tab
:
DataStudioTabsItemType
;
height
:
number
;
height
:
number
;
};
};
export
interface
ProcessStep
extends
DataNode
{
export
interface
ProcessStep
extends
DataNode
{
status
:
string
;
status
:
string
;
type
:
string
;
type
:
string
;
startTime
:
string
;
startTime
:
string
;
endTime
:
string
;
endTime
:
string
;
time
:
number
;
time
:
number
;
log
:
string
;
log
:
string
;
lastUpdateStep
:
ProcessStep
;
lastUpdateStep
:
ProcessStep
;
children
:
ProcessStep
[];
children
:
ProcessStep
[];
}
}
const
buildExpandKeys
=
(
node
:
ProcessStep
)
=>
{
const
buildExpandKeys
=
(
node
:
ProcessStep
)
=>
{
const
keys
:
Key
[]
=
[];
const
keys
:
Key
[]
=
[];
keys
.
push
(
node
.
key
);
keys
.
push
(
node
.
key
);
if
(
node
.
children
.
length
>
0
)
{
if
(
node
.
children
.
length
>
0
)
{
node
.
children
.
forEach
((
item
:
ProcessStep
)
=>
{
node
.
children
.
forEach
((
item
:
ProcessStep
)
=>
{
keys
.
push
(...
buildExpandKeys
(
item
));
keys
.
push
(...
buildExpandKeys
(
item
));
});
});
}
}
return
keys
;
return
keys
;
};
};
const
ConsoleContent
=
(
props
:
ConsoleProps
)
=>
{
const
ConsoleContent
=
(
props
:
ConsoleProps
)
=>
{
const
{
tab
}
=
props
;
const
{
tab
}
=
props
;
const
[
selectNode
,
setSelectNode
]
=
useState
<
ProcessStep
>
();
const
[
selectNode
,
setSelectNode
]
=
useState
<
ProcessStep
>
();
const
[
processNode
,
setProcessNode
]
=
useState
<
ProcessStep
>
();
const
[
processNode
,
setProcessNode
]
=
useState
<
ProcessStep
>
();
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
<
Key
[]
>
([]);
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
<
Key
[]
>
([]);
const
process
=
`FlinkSubmit/
${
tab
.
params
.
taskId
}
`
;
const
process
=
`FlinkSubmit/
${
tab
.
params
.
taskId
}
`
;
const
topic
=
`
${
SSE_TOPIC
.
PROCESS_CONSOLE
}
/
${
process
}
`
;
const
topic
=
`
${
SSE_TOPIC
.
PROCESS_CONSOLE
}
/
${
process
}
`
;
const
{
subscribeTopic
}
=
useModel
(
'Sse'
,
(
model
:
any
)
=>
({
const
{
subscribeTopic
}
=
useModel
(
'Sse'
,
(
model
:
any
)
=>
({
subscribeTopic
:
model
.
subscribeTopic
subscribeTopic
:
model
.
subscribeTopic
}));
}));
const
themeValue
=
useThemeValue
();
const
onUpdate
=
(
data
:
ProcessStep
)
=>
{
const
onUpdate
=
(
data
:
ProcessStep
)
=>
{
setProcessNode
((
prevState
:
any
)
=>
{
setProcessNode
((
prevState
:
any
)
=>
{
//如果key不一致代表重新提交了任务,清空旧状态
//如果key不一致代表重新提交了任务,清空旧状态
if
(
prevState
&&
prevState
.
key
!=
data
.
key
)
{
if
(
prevState
&&
prevState
.
key
!=
data
.
key
)
{
setSelectNode
(
undefined
);
setSelectNode
(
undefined
);
}
}
return
data
;
return
data
;
});
});
setSelectNode
((
prevState
:
any
)
=>
{
setSelectNode
((
prevState
:
any
)
=>
{
if
(
prevState
&&
prevState
.
key
==
data
.
lastUpdateStep
.
key
)
{
if
(
prevState
&&
prevState
.
key
==
data
.
lastUpdateStep
.
key
)
{
//更新当前节点
//更新当前节点
return
data
.
lastUpdateStep
;
return
data
.
lastUpdateStep
;
}
else
if
(
!
prevState
||
prevState
.
key
==
data
.
key
)
{
}
else
if
(
!
prevState
||
prevState
.
key
==
data
.
key
)
{
//未选择节点状态下选择根节点
//未选择节点状态下选择根节点
return
data
;
return
data
;
}
}
return
prevState
;
return
prevState
;
});
});
};
};
useRequest
(
useRequest
(
{
url
:
API_CONSTANTS
.
PROCESS_LOG
,
params
:
{
processName
:
process
}
},
{
url
:
API_CONSTANTS
.
PROCESS_LOG
,
params
:
{
processName
:
process
}},
{
onSuccess
:
async
(
res
)
=>
onUpdate
(
res
)
}
{
onSuccess
:
async
(
res
)
=>
onUpdate
(
res
)}
);
useEffect
(()
=>
subscribeTopic
([
topic
],
(
data
:
SseData
)
=>
onUpdate
(
data
.
data
)),
[]);
const
onSelect
=
(
_selectedKeys
:
Key
[],
info
:
{
node
:
ProcessStep
})
=>
setSelectNode
(
info
.
node
);
const
renderTitle
=
(
node
:
any
)
=>
{
const
startDate
=
new
Date
(
node
.
startTime
);
const
endDate
=
new
Date
();
const
duration
=
node
.
time
?
node
.
time
:
endDate
.
getTime
()
-
startDate
.
getTime
();
return
(
<
Space
size=
{
5
}
>
{
node
.
status
==
'RUNNING'
&&
<
LoadingOutlined
/>
}
{
node
.
status
==
'FINISHED'
&&
(
<
CheckOutlined
style=
{
{
color
:
'green'
,
fontWeight
:
'bold'
}
}
/>
)
}
{
node
.
status
==
'FAILED'
&&
(
<
CloseCircleFilled
style=
{
{
color
:
'red'
,
fontWeight
:
'bold'
}
}
/>
)
}
<
Text
>
{
node
.
title
}
</
Text
>
<
Text
type=
{
'secondary'
}
style=
{
{
marginLeft
:
'auto'
}
}
>
{
parseMilliSecondStr
(
duration
)
}
</
Text
>
</
Space
>
);
);
};
useEffect
(()
=>
subscribeTopic
([
topic
],
(
data
:
SseData
)
=>
onUpdate
(
data
.
data
)),
[]);
const
onSelect
=
(
_selectedKeys
:
Key
[],
info
:
{
node
:
ProcessStep
})
=>
setSelectNode
(
info
.
node
);
useEffect
(()
=>
{
const
renderTitle
=
(
node
:
any
)
=>
{
if
(
processNode
)
{
const
startDate
=
new
Date
(
node
.
startTime
);
setExpandedKeys
(
buildExpandKeys
(
processNode
));
const
endDate
=
new
Date
();
}
const
duration
=
node
.
time
?
node
.
time
:
endDate
.
getTime
()
-
startDate
.
getTime
();
},
[
processNode
]);
return
(
<
Space
size=
{
5
}
>
{
node
.
status
==
'RUNNING'
&&
<
LoadingOutlined
/>
}
{
node
.
status
==
'FINISHED'
&&
(
<
CheckOutlined
style=
{
{
color
:
'green'
,
fontWeight
:
'bold'
}
}
/>
)
}
{
node
.
status
==
'FAILED'
&&
(
<
CloseCircleFilled
style=
{
{
color
:
'red'
,
fontWeight
:
'bold'
}
}
/>
)
}
<
Text
>
{
node
.
title
}
</
Text
>
<
Text
type=
{
'secondary'
}
style=
{
{
marginLeft
:
'auto'
}
}
>
{
parseMilliSecondStr
(
duration
)
}
</
Text
>
</
Space
>
);
};
useEffect
(()
=>
{
if
(
processNode
)
{
setExpandedKeys
(
buildExpandKeys
(
processNode
));
}
},
[
processNode
]);
const
handleExpand
=
(
expandedKeys
:
Key
[])
=>
{
const
handleExpand
=
(
expandedKeys
:
Key
[])
=>
{
setExpandedKeys
(
expandedKeys
);
setExpandedKeys
(
expandedKeys
);
};
};
return
(
return
(
<
div
style=
{
{
overflow
:
'hidden'
}
}
>
<
div
style=
{
{
overflow
:
'hidden'
}
}
>
<
MovableSidebar
<
MovableSidebar
defaultSize=
{
{
defaultSize=
{
{
width
:
300
,
width
:
300
,
height
:
props
.
height
-
53
height
:
props
.
height
-
53
}
}
}
}
minWidth=
{
20
}
minWidth=
{
20
}
visible=
{
true
}
visible=
{
true
}
enable=
{
{
right
:
true
}
}
enable=
{
{
right
:
true
}
}
headerVisible=
{
false
}
headerVisible=
{
false
}
style=
{
{
borderInlineStart
:
`1px`
,
float
:
'left'
}
}
style=
{
{
float
:
'left'
,
borderInlineEnd
:
`1px solid ${themeValue.borderColor}`
,
paddingInline
:
10
}
}
>
>
{
processNode
?
(
{
processNode
?
(
<
DirectoryTree
<
DirectoryTree
className=
{
'treeList'
}
className=
{
'treeList'
}
style=
{
{
height
:
props
.
height
}
}
showIcon=
{
false
}
showIcon=
{
fals
e
}
titleRender=
{
renderTitl
e
}
titleRender=
{
renderTitle
}
onSelect=
{
onSelect
}
onSelect=
{
onSelect
}
treeData=
{
[
processNode
]
}
treeData=
{
[
processNode
]
}
expandedKeys=
{
expandedKeys
}
expandedKeys=
{
expandedKeys
}
onExpand=
{
handleExpand
}
onExpand=
{
handleExpand
}
/>
/>
)
:
(
)
:
(
<
Empty
/>
<
Empty
/>
)
}
)
}
</
MovableSidebar
>
</
MovableSidebar
>
<
div
style=
{
{
display
:
"inline"
,
width
:
1500
}
}
>
<
div
>
<
CodeShow
<
CodeShow
code=
{
selectNode
?.
log
?
selectNode
.
log
:
''
}
code=
{
selectNode
?.
log
?
selectNode
.
log
:
''
}
height=
{
props
.
height
-
53
}
height=
{
props
.
height
-
53
}
language=
{
'java-log'
}
language=
{
'kotlin'
}
lineNumbers=
{
"off"
}
lineNumbers=
{
'off'
}
autoWrap=
{
"off"
}
//TODO 按钮显示有问题,先注释
//TODO 按钮显示有问题,先注释
// showFloatButton
// showFloatButton
/>
/>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
};
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
height
:
Studio
.
bottomContainer
.
height
,
Studio
:
StateType
console
:
Studio
.
bottomContainerContent
.
console
})
=>
({
height
:
Studio
.
bottomContainer
.
height
,
console
:
Studio
.
bottomContainerContent
.
console
}))(
ConsoleContent
);
}))(
ConsoleContent
);
dinky-web/src/pages/DataStudio/HeaderContainer/Explain/index.tsx
View file @
1cd2930d
...
@@ -24,7 +24,7 @@ import { StateType } from '@/pages/DataStudio/model';
...
@@ -24,7 +24,7 @@ import { StateType } from '@/pages/DataStudio/model';
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
ConsoleSqlOutlined
}
from
'@ant-design/icons'
;
import
{
ConsoleSqlOutlined
}
from
'@ant-design/icons'
;
import
ProList
from
'@ant-design/pro-list'
;
import
ProList
from
'@ant-design/pro-list'
;
import
{
Space
,
Tag
,
Typography
}
from
'antd'
;
import
{
Button
,
Drawer
,
Space
,
Tag
,
Typography
}
from
'antd'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
connect
}
from
'umi'
;
import
{
connect
}
from
'umi'
;
...
@@ -48,6 +48,8 @@ export type ExplainProps = {
...
@@ -48,6 +48,8 @@ export type ExplainProps = {
const
Explain
:
React
.
FC
<
ExplainProps
>
=
(
props
:
any
)
=>
{
const
Explain
:
React
.
FC
<
ExplainProps
>
=
(
props
:
any
)
=>
{
const
[
explainData
,
setExplainData
]
=
useState
([]);
const
[
explainData
,
setExplainData
]
=
useState
([]);
const
[
result
,
setResult
]
=
useState
(<
Text
>
{
l
(
'pages.datastudio.explain.validate'
)
}
</
Text
>);
const
[
result
,
setResult
]
=
useState
(<
Text
>
{
l
(
'pages.datastudio.explain.validate'
)
}
</
Text
>);
const
[
showModal
,
setShowModal
]
=
useState
(
false
);
const
[
explainInfo
,
setExplainInfo
]
=
useState
(
""
);
const
{
const
{
tabs
:
{
panes
,
activeKey
}
tabs
:
{
panes
,
activeKey
}
}
=
props
;
}
=
props
;
...
@@ -103,7 +105,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
...
@@ -103,7 +105,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
}
}
});
});
},
[]);
},
[]);
const
showPlanDrawer
=
(
info
:
string
)
=>
{
setShowModal
(
true
);
setExplainInfo
(
info
)
};
const
renderContent
=
()
=>
{
const
renderContent
=
()
=>
{
return
(
return
(
<>
<>
...
@@ -142,15 +147,18 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
...
@@ -142,15 +147,18 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
return
(
return
(
<>
<>
{
row
.
sql
?
(
{
row
.
sql
?
(
<>
<
Paragraph
ellipsis=
{
{
rows
:
2
,
expandable
:
true
,
symbol
:
'more'
}
}
>
<
Paragraph
ellipsis=
{
{
rows
:
2
,
expandable
:
true
,
symbol
:
'more'
}
}
>
{
row
.
sql
}
{
row
.
sql
}
</
Paragraph
>
</
Paragraph
>
</>
)
:
null
}
)
:
null
}
{
row
.
error
?
(
{
row
.
error
?
(
<
Paragraph
>
<
Paragraph
>
<
CodeShow
code=
{
row
.
error
}
language=
'java'
height=
'500px'
/>
<
CodeShow
code=
{
row
.
error
}
language=
'java'
height=
'500px'
/>
</
Paragraph
>
</
Paragraph
>
)
:
null
}
)
:
null
}
{
row
.
explain
?
<
a
onClick=
{
()
=>
showPlanDrawer
(
row
.
explain
)
}
style=
{
{
float
:
"right"
}
}
type=
{
"link"
}
>
Show Plan
</
a
>
:<></>
}
</>
</>
);
);
}
}
...
@@ -199,18 +207,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
...
@@ -199,18 +207,10 @@ const Explain: React.FC<ExplainProps> = (props: any) => {
<
blockquote
>
{
result
}
</
blockquote
>
<
blockquote
>
{
result
}
</
blockquote
>
</
Paragraph
>
</
Paragraph
>
{
renderContent
()
}
{
renderContent
()
}
<
Drawer
width=
{
"50%"
}
title=
"Show Plan"
placement=
"right"
onClose=
{
()
=>
setShowModal
(
false
)
}
open=
{
showModal
}
>
<
CodeShow
style=
{
{
alignItems
:
"inherit"
}
}
code=
{
explainInfo
}
language=
'java'
height=
'500px'
/>
</
Drawer
>
</>
</>
//
<
Modal
// width={'100%'}
// destroyOnClose
// centered
// title={l('pages.datastudio.explain.validate.msg')}
// open={modalVisible}
// footer={false}
// onCancel={onClose}
// >
//
// </Modal>
);
);
};
};
...
...
dinky-web/src/utils/function.tsx
View file @
1cd2930d
...
@@ -146,27 +146,27 @@ export function convertCodeEditTheme() {
...
@@ -146,27 +146,27 @@ export function convertCodeEditTheme() {
],
],
// colors is an object of color identifiers and their color values.
// colors is an object of color identifiers and their color values.
colors
:
{
colors
:
{
'editor.background'
:
'#2f2e2e'
,
// editor background color
//
'editor.background': '#2f2e2e', // editor background color
'editor.lineHighlightBackground'
:
'#959cb6'
,
// editor line highlight background color
//
'editor.lineHighlightBackground': '#959cb6', // editor line highlight background color
'editorLineNumber.foreground'
:
'#ffffff'
,
// editor line number color
//
'editorLineNumber.foreground': '#ffffff', // editor line number color
'editorCursor.foreground'
:
'#ffffff'
,
// editor cursor color
//
'editorCursor.foreground': '#ffffff', // editor cursor color
'editorIndentGuide.background'
:
'#ffffff'
,
// editor indent guide color
//
'editorIndentGuide.background': '#ffffff', // editor indent guide color
'editor.foreground'
:
'#ffffff'
,
// editor selection highlight border color
//
'editor.foreground': '#ffffff', // editor selection highlight border color
'editor.selectionBackground'
:
'#4ba1ef'
,
// editor selection highlight color
//
'editor.selectionBackground': '#4ba1ef', // editor selection highlight color
'editor.selectionHighlightBorder'
:
'#4ba1ef'
,
// editor selection highlight border color
//
'editor.selectionHighlightBorder': '#4ba1ef', // editor selection highlight border color
'editor.findMatchBackground'
:
'#4ba1ef'
,
// editor find match highlight color
//
'editor.findMatchBackground': '#4ba1ef', // editor find match highlight color
'editor.wordHighlightBackground'
:
'#8bb2d2'
// editor word highlight color
//
'editor.wordHighlightBackground': '#8bb2d2' // editor word highlight color
}
}
});
});
const
theme
=
getLocalTheme
();
const
theme
=
getLocalTheme
();
switch
(
theme
)
{
switch
(
theme
)
{
case
THEME
.
dark
:
case
THEME
.
dark
:
return
CODE_EDIT_THEME
.
VS_CUSTOME
;
case
THEME
.
light
:
return
CODE_EDIT_THEME
.
DARK
;
return
CODE_EDIT_THEME
.
DARK
;
case
THEME
.
light
:
return
CODE_EDIT_THEME
.
VS_CUSTOME
;
default
:
default
:
return
CODE_EDIT_THEME
.
HC_BLACK
;
return
CODE_EDIT_THEME
.
VS_CUSTOME
;
}
}
}
}
...
...
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