forked from nervosnetwork/ckb-explorer-frontend
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
216 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@import '../../../styles//variables.module.scss'; | ||
|
||
.container { | ||
text-wrap: nowrap; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
margin: 24px 120px; | ||
font-size: 1rem; | ||
|
||
a { | ||
color: var(--primary-color); | ||
} | ||
|
||
dl { | ||
display: flex; | ||
|
||
dt, | ||
dd { | ||
display: flex; | ||
align-items: center; | ||
gap: 4px; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
dt::after { | ||
content: ':'; | ||
margin-right: 4px; | ||
} | ||
} | ||
|
||
table { | ||
width: 100%; | ||
text-align: left; | ||
cursor: default; | ||
|
||
td, | ||
th { | ||
padding: 8px; | ||
padding-right: 16px; | ||
|
||
&:last-child { | ||
text-align: right; | ||
} | ||
} | ||
|
||
tbody { | ||
tr:hover { | ||
background: #ccc; | ||
} | ||
} | ||
} | ||
|
||
svg { | ||
pointer-events: none; | ||
} | ||
|
||
button { | ||
display: flex; | ||
align-items: center; | ||
appearance: none; | ||
padding: 0; | ||
border: none; | ||
background: none; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
color: var(--primary-color); | ||
} | ||
} | ||
|
||
@media screen and (width < $extraLargeBreakPoint) { | ||
margin: 24px 20px; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,120 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { Link, useParams } from 'react-router-dom' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { CopyIcon, OpenInNewWindowIcon } from '@radix-ui/react-icons' | ||
import { Tooltip } from 'antd' | ||
import Content from '../../../components/Content' | ||
import { explorerService } from '../../../services/ExplorerService' | ||
import { useSetToast } from '../../../components/Toast' | ||
// import type { Fiber } from '../../../services/ExplorerService/fetcher' | ||
// import { shannonToCkb } from '../../../utils/util' | ||
// import { localeNumberString } from '../../../utils/number' | ||
// import { parseNumericAbbr } from '../../../utils/chart' | ||
import styles from './index.module.scss' | ||
import Loading from '../../../components/Loading' | ||
|
||
const Peer = () => { | ||
return <div>Channel</div> | ||
const [t] = useTranslation() | ||
const { id } = useParams<{ id: string }>() | ||
const setToast = useSetToast() | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ['fiber', 'peer', id], | ||
queryFn: () => { | ||
return explorerService.api.getFiberPeerDetail(id) | ||
}, | ||
enabled: !!id, | ||
}) | ||
if (isLoading) { | ||
return <Loading show /> | ||
} | ||
|
||
if (!data) { | ||
return <div>Fiber Peer Not Found</div> | ||
} | ||
const peer = data.data | ||
const channels = peer.fiberChannels | ||
|
||
const handleCopy = (e: React.SyntheticEvent) => { | ||
const elm = e.target | ||
if (!(elm instanceof HTMLElement)) return | ||
const { copyText } = elm.dataset | ||
if (!copyText) return | ||
e.stopPropagation() | ||
e.preventDefault() | ||
navigator?.clipboard.writeText(copyText).then(() => setToast({ message: t('common.copied') })) | ||
} | ||
|
||
return ( | ||
<Content> | ||
<div className={styles.container} onClick={handleCopy}> | ||
<div> | ||
<dl> | ||
<dt>{t('fiber.peer.peer_id')}</dt> | ||
<dd> | ||
{peer.peerId} | ||
<button type="button" data-copy-text={peer.peerId}> | ||
<CopyIcon /> | ||
</button> | ||
</dd> | ||
</dl> | ||
<dl> | ||
<dt>{t('fiber.peer.rpc_addr')}</dt> | ||
<dd> | ||
<Tooltip title={peer.rpcListeningAddr}> | ||
<span>{peer.rpcListeningAddr}</span> | ||
</Tooltip> | ||
<button type="button" data-copy-text={peer.rpcListeningAddr}> | ||
<CopyIcon /> | ||
</button> | ||
<a href={peer.rpcListeningAddr} title={peer.rpcListeningAddr} target="_blank" rel="noopener noreferrer"> | ||
<OpenInNewWindowIcon /> | ||
</a> | ||
</dd> | ||
</dl> | ||
<dl> | ||
<dt>{t('fiber.peer.open_time')}</dt> | ||
<dd> | ||
<small>Coming soon</small> | ||
</dd> | ||
</dl> | ||
<dl> | ||
<dt>{t('fiber.peer.update_time')}</dt> | ||
<dd> | ||
<small>Coming soon</small> | ||
</dd> | ||
</dl> | ||
</div> | ||
<div> | ||
<div>{`${t('fiber.peer.channels')}(${channels.length})`}</div> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>{t('fiber.channel.channel_id')}</th> | ||
<th>{t('fiber.channel.state')}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{channels.map(c => { | ||
return ( | ||
<tr key={c.channelId}> | ||
<td> | ||
<Tooltip title={c.channelId}> | ||
<Link to={`/fiber/channels/${c.channelId}`} className="monospace"> | ||
{`${c.channelId.slice(0, 10)}...${c.channelId.slice(-10)}`} | ||
</Link> | ||
</Tooltip> | ||
</td> | ||
<td>{c.stateName}</td> | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</Content> | ||
) | ||
} | ||
|
||
export default Peer |
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
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