-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: replace all then to promise (#96) * feat: bootnode mode (#97) * feat: bootnode mode * feat: assign specified node to be bootnode * fix: remove console log * fix: eslink and test * fix: adjust for pr comments * feat: optimize create network process (#100) * feat: transform bdk ui to quorum dashboard (#99) * feat: bdk ui dashboard * fix: modify reviewed code * fix(ui): network info json location --------- Co-authored-by: kidneyweak <[email protected]> * fix: modify ui to dashboard (#101) * update: 2.1.0 bdk dashboard * fix(ca): promise catch test error (#103) --------- Co-authored-by: Chengwei-Lin <[email protected]> Co-authored-by: JakeKuo <[email protected]> Co-authored-by: PianoChicken <[email protected]>
- Loading branch information
1 parent
88d2979
commit b0f47ac
Showing
35 changed files
with
701 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,3 +117,6 @@ src/command/test.ts | |
|
||
|
||
.scannerwork | ||
|
||
# Pnpm lockfile | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { Box, Text, Newline } from 'ink' | ||
import { NodeDetails } from '../models/type/dashboard.type' | ||
import { NodeContextService } from '../services/nodeContext' | ||
|
||
export default function NodeInfo (props: any) { | ||
const apiUrl = props.apiUrl | ||
const nodeInformationService = new NodeContextService(apiUrl) | ||
const [nodeInfo, setNodeInfo] = useState<NodeDetails>() | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
const res = await nodeInformationService.getNodeDetails() | ||
setNodeInfo(res) | ||
} | ||
fetchData() | ||
.then((response) => { return response }) | ||
.catch((error) => { return error }) | ||
}, [apiUrl]) | ||
|
||
return ( | ||
<Box width='50%' flexDirection='column' borderStyle='bold' borderColor='white' padding={1}> | ||
<Text color={'#00FF19'}>Node ID: {nodeInfo?.id}</Text> | ||
<Newline /> | ||
<Text color={'white'}>Node Name: {nodeInfo?.name}</Text> | ||
<Newline /> | ||
<Text color={'white'}>Enode: {nodeInfo?.enode}</Text> | ||
<Newline /> | ||
<Text color={'white'}>IP Address: {nodeInfo?.ip}</Text> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { Box, Text } from 'ink' | ||
import { NodeContextService } from '../services/nodeContext' | ||
import { PeerInformation } from '../models/type/dashboard.type' | ||
|
||
export default function PeerInfo (props: any) { | ||
const apiUrl: string = props.apiUrl | ||
const nodeInformationService = new NodeContextService(apiUrl) | ||
const [jsonData, setJsonData] = useState<PeerInformation[]>([]) | ||
|
||
const fetchData = async () => { | ||
const res: PeerInformation[] = await nodeInformationService.getNodePeers() | ||
setJsonData(res) | ||
} | ||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
fetchData() | ||
.then((response) => { return response }) | ||
.catch((error) => { return error }) | ||
}, 2500) | ||
|
||
return () => clearInterval(intervalId) | ||
}, [apiUrl, jsonData]) | ||
|
||
return ( | ||
<Box height='65%' flexDirection='column' borderStyle='bold' borderColor='white'> | ||
<Box height='10%' justifyContent='center'> | ||
<Text color={'white'} bold>Peer Information</Text> | ||
</Box> | ||
<Box height='90%' flexDirection='column'> | ||
{ jsonData?.map((item: PeerInformation, index: number) => { | ||
return ( | ||
<Box key={index} flexDirection='row' marginBottom={1} marginX={2} paddingLeft={3}> | ||
<Text color={'#00FF19'}>ID: {item.id}</Text> | ||
<Text> </Text> | ||
<Text color={'white'}>E-Node: {item.enode}</Text> | ||
<Text> </Text> | ||
<Text color={'white'}>Local Address: {item.network?.localAddress}</Text> | ||
<Text> </Text> | ||
<Text color={'white'}>Remote Address: {item.network?.remoteAddress}</Text> | ||
</Box> | ||
) | ||
}, | ||
)} | ||
</Box> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useState, useEffect, useLayoutEffect, memo } from 'react' | ||
import { Box, Text, Newline } from 'ink' | ||
import { NodeContextService } from '../services/nodeContext' | ||
import { debounce } from '../../util' | ||
|
||
const NodeStatus = memo(function NodeStatus (props: any) { | ||
const apiUrl = props.apiUrl | ||
const nodeInformationService = new NodeContextService(apiUrl) | ||
const [state, setState] = useState<string>('shutdown') | ||
const [stateColor, setStateColor] = useState<string>('#FF000F') | ||
const [block, setBlock] = useState<number>(0) | ||
const [peer, setPeer] = useState<number>(0) | ||
|
||
const fetchData = async () => { | ||
const res = await nodeInformationService.getBlocks() | ||
setBlock(res) | ||
} | ||
|
||
const fetchPeerData = async () => { | ||
const res = await nodeInformationService.getPeers() | ||
setPeer(res) | ||
} | ||
|
||
const debouncedFetchData = debounce(fetchData, 2500) | ||
const debouncedFetchPeerData = debounce(fetchPeerData, 2500) | ||
|
||
useLayoutEffect(() => { | ||
const intervalId = setInterval(() => { | ||
debouncedFetchData() | ||
debouncedFetchPeerData() | ||
}, 2500) | ||
|
||
return () => clearInterval(intervalId) | ||
}, [apiUrl]) | ||
|
||
useEffect(() => { | ||
if (block !== 0) { | ||
setState('running') | ||
setStateColor('#00FF19') | ||
} else { | ||
setState('shutdown') | ||
setStateColor('#FF000F') | ||
} | ||
}, [block, peer]) | ||
|
||
return ( | ||
<Box width='20%' flexDirection='column' borderStyle='bold' borderColor='white' padding={2}> | ||
<Text color={'#42c5f5'}>Node Status</Text> | ||
<Newline /> | ||
<Text color={stateColor}>Status: {state}</Text> | ||
<Newline /> | ||
<Text color={'#FF0099'}>Blocks: {block}</Text> | ||
<Newline /> | ||
<Text color={'cyan'}>Peers: {peer}</Text> | ||
<Newline /> | ||
</Box> | ||
) | ||
}, | ||
) | ||
export default NodeStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.