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
33a54d12
Unverified
Commit
33a54d12
authored
Mar 27, 2023
by
Licho
Committed by
GitHub
Mar 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: append receive data (#1785)
parent
7471ba6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
99 deletions
+73
-99
index.tsx
.../src/components/Studio/StudioConsole/StudioData/index.tsx
+28
-32
stompClient.ts
dlink-web/src/utils/stompClient.ts
+0
-66
stompClientUtil.ts
dlink-web/src/utils/stompClientUtil.ts
+45
-0
pom.xml
pom.xml
+0
-1
No files found.
dlink-web/src/components/Studio/StudioConsole/StudioData/index.tsx
View file @
33a54d12
...
@@ -17,65 +17,61 @@
...
@@ -17,65 +17,61 @@
*
*
*/
*/
import
{
Input
,
Space
}
from
"antd"
;
import
{
Input
,
Space
}
from
"antd"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
const
{
Search
}
=
Input
;
import
{
registerWatchTable
,
unRegisterWatchTable
}
from
"@/pages/DataStudio/service"
;
import
{
connect
}
from
"umi"
;
import
{
StateType
}
from
"@/pages/DataStudio/model"
;
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
registerWatchTable
,
unRegisterWatchTable
}
from
"@/pages/DataStudio/service"
;
import
stompClientUtil
from
"@/utils/stompClientUtil"
import
{
connect
}
from
"umi"
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
{
useEffect
,
useState
,
useRef
}
from
"react"
;
import
stompClient
from
"@/utils/stompClient"
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
CodeShow
from
"@/components/Common/CodeShow"
;
import
CodeShow
from
"@/components/Common/CodeShow"
;
const
{
Search
}
=
Input
;
const
StudioData
=
(
props
:
any
)
=>
{
const
StudioData
=
(
props
:
any
)
=>
{
const
{
height
,
isActive
}
=
props
;
const
{
height
,
isActive
}
=
props
;
const
[
consoleInfo
,
setConsoleInfo
]
=
useState
<
string
>
(
""
);
const
[
consoleInfo
,
setConsoleInfo
]
=
useState
<
string
>
(
""
);
const
preConsoleInfo
=
useRef
(
consoleInfo
)
const
[
tableName
,
setTableName
]
=
useState
<
string
>
(
""
);
const
[
tableName
,
setTableName
]
=
useState
<
string
>
(
""
);
const
preTableNameRef
=
useRef
(
tableName
)
const
preTableNameRef
=
useRef
(
tableName
)
const
preTableName
=
preTableNameRef
.
current
let
consoleHeight
=
(
height
-
37.6
);
let
consoleHeight
=
(
height
-
37.6
);
const
id
=
Number
(
localStorage
.
getItem
(
'dlink-tenantId'
));
const
id
=
Number
(
localStorage
.
getItem
(
'dlink-tenantId'
));
const
onSearchName
=
(
value
:
string
)
=>
{
const
onSearchName
=
(
value
:
string
)
=>
{
unRegisterWatchTable
({
id
,
table
:
preTableName
}).
then
(
res
=>
{
unRegisterWatchTable
({
id
,
table
:
preTableNameRef
.
current
}).
then
(
res
=>
{
setConsoleInfo
(
""
)
setConsoleInfo
(
""
)
stompClient
.
unsubscribe
();
stompClientUtil
.
unsubscribe
();
registerWatchTable
({
id
,
table
:
value
}).
then
(
res
=>
{
registerWatchTable
({
id
,
table
:
value
}).
then
(
res
=>
{
stompClient
.
subObj
=
stompClient
.
mqClient
.
subscribe
(
res
.
msg
,
(
res
)
=>
{
stompClientUtil
.
subScription
=
stompClientUtil
.
stompClient
.
subscribe
(
res
.
msg
,
(
res
:
any
)
=>
{
setConsoleInfo
(
consoleInfo
+
res
.
body
)
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
);
})
})
})
})
})
})
setTableName
(
value
)
setTableName
(
value
)
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
stompClient
.
con
();
stompClientUtil
.
connect
();
},
[
isActive
])
},
[
isActive
])
return
(<
div
style=
{
{
width
:
'100%'
}
}
>
<
Space
direction=
"horizontal"
style=
{
{
margin
:
10
}
}
>
<
Search
placeholder=
"请输入表名"
onSearch=
{
onSearchName
}
style=
{
{
width
:
200
}
}
/>
return
(<
div
style=
{
{
width
:
'100%'
}
}
>
<
Space
direction=
"horizontal"
style=
{
{
margin
:
10
}
}
>
<
Search
placeholder=
"table name"
onSearch=
{
onSearchName
}
style=
{
{
width
:
200
}
}
/>
</
Space
>
</
Space
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
<
Scrollbars
style=
{
{
height
:
consoleHeight
}
}
>
{
/* <CodeShow code={consoleInfo} language='Markdown' height={height} theme="vs" /> */
}
<
CodeShow
code=
{
consoleInfo
}
language=
'text'
height=
{
height
}
theme=
"vs-dark"
/>
<
CodeShow
code=
{
JSON
.
stringify
((
consoleInfo
?
consoleInfo
:
""
),
null
,
"
\
t"
)
}
language=
'json'
height=
{
height
}
theme=
"vs-dark"
/>
</
Scrollbars
>
</
Scrollbars
>
</
div
>)
</
div
>)
};
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
current
:
Studio
.
current
,
current
:
Studio
.
current
,
}))(
StudioData
);
}))(
StudioData
);
dlink-web/src/utils/stompClient.ts
deleted
100644 → 0
View file @
7471ba6f
import
{
reject
}
from
"lodash"
;
import
Stomp
,
{
Subscription
}
from
"stompjs"
;
interface
SocketRes
{
body
:
string
,
ack
?:
()
=>
{},
command
?:
string
,
headers
?:
object
,
nack
?:
()
=>
{},
}
export
let
stompClient
:
Stomp
.
Client
;
let
connetStatus
=
false
;
class
MyStompClient
{
mqClient
:
Stomp
.
Client
;
connetStatus
:
boolean
;
subObj
:
Subscription
;
constructor
()
{
const
baseUrl
=
"ws://127.0.0.1:8888/stomp"
;
let
socket
=
new
WebSocket
(
baseUrl
);
this
.
mqClient
=
Stomp
.
over
(
socket
);
this
.
connetStatus
=
false
;
this
.
subObj
=
{
id
:
""
,
unsubscribe
:
()
=>
{
}
};
this
.
con
();
}
con
()
{
this
.
mqClient
.
connect
(
{},
()
=>
{
this
.
connetStatus
=
true
;
console
.
log
(
"connectsuccess>>>>>>>>>>>>>>>>>>>"
);
},
(
err
:
any
)
=>
{
console
.
log
(
"error"
);
console
.
log
(
err
);
}
);
}
close
()
{
if
(
this
.
mqClient
)
{
this
.
mqClient
.
disconnect
(()
=>
{
console
.
log
(
"============connect release============"
);
this
.
connetStatus
=
false
;
});
}
}
subscribe
(
topicurl
:
string
)
{
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
this
.
subObj
=
this
.
mqClient
.
subscribe
(
topicurl
,
(
res
:
SocketRes
)
=>
{
resolve
(
res
.
body
)
})
}).
catch
(
err
=>
{
console
.
log
(
err
);
reject
(
err
)
})
}
unsubscribe
()
{
this
.
subObj
.
unsubscribe
()
this
.
subObj
=
{
id
:
""
,
unsubscribe
:
()
=>
{
}
};
}
}
export
default
new
MyStompClient
()
dlink-web/src/utils/stompClientUtil.ts
0 → 100644
View file @
33a54d12
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
();
}
connect
()
{
this
.
stompClient
.
connect
(
{},
()
=>
{
this
.
connectStatus
=
true
;
console
.
log
(
"connect success>>>>>>>>>>>>>>>>>>>"
);
},
(
err
:
any
)
=>
{
console
.
log
(
"error"
);
console
.
log
(
err
);
}
);
}
close
()
{
if
(
this
.
stompClient
)
{
this
.
stompClient
.
disconnect
(()
=>
{
console
.
log
(
"============connect release============"
);
this
.
connectStatus
=
false
;
});
}
}
unsubscribe
()
{
this
.
subScription
.
unsubscribe
()
this
.
subScription
=
{
id
:
""
,
unsubscribe
:
()
=>
{
}
};
}
}
export
default
new
StompClientUtil
()
pom.xml
View file @
33a54d12
...
@@ -67,7 +67,6 @@
...
@@ -67,7 +67,6 @@
<javax.mail>
1.6.2
</javax.mail>
<javax.mail>
1.6.2
</javax.mail>
<jaxb.version>
2.3.0
</jaxb.version>
<jaxb.version>
2.3.0
</jaxb.version>
<jedis.version>
2.9.0
</jedis.version>
<jedis.version>
2.9.0
</jedis.version>
<jedis.version>
2.9.0
</jedis.version>
<junit5.version>
5.9.1
</junit5.version>
<junit5.version>
5.9.1
</junit5.version>
<knife4j.version>
3.0.3
</knife4j.version>
<knife4j.version>
3.0.3
</knife4j.version>
<log4j.version>
2.19.0
</log4j.version>
<log4j.version>
2.19.0
</log4j.version>
...
...
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