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
32f03fba
Unverified
Commit
32f03fba
authored
Apr 06, 2023
by
Licho
Committed by
GitHub
Apr 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: multi tab to display watch table information. (#1858)
parent
7e48aae6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
70 deletions
+122
-70
index.tsx
.../src/components/Studio/StudioConsole/StudioData/index.tsx
+88
-31
index.tsx
dlink-web/src/components/Studio/StudioConsole/index.tsx
+33
-31
stompClientUtil.ts
dlink-web/src/utils/stompClientUtil.ts
+1
-8
No files found.
dlink-web/src/components/Studio/StudioConsole/StudioData/index.tsx
View file @
32f03fba
...
...
@@ -17,61 +17,118 @@
*
*/
import
{
Input
,
Space
}
from
"antd"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
{
Input
,
Modal
,
Tabs
}
from
"antd"
;
import
{
registerWatchTable
,
unRegisterWatchTable
}
from
"@/pages/DataStudio/service"
;
import
{
connect
}
from
"umi"
;
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
Component
,
useEffect
,
useState
}
from
"react"
;
import
stompClientUtil
from
"@/utils/stompClientUtil"
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
CodeShow
from
"@/components/Common/CodeShow"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
clearConsole
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
{
connect
}
from
"umi"
;
import
{
Subscription
}
from
"stompjs"
;
import
TabPane
=
Tabs
.
TabPane
;
const
{
Search
}
=
Input
;
const
StudioData
=
(
props
:
any
)
=>
{
const
{
height
,
isActive
}
=
props
;
const
DatePage
=
(
props
:
any
)
=>
{
const
{
height
,
title
}
=
props
;
const
{
stompClient
}
=
props
;
const
[
subScription
,
setSubScription
]
=
useState
<
Subscription
>
();
const
[
consoleInfo
,
setConsoleInfo
]
=
useState
<
string
>
(
""
);
const
preConsoleInfo
=
useRef
(
consoleInfo
)
const
[
tableName
,
setTableName
]
=
useState
<
string
>
(
""
);
const
preTableNameRef
=
useRef
(
tableName
)
let
consoleHeight
=
(
height
-
37.6
);
const
id
=
Number
(
localStorage
.
getItem
(
'dlink-tenantId'
));
const
onSearchName
=
(
value
:
string
)
=>
{
unRegisterWatchTable
({
id
,
table
:
preTableNameRef
.
current
}).
then
(
res
=>
{
setConsoleInfo
(
""
)
stompClientUtil
.
unsubscribe
();
registerWatchTable
({
id
,
table
:
value
}).
then
(
res
=>
{
stompClientUtil
.
subScription
=
stompClientUtil
.
stompClient
.
subscribe
(
res
.
msg
,
(
res
:
any
)
=>
{
preConsoleInfo
.
current
=
preConsoleInfo
.
current
+
"
\
n"
+
res
.
body
if
(
preConsoleInfo
.
current
.
length
>
1024
*
1024
)
{
preConsoleInfo
.
current
=
preConsoleInfo
.
current
.
substring
(
1024
,
preConsoleInfo
.
current
.
length
)
}
setConsoleInfo
(
preConsoleInfo
.
current
);
})
})
registerWatchTable
({
id
,
table
:
value
}).
then
(
res
=>
{
let
ss
=
stompClient
.
subscribe
(
res
.
msg
,
(
res
:
any
)
=>
{
setConsoleInfo
(
preConsoleInfo
=>
preConsoleInfo
+
"
\
n"
+
res
.
body
);
});
setSubScription
(
ss
);
})
setTableName
(
value
)
};
useEffect
(()
=>
{
stompClientUtil
.
connect
();
},
[
isActive
])
return
()
=>
unRegisterWatchTable
({
id
,
table
:
tableName
}).
then
(
res
=>
{
console
.
log
(
"unsubscribe: "
+
tableName
)
subScription
?.
unsubscribe
();
});
},
[
subScription
]);
const
editorDidMountHandle
=
(
editor
:
any
,
monaco
:
any
)
=>
{
onSearchName
(
title
);
editor
.
addAction
({
id
:
'btn-studio-data-clear'
,
label
:
l
(
'pages.datastudio.editor.clearConsole'
),
contextMenuGroupId
:
'9_cutcopypaste'
,
run
:
()
=>
{
clearConsole
().
then
((
result
)
=>
{
setConsoleInfo
(
""
)
});
},
})
};
return
(<
div
style=
{
{
width
:
'100%'
}
}
>
<
Space
direction=
"horizontal"
style=
{
{
margin
:
10
}
}
>
<
Search
placeholder=
"table name"
onSearch=
{
onSearchName
}
style=
{
{
width
:
200
}
}
/>
</
Space
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
CodeShow
code=
{
consoleInfo
}
language=
'text'
height=
{
height
}
theme=
"vs-dark"
/>
<
CodeShow
code=
{
consoleInfo
}
language=
'text'
height=
{
height
}
theme=
"vs-dark"
editorDidMountHandle=
{
editorDidMountHandle
}
/>
</
Scrollbars
>
</
div
>)
};
const
StudioData
=
(
props
:
any
)
=>
{
const
{
height
,
isActive
}
=
props
;
const
[
panes
,
setPanes
]
=
useState
<
[{
title
:
string
,
key
:
string
,
content
:
Component
}]
>
([]);
const
addTab
=
()
=>
{
let
title
:
string
Modal
.
confirm
({
title
:
'Please enter table name'
,
content
:
<
Input
onChange=
{
e
=>
title
=
e
.
target
.
value
}
/>,
onOk
()
{
const
activeKey
=
`
${
panes
.
length
+
1
}
`
;
const
newPanes
=
[...
panes
];
newPanes
.
push
({
title
:
title
,
content
:
<
DatePage
height=
{
height
}
title=
{
title
}
stompClient=
{
stompClientUtil
.
stompClient
}
/>,
key
:
activeKey
});
setPanes
(
newPanes
);
}
});
};
useEffect
(()
=>
{
stompClientUtil
.
connect
();
},
[
isActive
])
useEffect
(()
=>
{
return
()
=>
{
stompClientUtil
.
disconnect
();
}
},
[])
return
(<>
<
Tabs
type=
"editable-card"
onEdit=
{
(
targetKey
,
action
)
=>
{
if
(
action
===
'add'
)
{
addTab
();
}
else
if
(
action
===
'remove'
)
{
const
newPanes
=
panes
.
filter
((
pane
)
=>
pane
.
key
!==
targetKey
);
setPanes
(
newPanes
);
}
}
}
>
{
panes
.
map
((
pane
)
=>
(
<
TabPane
tab=
{
pane
.
title
}
key=
{
pane
.
key
}
>
{
pane
.
content
}
</
TabPane
>
))
}
</
Tabs
>
</>);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
current
:
Studio
.
current
,
}))(
StudioData
);
dlink-web/src/components/Studio/StudioConsole/index.tsx
View file @
32f03fba
...
...
@@ -18,35 +18,36 @@
*/
import
{
Empty
,
Tabs
}
from
"antd"
;
import
{
Button
,
Empty
,
Tabs
}
from
"antd"
;
import
{
ApartmentOutlined
,
BarChartOutlined
,
CalendarOutlined
,
CodeOutlined
,
DesktopOutlined
,
PrinterOutlined
,
DesktopOutlined
,
PrinterOutlined
,
TableOutlined
}
from
"@ant-design/icons"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
{
connect
}
from
"umi"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
{
connect
}
from
"umi"
;
import
StudioMsg
from
"./StudioMsg"
;
import
StudioTable
from
"./StudioTable"
;
import
StudioHistory
from
"./StudioHistory"
;
import
StudioData
from
"./StudioData"
import
StudioCA
from
"./StudioCA"
;
import
StudioProcess
from
"./StudioProcess"
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
Chart
from
"@/components/Chart"
;
import
React
,
{
useState
}
from
"react"
;
import
{
l
}
from
"@/utils/intl"
;
import
React
,
{
useState
}
from
"react"
;
import
{
l
}
from
"@/utils/intl"
;
const
{
TabPane
}
=
Tabs
;
const
StudioConsole
=
(
props
:
any
)
=>
{
const
{
TabPane
}
=
Tabs
;
const
StudioConsole
=
(
props
:
any
)
=>
{
const
{
height
,
current
}
=
props
;
const
{
height
,
current
}
=
props
;
let
consoleHeight
=
(
height
-
37.6
);
const
[
activeKey
,
setActiveKey
]
=
useState
<
string
>
(
"StudioMsg"
);
...
...
@@ -55,103 +56,104 @@ const StudioConsole = (props: any) => {
}
return
(
<
Tabs
defaultActiveKey=
"StudioMsg"
size=
"small"
tabPosition=
"top"
style=
{
{
border
:
"1px solid #f0f0f0"
,
height
:
height
,
margin
:
"0 32px"
}
}
onChange=
{
onTabsChange
}
>
<
TabPane
tab=
{
<
span
>
<
CodeOutlined
/>
<
CodeOutlined
/>
{
l
(
'pages.datastudio.label.info'
)
}
</
span
>
}
key=
"StudioMsg"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioMsg
height=
{
consoleHeight
}
isActive=
{
activeKey
===
"StudioMsg"
}
/>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioMsg
height=
{
consoleHeight
}
isActive=
{
activeKey
===
"StudioMsg"
}
/>
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
TableOutlined
/>
<
TableOutlined
/>
{
l
(
'pages.datastudio.label.result'
)
}
</
span
>
}
key=
"StudioTable"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
StudioTable
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
StudioTable
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
BarChartOutlined
/>
<
BarChartOutlined
/>
BI
</
span
>
}
key=
"StudioChart"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
Chart
height=
{
consoleHeight
}
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
Chart
height=
{
consoleHeight
}
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
ApartmentOutlined
/>
<
ApartmentOutlined
/>
{
l
(
'pages.datastudio.label.lineage'
)
}
</
span
>
}
key=
"StudioConsanguinity"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
StudioCA
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
current
?
<
StudioCA
/>
:
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
}
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
DesktopOutlined
/>
<
DesktopOutlined
/>
{
l
(
'pages.datastudio.label.process'
)
}
</
span
>
}
key=
"StudioProcess"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioProcess
/>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioProcess
/>
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
CalendarOutlined
/>
<
CalendarOutlined
/>
{
l
(
'pages.datastudio.label.history'
)
}
</
span
>
}
key=
"StudioHistory"
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioHistory
/>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
StudioHistory
/>
</
Scrollbars
>
</
TabPane
>
<
TabPane
tab=
{
<
span
>
<
PrinterOutlined
/>
<
PrinterOutlined
/>
{
l
(
'pages.datastudio.label.data'
)
}
</
span
>
}
key=
"StudioData"
>
<
StudioData
height=
{
consoleHeight
}
isActive=
{
activeKey
===
"StudioData"
}
/>
<
StudioData
height=
{
consoleHeight
}
isActive=
{
activeKey
===
"StudioData"
}
/>
</
TabPane
>
</
Tabs
>
);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
sql
:
Studio
.
sql
,
current
:
Studio
.
current
,
}))(
StudioConsole
);
dlink-web/src/utils/stompClientUtil.ts
View file @
32f03fba
...
...
@@ -4,13 +4,11 @@ import Stomp, { Subscription } from "stompjs";
class
StompClientUtil
{
stompClient
:
Stomp
.
Client
;
connectStatus
:
boolean
;
subScription
:
Subscription
;
constructor
()
{
const
baseUrl
=
"ws://127.0.0.1:8888/stomp"
;
const
socket
=
new
WebSocket
(
baseUrl
);
this
.
stompClient
=
Stomp
.
over
(
socket
);
this
.
connectStatus
=
false
;
this
.
subScription
=
{
id
:
""
,
unsubscribe
:
()
=>
{
}
};
this
.
connect
();
}
...
...
@@ -28,7 +26,7 @@ class StompClientUtil {
);
}
close
()
{
disconnect
()
{
if
(
this
.
stompClient
)
{
this
.
stompClient
.
disconnect
(()
=>
{
console
.
log
(
"============connect release============"
);
...
...
@@ -36,10 +34,5 @@ class StompClientUtil {
});
}
}
unsubscribe
()
{
this
.
subScription
.
unsubscribe
()
this
.
subScription
=
{
id
:
""
,
unsubscribe
:
()
=>
{
}
};
}
}
export
default
new
StompClientUtil
()
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