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
756d82bb
Unverified
Commit
756d82bb
authored
Oct 31, 2023
by
zhu-mingye
Committed by
GitHub
Oct 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix project expand bug (#2467)
* fix project expand bug * Spotless Apply --------- Co-authored-by:
zhu-mingye
<
zhu-mingye@users.noreply.github.com
>
parent
bce0f34e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
390 additions
and
382 deletions
+390
-382
index.tsx
dinky-web/src/components/CustomEditor/CodeShow/index.tsx
+2
-2
menu.ts
dinky-web/src/locales/zh-CN/menu.ts
+0
-1
index.tsx
...ages/DataStudio/BottomContainer/Tools/JsonToSql/index.tsx
+51
-40
service.tsx
...es/DataStudio/BottomContainer/Tools/JsonToSql/service.tsx
+3
-5
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Catalog/index.tsx
+325
-326
service.tsx
...eb/src/pages/DataStudio/LeftContainer/Catalog/service.tsx
+0
-1
index.tsx
.../pages/DataStudio/LeftContainer/Project/JobTree/index.tsx
+1
-0
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
+2
-2
route.tsx
dinky-web/src/pages/DataStudio/route.tsx
+6
-5
No files found.
dinky-web/src/components/CustomEditor/CodeShow/index.tsx
View file @
756d82bb
...
...
@@ -25,7 +25,7 @@ import { convertCodeEditTheme } from '@/utils/function';
import
{
Editor
,
useMonaco
}
from
'@monaco-editor/react'
;
import
{
editor
}
from
'monaco-editor'
;
import
{
EditorLanguage
}
from
'monaco-editor/esm/metadata'
;
import
{
CSSProperties
,
useEffect
,
useState
}
from
'react'
;
import
{
CSSProperties
,
useEffect
,
useState
}
from
'react'
;
import
FullscreenBtn
from
'../FullscreenBtn'
;
// loader.config({monaco});
...
...
@@ -245,7 +245,7 @@ const CodeShow = (props: CodeShowFormProps) => {
horizontalScrollbarSize
:
8
,
arrowSize
:
30
},
...
options
,
...
options
}
}
onMount=
{
editorDidMount
}
theme=
{
convertCodeEditTheme
()
}
...
...
dinky-web/src/locales/zh-CN/menu.ts
View file @
756d82bb
...
...
@@ -96,5 +96,4 @@ export default {
'menu.datastudio.tool.text-comparison'
:
'文本比对'
,
'menu.datastudio.tool.jsonToSql'
:
'JSON转Flink-SQL'
};
dinky-web/src/pages/DataStudio/BottomContainer/Tools/JsonToSql/index.tsx
View file @
756d82bb
import
React
,
{
useState
}
from
"react"
;
import
{
Button
,
Space
}
from
"antd"
;
import
CodeShow
from
"@/components/CustomEditor/CodeShow"
;
import
useThemeValue
from
"@/hooks/useThemeValue"
;
import
{
jsonToSql
}
from
"@/pages/DataStudio/BottomContainer/Tools/JsonToSql/service"
;
import
{
convertCodeEditTheme
}
from
"@/utils/function"
;
import
{
connect
}
from
"@@/exports"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
CodeEdit
from
"@/components/CustomEditor/CodeEdit"
;
import
CodeEdit
from
'@/components/CustomEditor/CodeEdit'
;
import
CodeShow
from
'@/components/CustomEditor/CodeShow'
;
import
useThemeValue
from
'@/hooks/useThemeValue'
;
import
{
jsonToSql
}
from
'@/pages/DataStudio/BottomContainer/Tools/JsonToSql/service'
;
import
{
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
convertCodeEditTheme
}
from
'@/utils/function'
;
import
{
connect
}
from
'@@/exports'
;
import
{
Button
,
Space
}
from
'antd'
;
import
React
,
{
useState
}
from
'react'
;
const
padding
=
10
;
const
JsonToSql
:
React
.
FC
=
(
props
:
connect
)
=>
{
const
{
height
}
=
props
;
const
maxHeight
=
height
-
36
-
(
padding
*
2
)
-
32
-
12
;
const
themeValue
=
useThemeValue
();
const
border
=
`1px solid
${
themeValue
.
borderColor
}
`
;
const
[
jsonData
,
setJsonData
]
=
useState
(
""
);
const
[
sqlData
,
setSqlData
]
=
useState
(
""
);
return
(
<
div
style=
{
{
padding
:
padding
}
}
>
<
Space
>
<
Button
children=
{
"Convert"
}
onClick=
{
()
=>
{
jsonToSql
({
"data"
:
jsonData
}).
then
(
setSqlData
)
}
}
/>
</
Space
>
const
JsonToSql
:
React
.
FC
=
(
props
:
connect
)
=>
{
const
{
height
}
=
props
;
const
maxHeight
=
height
-
36
-
padding
*
2
-
32
-
12
;
const
themeValue
=
useThemeValue
();
const
border
=
`1px solid
${
themeValue
.
borderColor
}
`
;
const
[
jsonData
,
setJsonData
]
=
useState
(
''
);
const
[
sqlData
,
setSqlData
]
=
useState
(
''
);
return
(
<
div
style=
{
{
padding
:
padding
}
}
>
<
Space
>
<
Button
children=
{
'Convert'
}
onClick=
{
()
=>
{
jsonToSql
({
data
:
jsonData
}).
then
(
setSqlData
);
}
}
/>
</
Space
>
<
div
style=
{
{
display
:
"flex"
,
paddingBlockStart
:
padding
}
}
>
<
div
style=
{
{
width
:
"50%"
,
border
}
}
>
<
CodeEdit
height=
{
maxHeight
+
"px"
}
code=
{
jsonData
}
language=
{
"json"
}
theme=
{
convertCodeEditTheme
()
}
onChange=
{
(
x
)
=>
{
setJsonData
(
x
??
""
);
}
}
/>
</
div
>
<
div
style=
{
{
width
:
"50%"
}
}
>
<
CodeShow
height=
{
maxHeight
}
code=
{
sqlData
}
language=
{
"json"
}
style=
{
{
border
}
}
options=
{
{
minimap
:
true
}
}
/>
</
div
>
</
div
>
<
div
style=
{
{
display
:
'flex'
,
paddingBlockStart
:
padding
}
}
>
<
div
style=
{
{
width
:
'50%'
,
border
}
}
>
<
CodeEdit
height=
{
maxHeight
+
'px'
}
code=
{
jsonData
}
language=
{
'json'
}
theme=
{
convertCodeEditTheme
()
}
onChange=
{
(
x
)
=>
{
setJsonData
(
x
??
''
);
}
}
/
>
</
div
>
)
}
<
div
style=
{
{
width
:
'50%'
}
}
>
<
CodeShow
height=
{
maxHeight
}
code=
{
sqlData
}
language=
{
'json'
}
style=
{
{
border
}
}
options=
{
{
minimap
:
true
}
}
/>
</
div
>
</
div
>
</
div
>
);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
height
:
Studio
.
bottomContainer
.
height
height
:
Studio
.
bottomContainer
.
height
}))(
JsonToSql
);
dinky-web/src/pages/DataStudio/BottomContainer/Tools/JsonToSql/service.tsx
View file @
756d82bb
import
{
postAll
}
from
"@/services/api"
;
import
{
postAll
}
from
'@/services/api'
;
export
async
function
jsonToSql
(
params
:
any
)
{
return
(
await
postAll
(
'/api/tools/jsonToFlinkSql'
,
params
)).
data
;
}
\ No newline at end of file
return
(
await
postAll
(
'/api/tools/jsonToFlinkSql'
,
params
)).
data
;
}
dinky-web/src/pages/DataStudio/LeftContainer/Catalog/index.tsx
View file @
756d82bb
...
...
@@ -17,358 +17,358 @@
*
*/
import
{
TableDataNode
}
from
'@/pages/DataStudio/LeftContainer/Catalog/data'
;
import
{
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
{
getCurrentData
}
from
'@/pages/DataStudio/function'
;
import
{
isSql
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
import
{
TableDataNode
}
from
'@/pages/DataStudio/LeftContainer/Catalog/data'
;
import
{
StateType
}
from
'@/pages/DataStudio/model'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
ColumnInfo
from
'@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/ColumnInfo'
;
import
TableInfo
from
'@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DIALECT
}
from
'@/services/constants'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
AppstoreOutlined
,
BlockOutlined
,
CodepenOutlined
,
DownOutlined
,
FunctionOutlined
,
TableOutlined
AppstoreOutlined
,
BlockOutlined
,
CodepenOutlined
,
DownOutlined
,
FunctionOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Button
,
Col
,
Empty
,
Modal
,
Row
,
Select
,
Spin
,
Tabs
}
from
'antd'
;
import
{
DataNode
}
from
'antd/es/tree'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Button
,
Col
,
Empty
,
Modal
,
Row
,
Select
,
Spin
,
Tabs
}
from
'antd'
;
import
{
DataNode
}
from
'antd/es/tree'
;
import
DirectoryTree
from
'antd/es/tree/DirectoryTree'
;
import
{
DefaultOptionType
}
from
'rc-select/lib/Select'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
getMSCatalogs
,
getMSColumns
,
getMSSchemaInfo
}
from
'./service'
;
import
{
getCurrentData
}
from
"@/pages/DataStudio/function"
;
import
{
DIALECT
}
from
"@/services/constants"
;
import
{
isSql
}
from
"@/pages/DataStudio/HeaderContainer/service"
;
import
{
connect
}
from
"@umijs/max"
;
import
{
DefaultOptionType
}
from
'rc-select/lib/Select'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
getMSCatalogs
,
getMSColumns
,
getMSSchemaInfo
}
from
'./service'
;
const
Catalog
:
React
.
FC
=
(
props
:
connect
)
=>
{
const
{
tabs
}
=
props
;
const
currentData
=
getCurrentData
(
tabs
.
panes
,
tabs
.
activeKey
);
if
(
!
currentData
)
{
return
<
Empty
description=
{
l
(
"pages.datastudio.catalog.selectDatasource"
)
}
/>
const
{
tabs
}
=
props
;
const
currentData
=
getCurrentData
(
tabs
.
panes
,
tabs
.
activeKey
);
if
(
!
currentData
)
{
return
<
Empty
description=
{
l
(
'pages.datastudio.catalog.selectDatasource'
)
}
/>;
}
const
dialect
=
currentData
?.
dialect
.
toLowerCase
()
??
''
;
const
fragment
=
currentData
?.
fragment
??
true
;
let
envId
:
number
|
undefined
;
let
databaseId
:
number
|
undefined
;
let
engine
:
string
|
undefined
;
if
(
dialect
===
DIALECT
.
FLINKSQLENV
)
{
envId
=
currentData
?.
id
;
engine
=
'Flink'
;
}
else
if
(
dialect
===
DIALECT
.
FLINK_SQL
)
{
envId
=
currentData
?.
envId
;
engine
=
'Flink'
;
}
else
if
(
isSql
(
dialect
))
{
databaseId
=
currentData
?.
databaseId
;
if
(
!
databaseId
)
{
return
<
Empty
description=
{
l
(
'pages.datastudio.catalog.openMission'
)
}
/>;
}
const
dialect
=
currentData
?.
dialect
.
toLowerCase
()
??
""
;
const
fragment
=
currentData
?.
fragment
??
true
;
let
envId
:
number
|
undefined
;
let
databaseId
:
number
|
undefined
;
let
engine
:
string
|
undefined
;
if
(
dialect
===
DIALECT
.
FLINKSQLENV
)
{
envId
=
currentData
?.
id
;
engine
=
"Flink"
;
}
else
if
(
dialect
===
DIALECT
.
FLINK_SQL
)
{
envId
=
currentData
?.
envId
;
engine
=
"Flink"
;
}
else
if
(
isSql
(
dialect
))
{
databaseId
=
currentData
?.
databaseId
;
if
(
!
databaseId
){
return
<
Empty
description=
{
l
(
"pages.datastudio.catalog.openMission"
)
}
/>
}
}
envId
=
envId
??
-
1
;
const
[
catalogSelect
,
setCatalogSelect
]
=
useState
<
DefaultOptionType
[]
>
([]);
const
[
catalog
,
setCatalog
]
=
useState
<
string
>
(
'default_catalog'
);
const
[
database
,
setDatabase
]
=
useState
<
string
>
(
''
);
const
[
table
,
setTable
]
=
useState
<
string
>
(
''
);
const
[
treeData
,
setTreeData
]
=
useState
<
DataNode
[]
>
([]);
const
[
modalVisit
,
setModalVisit
]
=
useState
(
false
);
const
[
row
,
setRow
]
=
useState
<
TableDataNode
>
();
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
columnData
,
setColumnData
]
=
useState
([]);
}
envId
=
envId
??
-
1
;
const
[
catalogSelect
,
setCatalogSelect
]
=
useState
<
DefaultOptionType
[]
>
([]);
const
[
catalog
,
setCatalog
]
=
useState
<
string
>
(
'default_catalog'
);
const
[
database
,
setDatabase
]
=
useState
<
string
>
(
''
);
const
[
table
,
setTable
]
=
useState
<
string
>
(
''
);
const
[
treeData
,
setTreeData
]
=
useState
<
DataNode
[]
>
([]);
const
[
modalVisit
,
setModalVisit
]
=
useState
(
false
);
const
[
row
,
setRow
]
=
useState
<
TableDataNode
>
();
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
columnData
,
setColumnData
]
=
useState
([]);
BtnRoute
[
'menu.datastudio.catalog'
][
0
].
onClick
=
()
=>
{
refreshMetaStoreTables
();
};
BtnRoute
[
'menu.datastudio.catalog'
][
0
].
onClick
=
()
=>
{
refreshMetaStoreTables
();
};
useEffect
(()
=>
{
getCatalogs
();
},
[
envId
,
databaseId
]);
useEffect
(()
=>
{
getCatalogs
();
},
[
envId
,
databaseId
]);
useEffect
(()
=>
{
if
(
table
)
{
setLoading
(
true
);
setColumnData
([]);
getMSColumns
({
envId
,
catalog
,
database
,
table
,
dialect
,
databaseId
}).
then
((
res
)
=>
{
setLoading
(
false
);
setColumnData
(
res
);
});
}
},
[
table
]);
useEffect
(()
=>
{
if
(
table
)
{
setLoading
(
true
);
setColumnData
([]);
getMSColumns
({
envId
,
catalog
,
database
,
table
,
dialect
,
databaseId
}).
then
((
res
)
=>
{
setLoading
(
false
);
setColumnData
(
res
);
});
}
},
[
table
]);
const
onRefreshTreeData
=
(
catalogAndDatabase
:
string
)
=>
{
setTreeData
([]);
setLoading
(
true
);
const
names
=
catalogAndDatabase
.
split
(
'.'
);
let
catalogTmp
=
'default_catalog'
;
let
databaseTmp
=
'default_database'
;
if
(
names
.
length
>
1
)
{
catalogTmp
=
names
[
0
];
databaseTmp
=
names
[
1
];
}
else
if
(
names
.
length
==
1
)
{
databaseTmp
=
names
[
0
];
const
onRefreshTreeData
=
(
catalogAndDatabase
:
string
)
=>
{
setTreeData
([]);
setLoading
(
true
);
const
names
=
catalogAndDatabase
.
split
(
'.'
);
let
catalogTmp
=
'default_catalog'
;
let
databaseTmp
=
'default_database'
;
if
(
names
.
length
>
1
)
{
catalogTmp
=
names
[
0
];
databaseTmp
=
names
[
1
];
}
else
if
(
names
.
length
==
1
)
{
databaseTmp
=
names
[
0
];
}
setCatalog
(
catalogTmp
);
setDatabase
(
databaseTmp
);
let
param
=
{
envId
:
envId
,
fragment
:
fragment
,
dialect
:
dialect
,
catalog
:
catalogTmp
,
database
:
databaseTmp
,
databaseId
};
const
result
=
getMSSchemaInfo
(
param
);
result
.
then
((
res
)
=>
{
setLoading
(
false
);
const
tables
:
any
[]
=
[];
if
(
res
.
tables
)
{
for
(
let
i
=
0
;
i
<
res
.
tables
.
length
;
i
++
)
{
tables
.
push
(
res
.
tables
[
i
]);
}
setCatalog
(
catalogTmp
);
setDatabase
(
databaseTmp
);
let
param
=
{
envId
:
envId
,
fragment
:
fragment
,
dialect
:
dialect
,
catalog
:
catalogTmp
,
database
:
databaseTmp
,
databaseId
};
const
result
=
getMSSchemaInfo
(
param
);
result
.
then
((
res
)
=>
{
setLoading
(
false
);
const
tables
:
any
[]
=
[];
if
(
res
.
tables
)
{
for
(
let
i
=
0
;
i
<
res
.
tables
.
length
;
i
++
)
{
tables
.
push
(
res
.
tables
[
i
]);
}
}
const
treeDataTmp
:
DataNode
[]
=
[];
const
tablesData
:
TableDataNode
[]
=
[];
for
(
const
t
of
tables
)
{
tablesData
.
push
({
title
:
t
.
name
,
key
:
t
.
name
,
icon
:
<
TableOutlined
/>,
isLeaf
:
true
,
isTable
:
true
,
name
:
t
.
name
,
schema
:
databaseTmp
,
catalog
:
catalog
,
comment
:
t
.
comment
,
type
:
t
.
type
,
engine
:
engine
??
t
.
engine
,
options
:
t
.
options
,
rows
:
t
.
rows
,
createTime
:
t
.
createTime
,
updateTime
:
t
.
updateTime
});
}
treeDataTmp
.
push
({
title
:
'tables'
,
key
:
'tables'
,
children
:
tablesData
});
}
const
treeDataTmp
:
DataNode
[]
=
[];
const
tablesData
:
TableDataNode
[]
=
[];
for
(
const
t
of
tables
)
{
tablesData
.
push
({
title
:
t
.
name
,
key
:
t
.
name
,
icon
:
<
TableOutlined
/>,
isLeaf
:
true
,
isTable
:
true
,
name
:
t
.
name
,
schema
:
databaseTmp
,
catalog
:
catalog
,
comment
:
t
.
comment
,
type
:
t
.
type
,
engine
:
engine
??
t
.
engine
,
options
:
t
.
options
,
rows
:
t
.
rows
,
createTime
:
t
.
createTime
,
updateTime
:
t
.
updateTime
});
}
treeDataTmp
.
push
({
title
:
'tables'
,
key
:
'tables'
,
children
:
tablesData
});
const
viewsData
:
DataNode
[]
=
[];
if
(
res
.
views
)
{
for
(
let
i
=
0
;
i
<
res
.
views
.
length
;
i
++
)
{
viewsData
.
push
({
title
:
res
.
views
[
i
],
key
:
res
.
views
[
i
],
icon
:
<
BlockOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'views'
,
key
:
'views'
,
children
:
viewsData
});
const
viewsData
:
DataNode
[]
=
[];
if
(
res
.
views
)
{
for
(
let
i
=
0
;
i
<
res
.
views
.
length
;
i
++
)
{
viewsData
.
push
({
title
:
res
.
views
[
i
],
key
:
res
.
views
[
i
],
icon
:
<
BlockOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'views'
,
key
:
'views'
,
children
:
viewsData
});
const
functionsData
:
DataNode
[]
=
[];
if
(
res
.
functions
)
{
for
(
let
i
=
0
;
i
<
res
.
functions
.
length
;
i
++
)
{
functionsData
.
push
({
title
:
res
.
functions
[
i
],
key
:
res
.
functions
[
i
],
icon
:
<
FunctionOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'functions'
,
key
:
'functions'
,
children
:
functionsData
});
const
functionsData
:
DataNode
[]
=
[];
if
(
res
.
functions
)
{
for
(
let
i
=
0
;
i
<
res
.
functions
.
length
;
i
++
)
{
functionsData
.
push
({
title
:
res
.
functions
[
i
],
key
:
res
.
functions
[
i
],
icon
:
<
FunctionOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'functions'
,
key
:
'functions'
,
children
:
functionsData
});
const
userFunctionsData
:
DataNode
[]
=
[];
if
(
res
.
userFunctions
)
{
for
(
let
i
=
0
;
i
<
res
.
userFunctions
.
length
;
i
++
)
{
userFunctionsData
.
push
({
title
:
res
.
userFunctions
[
i
],
key
:
res
.
userFunctions
[
i
],
icon
:
<
FunctionOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'user functions'
,
key
:
'userFunctions'
,
children
:
userFunctionsData
});
const
userFunctionsData
:
DataNode
[]
=
[];
if
(
res
.
userFunctions
)
{
for
(
let
i
=
0
;
i
<
res
.
userFunctions
.
length
;
i
++
)
{
userFunctionsData
.
push
({
title
:
res
.
userFunctions
[
i
],
key
:
res
.
userFunctions
[
i
],
icon
:
<
FunctionOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'user functions'
,
key
:
'userFunctions'
,
children
:
userFunctionsData
});
const
modulesData
:
DataNode
[]
=
[];
if
(
res
.
modules
)
{
for
(
let
i
=
0
;
i
<
res
.
modules
.
length
;
i
++
)
{
modulesData
.
push
({
title
:
res
.
modules
[
i
],
key
:
res
.
modules
[
i
],
icon
:
<
AppstoreOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'modules'
,
key
:
'modules'
,
children
:
modulesData
});
const
modulesData
:
DataNode
[]
=
[];
if
(
res
.
modules
)
{
for
(
let
i
=
0
;
i
<
res
.
modules
.
length
;
i
++
)
{
modulesData
.
push
({
title
:
res
.
modules
[
i
],
key
:
res
.
modules
[
i
],
icon
:
<
AppstoreOutlined
/>,
isLeaf
:
true
});
}
}
treeDataTmp
.
push
({
title
:
'modules'
,
key
:
'modules'
,
children
:
modulesData
});
setTreeData
(
treeDataTmp
);
});
};
setTreeData
(
treeDataTmp
);
});
};
const
getCatalogs
=
()
=>
{
if
(
envId
||
databaseId
)
{
setLoading
(
true
);
setTreeData
([]);
setCatalogSelect
([]);
setDatabase
(
''
);
let
param
=
{
envId
:
envId
,
fragment
:
fragment
,
dialect
:
dialect
,
databaseId
const
getCatalogs
=
()
=>
{
if
(
envId
||
databaseId
)
{
setLoading
(
true
);
setTreeData
([]);
setCatalogSelect
([]);
setDatabase
(
''
);
let
param
=
{
envId
:
envId
,
fragment
:
fragment
,
dialect
:
dialect
,
databaseId
};
getMSCatalogs
(
param
).
then
((
d
)
=>
{
setCatalogSelect
(
(
d
as
any
[]).
map
((
item
)
=>
{
setLoading
(
false
);
return
{
label
:
item
.
name
,
options
:
(
item
.
schemas
as
any
[]).
map
((
schema
)
=>
{
return
{
label
:
schema
.
name
,
value
:
item
.
name
+
'.'
+
schema
.
name
};
})
};
getMSCatalogs
(
param
).
then
((
d
)
=>
{
setCatalogSelect
(
(
d
as
any
[]).
map
((
item
)
=>
{
setLoading
(
false
);
return
{
label
:
item
.
name
,
options
:
(
item
.
schemas
as
any
[]).
map
((
schema
)
=>
{
return
{
label
:
schema
.
name
,
value
:
item
.
name
+
'.'
+
schema
.
name
};
})
};
})
);
});
}
})
);
});
}
};
const
refreshMetaStoreTables
=
()
=>
{
if
(
database
)
{
onRefreshTreeData
(
catalog
+
'.'
+
database
);
}
else
{
getCatalogs
();
}
};
const
refreshMetaStoreTables
=
()
=>
{
if
(
database
)
{
onRefreshTreeData
(
catalog
+
'.'
+
database
);
}
else
{
getCatalogs
();
}
};
const
onChangeMetaStoreCatalogs
=
(
value
:
string
)
=>
{
onRefreshTreeData
(
value
);
};
const
onChangeMetaStoreCatalogs
=
(
value
:
string
)
=>
{
onRefreshTreeData
(
value
);
};
const
openColumnInfo
=
(
_e
:
React
.
MouseEvent
,
node
:
TableDataNode
)
=>
{
if
(
node
.
isLeaf
&&
node
.
isTable
)
{
setTable
(
node
.
name
);
setRow
(
node
);
setModalVisit
(
true
);
}
};
const
openColumnInfo
=
(
_e
:
React
.
MouseEvent
,
node
:
TableDataNode
)
=>
{
if
(
node
.
isLeaf
&&
node
.
isTable
)
{
setTable
(
node
.
name
);
setRow
(
node
);
setModalVisit
(
true
);
}
};
const
cancelHandle
=
()
=>
{
setRow
(
undefined
);
setModalVisit
(
false
);
};
const
cancelHandle
=
()
=>
{
setRow
(
undefined
);
setModalVisit
(
false
);
};
return
(
<
Spin
spinning=
{
loading
}
>
<
div
style=
{
{
paddingInline
:
10
,
paddingBlock
:
5
}
}
>
<
Row
style=
{
{
paddingBlock
:
10
}
}
>
<
Col
span=
{
24
}
>
<
Select
value=
{
database
?
database
:
null
}
style=
{
{
width
:
'100%'
}
}
placeholder=
{
l
(
'pages.datastudio.catalog.catalogSelect'
)
}
optionLabelProp=
'label'
onChange=
{
onChangeMetaStoreCatalogs
}
options=
{
catalogSelect
}
/>
</
Col
>
</
Row
>
return
(
<
Spin
spinning=
{
loading
}
>
<
div
style=
{
{
paddingInline
:
10
,
paddingBlock
:
5
}
}
>
<
Row
style=
{
{
paddingBlock
:
10
}
}
>
<
Col
span=
{
24
}
>
<
Select
value=
{
database
?
database
:
null
}
style=
{
{
width
:
'100%'
}
}
placeholder=
{
l
(
'pages.datastudio.catalog.catalogSelect'
)
}
optionLabelProp=
'label'
onChange=
{
onChangeMetaStoreCatalogs
}
options=
{
catalogSelect
}
/>
</
Col
>
</
Row
>
{
treeData
.
length
>
0
?
(
<
DirectoryTree
showIcon
switcherIcon=
{
<
DownOutlined
/>
}
treeData=
{
treeData
}
onRightClick=
{
({
event
,
node
}:
any
)
=>
{
openColumnInfo
(
event
,
node
);
}
}
/>
)
:
(
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
)
}
</
div
>
<
Modal
title=
{
<>
{
row
?.
key
}
</>
??
<></>
}
open=
{
modalVisit
}
width=
{
10000
}
onCancel=
{
()
=>
{
cancelHandle
();
}
}
footer=
{
[
<
Button
key=
'back'
onClick=
{
()
=>
{
cancelHandle
();
}
}
>
{
l
(
'button.close'
)
}
</
Button
>
]
}
>
<
Tabs
defaultActiveKey=
'tableInfo'
size=
'small'
items=
{
[
{
key
:
'tableInfo'
,
label
:
(
<
span
>
<
TableOutlined
/>
{
l
(
'pages.datastudio.catalog.tableInfo'
)
}
{
treeData
.
length
>
0
?
(
<
DirectoryTree
showIcon
switcherIcon=
{
<
DownOutlined
/>
}
treeData=
{
treeData
}
onRightClick=
{
({
event
,
node
}:
any
)
=>
{
openColumnInfo
(
event
,
node
);
}
}
/>
)
:
(
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
)
}
</
div
>
<
Modal
title=
{
<>
{
row
?.
key
}
</>
??
<></>
}
open=
{
modalVisit
}
width=
{
10000
}
onCancel=
{
()
=>
{
cancelHandle
();
}
}
footer=
{
[
<
Button
key=
'back'
onClick=
{
()
=>
{
cancelHandle
();
}
}
>
{
l
(
'button.close'
)
}
</
Button
>
]
}
>
<
Tabs
defaultActiveKey=
'tableInfo'
size=
'small'
items=
{
[
{
key
:
'tableInfo'
,
label
:
(
<
span
>
<
TableOutlined
/>
{
l
(
'pages.datastudio.catalog.tableInfo'
)
}
</
span
>
),
children
:
row
?
(
<
TableInfo
tableInfo=
{
row
}
/>
)
:
(
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
)
},
{
key
:
'columnsInfo'
,
label
:
(
<
span
>
<
CodepenOutlined
/>
{
l
(
'pages.datastudio.catalog.fieldInformation'
)
}
),
children
:
row
?
(
<
TableInfo
tableInfo=
{
row
}
/>
)
:
(
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
)
},
{
key
:
'columnsInfo'
,
label
:
(
<
span
>
<
CodepenOutlined
/>
{
l
(
'pages.datastudio.catalog.fieldInformation'
)
}
</
span
>
),
children
:
<
Spin
spinning=
{
loading
}
>
{
<
ColumnInfo
columnInfo=
{
columnData
}
/>
}
</
Spin
>
}
]
}
/>
</
Modal
>
</
Spin
>
);
),
children
:
<
Spin
spinning=
{
loading
}
>
{
<
ColumnInfo
columnInfo=
{
columnData
}
/>
}
</
Spin
>
}
]
}
/>
</
Modal
>
</
Spin
>
);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
tabs
:
Studio
.
tabs
}))(
Catalog
);
\ No newline at end of file
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
tabs
:
Studio
.
tabs
}))(
Catalog
);
dinky-web/src/pages/DataStudio/LeftContainer/Catalog/service.tsx
View file @
756d82bb
...
...
@@ -19,7 +19,6 @@
import
{
StudioMetaStoreParam
}
from
'@/pages/DataStudio/LeftContainer/Catalog/data'
;
import
{
postAll
}
from
'@/services/api'
;
import
{
getDataByParamsReturnResult
}
from
'@/services/BusinessCrud'
;
export
async
function
getMSSchemaInfo
(
params
:
StudioMetaStoreParam
)
{
return
(
await
postAll
(
'/api/studio/getMSSchemaInfo'
,
params
)).
data
;
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/JobTree/index.tsx
View file @
756d82bb
...
...
@@ -148,6 +148,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
onSelect=
{
(
_
,
info
)
=>
onNodeClick
(
info
)
}
onRightClick=
{
onRightClick
}
expandedKeys=
{
expandKeys
}
expandAction=
{
'doubleClick'
}
selectedKeys=
{
selectKey
}
onExpand=
{
onExpand
}
treeData=
{
data
}
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
View file @
756d82bb
...
...
@@ -103,7 +103,7 @@ const Project: React.FC = (props: connect) => {
const
onExpand
=
(
expandedKeys
:
Key
[])
=>
{
dispatch
({
type
:
STUDIO_MODEL
.
updateProjectExpandKey
,
payload
:
[...
expandedKeys
,
...
expandKeys
]
payload
:
expandedKeys
});
};
...
...
@@ -124,7 +124,7 @@ const Project: React.FC = (props: connect) => {
dispatch
({
type
:
STUDIO_MODEL
.
updateProjectSelectKey
,
payload
:
[
key
]
});
if
(
!
isLeaf
)
{
dispatch
({
type
:
STUDIO_MODEL
.
updateProjectExpandKey
,
payload
:
[
key
,
...
expandKeys
]
});
dispatch
({
type
:
STUDIO_MODEL
.
updateProjectExpandKey
,
payload
:
[
...
expandKeys
,
key
]
});
return
;
}
...
...
dinky-web/src/pages/DataStudio/route.tsx
View file @
756d82bb
...
...
@@ -22,7 +22,9 @@ import Console from '@/pages/DataStudio/BottomContainer/Console';
import
Lineage
from
'@/pages/DataStudio/BottomContainer/Lineage'
;
import
Result
from
'@/pages/DataStudio/BottomContainer/Result'
;
import
TableData
from
'@/pages/DataStudio/BottomContainer/TableData'
;
import
JsonToSql
from
'@/pages/DataStudio/BottomContainer/Tools/JsonToSql'
;
import
{
isSql
}
from
'@/pages/DataStudio/HeaderContainer/service'
;
import
Catalog
from
'@/pages/DataStudio/LeftContainer/Catalog'
;
import
DataSource
from
'@/pages/DataStudio/LeftContainer/DataSource'
;
import
Project
from
'@/pages/DataStudio/LeftContainer/Project'
;
import
{
TabsPageSubType
,
TabsPageType
}
from
'@/pages/DataStudio/model'
;
...
...
@@ -50,7 +52,8 @@ import {
PlusCircleOutlined
,
PlusOutlined
,
ReloadOutlined
,
RightSquareOutlined
,
RotateRightOutlined
,
RightSquareOutlined
,
RotateRightOutlined
,
SettingOutlined
,
ShrinkOutlined
,
TableOutlined
,
...
...
@@ -58,8 +61,6 @@ import {
}
from
'@ant-design/icons'
;
import
{
DiffEditor
}
from
'@monaco-editor/react'
;
import
{
ReactNode
}
from
'react'
;
import
Catalog
from
"@/pages/DataStudio/LeftContainer/Catalog"
;
import
JsonToSql
from
"@/pages/DataStudio/BottomContainer/Tools/JsonToSql"
;
export
const
LeftSide
=
[
{
...
...
@@ -218,8 +219,8 @@ export const LeftBottomMoreTabs: { [c: string]: TabProp[] } = {
},
{
key
:
'menu.datastudio.tool.jsonToSql'
,
icon
:<
RotateRightOutlined
/>,
label
:
l
(
"menu.datastudio.tool.jsonToSql"
),
icon
:
<
RotateRightOutlined
/>,
label
:
l
(
'menu.datastudio.tool.jsonToSql'
),
children
:
<
JsonToSql
/>
}
]
...
...
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