Display node details on map

This commit is contained in:
maciejhirsz
2018-07-18 15:18:35 +02:00
parent 966d390c46
commit 1a4322888c
6 changed files with 109 additions and 154 deletions
@@ -54,20 +54,6 @@
bottom: 0;
}
.Chain-map-node {
width: 10px;
height: 10px;
background: #d64ca8;
border: 1px solid #000;
border-radius: 6px;
margin-left: -6px;
margin-top: -6px;
position: absolute;
top: 50%;
left: 50%;
cursor: pointer;
}
.Chain-node-list {
width: 100%;
border-collapse: collapse;
+4 -26
View File
@@ -4,14 +4,8 @@ import { formatNumber, secondsWithPrecision, viewport } from '../utils';
import { Tile, Icon, Node, Ago } from './';
import { Types } from '@dotstats/common';
import nodeIcon from '../icons/server.svg';
import nodeTypeIcon from '../icons/terminal.svg';
import peersIcon from '../icons/broadcast.svg';
import transactionsIcon from '../icons/inbox.svg';
import blockIcon from '../icons/package.svg';
import blockHashIcon from '../icons/file-binary.svg';
import blockTimeIcon from '../icons/history.svg';
import propagationTimeIcon from '../icons/dashboard.svg';
import lastTimeIcon from '../icons/watch.svg';
import worldIcon from '../icons/globe.svg';
@@ -130,14 +124,10 @@ export class Chain extends React.Component<Chain.Props, Chain.State> {
// const location = [48.8589507, 2.2770201] as Types.NodeLocation; // Paris
// const location = [36.7183391, -4.5193071]as Types.NodeLocation; // Malaga
const { left, top } = this.pixelPosition(location[0], location[1]);
return (
<span
key={node.id}
className="Chain-map-node"
style={this.pixelPosition(location[0], location[1])}
title={node.nodeDetails[0]}
data-location={JSON.stringify(node.location)}
/>
<Node.Location key={node.id} left={left} top={top} {...node} />
);
})
}
@@ -148,19 +138,7 @@ export class Chain extends React.Component<Chain.Props, Chain.State> {
private renderTable() {
return (
<table className="Chain-node-list">
<thead>
<tr>
<th><Icon src={nodeIcon} alt="Node" /></th>
<th><Icon src={nodeTypeIcon} alt="Implementation" /></th>
<th><Icon src={peersIcon} alt="Peer Count" /></th>
<th><Icon src={transactionsIcon} alt="Transactions in Queue" /></th>
<th><Icon src={blockIcon} alt="Block" /></th>
<th><Icon src={blockHashIcon} alt="Block Hash" /></th>
<th><Icon src={blockTimeIcon} alt="Block Time" /></th>
<th><Icon src={propagationTimeIcon} alt="Block Propagation Time" /></th>
<th><Icon src={lastTimeIcon} alt="Last Block Time" /></th>
</tr>
</thead>
<Node.Header />
<tbody>
{
this.nodes().sort(sortNodes).map((node) => <Node.Row key={node.id} {...node} />)
+43
View File
@@ -0,0 +1,43 @@
.Node-Location {
width: 10px;
height: 10px;
background: #d64ca8;
border: 1px solid #000;
border-radius: 6px;
margin-left: -6px;
margin-top: -6px;
position: absolute;
top: 50%;
left: 50%;
cursor: pointer;
}
.Node-details {
display: none;
min-width: 335px;
position: absolute;
left: 16px;
top: -4px;
font-family: monospace, sans-serif;
background: #222;
color: #fff;
box-shadow: 0 3px 20px rgba(0,0,0,0.5);
border-collapse: collapse;
}
.Node-details td {
text-align: left;
padding: 0.5em 1em;
}
.Node-details td:nth-child(odd) {
padding-right: 0.2em;
}
.Node-details td:nth-child(even) {
padding-left: 0.2em;
}
.Node-Location:hover .Node-details {
display: initial;
}
+59 -7
View File
@@ -1,8 +1,20 @@
import * as React from 'react';
import { formatNumber, trimHash, milliOrSecond, secondsWithPrecision } from '../utils';
import { Ago } from './Ago';
import { Ago, Icon } from './';
import { Types, Maybe } from '@dotstats/common';
import nodeIcon from '../icons/server.svg';
import nodeTypeIcon from '../icons/terminal.svg';
import peersIcon from '../icons/broadcast.svg';
import transactionsIcon from '../icons/inbox.svg';
import blockIcon from '../icons/package.svg';
import blockHashIcon from '../icons/file-binary.svg';
import blockTimeIcon from '../icons/history.svg';
import propagationTimeIcon from '../icons/dashboard.svg';
import lastTimeIcon from '../icons/watch.svg';
import './Node.css';
export namespace Node {
export interface Props {
id: Types.NodeId;
@@ -17,6 +29,24 @@ export namespace Node {
top: number;
}
export function Header() {
return (
<thead>
<tr>
<th><Icon src={nodeIcon} alt="Node" /></th>
<th><Icon src={nodeTypeIcon} alt="Implementation" /></th>
<th><Icon src={peersIcon} alt="Peer Count" /></th>
<th><Icon src={transactionsIcon} alt="Transactions in Queue" /></th>
<th><Icon src={blockIcon} alt="Block" /></th>
<th><Icon src={blockHashIcon} alt="Block Hash" /></th>
<th><Icon src={blockTimeIcon} alt="Block Time" /></th>
<th><Icon src={propagationTimeIcon} alt="Block Propagation Time" /></th>
<th><Icon src={lastTimeIcon} alt="Last Block Time" /></th>
</tr>
</thead>
)
}
export function Row(props: Props) {
const [name, implementation, version] = props.nodeDetails;
const [height, hash, blockTime, blockTimestamp, propagationTime] = props.blockDetails;
@@ -39,14 +69,36 @@ export namespace Node {
export function Location(props: Props & PixelPosition) {
const { left, top } = props;
const [name, implementation, version] = props.nodeDetails;
const [height, hash, blockTime, blockTimestamp, propagationTime] = props.blockDetails;
return (
<span
className="Chain-map-node"
style={{ left, top }}
title={props.nodeDetails[0]}
data-location={JSON.stringify(props.location)}
/>
<div className="Node-Location" style={{ left, top }}>
<table className="Node-details">
<tbody>
<tr>
<td><Icon src={nodeIcon} alt="Node" /></td><td colSpan={5}>{name}</td>
</tr>
<tr>
<td><Icon src={nodeTypeIcon} alt="Implementation" /></td><td colSpan={5}>{implementation} v{version}</td>
</tr>
<tr>
<td><Icon src={blockIcon} alt="Block" /></td><td colSpan={5}>#{formatNumber(height)}</td>
</tr>
<tr>
<td><Icon src={blockHashIcon} alt="Block Hash" /></td><td colSpan={5}>{trimHash(hash, 20)}</td>
</tr>
<tr>
<td><Icon src={blockTimeIcon} alt="Block Time" /></td>
<td style={{ width: 80 }}>{secondsWithPrecision(blockTime/1000)}</td>
<td><Icon src={propagationTimeIcon} alt="Block Propagation Time" /></td>
<td style={{ width: 58 }}>{propagationTime === null ? '∞' : milliOrSecond(propagationTime as number)}</td>
<td><Icon src={lastTimeIcon} alt="Last Block Time" /></td>
<td style={{ minWidth: 82 }}><Ago when={blockTimestamp} /></td>
</tr>
</tbody>
</table>
</div>
);
}
}