forked from near/nearcore
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6b02fa2
commit a38478f
Showing
10 changed files
with
124 additions
and
2 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
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
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,3 @@ | ||
.snapshot-hosts-view { | ||
margin: 10px; | ||
} |
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,51 @@ | ||
import { useQuery } from 'react-query'; | ||
import { toHumanTime } from './utils'; | ||
import { fetchSnapshotHosts } from './api'; | ||
import './SnapshotHostsView.scss'; | ||
|
||
type SnapshotHostsViewProps = { | ||
addr: string; | ||
}; | ||
|
||
export const SnapshotHostsView = ({ addr }: SnapshotHostsViewProps) => { | ||
const { | ||
data: snapshotHosts, | ||
error, | ||
isLoading, | ||
} = useQuery(['snapshotHosts', addr], () => fetchSnapshotHosts(addr)); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} else if (error) { | ||
return <div className="error">{(error as Error).stack}</div>; | ||
} | ||
|
||
const snapshot_hosts = snapshotHosts!.status_response.SnapshotHosts; | ||
|
||
return ( | ||
<div className="snapshot-hosts-view"> | ||
<table> | ||
<thead> | ||
<th>Peer ID</th> | ||
<th>Shards</th> | ||
<th>Epoch Height</th> | ||
<th>Sync Hash</th> | ||
</thead> | ||
<tbody> | ||
{snapshot_hosts.hosts.map( | ||
(host) => { | ||
return ( | ||
<tr key={host.peer_id}> | ||
<td>{host.peer_id}</td> | ||
<td>{JSON.stringify(host.shards)}</td> | ||
<td>{host.epoch_height}</td> | ||
<td>{host.sync_hash}</td> | ||
</tr> | ||
); | ||
} | ||
)} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; |
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